Compare commits

...

2 Commits

Author SHA1 Message Date
cnc
8ff22065dd 参考所有分组:补生成组件manpage源约束
结论:按 align-linuxcnc 约束补齐 kinematics manifest 的 halcompile generated manpage metadata,并让 M428/M429/M430 INI TOOL_TABLE 的不可解析 LinuxCNC 源现状成为显式基线。

验证:check-linuxcnc-inputs --require-kinematics-complete、check-linuxcnc-switchkins-remap-table、test-native、test-linuxcnc-source-link 均通过。
2026-06-03 11:29:47 +08:00
cnc
5c2d5cfa05 参考所有分组:保持OPFS备份失败非致命
结论:按 LinuxCNC rs274ngc_pre.cc save_parameters() 中 unlink/link 失败不阻止 rename 主参数文件的语义,OPFS 参数 .bak 写入失败时不让解析保存失败,并避免把目录当作可 unlink 的备份文件删除;未扩展 smoke 解析行为。

验证:./test-native.sh;./test-linuxcnc-source-link.sh;./test-web-wasm-browser-smoke.sh。
2026-06-03 11:22:08 +08:00
4 changed files with 112 additions and 24 deletions

View File

@@ -461,6 +461,34 @@ if [[ -n "$manifest" && "$require_complete" == "--require-kinematics-complete" ]
exit 1
fi
generated_component_manpage_sources=()
for source in "${manifest_generated_sources[@]}"; do
case "$source" in
src/objects/hal/components/*.c)
component_name=$(basename "$source" .c)
manpage_source="src/objects/man/man9/$component_name.9.adoc"
if [[ -f "$linuxcnc_root/$manpage_source" ]]; then
generated_component_manpage_sources+=("$manpage_source")
fi
;;
esac
done
mapfile -t generated_component_manpage_sources < <(
printf '%s\n' "${generated_component_manpage_sources[@]}" | sed '/^$/d' | sort -u
)
missing_generated_component_manpage_sources=()
for source in "${generated_component_manpage_sources[@]}"; do
if ! printf '%s\n' "${manifest_metadata_sources[@]}" | grep -Fx -- "$source" >/dev/null; then
missing_generated_component_manpage_sources+=("$source")
fi
done
if ((${#missing_generated_component_manpage_sources[@]} > 0)); then
echo "manifest does not cover all LinuxCNC generated component manpage sources adjacent to generated kinematics sources: $manifest" >&2
printf 'missing generated component manpage source: %s\n' "${missing_generated_component_manpage_sources[@]}" >&2
exit 1
fi
missing_m428_m430_ini_remap_sources=()
unresolved_m428_m430_ini_remaps=()
for source in "${manifest_m428_m430_ini_sources[@]}"; do
@@ -1134,6 +1162,37 @@ if [[ -n "$manifest" && "$require_complete" == "--require-kinematics-complete" ]
printf '%s\n' "${unresolved_m428_m430_config_tooldata_sources[@]}" | sed '/^$/d' | sort -u
)
# Source basis: these LinuxCNC M428/M429/M430 INI files name TOOL_TABLE
# entries that are absent from the current LinuxCNC source tree. Keep the
# unresolved set explicit so new missing tool tables do not pass silently.
expected_unresolved_m428_m430_config_tooldata_sources=(
"configs/sim/axis/vismach/hexapod-sim/hexapod.ini TOOL_TABLE=hexapod.tbl"
"configs/sim/axis/vismach/scara/scara.ini TOOL_TABLE=scara.tbl"
"configs/sim/qtvcp_screens/non-trivial/scara/scara.ini TOOL_TABLE=scara.tbl"
)
unexpected_unresolved_m428_m430_config_tooldata_sources=()
for source in "${unresolved_m428_m430_config_tooldata_sources[@]}"; do
if ! printf '%s\n' "${expected_unresolved_m428_m430_config_tooldata_sources[@]}" | grep -Fx -- "$source" >/dev/null; then
unexpected_unresolved_m428_m430_config_tooldata_sources+=("$source")
fi
done
missing_expected_unresolved_m428_m430_config_tooldata_sources=()
for source in "${expected_unresolved_m428_m430_config_tooldata_sources[@]}"; do
if ! printf '%s\n' "${unresolved_m428_m430_config_tooldata_sources[@]}" | grep -Fx -- "$source" >/dev/null; then
missing_expected_unresolved_m428_m430_config_tooldata_sources+=("$source")
fi
done
if ((${#unexpected_unresolved_m428_m430_config_tooldata_sources[@]} > 0)); then
echo "LinuxCNC M428/M429/M430 INI TOOL_TABLE files have new unresolved sources: $manifest" >&2
printf 'unexpected unresolved M428/M429/M430 tool table source: %s\n' "${unexpected_unresolved_m428_m430_config_tooldata_sources[@]}" >&2
exit 1
fi
if ((${#missing_expected_unresolved_m428_m430_config_tooldata_sources[@]} > 0)); then
echo "LinuxCNC M428/M429/M430 INI TOOL_TABLE unresolved source set changed: $manifest" >&2
printf 'missing expected unresolved M428/M429/M430 tool table source: %s\n' "${missing_expected_unresolved_m428_m430_config_tooldata_sources[@]}" >&2
exit 1
fi
missing_m428_m430_config_tooldata_sources=()
for source in "${m428_m430_config_tooldata_sources[@]}"; do
if ! printf '%s\n' "${manifest_tooldata_sources[@]}" | grep -Fx -- "$source" >/dev/null; then

View File

@@ -277,9 +277,15 @@ metadata:docs/man/man9/tripodkins.9:LinuxCNC tripodkins generated manpage source
metadata:src/objects/hal/components/gantry.mak:halcompile-generated gantry component make metadata
metadata:src/objects/man/man9/gantry.9.adoc:halcompile-generated gantry component manpage source
metadata:src/objects/hal/components/matrixkins.mak:halcompile-generated matrixkins make metadata adjacent to generated kinematics source
metadata:src/objects/man/man9/matrixkins.9.adoc:halcompile-generated matrixkins manpage source adjacent to generated kinematics source
metadata:src/objects/hal/components/millturn.mak:halcompile-generated millturn make metadata adjacent to generated kinematics source
metadata:src/objects/man/man9/millturn.9.adoc:halcompile-generated millturn manpage source adjacent to generated kinematics source
metadata:src/objects/hal/components/userkins.mak:halcompile-generated userkins make metadata adjacent to generated kinematics source
metadata:src/objects/man/man9/userkins.9.adoc:halcompile-generated userkins manpage source adjacent to generated kinematics source
metadata:src/objects/hal/components/xyzab_tdr_kins.mak:halcompile-generated XYZAB table dual rotary make metadata adjacent to generated kinematics source
metadata:src/objects/man/man9/xyzab_tdr_kins.9.adoc:halcompile-generated XYZAB table dual rotary manpage source adjacent to generated kinematics source
metadata:src/objects/hal/components/xyzacb_trsrn.mak:halcompile-generated XYZACB TRSRN make metadata adjacent to generated kinematics source
metadata:src/objects/man/man9/xyzacb_trsrn.9.adoc:halcompile-generated XYZACB TRSRN manpage source adjacent to generated kinematics source
metadata:src/objects/hal/components/xyzbca_trsrn.mak:halcompile-generated XYZBCA TRSRN make metadata adjacent to generated kinematics source
metadata:src/objects/man/man9/xyzbca_trsrn.9.adoc:halcompile-generated XYZBCA TRSRN manpage source adjacent to generated kinematics source
asset:src/emc/kinematics/blend.fig:LinuxCNC kinematics reference asset tracked for full directory coverage

View File

@@ -141,6 +141,21 @@ async function removeOpfsEntry(workspacePath, relativePath, recursive) {
}
}
async function removeOpfsFileEntry(workspacePath, relativePath) {
assertRelativePath(relativePath);
const parts = relativePath.split("/");
const entryName = parts.pop();
try {
const directory = await getOpfsDirectoryHandle([workspacePath, ...parts].filter(Boolean).join("/"), false);
await directory.getFileHandle(entryName, { create: false });
await directory.removeEntry(entryName, { recursive: false });
} catch (error) {
if (error?.name !== "NotFoundError" && error?.name !== "TypeMismatchError") {
throw error;
}
}
}
async function opfsEntryExists(workspacePath, relativePath) {
assertRelativePath(relativePath);
const parts = relativePath.split("/");
@@ -498,7 +513,7 @@ function installOpfsWorkspace(module, options) {
if (backupData !== null) {
await writeOpfsFile(workspacePath, `${path}.bak`, backupData);
} else {
await removeOpfsEntry(workspacePath, `${path}.bak`, false);
await removeOpfsFileEntry(workspacePath, `${path}.bak`);
}
return data;
},
@@ -712,9 +727,22 @@ export async function createWasmSimulator(moduleOptions = {}) {
// replacing filename. Browser filesystems may not expose that link
// through the WASM mirror, so preserve the loaded OPFS file here.
if (previousParameterFile === null) {
await opfs.removeFile(`${parameterPath}.bak`);
try {
const backupStat = await opfs.stat(`${parameterPath}.bak`);
if (backupStat.kind === "file") {
await opfs.removeFile(`${parameterPath}.bak`);
}
} catch (error) {
if (error?.name !== "NotFoundError") {
throw error;
}
}
} else {
await opfs.writeFile(`${parameterPath}.bak`, previousParameterFile);
try {
await opfs.writeFile(`${parameterPath}.bak`, previousParameterFile);
} catch (_backupError) {
// LinuxCNC treats link(filename, filename + ".bak") failure as non-fatal.
}
}
return events;
} finally {

View File

@@ -6,6 +6,7 @@ export async function runBrowserOpfsParameterSections(context, simulator) {
expectMissingOpfsFile,
expectMissingWasmPath,
expectNoEvent,
expectOpfsDirectoryStat,
expectText,
expectWasmFilesMissing,
near,
@@ -15,14 +16,11 @@ export async function runBrowserOpfsParameterSections(context, simulator) {
withSmokeSimulator,
} = context;
const backend = { backend: "linuxcnc-rs274" };
const parseWithParameters = (program, path) =>
simulator.parseWithParameterFile(program, path, "linuxcnc", backend);
await runSection("opfs parameter save", async () => {
await simulator.parseWithParameterFile(
"G21 G90\nG0 X1\nG28.1\nM30\n",
"parameters/rs274ngc.var",
"linuxcnc",
backend,
);
await simulator.parseWithParameterFile("G21 G90\nG0 X1\nG28.1\nM30\n", "parameters/rs274ngc.var", "linuxcnc", backend);
const opfsParameterFile = await readOpfsText(simulator, "parameters/rs274ngc.var");
expectIncludes(opfsParameterFile, "5161\t1.000000", "LinuxCNC parameter file was not persisted into OPFS");
});
@@ -45,12 +43,7 @@ export async function runBrowserOpfsParameterSections(context, simulator) {
await runSection("opfs default parameter backup", async () => {
// LinuxCNC source basis: rs274ngc_pre.cc save_parameters()
// preserves the previous default parameter file as filename + ".bak".
await simulator.parseWithParameterFile(
"G21 G90\nM30\n",
"parameters/rs274ngc.var",
"linuxcnc",
backend,
);
await parseWithParameters("G21 G90\nM30\n", "parameters/rs274ngc.var");
const defaultParameterBackup = await readOpfsText(simulator, "parameters/rs274ngc.var.bak");
expectIncludes(defaultParameterBackup, "5161\t1.000000", "LinuxCNC default OPFS parameter backup did not preserve the previous file");
});
@@ -60,11 +53,9 @@ export async function runBrowserOpfsParameterSections(context, simulator) {
// LinuxCNC source basis: rs274ngc_pre.cc save_parameters() writes
// filename + ".new", then renames it over the parameter file.
simulator.fs.module.FS.writeFile("rs274ngc.var.new", "stale wasm temporary parameter file\n");
const restoredParameterEvents = await simulator.parseWithParameterFile(
const restoredParameterEvents = await parseWithParameters(
"G21 G90\nF100\nO10 if [#5161 EQ 1]\nG1 X9\nO10 endif\n",
"parameters/rs274ngc.var",
"linuxcnc",
backend,
);
expectEvent(restoredParameterEvents, (event) => event.type === "linear-feed" && near(event.end.x, 9),
"LinuxCNC parameter file was not restored from OPFS");
@@ -97,12 +88,7 @@ export async function runBrowserOpfsParameterSections(context, simulator) {
// LinuxCNC source basis: rs274ngc_pre.cc save_parameters() unlinks
// filename + ".bak", links the current parameter file to it,
// then renames filename + ".new" over filename.
await simulator.parseWithParameterFile(
"G21 G90\nG0 X4\nG28.1\nM30\n",
"parameters/existing-save.var",
"linuxcnc",
backend,
);
await parseWithParameters("G21 G90\nG0 X4\nG28.1\nM30\n", "parameters/existing-save.var");
const existingSaveParameterFile = await readOpfsText(simulator, "parameters/existing-save.var");
expectIncludes(existingSaveParameterFile, "5161\t4.000000", "LinuxCNC existing OPFS parameter file was not replaced after save");
const existingSaveParameterBackup = await readOpfsText(simulator, "parameters/existing-save.var.bak");
@@ -111,6 +97,15 @@ export async function runBrowserOpfsParameterSections(context, simulator) {
() => simulator.fs.opfs.readFile("parameters/existing-save.var.new"),
"LinuxCNC existing OPFS parameter temporary file remained after save",
);
await simulator.fs.opfs.writeFile("parameters/backup-directory.var", "5161\t6.000000\n");
const backupDirectory = simulator.fs.opfs.resolvePath("parameters/backup-directory.var.bak");
simulator.fs.module.FS.mkdir(backupDirectory);
await simulator.fs.opfs.persistDirectory("parameters/backup-directory.var.bak");
await parseWithParameters("G21 G90\nG0 X7\nG28.1\nM30\n", "parameters/backup-directory.var");
expectIncludes(await readOpfsText(simulator, "parameters/backup-directory.var"), "5161\t7.000000",
"LinuxCNC OPFS parameter file was not saved when backup link failed");
await expectOpfsDirectoryStat(simulator, "parameters/backup-directory.var.bak",
"LinuxCNC non-fatal OPFS backup failure did not leave the existing backup path intact");
});
await runSection("opfs parameter stale backup cleanup", async () => {