Skip to content

Commit 723b927

Browse files
committed
refactor: enhance CMake configurations for better build output and module support
1 parent 528ed7e commit 723b927

File tree

6 files changed

+29
-24
lines changed

6 files changed

+29
-24
lines changed

.github/workflows/compilation_on_android_ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ jobs:
369369
mkdir build && cd build
370370
cmake .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }}
371371
cmake --build . --config Release --parallel 4
372-
ctest
372+
ctest --output-on-failure
373373
working-directory: tests/unit
374374

375375
build_regression_tests:

tests/unit/compilation/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ add_definitions (-DWASM_ENABLE_DUMP_CALL_STACK=1)
1414
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
1515

1616
set (WAMR_BUILD_LIBC_WASI 0)
17+
set (WAMR_BUILD_LIBC_BUILTIN 1)
18+
set (WAMR_BUILD_MULTI_MODULE 1)
1719
set (WAMR_BUILD_APP_FRAMEWORK 0)
1820
set (WAMR_BUILD_THREAD_MGR 1)
1921
set (WAMR_BUILD_AOT 1)

tests/unit/libc-builtin/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ set (WAMR_BUILD_JIT 0)
1414
set (WAMR_BUILD_LIBC_BUILTIN 1)
1515
set (WAMR_BUILD_LIBC_WASI 0)
1616
set (WAMR_BUILD_APP_FRAMEWORK 0)
17+
# FIXME: if removed, LibcBuiltinTest.calloc will be failed
18+
set (WAMR_BUILD_MULTI_MODULE 1)
1719

1820
include (../unit_common.cmake)
1921

tests/unit/running-modes/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ ExternalProject_Add(
1616
CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps -B build
1717
-DWASI_SDK_PREFIX=${WASI_SDK_DIR}
1818
-DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN}
19-
BUILD_COMMAND ${CMAKE_COMMAND} --build build
19+
BUILD_COMMAND ${CMAKE_COMMAND} --build build --verbose
2020
INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR}
2121
)
2222

2323
add_definitions(-DRUN_ON_LINUX)
2424

25-
set(WAMR_BUILD_LIBC_WASI 1)
25+
set(WAMR_BUILD_LIBC_BUILTIN 1)
26+
set(WAMR_BUILD_MULTI_MODULE 0)
27+
set(WAMR_BUILD_LIBC_WASI 0)
2628
set(WAMR_BUILD_APP_FRAMEWORK 0)
2729
set(WAMR_BUILD_JIT 1)
2830
set(WAMR_BUILD_FAST_JIT 1)
31+
set(WAMR_BUILD_REF_TYPES 1)
2932

3033
# if only load this CMake other than load it as subdirectory
3134
include(../unit_common.cmake)

tests/unit/running-modes/wasm-apps/CMakeLists.txt

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,30 @@
44
cmake_minimum_required(VERSION 3.14)
55
project(wasm-apps)
66

7-
# set(CMAKE_C_FLAGS "-nostdlib -pthread -Qunused-arguments")
8-
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -z stack-size=8192 -nostdlib")
9-
107
add_executable(mytest.wasm mytest.c)
11-
target_link_libraries(mytest.wasm)
12-
target_compile_options(mytest.wasm PRIVATE
13-
-pthread
14-
)
8+
target_compile_options(mytest.wasm PUBLIC -nostdlib)
159
target_link_options(mytest.wasm PRIVATE
10+
-nostdlib
1611
LINKER:--allow-undefined
1712
LINKER:--export-all
13+
LINKER:--initial-memory=131072
1814
LINKER:--no-entry
1915
)
2016

2117
add_executable(hello.wasm hello.c)
22-
target_link_libraries(hello.wasm)
23-
24-
add_custom_command(TARGET hello.wasm POST_BUILD
25-
COMMAND ${CMAKE_COMMAND} -E copy
26-
${CMAKE_CURRENT_BINARY_DIR}/hello.wasm
27-
${CMAKE_CURRENT_BINARY_DIR}/../
28-
COMMENT "Copy hello.wasm to the same directory of google test"
29-
)
18+
target_compile_options(hello.wasm PUBLIC -nostdlib)
19+
target_link_options(hello.wasm PRIVATE
20+
-nostdlib
21+
LINKER:--allow-undefined
22+
LINKER:--export-all
23+
LINKER:--initial-memory=131072
24+
LINKER:--no-entry
25+
)
3026

31-
add_custom_command(TARGET mytest.wasm POST_BUILD
32-
COMMAND ${CMAKE_COMMAND} -E copy
33-
${CMAKE_CURRENT_BINARY_DIR}/mytest.wasm
34-
${CMAKE_CURRENT_BINARY_DIR}/../
35-
COMMENT "Copy mytest.wasm to the same directory of google test"
36-
)
27+
# install .wasm
28+
set(
29+
WASM_FILES
30+
${CMAKE_CURRENT_BINARY_DIR}/hello.wasm
31+
${CMAKE_CURRENT_BINARY_DIR}/mytest.wasm
32+
)
33+
install(FILES ${WASM_FILES} DESTINATION .)

tests/unit/wasm-vm/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(WAMR_BUILD_AOT 0)
1111
set(WAMR_BUILD_FAST_INTERP 0)
1212
set(WAMR_BUILD_INTERP 1)
1313
set(WAMR_BUILD_JIT 0)
14+
set(WAMR_BUILD_LIBC_BUILTIN 1)
1415

1516
add_definitions (-Dattr_container_malloc=malloc)
1617
add_definitions (-Dattr_container_free=free)

0 commit comments

Comments
 (0)