[emscripten] Crash if emdawnwebgpu.port.py is used from src/
emdawnwebgpu.port.py only works if used from a built package directory.
Add an error message if it's used from Dawn's src/.
No-Try: true
Fixed: 415850603
Change-Id: I1a63e85441f995d79a801663a3ac457482117fdc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/240874
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/emdawnwebgpu/pkg/emdawnwebgpu.port.py b/src/emdawnwebgpu/pkg/emdawnwebgpu.port.py
index 18d4280..0d374f3 100644
--- a/src/emdawnwebgpu/pkg/emdawnwebgpu.port.py
+++ b/src/emdawnwebgpu/pkg/emdawnwebgpu.port.py
@@ -66,6 +66,17 @@
_srcs = [
os.path.join(_src_dir, 'webgpu.cpp'),
]
+
+# Check for a generated file that would only be there in the built package
+if not os.path.isfile(os.path.join(_c_include_dir, 'webgpu', 'webgpu.h')):
+ raise Exception(
+ "emdawnwebgpu.port.py may only be used from a built emdawnwebgpu_pkg, "
+ "not from Dawn's source tree. You can use pre-built packages from "
+ "https://github.com/google/dawn/releases or build it locally.")
+
+# Collect a list of all files that affect the compiled port so that we know
+# when to recompile it. (Normally Emscripten handles this, but not here because
+# of the way that we "misuse" the ports system.)
_files_affecting_port_build = sorted([
__file__,
*_srcs,