From f5bf5ba5170058f9a9634438f7ff06f1a02e1da6 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Wed, 25 Sep 2024 10:24:51 +0300 Subject: Enable emscripten builds to compile slang.dll to WebAssembly. (#5131) * Compile fixes for Wasm The issues are all are due to 'long' types being 32 bits on WASM. - class members redeclared errors - << with StringBuilder and unsigned long is ambiguous This helps to address issue #5115. * Use the host executable suffix for generators Since the generators are run at build-time, we should not use CMAKE_EXECUTABLE_SUFFIX, which is the suffix for the target platform. Instead, define CMAKE_HOST_EXECUTABLE_SUFFIX as appropriate, and use that suffix instead. This helps to address issue #5115. * Add support for Wasm as a platform This helps to address issue #5115. * Add emscripten build This closes #5115. --- include/slang.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/slang.h b/include/slang.h index 30aa239a7..1c05b4c08 100644 --- a/include/slang.h +++ b/include/slang.h @@ -111,6 +111,8 @@ Operating system defines, see http://sourceforge.net/p/predef/wiki/OperatingSyst # define SLANG_PSP2 1 # elif defined(__ghs__) # define SLANG_WIIU 1 +# elif defined(__EMSCRIPTEN__) +# define SLANG_WASM 1 # else # error "unknown target platform" # endif @@ -417,7 +419,9 @@ convention for interface methods. # define SLANG_PROCESSOR_ARM 1 #elif defined(_M_ARM64) || defined(__aarch64__) # define SLANG_PROCESSOR_ARM_64 1 -#endif +#elif defined(__EMSCRIPTEN__) +# define SLANG_PROCESSOR_WASM 1 +#endif #ifndef SLANG_PROCESSOR_ARM # define SLANG_PROCESSOR_ARM 0 @@ -465,6 +469,8 @@ convention for interface methods. # endif #elif SLANG_PROCESSOR_FAMILY_POWER_PC # define SLANG_BIG_ENDIAN 1 +#elif SLANG_WASM +# define SLANG_LITTLE_ENDIAN 1 #endif #ifndef SLANG_LITTLE_ENDIAN -- cgit v1.2.3