Skip to content

Commit

Permalink
Raise errors from WASM compile
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Oct 5, 2024
1 parent 13ab648 commit 5171e22
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions wasmCompile.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
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);
});
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 5171e22

Please sign in to comment.