mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 14:20:35 +08:00
perf: optimize persist delta gating and diagnostics
This commit is contained in:
61
scripts/build-native-wasm.mjs
Normal file
61
scripts/build-native-wasm.mjs
Normal file
@@ -0,0 +1,61 @@
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
const ROOT = process.cwd();
|
||||
const CRATE_DIR = path.resolve(ROOT, "native", "stbme-core");
|
||||
const OUT_DIR = path.resolve(ROOT, "vendor", "wasm", "pkg");
|
||||
|
||||
function runCommand(command, args, cwd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(command, args, {
|
||||
cwd,
|
||||
stdio: "inherit",
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
child.on("error", reject);
|
||||
child.on("exit", (code, signal) => {
|
||||
if (signal) {
|
||||
reject(new Error(`${command} terminated by signal ${signal}`));
|
||||
return;
|
||||
}
|
||||
if (code !== 0) {
|
||||
reject(new Error(`${command} exited with code ${code}`));
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await mkdir(OUT_DIR, { recursive: true });
|
||||
|
||||
console.log(`[ST-BME][native] building Rust/WASM from ${CRATE_DIR}`);
|
||||
await runCommand(
|
||||
"wasm-pack",
|
||||
[
|
||||
"build",
|
||||
"--target",
|
||||
"web",
|
||||
"--release",
|
||||
"--out-dir",
|
||||
path.relative(CRATE_DIR, OUT_DIR),
|
||||
"--out-name",
|
||||
"stbme_core_pkg",
|
||||
],
|
||||
CRATE_DIR,
|
||||
);
|
||||
|
||||
console.log("[ST-BME][native] wasm artifact build completed");
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.error("[ST-BME][native] build failed:", message);
|
||||
console.error(
|
||||
"[ST-BME][native] Ensure rustup + wasm32 target + wasm-pack are installed.",
|
||||
);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
@@ -16,6 +16,8 @@ const SOURCE_ROOTS = [
|
||||
"sync",
|
||||
"ui",
|
||||
"vector",
|
||||
"vendor/wasm",
|
||||
"native",
|
||||
];
|
||||
|
||||
async function collectFiles(targetPath) {
|
||||
|
||||
Reference in New Issue
Block a user