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..5b7b5504 --- /dev/null +++ b/wasmCompile.mjs @@ -0,0 +1,28 @@ +import { exec } from "child_process"; + +try { + await new Promise((resolve, reject) => { + 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`, + (error, stdout, stderr) => { + console.log(stdout); + console.error(stderr); + if (error === null) { + resolve(); + } else { + reject(); + } + } + ); + }); +} catch (exception) { + process.exit(1); +}