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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user