In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to develop native modules for iotjs". In daily operation, I believe many people have doubts about how to develop native modules for iotjs. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to develop native modules for iotjs"! Next, please follow the editor to study!
Develop native modules for iotjs
Iotjs is Samsung's open source javascript Internet of things development platform. It provides javascript applications with the ability to access hardware, network, file system and asynchronization. The function is similar to nodejs, but iotjs is much smaller in terms of code volume and memory requirements, so it is the first choice to develop iot device applications with javascript.
AWTK, full name Toolkit AnyWhere, is an open source GUI engine developed by ZLG, designed for embedded systems, WEB, various Mini Program, mobile phones and PC to create a general GUI engine, providing users with a powerful, efficient and reliable, easy-to-use GUI engine that can easily make cool effects.
1. Modify the name of the module
There is no problem if the name of the module uses mymodule, but mymodule is a meaningless name that does not express the real functionality of the actual module. I need to rename the module to awtk here, which can be done in the following ways:
Directory name using awtk-module
Mkdir awtk-module
Rename the source file of the C code to awtk_module.c and the initialization function to InitAwtkNativeModule.
Create awtk-module/modules.json
{"modules": {"awtk": {"native_files": ["awtk_module.c"], "init": "InitAwtkNativeModule", "external_libs": ["awtk-jerryscript", "jerryscript", "awtk", "assets", "glad", "gpinyin", "linebreak", "nanovg"] "platforms": {"linux": {"external_libs": ["SDL2", "gtk-3", "gdk-3", "sndio", "Xext", "X11", "stdc++", "dl", "m"]}
Modify compilation script parameters
Tools/build.py-external-modules=awtk-module-cmake-param=-DENABLE_MODULE_AWTK=ON
ENABLE_MODULE_ must write the name of the actual module, if you forget to change the MYMODULE to the name of the actual module, the error so that you have no idea what is going on.
II. Compilation parameters
Your own modules inevitably use external libraries, but you can specify the name of the library in modules.json, but not the path to the library or the header file. The attempt was unsuccessful, and then I had to write a cmake file myself, which was referenced in iotjs's CMakeLists.txt.
The awtk.cmake is as follows:
GET_FILENAME_COMPONENT (PROJ_ROOT "${CMAKE_CURRENT_LIST_DIR} /.. /" ABSOLUTE) SET (AWTK_ROOT ${PROJ_ROOT} / awtk) SET (AWTK_JS_ROOT ${PROJ_ROOT} / awtk-js) SET (APP_ASSETS_ROOT ${AWTK_ROOT} / demos) SET (AWTK_JS_FILE ${AWTK_JS_ROOT} / src/awtk.js) MESSAGE ("AWTK_ROOT=$ {AWTK_ROOT}") MESSAGE ("AWTK_JS_") ROOT=$ {AWTK_JS_ROOT} ") MESSAGE (" AWTK_JS_ROOT=$ {CMAKE_CURRENT_LIST_DIR} ") SET (CMAKE_VERBOSE_MAKEFILE ON) ADD_COMPILE_OPTIONS ("-DAWTK_JS_FILE=\ "${AWTK_JS_FILE}\") ADD_COMPILE_OPTIONS ("-DAPP_ASSETS_ROOT=\ "${APP_ASSETS_ROOT}\") LINK_DIRECTORIES ("${AWTK_ROOT} / lib" ${AWTK_JS_ROOT} / lib ") INCLUDE_DIRECTORIES ("${AWTK_ROOT} / src/"${AWTK_ROOT} / src/ext_widgets/"${AWTK_JS_ROOT} / src/jerryscript")
Using the following line of code to turn on verbose mode, you can see a lot of debugging information, which can help you quickly locate the problem:
SET (CMAKE_VERBOSE_MAKEFILE ON)
Then quote in CMakeLists.txt:
Include (.. / awtk-iotjs/awtk-module/awtk.cmake) include (cmake/iotjs.cmake)
It must be referenced before iotjs.cmake, otherwise it will be invalid.
Third, put it in a separate directory
It is easier to manage modules in separate directories. Awtk-iotjs is a module written for iotjs that relies on awtk and awtk-js to put several modules in the same directory.
Awtk
Awtk-js
Iotjs
Awtk-iotjs
The compilation script is changed to:
${iotjs_ROOT} / tools/build.py-- external-modules=$ {CWD} / awtk-module-- cmake-param=-DENABLE_MODULE_AWTK=ON
Run the script to:
If ["$1" = ""]; then JS_FILE= "demos/button.js" else JS_FILE= "$1" fi$ {iotjs_ROOT} / build/x86_64-linux/debug/bin/iotjs "$JS_FILE" this is the end of the study on "how to develop native modules for iotjs", hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.