Skip to content

Commit

Permalink
working on shadow-node target
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkie committed Nov 23, 2019
1 parent ee7047a commit 38a0b22
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 41 deletions.
14 changes: 10 additions & 4 deletions deps/shadow-node/cmake/iotjs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,16 @@ endforeach()
iotjs_add_compile_flags(-Wall -Wextra -Werror -Wno-unused-parameter)
iotjs_add_compile_flags(-Wsign-conversion -std=gnu99)

if(ENABLE_SNAPSHOT)
set(JS2C_DEPENDS
${ROOT_DIR}/tools/js2c.py
${IOTJS_SOURCE_DIR}/js/*.js
)

if(EXTERNAL_SNAPSHOT_TOOL)
set(JS2C_SNAPSHOT_ARG --snapshot-tool=${EXTERNAL_SNAPSHOT_TOOL})
elseif(ENABLE_SNAPSHOT)
set(JS2C_SNAPSHOT_ARG --snapshot-tool=${JERRY_HOST_SNAPSHOT})
list(APPEND JS2C_DEPENDS jerry-snapshot)
iotjs_add_compile_flags(-DENABLE_SNAPSHOT)
endif()

Expand All @@ -327,9 +335,7 @@ add_custom_command(
ARGS --buildtype=${JS2C_RUN_MODE}
--modules '${IOTJS_JS_MODULES}'
${JS2C_SNAPSHOT_ARG}
DEPENDS ${ROOT_DIR}/tools/js2c.py
jerry-snapshot
${IOTJS_SOURCE_DIR}/js/*.js
DEPENDS ${JS2C_DEPENDS}
)

set(IOTJS_NAPI_SRC)
Expand Down
78 changes: 41 additions & 37 deletions deps/shadow-node/cmake/jerry.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,47 @@

cmake_minimum_required(VERSION 2.8)

# Host jerry for snapshot generation
set(DEPS_HOST_JERRY deps/jerry-host)
ExternalProject_Add(hostjerry
PREFIX ${DEPS_HOST_JERRY}
SOURCE_DIR ${ROOT_DIR}/deps/jerry/
BUILD_IN_SOURCE 0
BINARY_DIR ${DEPS_HOST_JERRY}
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${DEPS_HOST_JERRY}
-DENABLE_ALL_IN_ONE=ON
-DENABLE_LTO=${ENABLE_LTO}
-DJERRY_CMDLINE=OFF
-DJERRY_CMDLINE_SNAPSHOT=ON
-DJERRY_EXT=ON
-DFEATURE_LOGGING=ON
-DFEATURE_SNAPSHOT_SAVE=${ENABLE_SNAPSHOT}
-DFEATURE_PROFILE=${FEATURE_PROFILE}
${EXTRA_JERRY_CMAKE_PARAMS}

# The snapshot tool does not require the system allocator
# turn it off by default.
#
# Additionally this is required if one compiles on a
# 64bit system to a 32bit system with system allocator
# enabled. This is beacuse on 64bit the system allocator
# should not be used as it returns 64bit pointers which
# can not be represented correctly in the JerryScript engine
# currently.
-DFEATURE_SYSTEM_ALLOCATOR=OFF
)
set(JERRY_HOST_SNAPSHOT
${CMAKE_BINARY_DIR}/${DEPS_HOST_JERRY}/bin/jerry-snapshot)
add_executable(jerry-snapshot IMPORTED)
add_dependencies(jerry-snapshot hostjerry)
set_property(TARGET jerry-snapshot PROPERTY
IMPORTED_LOCATION ${JERRY_HOST_SNAPSHOT})
if(EXTERNAL_SNAPSHOT_TOOL)
message("use ${EXTERNAL_SNAPSHOT_TOOL}, skip host-jerry")
else()
# Host jerry for snapshot generation
set(DEPS_HOST_JERRY deps/jerry-host)
ExternalProject_Add(hostjerry
PREFIX ${DEPS_HOST_JERRY}
SOURCE_DIR ${ROOT_DIR}/deps/jerry/
BUILD_IN_SOURCE 0
BINARY_DIR ${DEPS_HOST_JERRY}
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${DEPS_HOST_JERRY}
-DENABLE_ALL_IN_ONE=ON
-DENABLE_LTO=${ENABLE_LTO}
-DJERRY_CMDLINE=OFF
-DJERRY_CMDLINE_SNAPSHOT=ON
-DJERRY_EXT=ON
-DFEATURE_LOGGING=ON
-DFEATURE_SNAPSHOT_SAVE=${ENABLE_SNAPSHOT}
-DFEATURE_PROFILE=${FEATURE_PROFILE}
${EXTRA_JERRY_CMAKE_PARAMS}

# The snapshot tool does not require the system allocator
# turn it off by default.
#
# Additionally this is required if one compiles on a
# 64bit system to a 32bit system with system allocator
# enabled. This is beacuse on 64bit the system allocator
# should not be used as it returns 64bit pointers which
# can not be represented correctly in the JerryScript engine
# currently.
-DFEATURE_SYSTEM_ALLOCATOR=OFF
)
set(JERRY_HOST_SNAPSHOT
${CMAKE_BINARY_DIR}/${DEPS_HOST_JERRY}/bin/jerry-snapshot)
add_executable(jerry-snapshot IMPORTED)
add_dependencies(jerry-snapshot hostjerry)
set_property(TARGET jerry-snapshot PROPERTY
IMPORTED_LOCATION ${JERRY_HOST_SNAPSHOT})
endif()

# Utility method to add -D<KEY>=<KEY_Value>
macro(add_cmake_arg TARGET_ARG KEY)
Expand Down
1 change: 1 addition & 0 deletions openwrt/package/yodaos/shadow-node/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CMAKE_OPTIONS += \
-DEXTERNAL_COMPILE_FLAGS='' \
-DEXTERNAL_LINKER_FLAGS='' \
-DEXTERNAL_INCLUDE_DIR='' \
-DEXTERNAL_SNAPSHOT_TOOL='$(HOST_BUILD_DIR)/usr/bin/jerry-snapshot' \
-DINSTALL_PREFIX='/usr'

define Package/shadow-node
Expand Down

0 comments on commit 38a0b22

Please sign in to comment.