Enable WASI feature, enhance security and add SGX sample (#142)
Change emcc to clang Refine interpreter to improve perforamnce
This commit is contained in:
@ -96,7 +96,7 @@ int main(int argc, char ** argv)
|
||||
/* Periodically call the lv_task handler.
|
||||
* It could be done in a timer interrupt or an OS task too.*/
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count/ 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count/ 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
lv_task_handler();
|
||||
@ -146,7 +146,8 @@ static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_RELEASED) {
|
||||
label_count1_value++;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
CC = emcc
|
||||
CC = clang-8
|
||||
APP_DIR = ${shell pwd}
|
||||
IWASM_DIR=../../../../core/iwasm
|
||||
CFLAGS += -O3 \
|
||||
@ -23,7 +23,9 @@ SRCS += $(IWASM_DIR)/lib/app-libs/extension/gui/src/*.c
|
||||
|
||||
all:
|
||||
@$(CC) $(CFLAGS) $(SRCS) \
|
||||
-s WASM=1 -s SIDE_MODULE=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=2 \
|
||||
-s TOTAL_MEMORY=65536 -s TOTAL_STACK=2048\
|
||||
-s "EXPORTED_FUNCTIONS=['_on_init', '_on_timer_callback', '_on_widget_event']" \
|
||||
--target=wasm32 -O3 -z stack-size=2048 -Wl,--initial-memory=65536 \
|
||||
-Wl,--allow-undefined \
|
||||
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
|
||||
-Wl,--export=on_init -Wl,--export=on_timer_callback \
|
||||
-Wl,--export=on_widget_event \
|
||||
-o ui_app_lvgl_compatible.wasm
|
||||
|
||||
@ -24,7 +24,7 @@ char label_count1_str[11] = { 0 };
|
||||
void timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count / 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
++count;
|
||||
@ -65,7 +65,8 @@ static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_RELEASED) {
|
||||
label_count1_value--;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
if (label_count1_value == 0)
|
||||
label_count1_value = 100;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
CC = emcc
|
||||
CC = clang-8
|
||||
APP_DIR = ${shell pwd}
|
||||
IWASM_DIR=../../../../core/iwasm
|
||||
CFLAGS += -O3 \
|
||||
@ -23,7 +23,9 @@ SRCS += $(IWASM_DIR)/lib/app-libs/extension/gui/src/*.c
|
||||
|
||||
all:
|
||||
@$(CC) $(CFLAGS) $(SRCS) \
|
||||
-s WASM=1 -s SIDE_MODULE=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=2 \
|
||||
-s TOTAL_MEMORY=65536 -s TOTAL_STACK=2048\
|
||||
-s "EXPORTED_FUNCTIONS=['_on_init', '_on_timer_callback', '_on_widget_event']" \
|
||||
--target=wasm32 -O3 -z stack-size=2048 -Wl,--initial-memory=65536 \
|
||||
-Wl,--allow-undefined \
|
||||
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
|
||||
-Wl,--export=on_init -Wl,--export=on_timer_callback \
|
||||
-Wl,--export=on_widget_event \
|
||||
-o ui_app.wasm
|
||||
|
||||
@ -21,7 +21,7 @@ char label_count1_str[11] = { 0 };
|
||||
void timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count / 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
wgl_label_set_text(count_label, count_str);
|
||||
}
|
||||
++count;
|
||||
@ -58,7 +58,8 @@ static void btn_event_cb(wgl_obj_t btn, wgl_event_t event)
|
||||
{
|
||||
if(event == WGL_EVENT_RELEASED) {
|
||||
label_count1_value++;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
wgl_label_set_text(label_count1, label_count1_str);
|
||||
|
||||
//wgl_cont_set_fit4(btn, WGL_FIT_FLOOD, WGL_FIT_FLOOD, WGL_FIT_FLOOD, WGL_FIT_FLOOD);
|
||||
|
||||
@ -24,7 +24,7 @@ endif ()
|
||||
|
||||
# Set BUILD_TARGET, currently values supported:
|
||||
# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
|
||||
if (NOT BUILD_TARGET)
|
||||
if (NOT DEFINED BUILD_TARGET)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
# Build as X86_64 by default in 64-bit platform
|
||||
set (BUILD_TARGET "X86_64")
|
||||
|
||||
@ -16,10 +16,10 @@ zephyr_compile_definitions (-DNVALGRIND
|
||||
-Dattr_container_free=bh_free
|
||||
-DWASM_ENABLE_GUI=1)
|
||||
|
||||
# Build as ARM_32 by default, change to "X86_32", "MIPS_32" or "XTENSA_32"
|
||||
# if we want to support x86, mips or xtensa
|
||||
if (NOT BUILD_TARGET)
|
||||
set (BUILD_TARGET "ARM_32")
|
||||
# Build as General by default, change to "ARM_32", "X86_32", "MIPS_32" or "XTENSA_32"
|
||||
# if we want to support arm_32, x86, mips or xtensa
|
||||
if (NOT DEFINED BUILD_TARGET)
|
||||
set (BUILD_TARGET "General")
|
||||
endif ()
|
||||
|
||||
string(TOUPPER ${BUILD_TARGET} BUILD_TARGET)
|
||||
@ -32,108 +32,73 @@ elseif (BUILD_TARGET STREQUAL "MIPS_32")
|
||||
add_definitions(-DBUILD_TARGET_MIPS_32)
|
||||
elseif (BUILD_TARGET STREQUAL "XTENSA_32")
|
||||
add_definitions(-DBUILD_TARGET_XTENSA_32)
|
||||
elseif (BUILD_TARGET STREQUAL "GENERAL")
|
||||
# Will use invokeNative_general.c instead of assembly code,
|
||||
# but the maximum number of native arguments is limited to 20,
|
||||
# and there are possible issues when passing arguments to
|
||||
# native function for some cpus, e.g. int64 and double arguments
|
||||
# in arm and mips need to be 8-bytes aligned, and some arguments
|
||||
# of x86_64 are passed by registers but not stack
|
||||
else ()
|
||||
message (FATAL_ERROR "-- Build target isn't set")
|
||||
endif ()
|
||||
|
||||
message ("-- Build as target ${BUILD_TARGET}")
|
||||
|
||||
set (IWASM_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/core/iwasm)
|
||||
set (APP_MGR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/core/app-mgr)
|
||||
set (SHARED_LIB_ROOT ${IWASM_ROOT}/../shared-lib)
|
||||
set (WASM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/core/iwasm)
|
||||
set (APP_MGR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/core/app-mgr)
|
||||
set (SHARED_DIR ${WASM_DIR}/../shared-lib)
|
||||
|
||||
target_include_directories(app PRIVATE ${IWASM_ROOT}/runtime/include
|
||||
${IWASM_ROOT}/runtime/platform/zephyr
|
||||
${IWASM_ROOT}/runtime/platform/include
|
||||
${IWASM_ROOT}/runtime/utils
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm
|
||||
${IWASM_ROOT}/lib/native/base
|
||||
${IWASM_ROOT}/lib/native/libc
|
||||
${IWASM_ROOT}/lib/native/extension/sensor
|
||||
${IWASM_ROOT}/lib/native/extension/connection
|
||||
${IWASM_ROOT}/lib/native/extension/gui
|
||||
${IWASM_ROOT}/lib/native-interface
|
||||
${IWASM_ROOT}/lib/3rdparty
|
||||
${IWASM_ROOT}/lib/3rdparty/lvgl
|
||||
${IWASM_ROOT}/lib/3rdparty/lvgl/src
|
||||
${APP_MGR_ROOT}/app-manager
|
||||
${APP_MGR_ROOT}/app-mgr-shared
|
||||
${SHARED_LIB_ROOT}/include
|
||||
${SHARED_LIB_ROOT}/platform/include
|
||||
${SHARED_LIB_ROOT}/platform/zephyr
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems
|
||||
${SHARED_LIB_ROOT}/utils
|
||||
${SHARED_LIB_ROOT}/coap/er-coap
|
||||
${SHARED_LIB_ROOT}/coap/extension
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr
|
||||
)
|
||||
set (TARGET_PLATFORM "zephyr")
|
||||
|
||||
file (GLOB_RECURSE GUI_SRC ${IWASM_ROOT}/lib/native/extension/gui/*.c ${IWASM_ROOT}/lib/3rdparty/lvgl/*.c)
|
||||
include (${WASM_DIR}/runtime/platform/${TARGET_PLATFORM}/platform.cmake)
|
||||
include (${WASM_DIR}/runtime/utils/utils.cmake)
|
||||
include (${WASM_DIR}/runtime/vmcore-wasm/vmcore.cmake)
|
||||
include (${WASM_DIR}/lib/native/base/wasm_lib_base.cmake)
|
||||
include (${WASM_DIR}/lib/native/libc/wasm_libc.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/sensor/wasm_lib_sensor.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/gui/wasm_lib_gui.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/connection/wasm_lib_conn.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/connection/${TARGET_PLATFORM}/connection_mgr.cmake)
|
||||
include (${WASM_DIR}/lib/native-interface/native_interface.cmake)
|
||||
include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
|
||||
include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
|
||||
include (${SHARED_DIR}/platform/${TARGET_PLATFORM}/shared_platform.cmake)
|
||||
include (${SHARED_DIR}/utils/shared_utils.cmake)
|
||||
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
|
||||
include (${SHARED_DIR}/coap/lib_coap.cmake)
|
||||
|
||||
set (IWASM_SRCS
|
||||
${IWASM_ROOT}/runtime/platform/zephyr/wasm_native.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_dlfcn.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_hashmap.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_log.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_vector.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_application.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_interp.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_loader.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_runtime.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/invokeNative_general.c
|
||||
${IWASM_ROOT}/lib/native/base/base_lib_export.c
|
||||
${IWASM_ROOT}/lib/native/base/request_response.c
|
||||
${IWASM_ROOT}/lib/native/base/timer_wrapper.c
|
||||
${IWASM_ROOT}/lib/native/libc/libc_wrapper.c
|
||||
${IWASM_ROOT}/lib/native/extension/sensor/runtime_sensor.c
|
||||
${IWASM_ROOT}/lib/native/extension/connection/connection_wrapper.c
|
||||
${IWASM_ROOT}/lib/native/extension/connection/zephyr/connection_lib_impl.c
|
||||
${GUI_SRC}
|
||||
${IWASM_ROOT}/lib/native-interface/attr_container.c
|
||||
${IWASM_ROOT}/lib/native-interface/restful_utils.c
|
||||
${APP_MGR_ROOT}/app-manager/app_manager.c
|
||||
${APP_MGR_ROOT}/app-manager/app_manager_host.c
|
||||
${APP_MGR_ROOT}/app-manager/ble_msg.c
|
||||
${APP_MGR_ROOT}/app-manager/event.c
|
||||
${APP_MGR_ROOT}/app-manager/message.c
|
||||
${APP_MGR_ROOT}/app-manager/module_jeff.c
|
||||
${APP_MGR_ROOT}/app-manager/module_utils.c
|
||||
${APP_MGR_ROOT}/app-manager/module_wasm_app.c
|
||||
${APP_MGR_ROOT}/app-manager/module_wasm_lib.c
|
||||
${APP_MGR_ROOT}/app-manager/resource_reg.c
|
||||
${APP_MGR_ROOT}/app-manager/watchdog.c
|
||||
${APP_MGR_ROOT}/app-manager/platform/zephyr/app_mgr_zephyr.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_assert.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_definition.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_platform.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_platform_log.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_thread.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_time.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_math.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/bh_memory.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/mem_alloc.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_alloc.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_hmu.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_kfc.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/tlsf/tlsf.c
|
||||
${SHARED_LIB_ROOT}/utils/bh_list.c
|
||||
${SHARED_LIB_ROOT}/utils/bh_log.c
|
||||
${SHARED_LIB_ROOT}/utils/bh_queue.c
|
||||
${SHARED_LIB_ROOT}/utils/runtime_timer.c
|
||||
${SHARED_LIB_ROOT}/coap/er-coap/er-coap.c
|
||||
${SHARED_LIB_ROOT}/coap/extension/coap_conversion.c
|
||||
${SHARED_LIB_ROOT}/coap/extension/coap_over_tcp.c
|
||||
)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr)
|
||||
|
||||
set (LVGL_DRV_SRCS
|
||||
set (LVGL_DRV_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_ili9340_adafruit_1480.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_ili9340.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/XPT2046.c
|
||||
)
|
||||
|
||||
target_sources(app PRIVATE ${IWASM_SRCS}
|
||||
${LVGL_DRV_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/iwasm_main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/ext_lib_export.c)
|
||||
set (IWASM_SRCS
|
||||
${WASM_PLATFORM_LIB_SOURCE}
|
||||
${WASM_UTILS_LIB_SOURCE}
|
||||
${VMCORE_LIB_SOURCE}
|
||||
${WASM_LIBC_SOURCE}
|
||||
${APP_MGR_SOURCE}
|
||||
${WASM_LIB_BASE_SOURCE}
|
||||
${WASM_LIB_EXT_SOURCE}
|
||||
${WASM_LIB_SENSOR_SOURCE}
|
||||
${WASM_LIB_GUI_SOURCE}
|
||||
${WASM_LIB_CONN_SOURCE}
|
||||
${WASM_LIB_CONN_MGR_SOURCE}
|
||||
${PLATFORM_SHARED_SOURCE}
|
||||
${UTILS_SHARED_SOURCE}
|
||||
${MEM_ALLOC_SHARED_SOURCE}
|
||||
${NATIVE_INTERFACE_SOURCE}
|
||||
)
|
||||
|
||||
target_sources(app PRIVATE
|
||||
${IWASM_SRCS}
|
||||
${LVGL_DRV_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/iwasm_main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/ext_lib_export.c
|
||||
)
|
||||
|
||||
@ -55,7 +55,8 @@ char label_count1_str[11] = { 0 };
|
||||
static lv_res_t btn_rel_action(lv_obj_t * btn)
|
||||
{
|
||||
label_count1_value++;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
@ -95,7 +96,7 @@ int main()
|
||||
/* Periodically call the lv_task handler.
|
||||
* It could be done in a timer interrupt or an OS task too.*/
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count/ 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count/ 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
lv_task_handler();
|
||||
|
||||
@ -14,7 +14,7 @@ endif ()
|
||||
|
||||
# Set BUILD_TARGET, currently values supported:
|
||||
# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
|
||||
if (NOT BUILD_TARGET)
|
||||
if (NOT DEFINED BUILD_TARGET)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
# Build as X86_64 by default in 64-bit platform
|
||||
set (BUILD_TARGET "X86_64")
|
||||
|
||||
@ -22,8 +22,6 @@ void monitor_sdl_clean_up(void);
|
||||
|
||||
static uint32_t tft_fb[MONITOR_HOR_RES * MONITOR_VER_RES];
|
||||
|
||||
|
||||
|
||||
int
|
||||
time_get_ms(wasm_module_inst_t module_inst)
|
||||
{
|
||||
@ -42,7 +40,7 @@ static volatile bool sdl_refr_qry = false;
|
||||
static volatile bool sdl_quit_qry = false;
|
||||
|
||||
void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0 || y2 < 0 || x1 > MONITOR_HOR_RES - 1
|
||||
@ -52,16 +50,16 @@ void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
||||
int32_t y;
|
||||
uint32_t w = x2 - x1 + 1;
|
||||
|
||||
for (y = y1; y <= y2; y++) {
|
||||
memcpy(&tft_fb[y * MONITOR_HOR_RES + x1], color_p,
|
||||
w * sizeof(lv_color_t));
|
||||
w * sizeof(lv_color_t));
|
||||
|
||||
color_p += w;
|
||||
}
|
||||
sdl_refr_qry = true;
|
||||
|
||||
/*IMPORTANT! It must be called to tell the system the flush is ready*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +71,7 @@ void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
* @param color fill color
|
||||
*/
|
||||
void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color)
|
||||
lv_color_t color)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0)
|
||||
@ -113,7 +111,7 @@ void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
* @param color_p an array of colors
|
||||
*/
|
||||
void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
const lv_color_t * color_p)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0)
|
||||
|
||||
@ -15,10 +15,10 @@ zephyr_compile_definitions (-DNVALGRIND
|
||||
-Dattr_container_malloc=bh_malloc
|
||||
-Dattr_container_free=bh_free)
|
||||
|
||||
# Build as ARM_32 by default, change to "X86_32", "MIPS_32" or "XTENSA_32"
|
||||
# if we want to support x86, mips or xtensa
|
||||
if (NOT BUILD_TARGET)
|
||||
set (BUILD_TARGET "ARM_32")
|
||||
# Build as General by default, change to "ARM_32", "X86_32", "MIPS_32" or "XTENSA_32"
|
||||
# if we want to support arm_32, x86, mips or xtensa
|
||||
if (NOT DEFINED BUILD_TARGET)
|
||||
set (BUILD_TARGET "General")
|
||||
endif ()
|
||||
|
||||
string(TOUPPER ${BUILD_TARGET} BUILD_TARGET)
|
||||
@ -31,101 +31,70 @@ elseif (BUILD_TARGET STREQUAL "MIPS_32")
|
||||
add_definitions(-DBUILD_TARGET_MIPS_32)
|
||||
elseif (BUILD_TARGET STREQUAL "XTENSA_32")
|
||||
add_definitions(-DBUILD_TARGET_XTENSA_32)
|
||||
elseif (BUILD_TARGET STREQUAL "GENERAL")
|
||||
# Will use invokeNative_general.c instead of assembly code,
|
||||
# but the maximum number of native arguments is limited to 20,
|
||||
# and there are possible issues when passing arguments to
|
||||
# native function for some cpus, e.g. int64 and double arguments
|
||||
# in arm and mips need to be 8-bytes aligned, and some arguments
|
||||
# of x86_64 are passed by registers but not stack
|
||||
else ()
|
||||
message (FATAL_ERROR "-- Build target isn't set")
|
||||
endif ()
|
||||
|
||||
message ("-- Build as target ${BUILD_TARGET}")
|
||||
set (IWASM_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/core/iwasm)
|
||||
set (APP_MGR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/core/app-mgr)
|
||||
set (SHARED_LIB_ROOT ${IWASM_ROOT}/../shared-lib)
|
||||
set (WASM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/core/iwasm)
|
||||
set (APP_MGR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/core/app-mgr)
|
||||
set (SHARED_DIR ${WASM_DIR}/../shared-lib)
|
||||
|
||||
target_include_directories(app PRIVATE ${IWASM_ROOT}/runtime/include
|
||||
${IWASM_ROOT}/runtime/platform/zephyr
|
||||
${IWASM_ROOT}/runtime/platform/include
|
||||
${IWASM_ROOT}/runtime/utils
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm
|
||||
${IWASM_ROOT}/lib/native/base
|
||||
${IWASM_ROOT}/lib/native/libc
|
||||
${IWASM_ROOT}/lib/native/extension/sensor
|
||||
${IWASM_ROOT}/lib/native/extension/connection
|
||||
${IWASM_ROOT}/lib/native-interface
|
||||
${APP_MGR_ROOT}/app-manager
|
||||
${APP_MGR_ROOT}/app-mgr-shared
|
||||
${SHARED_LIB_ROOT}/include
|
||||
${SHARED_LIB_ROOT}/platform/include
|
||||
${SHARED_LIB_ROOT}/platform/zephyr
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems
|
||||
${SHARED_LIB_ROOT}/utils
|
||||
${SHARED_LIB_ROOT}/coap/er-coap
|
||||
${SHARED_LIB_ROOT}/coap/extension
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr
|
||||
)
|
||||
set (TARGET_PLATFORM "zephyr")
|
||||
|
||||
set (IWASM_SRCS
|
||||
${IWASM_ROOT}/runtime/platform/zephyr/wasm_native.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_dlfcn.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_hashmap.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_log.c
|
||||
${IWASM_ROOT}/runtime/utils/wasm_vector.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_application.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_interp.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_loader.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/wasm_runtime.c
|
||||
${IWASM_ROOT}/runtime/vmcore-wasm/invokeNative_general.c
|
||||
${IWASM_ROOT}/lib/native/base/base_lib_export.c
|
||||
${IWASM_ROOT}/lib/native/base/request_response.c
|
||||
${IWASM_ROOT}/lib/native/base/timer_wrapper.c
|
||||
${IWASM_ROOT}/lib/native/libc/libc_wrapper.c
|
||||
${IWASM_ROOT}/lib/native/extension/sensor/runtime_sensor.c
|
||||
${IWASM_ROOT}/lib/native/extension/connection/connection_wrapper.c
|
||||
${IWASM_ROOT}/lib/native/extension/connection/zephyr/connection_lib_impl.c
|
||||
${IWASM_ROOT}/lib/native-interface/attr_container.c
|
||||
${IWASM_ROOT}/lib/native-interface/restful_utils.c
|
||||
${APP_MGR_ROOT}/app-manager/app_manager.c
|
||||
${APP_MGR_ROOT}/app-manager/app_manager_host.c
|
||||
${APP_MGR_ROOT}/app-manager/ble_msg.c
|
||||
${APP_MGR_ROOT}/app-manager/event.c
|
||||
${APP_MGR_ROOT}/app-manager/message.c
|
||||
${APP_MGR_ROOT}/app-manager/module_jeff.c
|
||||
${APP_MGR_ROOT}/app-manager/module_utils.c
|
||||
${APP_MGR_ROOT}/app-manager/module_wasm_app.c
|
||||
${APP_MGR_ROOT}/app-manager/module_wasm_lib.c
|
||||
${APP_MGR_ROOT}/app-manager/resource_reg.c
|
||||
${APP_MGR_ROOT}/app-manager/watchdog.c
|
||||
${APP_MGR_ROOT}/app-manager/platform/zephyr/app_mgr_zephyr.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_assert.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_definition.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_platform.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_platform_log.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_thread.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_time.c
|
||||
${SHARED_LIB_ROOT}/platform/zephyr/bh_math.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/bh_memory.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/mem_alloc.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_alloc.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_hmu.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/ems/ems_kfc.c
|
||||
${SHARED_LIB_ROOT}/mem-alloc/tlsf/tlsf.c
|
||||
${SHARED_LIB_ROOT}/utils/bh_list.c
|
||||
${SHARED_LIB_ROOT}/utils/bh_log.c
|
||||
${SHARED_LIB_ROOT}/utils/bh_queue.c
|
||||
${SHARED_LIB_ROOT}/utils/runtime_timer.c
|
||||
${SHARED_LIB_ROOT}/coap/er-coap/er-coap.c
|
||||
${SHARED_LIB_ROOT}/coap/extension/coap_conversion.c
|
||||
${SHARED_LIB_ROOT}/coap/extension/coap_over_tcp.c
|
||||
)
|
||||
include (${WASM_DIR}/runtime/platform/${TARGET_PLATFORM}/platform.cmake)
|
||||
include (${WASM_DIR}/runtime/utils/utils.cmake)
|
||||
include (${WASM_DIR}/runtime/vmcore-wasm/vmcore.cmake)
|
||||
include (${WASM_DIR}/lib/native/base/wasm_lib_base.cmake)
|
||||
include (${WASM_DIR}/lib/native/libc/wasm_libc.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/sensor/wasm_lib_sensor.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/connection/wasm_lib_conn.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/connection/${TARGET_PLATFORM}/connection_mgr.cmake)
|
||||
include (${WASM_DIR}/lib/native-interface/native_interface.cmake)
|
||||
include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
|
||||
include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
|
||||
include (${SHARED_DIR}/platform/${TARGET_PLATFORM}/shared_platform.cmake)
|
||||
include (${SHARED_DIR}/utils/shared_utils.cmake)
|
||||
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
|
||||
include (${SHARED_DIR}/coap/lib_coap.cmake)
|
||||
|
||||
set (LVGL_DRV_SRCS
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr)
|
||||
|
||||
set (LVGL_DRV_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_ili9340_adafruit_1480.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_ili9340.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/display_indev.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/XPT2046.c
|
||||
)
|
||||
|
||||
target_sources(app PRIVATE ${IWASM_SRCS}
|
||||
${LVGL_DRV_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/iwasm_main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/ext_lib_export.c)
|
||||
set (IWASM_SRCS
|
||||
${WASM_PLATFORM_LIB_SOURCE}
|
||||
${WASM_UTILS_LIB_SOURCE}
|
||||
${VMCORE_LIB_SOURCE}
|
||||
${WASM_LIBC_SOURCE}
|
||||
${APP_MGR_SOURCE}
|
||||
${WASM_LIB_BASE_SOURCE}
|
||||
${WASM_LIB_EXT_SOURCE}
|
||||
${WASM_LIB_SENSOR_SOURCE}
|
||||
${WASM_LIB_CONN_SOURCE}
|
||||
${WASM_LIB_CONN_MGR_SOURCE}
|
||||
${PLATFORM_SHARED_SOURCE}
|
||||
${UTILS_SHARED_SOURCE}
|
||||
${MEM_ALLOC_SHARED_SOURCE}
|
||||
${NATIVE_INTERFACE_SOURCE}
|
||||
)
|
||||
target_sources(app PRIVATE
|
||||
${IWASM_SRCS}
|
||||
${LVGL_DRV_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/zephyr/iwasm_main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/ext_lib_export.c
|
||||
)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
CC = emcc
|
||||
CC = clang-8
|
||||
LVGL_DIR = ${shell pwd}
|
||||
IWASM_DIR=../../../core/iwasm
|
||||
CFLAGS += -O3 \
|
||||
@ -50,7 +50,8 @@ SRCS += $(LVGL_DIR)/src/main.c
|
||||
SRCS += $(IWASM_DIR)/lib/app-libs/base/timer.c
|
||||
all:
|
||||
@$(CC) $(CFLAGS) $(SRCS) \
|
||||
-s WASM=1 -s SIDE_MODULE=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=2 \
|
||||
-s TOTAL_MEMORY=65536 -s TOTAL_STACK=2048\
|
||||
-s "EXPORTED_FUNCTIONS=['_on_init', '_on_timer_callback']" \
|
||||
--target=wasm32 -O3 -z stack-size=2048 -Wl,--initial-memory=65536 \
|
||||
-Wl,--allow-undefined \
|
||||
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
|
||||
-Wl,--export=on_init -Wl,--export=on_timer_callback \
|
||||
-o ui_app.wasm
|
||||
|
||||
@ -56,7 +56,7 @@ char label_count1_str[11] = { 0 };
|
||||
void timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count / 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
lv_task_handler();
|
||||
@ -67,7 +67,8 @@ void timer1_update(user_timer_t timer1)
|
||||
static lv_res_t btn_rel_action(lv_obj_t * btn)
|
||||
{
|
||||
label_count1_value++;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ set (BUILD_AS_64BIT_SUPPORT "YES")
|
||||
|
||||
# Set BUILD_TARGET, currently values supported:
|
||||
# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
|
||||
if (NOT BUILD_TARGET)
|
||||
if (NOT DEFINED BUILD_TARGET)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if (BUILD_AS_64BIT_SUPPORT STREQUAL "YES")
|
||||
# Build as X86_64 by default in 64-bit platform
|
||||
|
||||
@ -63,15 +63,18 @@ for i in `ls *.c`
|
||||
do
|
||||
APP_SRC="$i ${APP_LIB_SRC}"
|
||||
OUT_FILE=${i%.*}.wasm
|
||||
emcc -O3 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
|
||||
-I${APP_LIBS}/extension/connection \
|
||||
-I${APP_LIBS}/extension/gui \
|
||||
-DENABLE_WGL=1 \
|
||||
-s WASM=1 -s SIDE_MODULE=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=2 \
|
||||
-s TOTAL_MEMORY=65536 -s TOTAL_STACK=4096 \
|
||||
-s "EXPORTED_FUNCTIONS=['_on_init', '_on_destroy', '_on_request', '_on_response', \
|
||||
'_on_sensor_event', '_on_timer_callback', '_on_connection_data', '_on_widget_event']" \
|
||||
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
||||
clang-8 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
|
||||
-I${APP_LIBS}/extension/connection \
|
||||
-I${APP_LIBS}/extension/gui \
|
||||
-DENABLE_WGL=1 \
|
||||
--target=wasm32 -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
|
||||
-Wl,--allow-undefined \
|
||||
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
|
||||
-Wl,--export=on_init -Wl,--export=on_destroy \
|
||||
-Wl,--export=on_request -Wl,--export=on_response \
|
||||
-Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
|
||||
-Wl,--export=on_connection_data -Wl,--export=on_widget_event \
|
||||
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
||||
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
|
||||
echo "build ${OUT_FILE} success"
|
||||
else
|
||||
|
||||
@ -55,13 +55,16 @@ for i in `ls *.c | grep -v gui`
|
||||
do
|
||||
APP_SRC="$i ${APP_LIB_SRC}"
|
||||
OUT_FILE=${i%.*}.wasm
|
||||
emcc -O3 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
|
||||
-I${APP_LIBS}/extension/connection \
|
||||
-s WASM=1 -s SIDE_MODULE=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=2 \
|
||||
-s TOTAL_MEMORY=65536 -s TOTAL_STACK=4096 \
|
||||
-s "EXPORTED_FUNCTIONS=['_on_init', '_on_destroy', '_on_request', '_on_response', \
|
||||
'_on_sensor_event', '_on_timer_callback', '_on_connection_data']" \
|
||||
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
||||
clang-8 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
|
||||
-I${APP_LIBS}/extension/connection \
|
||||
--target=wasm32 -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
|
||||
-Wl,--allow-undefined \
|
||||
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
|
||||
-Wl,--export=on_init -Wl,--export=on_destroy \
|
||||
-Wl,--export=on_request -Wl,--export=on_response \
|
||||
-Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
|
||||
-Wl,--export=on_connection_data \
|
||||
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
||||
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
|
||||
echo "build ${OUT_FILE} success"
|
||||
else
|
||||
|
||||
@ -2,4 +2,5 @@ extern void iwasm_main();
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
iwasm_main(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ char label_count1_str[11] = { 0 };
|
||||
void timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count / 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
wgl_label_set_text(count_label, count_str);
|
||||
}
|
||||
++count;
|
||||
@ -63,7 +63,8 @@ static void btn_event_cb(wgl_obj_t btn, wgl_event_t event)
|
||||
{
|
||||
if(event == WGL_EVENT_RELEASED) {
|
||||
label_count1_value++;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
wgl_label_set_text(label_count1, label_count1_str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ char label_count1_str[11] = { 0 };
|
||||
void timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
sprintf(count_str, "%d", count / 100);
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
++count;
|
||||
@ -65,7 +65,8 @@ static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_RELEASED) {
|
||||
label_count1_value--;
|
||||
sprintf(label_count1_str, "%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
if (label_count1_value == 0)
|
||||
label_count1_value = 100;
|
||||
|
||||
Reference in New Issue
Block a user