[170] Linux: scripts/update-linux.sh (master holen, veraltete WASM-Pakete bauen, Zwischendateien/Caches löschen; --start/--appimage/--keep-build); wasm-fresh mit --no-opt und Rückfall ohne wasm-opt
This commit is contained in:
3 files changed
+127
-8
No files matched your search
+23
-8
@@ -2,7 +2,9 @@
|
||||
// eines Crates (oder eines per Pfad eingebundenen Crates) neuer als das gebaute `.wasm`, läuft das
|
||||
// passende `npm run build:*`. Sonst passen TS-Oberfläche und Kern nicht zusammen (z. B. „Plan-Puffer
|
||||
// unlesbar“ nach einem `git pull` mit Formatänderung). Aufruf: `node scripts/wasm-fresh.mjs` (auch aus
|
||||
// `tauri-native.mjs`); Opt-out: DOSSIER_NO_WASM_CHECK=1.
|
||||
// `tauri-native.mjs`, `scripts/update-linux.sh`); Opt-out: DOSSIER_NO_WASM_CHECK=1. `--no-opt` (oder
|
||||
// DOSSIER_WASM_NO_OPT=1) baut ohne wasm-opt; scheitert ein Build, wird er einmal ohne wasm-opt wiederholt
|
||||
// (zu altes System-`wasm-opt` bricht Module mit `Table.grow`).
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, readdirSync, statSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
@@ -13,12 +15,20 @@ const root = fileURLToPath(new URL("..", import.meta.url));
|
||||
/** Paket → gebaute Datei, npm-Skript und die Crates, aus denen es entsteht (inkl. Pfad-Abhängigkeiten). */
|
||||
export const PACKAGES = [
|
||||
{ wasm: "src/engine/pkgCore/core_bg.wasm", script: "build:core", crates: ["core", "kernel2d", "hatchgen", "render3d"] },
|
||||
{ wasm: "src/engine/pkg/render2d_bg.wasm", script: "build:engine", crates: ["render2d"] },
|
||||
{ wasm: "src/engine/pkg3d/render3d_bg.wasm", script: "build:engine3d", crates: ["render3d", "hatchgen"] },
|
||||
{ wasm: "src/engine/pkgFileIo/fileio_bg.wasm", script: "build:fileio", crates: ["fileio", "hatchgen"] },
|
||||
{ wasm: "src/engine/pkgTruck/trucksolid_bg.wasm", script: "build:truck", crates: ["trucksolid"] },
|
||||
{ wasm: "src/engine/pkg/render2d_bg.wasm", script: "build:engine", crates: ["render2d"], crate: "render2d", out: "pkg", name: "render2d" },
|
||||
{ wasm: "src/engine/pkg3d/render3d_bg.wasm", script: "build:engine3d", crates: ["render3d", "hatchgen"], crate: "render3d", out: "pkg3d", name: "render3d" },
|
||||
{ wasm: "src/engine/pkgFileIo/fileio_bg.wasm", script: "build:fileio", crates: ["fileio", "hatchgen"], crate: "fileio", out: "pkgFileIo", name: "fileio" },
|
||||
{ wasm: "src/engine/pkgTruck/trucksolid_bg.wasm", script: "build:truck", crates: ["trucksolid"], crate: "trucksolid", out: "pkgTruck", name: "trucksolid" },
|
||||
];
|
||||
|
||||
/** Baut ein Paket; `noOpt`: ohne wasm-opt (`--no-opt` muss vor den Feature-Argumenten stehen). */
|
||||
function build(p, noOpt) {
|
||||
const run = (cmd, args) => spawnSync(cmd, args, { cwd: root, stdio: "inherit", shell: process.platform === "win32" }).status === 0;
|
||||
if (!noOpt) return run("npm", ["run", p.script]);
|
||||
if (!p.crate) return run("node", ["scripts/build-core.mjs", "--no-opt"]);
|
||||
return run("wasm-pack", ["build", `src-tauri/${p.crate}`, "--release", "--no-opt", "--target", "web", "--out-dir", `../../src/engine/${p.out}`, "--out-name", p.name, "--no-default-features", "--features", "web"]);
|
||||
}
|
||||
|
||||
function newest(dir) {
|
||||
if (!existsSync(dir)) return 0;
|
||||
let t = 0;
|
||||
@@ -44,9 +54,14 @@ export function stalePackages(base = root) {
|
||||
}
|
||||
|
||||
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1] && !process.env.DOSSIER_NO_WASM_CHECK) {
|
||||
const noOpt = process.argv.includes("--no-opt") || process.env.DOSSIER_WASM_NO_OPT === "1";
|
||||
for (const p of stalePackages()) {
|
||||
console.log(`[wasm-fresh] ${p.wasm} ist veraltet → npm run ${p.script}`);
|
||||
const r = spawnSync("npm", ["run", p.script], { cwd: root, stdio: "inherit", shell: process.platform === "win32" });
|
||||
if (r.status !== 0) process.exit(r.status ?? 1);
|
||||
console.log(`[wasm-fresh] ${p.wasm} ist veraltet → ${p.script}${noOpt ? " (ohne wasm-opt)" : ""}`);
|
||||
if (build(p, noOpt)) continue;
|
||||
if (!noOpt) {
|
||||
console.log(`[wasm-fresh] ${p.script} gescheitert → noch einmal ohne wasm-opt`);
|
||||
if (build(p, true)) continue;
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user