Use Node.js in your end devices(QQ: 796448809)
Ubuntu 14.04 is recommended. Other Unix like platforms can be used. If it doesn’t seem to work properly on other platforms, please look into the Issues page. Someone may have already tried. If you can’t find any related one, please leave an issue for help.
This document assumes ‘harmony’ as the root directory. JerryScript, libtuv are included as sub-modules in deps
directory.
※ harmony? It’s from the initial code name of our project. (Sounds good, isn’t it? :))
You need to install some packages to build IoT.js, as follows;
sudo apt-get install gyp cmake build-essential valgrind
gcc compiler 4.8 or higher versions are required to compile. If you don’t know how to do it, you can get some help from how-to-install-gcc-4-8 or google.
Clone our repository to look around and test it. If it attracts you and you want to try something interested, please fork it.
To get the source for this repository,
cd harmony
git clone https://github.com/Samsung/iotjs.git
cd iotjs
Sub-modules(http-parser, JerryScript, libuv and libtuv) will be pulled. And matching hash will be checked out for your current IoT.js version when you run the build script.
IoT.js and required sub-modules are generated all at once in tools directory with build.py.
cd iotjs
NDK_DIR=$HOME/Android/sdk/ndk-bundle # or change to your ndk directory
./tools/build.py \
--target-arch=aarch64 \
--target-os=linux-android \
--cmake-param=-DANDROID_NDK=$NDK_DIR \
--cmake-param=-DANDROID_NATIVE_API_LEVEL=23 \
--cmake-param=-DANDROID_ABI=armeabi-v7a \
--cmake-param=-DANDROID_TOOLCHAIN=clang \
--cmake-toolchain-file=$NDK_DIR/build/cmake/android.toolchain.cmake\
--profile=./profiles/basic.profile
Some basic options are provided.
Existing build options are listed as follows;
buildtype=debug|release (debug is default)
builddir=build (build is default)
clean
buildlib (default is False)
profile=path-to-profile (default: profiles/default.profile)
target-arch=x86|x86_64|x64|i686|arm|aarch64 (depends on your host platform)
target-os=linux|linux-android|nuttx|darwin|osx (linux is default)
target-board
cmake-param
compile-flag
link_flag
external-include-dir
external-lib
jerry-cmake-param
jerry-compile-flag
jerry-link-flag
jerry-lto
jerry-heap-section
jerry-heaplimit (default is 81, may change)
jerry-memstat (default is False)
no-init-submodule (default is init)
no-check-tidy (default is check)
no-check-test (default is check)
no-parallel-build
no-snapshot
nuttx-home= (no default value)
To give options, please use two dashes ‘–’ before the option name as described in the following sections.
Options that may need explanations.
region sram overflowed by xxxx bytes
, you may have to decrease about that amount.If you want to know more details about options, please check the Build Script page.
There are two ways to include extended module.
The first way is to specify the ENABLE_MODULE_[NAME]=ON
CMake parameter, where [NAME]
is the uppercase name of the module.
./tools/build.py --cmake-param=-DENABLE_MODULE_DGRAM=ON
The second way is by using profile descriptors, where a profile file contains the list of enabled modules. E.g.:
my-profile
ENABLE_MODULE_IOTJS_CORE_MODULES
ENABLE_MODULE_IOTJS_BASIC_MODULES
ENABLE_MODULE_DGRAM
./tools/build.py --profile=./my-profile
It’s a good practice to build in separate directory, like ‘build’. IoT.js generates all outputs into separate ‘build’ directory. You can change this by –builddir option. Usually you won’t need to use this option. Target and architecture name are used as a name for a directory inside ‘build’ directory.
To build debug version, type the command like below. And you can find the binary in ‘output’ directory.
./tools/build.py --builddir=output
To build 32bit version in x86_64 with debug version as a library, type the command like below.
./tools/build.py --target-arch=i686 --buildlib
To build release version with different jerry revision, type the command like below. (Assume that you have already checked it out.)
./tools/build.py --buildtype=release --no-init-submodule
This section for explaining how to build only IoT.js when you did some modification. IoT.js uses CMake for makefile generation. You can go inside the build folder and build with ‘make’ command. Go inside where your target platform name is, for example x86_64 linux,
cd build/x86_64-linux/release/iotjs
make
Executable name is ‘iotjs’ and resides in (target-arch)-(target-os)/(buildtype)/iotjs. To run greetings JavaScript in test folder, for example;
./build/aarch64-linux-android/debug/bin/iotjs ./test/run_pass/test_console.js
Some execution options are provided as follows;
memstat
show-opcodes
To give options, please use two dashes ‘–’ before the option name as described in following sections.
For more details on options, please see below.
To print memory statistics, follow the below steps;
./tools/build.py --jerry-memstat
./build/aarch64-linux-android/debug/bin/iotjs --memstat ./test/run_pass/test_console.js
With given show-opcodes
option, opcodes will be shown.
./build/aarch64-linux-android/debug/bin/iotjs --show-opcodes ./test/run_pass/test_console.js
Just remove the folder as follows;
rm -rf build