[emdawnwebgpu] Switch tests to use JSPI instead of Asyncify
This requires setting `GTEST_HAS_EXCEPTIONS=0` because otherwise for
some reason gtest assumes exception support (but Emscripten should be
building with exceptions disabled by default).
Also add missing emdawnwebgpu_config dependencies in the CMake build.
Change-Id: Ib62af379a764c4e5a456c432e682461869554c92
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/213394
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/emdawnwebgpu/CMakeLists.txt b/src/emdawnwebgpu/CMakeLists.txt
index 3f67954..de67353 100644
--- a/src/emdawnwebgpu/CMakeLists.txt
+++ b/src/emdawnwebgpu/CMakeLists.txt
@@ -191,6 +191,7 @@
target_include_directories(emdawnwebgpu_config BEFORE INTERFACE
"${EM_BUILD_GEN_DIR}/include"
)
+ add_dependencies(emdawnwebgpu_config webgpu_generated_struct_info_js emdawnwebgpu_js_gen)
target_link_options(emdawnwebgpu_config INTERFACE
# We are using Dawn-generated bindings, not built-in ones
"-sUSE_WEBGPU=0"
@@ -244,7 +245,7 @@
# We need ASYNCIFY for Future implementation. Note that for
# some reason, at the moment, these tests do not work with
# JSPI.
- "-sASYNCIFY=1"
+ "-sJSPI=1"
)
endif()
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 1bc7f06..1ffa3d8 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -76,6 +76,13 @@
# For Emscripten builds, we need to disable pthreads.
set(gtest_disable_pthreads ON)
endif()
+
+ # We don't use exceptions, so we don't need gtest to handle them. Emscripten
+ # builds in particular, with JSPI enabled, crash without this enabled.
+ # There doesn't seem to be an option to tell the gtest build files to do
+ # this, so we set it globally. (This seems to be the intended usage.)
+ add_definitions(-DGTEST_HAS_EXCEPTIONS=0)
+
add_subdirectory(${DAWN_GOOGLETEST_DIR} "${CMAKE_CURRENT_BINARY_DIR}/googletest" EXCLUDE_FROM_ALL)
endif()