From 023af39a222359b9999d31aca2158d4d32c5518e Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 10 May 2024 03:29:12 +0200 Subject: [PATCH] CMakeLists.txt: Support emscripten 3.1.58 SINGLE_FILE without a worker.js file Signed-off-by: Username404-59 --- CMakeLists.txt | 8 +++++++- resources/package.json | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bf96b6..6196ff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ".") diff --git a/resources/package.json b/resources/package.json index f936267..b9718d5 100644 --- a/resources/package.json +++ b/resources/package.json @@ -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"