From 3bf6e684390832db0455d5268eeaa90f57013f82 Mon Sep 17 00:00:00 2001 From: xhacker-zzz <63585800+xhacker-zzz@users.noreply.github.com> Date: Sat, 21 Jan 2023 01:33:13 +0800 Subject: [PATCH] add build script for Windows --- build-wasm.cmd | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 build-wasm.cmd diff --git a/build-wasm.cmd b/build-wasm.cmd new file mode 100644 index 0000000..de10f77 --- /dev/null +++ b/build-wasm.cmd @@ -0,0 +1,40 @@ +@echo off +setlocal + +set "CURR_DIR=%CD%" + +set "BUILD_TYPE=%1" +if "%BUILD_TYPE%"=="" set "BUILD_TYPE=Release" + +md build\wasm 2>nul +if not exist build\emsdk ( + git clone https://github.com/emscripten-core/emsdk.git build\emsdk +) + +pushd build\emsdk +rem git pull +call emsdk.bat install 3.0.0 +call emsdk.bat activate 3.0.0 +call emsdk_env.bat +popd + +pushd build\wasm + +call emcmake cmake -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..\.. +rem Check if Ninja binary exists +if not exist "ninja.exe" ( + rem Install Ninja + curl -L https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip -o ninja.zip + unzip ninja.zip + del ninja.zip +) +ninja.exe -f build.ninja -j 3 + +set "TARGET_FILES=KgmLegacy.js KgmWasm.js KgmWasm.wasm KgmWasmBundle.js %CURR_DIR%\LICENSE.txt" + +for %%f in (%TARGET_FILES%) do ( +copy "%%f" "%CURR_DIR%\npm" +) +popd + +endlocal \ No newline at end of file