51 lines
2.7 KiB
JavaScript
51 lines
2.7 KiB
JavaScript
#!/usr/bin/env node
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { spawnSync } from "node:child_process";
|
|
|
|
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
|
|
const buildDirectory = path.join(root, "freecad-source", "build-web", "cam-configure", "bin");
|
|
const smoke = path.join(root, "freecad-source", "src", "WebAssembly", "FreeCADCoreProbe", "cam-runtime-smoke.js");
|
|
const output = path.join(root, "docs", "p6", "cam-runtime.json");
|
|
const log = path.join(root, "docs", "freecad-p6-cam-b-runtime.log");
|
|
const run = spawnSync(process.execPath, [smoke, buildDirectory], { cwd: root, encoding: "utf8" });
|
|
if (run.status !== 0) {
|
|
fs.writeFileSync(log, `${run.stdout ?? ""}${run.stderr ?? ""}`);
|
|
process.stderr.write(run.stderr || run.stdout || "CAM runtime smoke failed\n");
|
|
process.exit(run.status || 1);
|
|
}
|
|
const parsed = JSON.parse(run.stdout.trim());
|
|
const wasm = path.join(buildDirectory, "FreeCADWebCAMProbe.wasm");
|
|
const report = {
|
|
schema: "freecad-web-p6-cam-runtime/v1",
|
|
result: parsed.result,
|
|
module: "CAM",
|
|
sourceRevision: JSON.parse(fs.readFileSync(path.join(root, "docs", "p6", "cam-source-boundary.json"), "utf8")).sourceRevision,
|
|
initialization: {
|
|
calls: parsed.details.stateAfterErrors.calls,
|
|
runs: parsed.details.stateAfterErrors.runs,
|
|
initialized: parsed.details.stateAfterErrors.initialized,
|
|
},
|
|
typeRegistration: {
|
|
expected: parsed.typeCount,
|
|
visible: Object.values(parsed.details.types).filter((value) => value === 1).length,
|
|
representative: "Path::Feature",
|
|
},
|
|
errors: {
|
|
unknownType: parsed.details.unknownTypeError,
|
|
missingModule: parsed.details.unknownModuleError,
|
|
guiModule: parsed.details.guiModuleError,
|
|
emptyModule: parsed.details.emptyModuleError,
|
|
},
|
|
resources: { activeHandlesAfterRelease: parsed.activeHandles, released: parsed.activeHandles === 0 },
|
|
artifacts: {
|
|
probeJsSha256: crypto.createHash("sha256").update(fs.readFileSync(path.join(buildDirectory, "FreeCADWebCAMProbe.js"))).digest("hex"),
|
|
probeWasmSha256: crypto.createHash("sha256").update(fs.readFileSync(wasm)).digest("hex"),
|
|
},
|
|
};
|
|
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
fs.writeFileSync(output, `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(log, `${JSON.stringify({ result: report.result, initializationRuns: report.initialization.runs, visibleTypes: report.typeRegistration.visible, resourcesReleased: report.resources.released })}\n`);
|
|
console.log(JSON.stringify({ result: report.result, artifact: "docs/p6/cam-runtime.json", visibleTypes: report.typeRegistration.visible }));
|