add tizen appfw build env
authorSumin Lim <sumin.lim@samsung.com>
Sun, 11 Jun 2017 21:07:48 +0000 (06:07 +0900)
committerSumin Lim <sumin.lim@samsung.com>
Sun, 11 Jun 2017 21:07:48 +0000 (06:07 +0900)
cmake/iotjs.cmake
packaging/iotjs.spec
src/iotjs_magic_strings.h
src/iotjs_module.h
src/js/tizenappfw.js [new file with mode: 0644]
src/modules/iotjs_module_tizenappfw.c [new file with mode: 0644]
src/modules/iotjs_module_tizenappfw.h [new file with mode: 0644]

index 2095536c66be8434c33fce6069fd171143fe5458..678205f6a52fe0da2138176ce293bc4e6a0ec04b 100644 (file)
@@ -227,15 +227,38 @@ separate_arguments(EXTERNAL_INCLUDE_DIR)
 separate_arguments(EXTERNAL_STATIC_LIB)
 separate_arguments(EXTERNAL_SHARED_LIB)
 
-set(IOTJS_INCLUDE_DIRS
-  ${EXTERNAL_INCLUDE_DIR}
-  ${ROOT_DIR}/include
-  ${IOTJS_SOURCE_DIR}
-  ${JERRY_PORT_DIR}/include
-  ${JERRY_INCLUDE_DIR}
-  ${HTTPPARSER_INCLUDE_DIR}
-  ${TUV_INCLUDE_DIR}
+#For TIZEN
+if("${TARGET_OS}" STREQUAL "TIZEN")
+  message (STATUS "-- INCLUDE MODULE FOR TIZEN -- ")
+  INCLUDE(FindPkgConfig)
+  SET(dependents "dlog appcore-agent capi-appfw-service-application capi-appfw-app-common")
+    pkg_check_modules(fw_name REQUIRED ${dependents})
+
+  FOREACH(flag ${fw_name_CFLAGS})
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
+  ENDFOREACH(flag)
+
+  set(IOTJS_INCLUDE_DIRS
+      ${EXTERNAL_INCLUDE_DIR}
+      ${ROOT_DIR}/include
+      ${IOTJS_SOURCE_DIR}
+      ${JERRY_PORT_DIR}/include
+      ${JERRY_INCLUDE_DIR}
+      ${HTTPPARSER_INCLUDE_DIR}
+      ${TUV_INCLUDE_DIR}
+      ${fw_name_CFLAGS}
+    )
+else()
+  set(IOTJS_INCLUDE_DIRS
+    ${EXTERNAL_INCLUDE_DIR}
+    ${ROOT_DIR}/include
+    ${IOTJS_SOURCE_DIR}
+    ${JERRY_PORT_DIR}/include
+    ${JERRY_INCLUDE_DIR}
+    ${HTTPPARSER_INCLUDE_DIR}
+    ${TUV_INCLUDE_DIR}
 )
+endif()
 
 set(IOTJS_CFLAGS ${IOTJS_CFLAGS} ${CFLAGS_COMMON})
 
@@ -254,6 +277,7 @@ target_link_libraries(${TARGET_LIB_IOTJS}
   libhttp-parser
   ${EXTERNAL_STATIC_LIB}
   ${EXTERNAL_SHARED_LIB}
+  ${fw_name_LDFLAGS}
 )
 
 if(NOT BUILD_LIB_ONLY)
index 2195452aae817ec748fd4f481f07a8059d2130d6..1827a9b3630f8428855f088796dcf5c08187a956 100644 (file)
@@ -57,8 +57,9 @@ cat LICENSE
 cp %{SOURCE1001} .
 
 %build
-./tools/build.py --clean --buildtype=debug --target-arch=arm --target-os=tizen --target-board=artik10 --no-init-submodule --no-parallel-build --no-check-test 
-
+./tools/build.py --clean --buildtype=debug --target-arch=arm --target-os=tizen --target-board=artik10 \
+ --no-init-submodule --no-parallel-build --no-check-test \
+ --external-shared-lib=appcore-agent --iotjs-include-module=tizenappfw
 %install
 #rm -rf %{buildroot}
 
index d5a0d0fa88a3bba7cd1f9fa9910edf45edfecfe7..d4153f81377305adbdb43e59a7f9087a9fbc63d6 100644 (file)
 #define IOTJS_MAGIC_STRING_WRITESYNC "writeSync"
 #define IOTJS_MAGIC_STRING_WRITEUINT8 "writeUInt8"
 #define IOTJS_MAGIC_STRING_WRITE "write"
-
+#define IOTJS_MAGIC_STRING_TIZENAPPSTATE "appOn"
+#define IOTJS_MAGIC_STRING_TIZENAPPSTART "appStart"
 #endif /* IOTJS_STRING_CONSTANTS_H */
index fb880b10d3c2d5309747cad7d0aabe6b84830672..1537956b837c4095319b0951af9591f1f56613f5 100644 (file)
@@ -52,7 +52,8 @@ typedef iotjs_jval_t (*register_func)();
   E(F, TCP, Tcp, tcp)                            \
   E(F, TIMER, Timer, timer)                      \
   E(F, UART, Uart, uart)                         \
-  E(F, UDP, Udp, udp)
+  E(F, UDP, Udp, udp)                            \
+  E(F, TIZENAPPFW, Tizenappfw, tizenappfw)
 
 #define ENUMDEF_MODULE_LIST(upper, Camel, lower) MODULE_##upper,
 
diff --git a/src/js/tizenappfw.js b/src/js/tizenappfw.js
new file mode 100644 (file)
index 0000000..256bec4
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var util = require('util');
+var tizenappfwBuiltin = process.binding(process.binding.tizenappfw);
+
+
+function Tizenappfw() {
+}
+
+
+Tizenappfw.prototype.start = function() {
+  tizenappfwBuiltin.appStart(util.format.apply(this, arguments) + '\n');
+};
+
+
+Tizenappfw.prototype.on = function() {
+  tizenappfwBuiltin.appOn(util.format.apply(this, arguments) + '\n');
+};
+
+
+module.exports = new Tizenappfw();
+module.exports.Tizenappfw = Tizenappfw;
diff --git a/src/modules/iotjs_module_tizenappfw.c b/src/modules/iotjs_module_tizenappfw.c
new file mode 100644 (file)
index 0000000..d8793fe
--- /dev/null
@@ -0,0 +1,58 @@
+/* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iotjs_def.h"
+#include "iotjs_module_tizenappfw.h"
+//#include <service_app.h>
+
+
+static void AppStateOn(iotjs_jhandler_t* jhandler, FILE* out_fd) {
+  JHANDLER_CHECK_ARGS(2, string, function);
+  iotjs_string_t msg = JHANDLER_GET_ARG(0, string);
+  fprintf(out_fd, "%s", iotjs_string_data(&msg));
+  iotjs_string_destroy(&msg);
+
+  const iotjs_jval_t* jcallback1 = JHANDLER_GET_ARG(1, function);
+  int result = (jcallback1 == NULL)?1:0;
+  DLOG("result %d", result);
+}
+
+
+static void AppStart(iotjs_jhandler_t* jhandler, FILE* out_fd) {
+  JHANDLER_CHECK_ARGS(1, string);
+  iotjs_string_t msg = JHANDLER_GET_ARG(0, string);
+  fprintf(out_fd, "%s", iotjs_string_data(&msg));
+  iotjs_string_destroy(&msg);
+}
+
+
+JHANDLER_FUNCTION(On) {
+  AppStateOn(jhandler, stdout);
+}
+
+JHANDLER_FUNCTION(Start) {
+  AppStart(jhandler, stdout);
+}
+
+iotjs_jval_t InitTizenappfw() {
+  iotjs_jval_t tizenappfw = iotjs_jval_create_object();
+
+  iotjs_jval_set_method(&tizenappfw, IOTJS_MAGIC_STRING_TIZENAPPSTATE, On);
+  iotjs_jval_set_method(&tizenappfw, IOTJS_MAGIC_STRING_TIZENAPPSTART, Start);
+  return tizenappfw;
+}
diff --git a/src/modules/iotjs_module_tizenappfw.h b/src/modules/iotjs_module_tizenappfw.h
new file mode 100644 (file)
index 0000000..e6df7f6
--- /dev/null
@@ -0,0 +1,8 @@
+
+
+#ifndef IOTJS_MODULE_TIZENAPPFW_H
+#define IOTJS_MODULE_TIZENAPPFW_H
+
+
+#endif /* IOTJS_MODULE_TIZENAPPFW_H */