From 13ab64876c8d5966ea1ffbe9e2f599f73dd6694a Mon Sep 17 00:00:00 2001 From: Jonah <47046556+jwbonner@users.noreply.github.com> Date: Sat, 5 Oct 2024 18:10:35 -0400 Subject: [PATCH] Fix WASM build on Windows --- package.json | 2 +- wasmCompile.mjs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 wasmCompile.mjs diff --git a/package.json b/package.json index 07db0954..bf5971f8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "format": "prettier --write .", "check-format": "prettier --check .", "test-ytdl": "node testYtdl.mjs", - "wasm:compile": "emcc src/hub/dataSources/wpilog/indexer/wpilogIndexer.c -o bundles/hub\\$wpilogIndexer.js -sEXPORTED_FUNCTIONS=_run,_malloc -sALLOW_MEMORY_GROWTH -O3", + "wasm:compile": "node wasmCompile.mjs", "docs:start": "cd docsSite && npm run start && cd ..", "docs:build": "cd docsSite && npm run build && cd ..", "docs:build-embed": "cd docsSite && npm run build-embed && cd ..", diff --git a/wasmCompile.mjs b/wasmCompile.mjs new file mode 100644 index 00000000..ecb68cd3 --- /dev/null +++ b/wasmCompile.mjs @@ -0,0 +1,13 @@ +import { exec } from "child_process"; + +await new Promise((resolve) => { + let inPath, outPath; + if (process.platform === "win32") { + inPath = "src\\hub\\dataSources\\wpilog\\indexer\\wpilogIndexer.c"; + outPath = "bundles\\hub$wpilogIndexer.js"; + } else { + inPath = "'src/hub/dataSources/wpilog/indexer/wpilogIndexer.c'"; + outPath = "'bundles/hub$wpilogIndexer.js' "; + } + exec(`emcc ${inPath} -o ${outPath} -sEXPORTED_FUNCTIONS=_run,_malloc -sALLOW_MEMORY_GROWTH -O3`, resolve); +});