Skip to content

Commit

Permalink
Fix WASM build on Windows (Mechanical-Advantage#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner authored Oct 5, 2024
1 parent 874944a commit 4df1ba4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..",
Expand Down
28 changes: 28 additions & 0 deletions wasmCompile.mjs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 4df1ba4

Please sign in to comment.