mirror of
https://github.com/KhronosGroup/glslang
synced 2024-09-19 12:19:53 +00:00
web: Fix emscripten build
The web/emscripten build has been broken for an unknown amount of time and for multiple reasons: - Calling `cat` on Windows - The latest version of wasm-ld does not support the `--no-undefined` flag - `ccall` was not being exported Fixes #3272.
This commit is contained in:
parent
77417d5c9e
commit
45ce545ad3
@ -159,8 +159,8 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC)
|
||||
add_compile_options(-fno-exceptions)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
# Error if there's symbols that are not found at link time.
|
||||
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten"))
|
||||
# Error if there's symbols that are not found at link time. Some linkers do not support this flag.
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
add_link_options("-Wl,-undefined,error")
|
||||
elseif(NOT APPLE)
|
||||
|
@ -53,6 +53,9 @@ if(ENABLE_GLSLANG_JS)
|
||||
target_link_libraries(glslang.js "-s ALLOW_MEMORY_GROWTH=1")
|
||||
target_link_libraries(glslang.js "-s FILESYSTEM=0")
|
||||
|
||||
# We use ccall in glslang.pre.js, so make sure it's exposed
|
||||
target_link_libraries(glslang.js "-s EXPORTED_RUNTIME_METHODS=ccall")
|
||||
|
||||
if(ENABLE_EMSCRIPTEN_SINGLE_FILE)
|
||||
target_link_libraries(glslang.js "-s SINGLE_FILE=1")
|
||||
endif()
|
||||
@ -64,8 +67,18 @@ if(ENABLE_GLSLANG_JS)
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE)
|
||||
add_custom_command(TARGET glslang.js POST_BUILD
|
||||
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js >> ${CMAKE_CURRENT_BINARY_DIR}/glslang.js)
|
||||
if (CMAKE_HOST_SYSTEM MATCHES "Windows.*")
|
||||
# There are several ways we could append one file to another on Windows, but unfortunately 'cat' is not one of them
|
||||
# (there is no 'cat' command in cmd). Also, since this will ultimately run in cmd and not pwsh, we need to ensure
|
||||
# Windows path separators are used.
|
||||
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/glslang.js" glslang_js_path)
|
||||
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js" glslang_after_js_path)
|
||||
add_custom_command(TARGET glslang.js POST_BUILD
|
||||
COMMAND type "${glslang_after_js_path}" >> "${glslang_js_path}")
|
||||
else()
|
||||
add_custom_command(TARGET glslang.js POST_BUILD
|
||||
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js >> ${CMAKE_CURRENT_BINARY_DIR}/glslang.js)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -25,7 +25,7 @@ Module['compileGLSLZeroCopy'] = function(glsl, shader_stage, gen_debug, spirv_ve
|
||||
|
||||
var p_output = Module['_malloc'](4);
|
||||
var p_output_len = Module['_malloc'](4);
|
||||
var id = ccall('convert_glsl_to_spirv',
|
||||
var id = Module['ccall']('convert_glsl_to_spirv',
|
||||
'number',
|
||||
['string', 'number', 'boolean', 'number', 'number', 'number'],
|
||||
[glsl, shader_stage_int, gen_debug, spirv_version_int, p_output, p_output_len]);
|
||||
|
Loading…
Reference in New Issue
Block a user