CMakeLists.txt: Support emscripten 3.1.58 SINGLE_FILE without a worker.js file

Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404-59 2024-05-10 03:29:12 +02:00
parent d4c854d8ef
commit 023af39a22
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 8 additions and 3 deletions

View File

@ -81,7 +81,10 @@ if (${IS_GNU} OR ${IS_CLANG})
else()
set(IS_HOST_NOT_ANDROID 0)
endif()
set(CMAKE_EXE_LINKER_FLAGS "--closure 1 --closure-args=\"--compilation_level SIMPLE\" -lnodefs.js -lembind -sDYNAMIC_EXECUTION=0 -sFORCE_FILESYSTEM=1 -sWASM=0 -sEXPORTED_FUNCTIONS=_main -sEXIT_RUNTIME=1 -sSINGLE_FILE=1 -sSAFE_HEAP=${IS_HOST_NOT_ANDROID} -sMALLOC='emmalloc' -sABORTING_MALLOC=0 -sJS_MATH=1 -sENVIRONMENT='web,webview,worker,node,shell' -sNODEJS_CATCH_EXIT=0 -sSTRICT=1 -sMINIMAL_RUNTIME=0 -sDISABLE_EXCEPTION_CATCHING=0 -sSTACK_SIZE=8MB -sALLOW_MEMORY_GROWTH=1 -Wno-pthreads-mem-growth -sMEMORY_GROWTH_GEOMETRIC_STEP=0 -sDECLARE_ASM_MODULE_EXPORTS=1 ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "--closure 1 --closure-args=\"--compilation_level SIMPLE\" -lnodefs.js -lembind -sDYNAMIC_EXECUTION=0 -sFORCE_FILESYSTEM=1 -sWASM=0 -sEXPORTED_FUNCTIONS=_main -sEXIT_RUNTIME=1 -sSINGLE_FILE=1 -sSAFE_HEAP=${IS_HOST_NOT_ANDROID} -sMALLOC='emmalloc' -sABORTING_MALLOC=0 -sJS_MATH=1 -sENVIRONMENT='web,webview,worker,node,shell' -sNODEJS_CATCH_EXIT=0 -sMINIMAL_RUNTIME=0 -sDISABLE_EXCEPTION_CATCHING=0 -sSTACK_SIZE=8MB -sALLOW_MEMORY_GROWTH=1 -Wno-pthreads-mem-growth -sMEMORY_GROWTH_GEOMETRIC_STEP=0 -sDECLARE_ASM_MODULE_EXPORTS=1 ${CMAKE_EXE_LINKER_FLAGS}")
if (EMSCRIPTEN_VERSION VERSION_LESS 3.1.58)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sSTRICT=1")
endif ()
if (EMSCRIPTEN_VERSION VERSION_LESS 3.1.54)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sDEMANGLE_SUPPORT=1")
elseif (EMSCRIPTEN_VERSION VERSION_LESS 3.1.55)
@ -210,6 +213,9 @@ if (EMSCRIPTEN)
set(NODE_PACKAGE_PROGRAM "${NPM_PRESENT}")
endif()
if (DEFINED NODE_PACKAGE_PROGRAM)
if (EMSCRIPTEN_VERSION VERSION_LESS 3.1.58)
set(YAO_ASSETS "\n \"assets\": \"../${EXENAME}.worker.js\",")
endif()
configure_file("resources/package.json" "processed/package.json" @ONLY)
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/processed/package.json" DESTINATION ".")
file(COPY "resources/.npmrc" DESTINATION ".")

View File

@ -3,8 +3,7 @@
"bin": "@EXENAME@.js",
"license": "@CPACK_RPM_PACKAGE_LICENSE@",
"devDependencies": { "@yao-pkg/pkg": "^5.9.0" },
"pkg": {
"assets": "../@EXENAME@.worker.js",
"pkg": {@YAO_ASSETS@
"targets": [
"latest-macos-x64",
"latest-macos-arm64"