Guard SDK sim-config staging paths
This commit is contained in:
@@ -4511,18 +4511,49 @@
|
||||
generatedToolTablePath(toolTable.wasmPath, expectedWasmPath);
|
||||
}
|
||||
|
||||
function assertSimConfigStagingPlan(machineRel, plan, expectedWasmDir) {
|
||||
if (plan.wasmDir !== expectedWasmDir) {
|
||||
throw new Error(`${machineRel}: browser sim staging root drift`);
|
||||
}
|
||||
if (!plan.iniPath.startsWith(`${expectedWasmDir}/`)) {
|
||||
throw new Error(`${machineRel}: browser sim INI staging path drift`);
|
||||
}
|
||||
if (plan.programPath !== null && !plan.programPath.startsWith(`${expectedWasmDir}/`)) {
|
||||
throw new Error(`${machineRel}: browser sim program staging path drift`);
|
||||
}
|
||||
|
||||
const paths = [];
|
||||
for (const file of plan.files) {
|
||||
if (file.path !== file.wasmPath) {
|
||||
throw new Error(`${file.sourceRel}: browser sim path/wasmPath drift`);
|
||||
}
|
||||
if (!file.wasmPath.startsWith(`${expectedWasmDir}/`)) {
|
||||
throw new Error(`${file.sourceRel}: browser sim file staging root drift`);
|
||||
}
|
||||
if (!file.sourceRel.startsWith("configs/sim/")) {
|
||||
throw new Error(`${file.sourceRel}: browser sim source root drift`);
|
||||
}
|
||||
if (paths.includes(file.wasmPath)) {
|
||||
throw new Error(`${machineRel}: duplicate browser sim staging path ${file.wasmPath}`);
|
||||
}
|
||||
paths.push(file.wasmPath);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSimMachineFiles(machineRel, iniFile, programFile = null) {
|
||||
const iniText = await fetchText(
|
||||
`../../vendor/linuxcnc/configs/sim/${machineRel}/${iniFile}`,
|
||||
);
|
||||
const expectedWasmDir = `/work/browser-sim/${machineRel}`;
|
||||
const plan = planSimConfigStaging({
|
||||
manifestText: await fetchText("../../tools/source-manifest.txt"),
|
||||
machineRel,
|
||||
iniFile,
|
||||
iniText,
|
||||
programFile,
|
||||
wasmDir: `/work/browser-sim/${machineRel}`,
|
||||
wasmDir: expectedWasmDir,
|
||||
});
|
||||
assertSimConfigStagingPlan(machineRel, plan, expectedWasmDir);
|
||||
|
||||
return {
|
||||
...plan,
|
||||
|
||||
Reference in New Issue
Block a user