File tree Expand file tree Collapse file tree 2 files changed +29
-11
lines changed
tests/unit/custom-section Expand file tree Collapse file tree 2 files changed +29
-11
lines changed Original file line number Diff line number Diff line change 2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
4
cmake_minimum_required (VERSION 3.14)
5
-
6
5
project (test -custom-section)
7
6
7
+ set (WASI_SDK_DIR "/opt/wasi-sdk" )
8
+ set (WASISDK_TOOLCHAIN "${WASI_SDK_DIR} /share/cmake/wasi-sdk.cmake" )
9
+
10
+ include (ExternalProject)
11
+ ExternalProject_Add(
12
+ custom-section-test -wasm-apps
13
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /wasm-apps
14
+ BUILD_ALWAYS YES
15
+ CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR} /wasm-apps -B build
16
+ -DWASI_SDK_PREFIX=${WASI_SDK_DIR}
17
+ -DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN}
18
+ BUILD_COMMAND ${CMAKE_COMMAND} --build build --verbose
19
+ INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR} /wasm-apps
20
+ )
21
+
8
22
add_definitions (-DRUN_ON_LINUX)
9
23
10
24
set (WAMR_BUILD_LIBC_WASI 0)
@@ -37,9 +51,6 @@ set (unit_test_sources
37
51
${IWASM_COMPL_SOURCE}
38
52
)
39
53
40
- # Automatically build wasm-apps for this test
41
- add_subdirectory (wasm-apps)
42
-
43
54
# Now simply link against gtest or gtest_main as needed. Eg
44
55
add_executable (custom_section_test ${unit_test_sources} )
45
56
Original file line number Diff line number Diff line change 2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
4
cmake_minimum_required (VERSION 3.14)
5
+ project (wasm-apps)
5
6
6
- project (wasm-apps-custom-section)
7
+ add_executable (app.wasm app.c)
8
+ target_compile_options (app.wasm PUBLIC -g -nostdlib)
9
+ target_link_options (app.wasm PRIVATE
10
+ -nostdlib
11
+ LINKER:--allow-undefined
12
+ LINKER:--export-all
13
+ LINKER:--no -entry
14
+ )
7
15
8
- # Add -g option so there will be debugger related custom sections
9
- add_custom_target (app.wasm ALL
10
- COMMAND /opt/wasi-sdk/bin/clang -g -nostdlib
11
- -Wl,--no -entry,--export-all
12
- -o ${CMAKE_CURRENT_BINARY_DIR} /app.wasm
13
- ${CMAKE_CURRENT_LIST_DIR} /app.c
16
+ # install .wasm
17
+ set (
18
+ WASM_FILES
19
+ ${CMAKE_CURRENT_BINARY_DIR} /app.wasm
14
20
)
21
+ install (FILES ${WASM_FILES} DESTINATION .)
You can’t perform that action at this time.
0 commit comments