Files
FreeCADWasmDev/tools/run_p6_cam_boundary_probe.mjs
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

49 lines
2.9 KiB
JavaScript

#!/usr/bin/env node
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { execFileSync } from "node:child_process";
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
const sourceRoot = path.join(root, "freecad-source");
const docsRoot = path.join(root, "docs");
const files = [
"src/Mod/CAM/CMakeLists.txt",
"src/Mod/CAM/Init.py",
"src/Mod/CAM/App/CMakeLists.txt",
"src/Mod/CAM/App/AppPath.cpp",
"src/Mod/CAM/Path/Main/Job.py",
"src/Mod/CAM/Path/Op/Base.py",
];
const matrix = JSON.parse(fs.readFileSync(path.join(docsRoot, "web-parity-matrix.json"), "utf8"));
const objects = JSON.parse(fs.readFileSync(path.join(docsRoot, "object-inventory.json"), "utf8"));
const row = matrix.rows.find((item) => item.module === "CAM");
const hashes = Object.fromEntries(files.map((file) => [file, crypto.createHash("sha256").update(fs.readFileSync(path.join(sourceRoot, file))).digest("hex")]));
const sourceRevision = execFileSync("git", ["-C", sourceRoot, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
const camObjects = objects.objects.filter((item) => item.module === "CAM").map((item) => item.name);
const report = {
schema: "freecad-web-p6-cam-source-boundary/v1",
module: "CAM",
result: "pass_probe_only",
sourceRevision,
cmake: { target: "Path", kind: "shared_library", appTarget: "Path", buildCondition: "BUILD_GUI gates InitGui.py; Path App target is native" },
dependencies: ["Part", "area-native", "FreeCADApp"],
actions: {
"create/recompute": { entry: "src/Mod/CAM/Path/Main/Job.py", operationEntry: "src/Mod/CAM/Path/Op/Base.py", objectTypes: row.object_types, formats: row.format_extensions },
"import/export": { entry: "src/Mod/CAM/Init.py", formats: row.format_extensions.filter((extension) => [".json", ".obj", ".step", ".svg"].includes(extension)) },
"inspect/source-inventory": { entry: "src/Mod/CAM/Init.py" },
"python-api": { entry: "src/Mod/CAM/Path", apiCount: row.python_api_count },
"save/reopen": { entry: "src/Mod/CAM/Path/Main/Job.py", format: ".fcstd" },
},
typeRegistration: { registeredTypes: camObjects, registrationEntry: "src/Mod/CAM/App/AppPath.cpp", count: camObjects.length },
guiRequired: row.gui_dependency,
guiExcludedFromHeadless: ["FreeCADGui", "PySide", "pivy.coin"],
objectTypeCount: row.object_type_count,
pythonApiCount: row.python_api_count,
inputs: hashes,
};
fs.mkdirSync(path.join(root, "docs/p6"), { recursive: true });
fs.writeFileSync(path.join(root, "docs/p6/cam-source-boundary.json"), `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(path.join(root, "docs/freecad-p6-cam-a-rg.log"), `result=${report.result}\nfiles=${files.length}\ntarget=${report.cmake.target}\ndependencies=${report.dependencies.join(",")}\n`);
console.log(JSON.stringify({ result: report.result, module: report.module, files: files.length, target: report.cmake.target, objectTypes: report.objectTypeCount, apiCount: report.pythonApiCount }));