31 lines
4.1 KiB
JavaScript
31 lines
4.1 KiB
JavaScript
#!/usr/bin/env node
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { createRequire } from "node:module";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
|
|
const docs = path.join(root, "docs/p6");
|
|
const build = path.resolve(process.argv[2] ?? path.join(root, "freecad-source/build-web/configure/bin"));
|
|
globalThis.__dirname = `${build}${path.sep}`;
|
|
globalThis.require = createRequire(import.meta.url);
|
|
const loader = await import(pathToFileURL(path.join(build, "FreeCADWebMeshRuntimeProbe.js")));
|
|
const kernel = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebMeshRuntimeProbe.wasm")) });
|
|
const c = (name, type = "number", argTypes = [], args = []) => kernel.ccall(name, type, argTypes, args);
|
|
const initialize = (name) => ({ run: c("fc_web_mesh_initialize", "number", ["string"], [name]), code: c("fc_web_mesh_error_code", "string"), message: c("fc_web_mesh_error_message", "string"), calls: c("fc_web_mesh_initialization_calls"), runs: c("fc_web_mesh_initialization_runs"), initialized: c("fc_web_mesh_initialized") });
|
|
const first = initialize("Mesh");
|
|
const repeated = initialize("Mesh");
|
|
const type = { run: c("fc_web_mesh_type_probe", "number", ["string"], ["Mesh::Feature"]), type: c("fc_web_mesh_last_type", "string"), code: c("fc_web_mesh_error_code", "string") };
|
|
const missing = initialize("MeshMissing");
|
|
const gui = initialize("MeshGui");
|
|
const create = { run: c("fc_web_mesh_create_recompute"), objectType: c("fc_web_mesh_kernel_object_type", "string"), facets: c("fc_web_mesh_kernel_facets"), points: c("fc_web_mesh_kernel_points"), resourcesReleased: c("fc_web_mesh_kernel_resources_released"), code: c("fc_web_mesh_kernel_error_code", "string"), message: c("fc_web_mesh_kernel_error_message", "string") };
|
|
const result = { first, repeated, type, missing, gui, create };
|
|
const stable = JSON.stringify(result);
|
|
if (first.run !== 1 || repeated.run !== 1 || first.runs !== 1 || repeated.runs !== 1 || type.run !== 1 || type.type !== "Mesh::Feature" || missing.code !== "module_unavailable" || gui.code !== "gui_dependency_unavailable" || repeated.initialized !== 1 || create.run !== 1 || create.objectType !== "Mesh::Feature" || create.facets !== 1 || create.points !== 3 || create.resourcesReleased !== 1) throw new Error(stable);
|
|
const report = { schema: "freecad-web-p6-mesh-runtime/v1", taskId: "FW-P6-MSH-B", module: "Mesh", result: "pass", resultSha256: crypto.createHash("sha256").update(stable).digest("hex"), responses: result, initialization: { calls: repeated.calls, runs: repeated.runs, idempotent: repeated.runs === 1 }, dependencies: { freecadApp: true, gui: false, qtConcurrent: false }, commands: ["EM_CACHE=/tmp/freecad-emscripten-cache cmake --build freecad-source/build-web/configure --target FreeCADWebMeshRuntimeProbe -j 8", "node tools/run_p6_mesh_runtime_smoke.mjs freecad-source/build-web/configure/bin"], artifacts: { wasm: "freecad-source/build-web/configure/bin/FreeCADWebMeshRuntimeProbe.wasm", workerLog: "docs/freecad-p6-mesh-b-runtime.log" }, boundaries: ["Runtime verifies Mesh App registration and Mesh::Feature visibility; the Mesh::Cube create/recompute fixture is source-backed; MeshGui/view providers and GUI commands remain excluded."] };
|
|
report.wasmSha256 = crypto.createHash("sha256").update(fs.readFileSync(path.join(build, "FreeCADWebMeshRuntimeProbe.wasm"))).digest("hex");
|
|
fs.writeFileSync(path.join(docs, "mesh-runtime.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(path.join(root, "docs/freecad-p6-mesh-b-runtime.log"), `${JSON.stringify({ result: report.result, initializationRuns: report.initialization.runs, type: report.responses.type.type, createObjectType: create.objectType, facets: create.facets, points: create.points, wasmSha256: report.wasmSha256 })}\n`);
|
|
console.log(JSON.stringify({ result: report.result, initializationRuns: report.initialization.runs, type: report.responses.type.type, createObjectType: create.objectType, facets: create.facets, points: create.points, wasmSha256: report.wasmSha256 }));
|