1- include (FetchContent )
21include (ExternalProject )
32include (CTest )
43enable_testing ()
54
65option (PYTHON_TESTS "Build Python with this wasi-libc and run its tests" OFF )
76
8- # ========= Clone libc-test === ==================================
7+ # ========= Download libc-test ==================================
98
10- FetchContent_Declare (
9+ set (LIBC_TEST_COMMIT 18e28496adee3d84fefdda6efcb9c5b8996a2398)
10+ ExternalProject_Add (
1111 libc-test
12- GIT_REPOSITORY https://github.com/bytecodealliance/libc-test
13- GIT_TAG 18e28496adee3d84fefdda6efcb9c5b8996a2398
14- GIT_SHALLOW true
12+ EXCLUDE_FROM_ALL ON
13+ URL "https://github.com/bytecodealliance/libc-test/archive/${LIBC_TEST_COMMIT} .tar.gz"
14+ DOWNLOAD_EXTRACT_TIMESTAMP ON
15+ CONFIGURE_COMMAND ""
16+ BUILD_COMMAND ""
17+ INSTALL_COMMAND ""
1518)
16- FetchContent_MakeAvailable (libc-test)
17- set (LIBC_TEST "${libc- test_SOURCE_DIR } " )
19+ ExternalProject_Get_Property (libc-test SOURCE_DIR )
20+ set (LIBC_TEST "${SOURCE_DIR } " )
1821message (STATUS "libc-test source directory: ${LIBC_TEST} " )
1922
2023# ========= Download wasmtime as a test runner ==================
@@ -54,6 +57,7 @@ set(libc_test_support_files
5457 "${LIBC_TEST} /src/common/rand.c"
5558 "${LIBC_TEST} /src/common/utf8.c"
5659)
60+ set_source_files_properties (${libc_test_support_files} PROPERTIES GENERATED TRUE )
5761set_source_files_properties ("${LIBC_TEST} /src/common/rand.c"
5862 PROPERTIES COMPILE_OPTIONS -Wno-unused-function)
5963set_source_files_properties ("${LIBC_TEST} /src/common/print.c"
@@ -79,7 +83,7 @@ function(add_test_executable executable_name src)
7983 # Build the test exeutable itself and apply all custom options as applicable.
8084 add_executable (${executable_name} ${src} ${libc_test_support_files} )
8185 target_include_directories (${executable_name} PRIVATE "${LIBC_TEST} /src/common" )
82- add_dependencies (${executable_name} sysroot builtins )
86+ add_dependencies (${executable_name} sysroot builtins libc-test )
8387
8488 if (TARGET_TRIPLE MATCHES "-threads" )
8589 target_link_options (${executable_name} PRIVATE -pthread
@@ -230,6 +234,7 @@ function(add_libc_test test_file)
230234 string (REPLACE "/" "_" test_name ${test_name} )
231235 set (test_name "libc_test_${test_name} " )
232236 set (test_file "${LIBC_TEST} /src/${test_file} " )
237+ set_source_files_properties (${test_file} PROPERTIES GENERATED TRUE )
233238
234239 add_test_pair (${test_name} ${test_file} ${ARGN} )
235240endfunction ()
0 commit comments