use custom es6 modularization instead of MODULARIZE=1
This commit is contained in:
parent
4391924ac5
commit
230117a02c
@ -112,18 +112,9 @@ if(EMSCRIPTEN)
|
|||||||
add_link_options("SHELL: --closure 1")
|
add_link_options("SHELL: --closure 1")
|
||||||
add_link_options("SHELL: -s ALLOW_MEMORY_GROWTH=1")
|
add_link_options("SHELL: -s ALLOW_MEMORY_GROWTH=1")
|
||||||
|
|
||||||
add_link_options("SHELL: -s MODULARIZE=1")
|
|
||||||
if(ENABLE_EMSCRIPTEN_SINGLE_FILE)
|
if(ENABLE_EMSCRIPTEN_SINGLE_FILE)
|
||||||
add_link_options("SHELL: -s SINGLE_FILE=1")
|
add_link_options("SHELL: -s SINGLE_FILE=1")
|
||||||
endif(ENABLE_EMSCRIPTEN_SINGLE_FILE)
|
endif(ENABLE_EMSCRIPTEN_SINGLE_FILE)
|
||||||
|
|
||||||
if(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE)
|
|
||||||
add_link_options("SHELL: -s ENVIRONMENT=node")
|
|
||||||
add_link_options("SHELL: -s BINARYEN_ASYNC_COMPILATION=0")
|
|
||||||
else()
|
|
||||||
add_link_options("SHELL: -s ENVIRONMENT=web,worker")
|
|
||||||
add_link_options("SHELL: -s EXPORT_ES6=1")
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
if(ENABLE_GLSLANG_WEB)
|
if(ENABLE_GLSLANG_WEB)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
|||||||
@ -4,7 +4,21 @@ target_link_libraries(glslang.js glslang SPIRV)
|
|||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
set_target_properties(glslang.js PROPERTIES
|
set_target_properties(glslang.js PROPERTIES
|
||||||
OUTPUT_NAME "glslang"
|
OUTPUT_NAME "glslang"
|
||||||
SUFFIX ".js"
|
SUFFIX ".js")
|
||||||
LINK_FLAGS "--bind -s EXPORT_NAME=\"glslangModule\"")
|
|
||||||
em_link_pre_js(glslang.js "${CMAKE_CURRENT_SOURCE_DIR}/glslang.pre.js")
|
em_link_pre_js(glslang.js "${CMAKE_CURRENT_SOURCE_DIR}/glslang.pre.js")
|
||||||
|
|
||||||
|
target_link_options(glslang.js PRIVATE
|
||||||
|
"SHELL:--bind -s MODULARIZE=1")
|
||||||
|
if(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE)
|
||||||
|
target_link_options(glslang.js PRIVATE
|
||||||
|
"SHELL:-s ENVIRONMENT=node -s BINARYEN_ASYNC_COMPILATION=0")
|
||||||
|
else()
|
||||||
|
target_link_options(glslang.js PRIVATE
|
||||||
|
"SHELL:-s ENVIRONMENT=web,worker")
|
||||||
|
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)
|
||||||
|
endif()
|
||||||
endif(EMSCRIPTEN)
|
endif(EMSCRIPTEN)
|
||||||
|
|||||||
26
glslang/OSDependent/Web/glslang.after.js
Normal file
26
glslang/OSDependent/Web/glslang.after.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export default (() => {
|
||||||
|
const initialize = () => {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
Module({
|
||||||
|
locateFile() {
|
||||||
|
const i = import.meta.url.lastIndexOf('/')
|
||||||
|
return import.meta.url.substring(0, i) + '/glslang.wasm';
|
||||||
|
},
|
||||||
|
onRuntimeInitialized() {
|
||||||
|
resolve({
|
||||||
|
compileGLSLZeroCopy: this.compileGLSLZeroCopy,
|
||||||
|
compileGLSL: this.compileGLSL,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let instance;
|
||||||
|
return () => {
|
||||||
|
if (!instance) {
|
||||||
|
instance = initialize();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
})();
|
||||||
Loading…
x
Reference in New Issue
Block a user