Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/shared-lib/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@
#define APP_HEAP_SIZE_MAX (1024 * 1024)

/* Default wasm stack size of each app */
#ifdef __x86_64__
#define DEFAULT_WASM_STACK_SIZE (12 * 1024)
#else
#define DEFAULT_WASM_STACK_SIZE (8 * 1024)
#endif

/* Default/min/max stack size of each app thread */
#ifndef __ZEPHYR__
Expand Down
36 changes: 27 additions & 9 deletions samples/gui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,37 @@ The sample also provides the native Linux version of application without the run

The number on top will plus one each second, and the number on the bottom will plus one when clicked.

Configure 32 bit or 64 bit build
==============
On 64 bit operating system, there is an option to build 32 bit or 64 bit binaries. In file `./lvgl-native-ui-app/CMakeLists.txt` and/or `./wasm-runtime-wgl/linux-build/CMakeLists.txt` , modify the line:
`set (BUILD_AS_64BIT_SUPPORT "YES")`
where `YES` means 64 bit build while `NO` means 32 bit build.

Install required SDK and libraries
==============
- 32 bit SDL(simple directmedia layer)
Use apt-get</br>
`sudo apt-get install libsdl2-dev:i386`</br>
Or download source from www.libsdl.org</br>
`./configure C_FLAGS=-m32 CXX_FLAGS=-m32 LD_FLAGS=-m32`</br>
`make`</br>
`sudo make install`</br>
- 32 bit SDL(simple directmedia layer) (Note: only necessary when `BUILD_AS_64BIT_SUPPORT` is set to `NO`)
Use apt-get:
`sudo apt-get install libsdl2-dev:i386`
Or download source from www.libsdl.org:
```
./configure C_FLAGS=-m32 CXX_FLAGS=-m32 LD_FLAGS=-m32
make
sudo make install
```
- 64 bit SDL(simple directmedia layer) (Note: only necessary when `BUILD_AS_64BIT_SUPPORT` is set to `YES`)
Use apt-get:
`sudo apt-get install libsdl2-dev`
Or download source from www.libsdl.org:
```
./configure
make
sudo make install
```

- Install EMSDK
<pre>
```
https://emscripten.org/docs/tools_reference/emsdk.html
</pre>
```

Build and Run
==============
Expand Down
30 changes: 19 additions & 11 deletions samples/gui/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ if [ ! -d "tlsf" ]; then
git clone https://github.com/mattconte/tlsf
fi

cd ${WAMR_DIR}/core/iwasm/lib/3rdparty
if [ ! -d "lvgl" ]; then
git clone https://github.com/littlevgl/lvgl.git --branch v6.0.1
fi
if [ ! -d "lv_drivers" ]; then
git clone https://github.com/littlevgl/lv_drivers.git
fi

echo "##################### 1. build native-ui-app start#####################"
cd $BUILD_DIR
mkdir -p lvgl-native-ui-app
Expand All @@ -32,6 +40,17 @@ echo $PWD
cp lvgl_native_ui_app ${OUT_DIR}
echo "#####################build native-ui-app success"


echo "##################### 2. build littlevgl wasm runtime start#####################"
cd $BUILD_DIR
mkdir -p wasm-runtime-wgl
cd wasm-runtime-wgl
cmake ${PROJECT_DIR}/wasm-runtime-wgl/linux-build
make
cp wasm_runtime_wgl ${OUT_DIR}/

echo "##################### build littlevgl wasm runtime end#####################"

echo "#####################build host-tool"
cd $BUILD_DIR
mkdir -p host-tool
Expand All @@ -46,17 +65,6 @@ cp host_tool ${OUT_DIR}
echo "#####################build host-tool success"


echo "##################### 2. build littlevgl wasm runtime start#####################"
cd $BUILD_DIR
mkdir -p wasm-runtime-wgl
cd wasm-runtime-wgl
cmake ${PROJECT_DIR}/wasm-runtime-wgl/linux-build
make
cp wasm_runtime_wgl ${OUT_DIR}/

echo "##################### build littlevgl wasm runtime end#####################"


echo "##################### 3. build wasm ui app start#####################"
cd ${PROJECT_DIR}/wasm-apps/wgl
make
Expand Down
48 changes: 22 additions & 26 deletions samples/gui/lvgl-native-ui-app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,32 @@ message ("lvgl_native_ui_app...")
project (lvgl_native_ui_app)

#################################################################
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -g)

set(lv_name lvgl)
set(lv_drivers_name lv_drivers)
set(LVGL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${lv_name})
set(LVGL_DRIVER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${lv_drivers_name})

if ((NOT EXISTS ${LVGL_SOURCE_DIR}) OR (NOT EXISTS ${LVGL_DRIVER_DIR}))
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl/CMakeLists.txt)

execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl )
if(result)
message(FATAL_ERROR "CMake step for lvgl failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl )
if(result)
message(FATAL_ERROR "Build step for lvgl failed: ${result}")
endif()
endif()

# Currently build as 64-bit by default. Set to "NO" to build 32-bit binaries.
set (BUILD_AS_64BIT_SUPPORT "YES")

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (${BUILD_AS_64BIT_SUPPORT} STREQUAL "YES")
# Add -fPIC flag if build as 64-bit
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
else ()
add_definitions (-m32)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
endif ()
endif ()

set(THIRDPARTY_DIR ../../../core/iwasm/lib/3rdparty)
set(LVGL_SOURCE_DIR ${THIRDPARTY_DIR}/lvgl)
set(LVGL_DRIVER_DIR ${THIRDPARTY_DIR}/lv_drivers)

#################################
set(CMAKE_C_STANDARD 11)#C11
set(CMAKE_CXX_STANDARD 17)#C17
set(CMAKE_CXX_STANDARD_REQUIRED ON)

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${THIRDPARTY_DIR})

add_definitions (-DLV_CONF_INCLUDE_SIMPLE)

file(GLOB_RECURSE INCLUDES "${LVGL_DRIVER_DIR}/*.h" "${LVGL_SOURCE_DIR}/*.h" "./*.h" )
file(GLOB_RECURSE SOURCES "${LVGL_DRIVER_DIR}/*.c" "${LVGL_SOURCE_DIR}/*.c" )
Expand Down
40 changes: 0 additions & 40 deletions samples/gui/lvgl-native-ui-app/CMakeLists.txt.in

This file was deleted.

10 changes: 6 additions & 4 deletions samples/gui/wasm-apps/lvgl-compatible/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lv_obj_t *hello_world_label;
lv_obj_t *count_label;
lv_obj_t *btn1;
lv_obj_t *label_count1;
int label_count1_value = 0;
int label_count1_value = 100;
char label_count1_str[11] = { 0 };

void timer1_update(user_timer_t timer1)
Expand Down Expand Up @@ -60,10 +60,10 @@ void on_init()

/*Create a label on the button*/
lv_obj_t *btn_label = lv_label_create(btn1, NULL);
lv_label_set_text(btn_label, "Click ++");
lv_label_set_text(btn_label, "Click --");

label_count1 = lv_label_create(NULL, NULL);
lv_label_set_text(label_count1, "0");
lv_label_set_text(label_count1, "100");
lv_obj_align(label_count1, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);

/* set up a timer */
Expand All @@ -75,8 +75,10 @@ void on_init()
static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
{
if(event == LV_EVENT_RELEASED) {
label_count1_value++;
label_count1_value--;
sprintf(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;
}
}
30 changes: 6 additions & 24 deletions samples/gui/wasm-runtime-wgl/linux-build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,8 @@ set(WASM_DIR ${REPO_ROOT_DIR}/core/iwasm)
set(APP_MGR_DIR ${REPO_ROOT_DIR}/core/app-mgr)
set(SHARED_DIR ${REPO_ROOT_DIR}/core/shared-lib)

set (lv_drivers_name lv_drivers)
set (lv_name lvgl)
set (LV_DRIVERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src/platform/linux/${lv_drivers_name})
set (LVGL_DIR ${WASM_DIR}/lib/3rdparty/${lv_name})

if ((NOT EXISTS ${LVGL_DIR}) OR (NOT EXISTS ${LV_DRIVERS_DIR}))
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl_drivers/CMakeLists.txt)

execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl_drivers )
if(result)
message(FATAL_ERROR "CMake step for lvgl drivers failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/download_lvgl_drivers )
if(result)
message(FATAL_ERROR "Build step for lvgl drivers failed: ${result}")
endif()
endif()
set (LV_DRIVERS_DIR ${WASM_DIR}/lib/3rdparty/lv_drivers)
set (LVGL_DIR ${WASM_DIR}/lib/3rdparty/lvgl)

file(GLOB_RECURSE LV_DRIVERS_SOURCES "${LV_DRIVERS_DIR}/*.c" )

Expand All @@ -44,9 +25,8 @@ if (NOT ("$ENV{VALGRIND}" STREQUAL "YES"))
add_definitions(-DNVALGRIND)
endif ()

# Currently build as 32-bit by default.
set (BUILD_AS_64BIT_SUPPORT "NO")
#set (BUILD_AS_64BIT_SUPPORT "YES")
# Currently build as 64-bit by default.
set (BUILD_AS_64BIT_SUPPORT "YES")

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (${BUILD_AS_64BIT_SUPPORT} STREQUAL "YES")
Expand Down Expand Up @@ -96,10 +76,12 @@ include (${SHARED_DIR}/coap/lib_coap.cmake)
set (PROJECT_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/../src/platform/${TARGET_PLATFORM})

include_directories(${SHARED_DIR}/include)
include_directories(${PROJECT_SRC_DIR})

add_definitions (-DWASM_ENABLE_BASE_LIB)
add_definitions (-Dattr_container_malloc=bh_malloc)
add_definitions (-Dattr_container_free=bh_free)
add_definitions (-DLV_CONF_INCLUDE_SIMPLE)

add_library (vmlib
${WASM_PLATFORM_LIB_SOURCE}
Expand Down
41 changes: 0 additions & 41 deletions samples/gui/wasm-runtime-wgl/linux-build/CMakeLists.txt.in

This file was deleted.

37 changes: 28 additions & 9 deletions samples/littlevgl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,38 @@ The sample also provides the native Linux version of application without the run

The number on top will plus one each second, and the number on the bottom will plus one when clicked.

Configure 32 bit or 64 bit build
==============
On 64 bit operating system, there is an option to build 32 bit or 64 bit binaries. In file `./vgl-native-ui-app/CMakeLists.txt` and/or `./vgl-wasm-runtime/CMakeLists.txt` , modify the line:
`set (BUILD_AS_64BIT_SUPPORT "YES")`
where `YES` means 64 bit build while `NO` means 32 bit build.

Install required SDK and libraries
==============
- 32 bit SDL(simple directmedia layer)
Use apt-get</br>
`sudo apt-get install libsdl2-dev:i386`</br>
Or download source from www.libsdl.org</br>
`./configure C_FLAGS=-m32 CXX_FLAGS=-m32 LD_FLAGS=-m32`</br>
`make`</br>
`sudo make install`</br>
- 32 bit SDL(simple directmedia layer) (Note: only necessary when `BUILD_AS_64BIT_SUPPORT` is set to `NO`)
Use apt-get:
`sudo apt-get install libsdl2-dev:i386`
Or download source from www.libsdl.org:
```
./configure C_FLAGS=-m32 CXX_FLAGS=-m32 LD_FLAGS=-m32
make
sudo make install
```
- 64 bit SDL(simple directmedia layer) (Note: only necessary when `BUILD_AS_64BIT_SUPPORT` is set to `YES`)
Use apt-get:
`sudo apt-get install libsdl2-dev`
Or download source from www.libsdl.org:
```
./configure
make
sudo make install
```

- Install EMSDK
<pre>
```
https://emscripten.org/docs/tools_reference/emsdk.html
</pre>
```


Build and Run
==============
Expand Down
Loading