Files
LiveSplitOne/buildCore.js
T
Christopher Serr b9e498f0a4 Switch to wasm-bindgen
This introduces wasm-bindgen which will allow us to directly use all
kinds of JS APIs in WASM without us having to manually provide all the
functionality as imports. Instead we let wasm-bindgen handle all the
importing. Additional webpack now handles the instantiation of the wasm
module for us, which simplifies a bunch of things as well.
2019-12-27 15:00:28 +01:00

42 lines
810 B
JavaScript

const { spawnSync } = require("child_process");
const fs = require("fs");
spawnSync(
"cargo",
["run"],
{
cwd: "livesplit-core/capi/bind_gen",
stdio: "inherit",
},
);
spawnSync(
"cargo",
[
"build",
"-p", "cdylib",
"--features", "wasm-web",
"--target", "wasm32-unknown-unknown",
"--release",
],
{
cwd: "livesplit-core",
stdio: "inherit",
},
);
spawnSync(
"wasm-bindgen",
[
"livesplit-core/target/wasm32-unknown-unknown/release/livesplit_core.wasm",
"--out-dir", "src/livesplit-core",
],
{
stdio: "inherit",
},
);
fs
.createReadStream("livesplit-core/capi/bindings/wasm_bindgen/index.ts")
.pipe(fs.createWriteStream("src/livesplit-core/index.ts"));