2022-12-10 19:23:36 +00:00
|
|
|
#
|
|
|
|
# Download and compile the WebAssembly testsuite into the WebAssembly binary format
|
|
|
|
#
|
|
|
|
|
2021-05-26 18:34:52 +00:00
|
|
|
if(INCLUDE_WASM_SPEC_TESTS)
|
2021-11-04 23:28:28 +00:00
|
|
|
set(WASM_SPEC_TEST_GZ_URL https://github.com/WebAssembly/testsuite/archive/refs/heads/main.tar.gz)
|
2022-12-10 19:23:36 +00:00
|
|
|
set(WASM_SPEC_TEST_GZ_PATH ${CMAKE_BINARY_DIR}/wasm-spec-testsuite.tar.gz CACHE PATH "")
|
|
|
|
set(WASM_SPEC_TEST_PATH ${CMAKE_CURRENT_BINARY_DIR}/Tests/Fixtures/SpecTests CACHE PATH "")
|
2021-05-26 18:34:52 +00:00
|
|
|
|
2023-08-10 21:45:19 +00:00
|
|
|
download_file(${WASM_SPEC_TEST_GZ_URL} ${WASM_SPEC_TEST_GZ_PATH})
|
2021-05-26 18:34:52 +00:00
|
|
|
|
|
|
|
set(SKIP_PRETTIER false)
|
|
|
|
if (WASM_SPEC_TEST_SKIP_FORMATTING)
|
|
|
|
set(SKIP_PRETTIER true)
|
|
|
|
endif()
|
|
|
|
|
2022-12-10 19:23:36 +00:00
|
|
|
find_program(WAT2WASM wat2wasm REQUIRED)
|
|
|
|
find_program(PRETTIER prettier OPTIONAL)
|
2023-06-12 10:08:22 +00:00
|
|
|
if (NOT SKIP_PRETTIER AND PRETTIER EQUAL "PRETTIER-NOTFOUND")
|
2022-12-10 19:23:36 +00:00
|
|
|
message(FATAL_ERROR "Prettier required to format Wasm spec tests! Install prettier or set WASM_SPEC_TEST_SKIP_FORMATTING to ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXISTS ${WASM_SPEC_TEST_GZ_PATH} AND NOT EXISTS ${WASM_SPEC_TEST_PATH}/const_0.wasm)
|
2021-05-26 18:34:52 +00:00
|
|
|
message(STATUS "Extracting the WebAssembly testsuite from ${WASM_SPEC_TEST_GZ_PATH}...")
|
2024-01-30 01:41:38 +00:00
|
|
|
extract_path("${CMAKE_CURRENT_BINARY_DIR}" "${WASM_SPEC_TEST_GZ_PATH}" "testsuite-main/*.wast" "${WASM_SPEC_TEST_PATH}")
|
2021-05-26 18:34:52 +00:00
|
|
|
file(MAKE_DIRECTORY ${WASM_SPEC_TEST_PATH})
|
2022-12-10 19:23:36 +00:00
|
|
|
file(GLOB WASM_TESTS "${CMAKE_CURRENT_BINARY_DIR}/testsuite-main/*.wast")
|
2021-05-26 18:34:52 +00:00
|
|
|
foreach(PATH ${WASM_TESTS})
|
|
|
|
get_filename_component(NAME ${PATH} NAME_WLE)
|
|
|
|
message(STATUS "Generating test cases for WebAssembly test ${NAME}...")
|
|
|
|
execute_process(
|
2022-12-10 19:23:36 +00:00
|
|
|
COMMAND env SKIP_PRETTIER=${SKIP_PRETTIER} bash ${SerenityOS_SOURCE_DIR}/Meta/generate-libwasm-spec-test.sh "${PATH}" "${CMAKE_CURRENT_BINARY_DIR}/Tests/Spec" "${NAME}" "${WASM_SPEC_TEST_PATH}")
|
2021-05-26 18:34:52 +00:00
|
|
|
endforeach()
|
2021-11-04 23:28:28 +00:00
|
|
|
file(REMOVE testsuite-main)
|
2021-05-26 18:34:52 +00:00
|
|
|
endif()
|
|
|
|
endif()
|