From d9bf58353fd0b14a6888c12d4d847f7a6c623cdc Mon Sep 17 00:00:00 2001 From: Severin Ibarluzea Date: Tue, 3 Mar 2026 16:28:33 -0800 Subject: [PATCH] Add platform DRC disable flags support --- lib/components/normal-components/Board.ts | 17 ++++- package.json | 2 +- .../platform-drc-checks-disabled.test.tsx | 64 +++++++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 tests/root-circuit/platform-drc-checks-disabled.test.tsx diff --git a/lib/components/normal-components/Board.ts b/lib/components/normal-components/Board.ts index e8365388c..fafc0577f 100644 --- a/lib/components/normal-components/Board.ts +++ b/lib/components/normal-components/Board.ts @@ -552,9 +552,20 @@ export class Board this.getInheritedProperty("routingDisabled") const pcbDisabled = this.root?.pcbDisabled - const shouldRunNetlistChecks = true - const shouldRunPlacementChecks = !pcbDisabled - const shouldRunRoutingChecks = !pcbDisabled && !routingDisabled + const netlistDrcChecksDisabled = + this.root?.platform?.netlistDrcChecksDisabled ?? + this.getInheritedProperty("netlistDrcChecksDisabled") + const placementDrcChecksDisabled = + this.root?.platform?.placementDrcChecksDisabled ?? + this.getInheritedProperty("placementDrcChecksDisabled") + const routingDrcChecksDisabled = + this.root?.platform?.routingDrcChecksDisabled ?? + this.getInheritedProperty("routingDrcChecksDisabled") + + const shouldRunNetlistChecks = !netlistDrcChecksDisabled + const shouldRunPlacementChecks = !pcbDisabled && !placementDrcChecksDisabled + const shouldRunRoutingChecks = + !pcbDisabled && !routingDisabled && !routingDrcChecksDisabled // If async trace routing is still in progress anywhere in this board subtree, // wait so routing DRC sees final routed traces and doesn't mark DRC complete early. diff --git a/package.json b/package.json index 738d67df2..0e9240d15 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@tscircuit/math-utils": "^0.0.29", "@tscircuit/miniflex": "^0.0.4", "@tscircuit/ngspice-spice-engine": "^0.0.8", - "@tscircuit/props": "^0.0.485", + "@tscircuit/props": "^0.0.487", "@tscircuit/schematic-match-adapt": "^0.0.16", "@tscircuit/schematic-trace-solver": "^v0.0.45", "@tscircuit/solver-utils": "^0.0.3", diff --git a/tests/root-circuit/platform-drc-checks-disabled.test.tsx b/tests/root-circuit/platform-drc-checks-disabled.test.tsx new file mode 100644 index 000000000..23977b0a9 --- /dev/null +++ b/tests/root-circuit/platform-drc-checks-disabled.test.tsx @@ -0,0 +1,64 @@ +import { expect, test } from "bun:test" +import { getTestFixture } from "tests/fixtures/get-test-fixture" + +const getErrorTypes = (circuitJson: Array<{ type: string }>) => + new Set( + circuitJson + .filter((elm) => elm.type.includes("error")) + .map((elm) => elm.type), + ) + +test("platform netlistDrcChecksDisabled disables netlist DRC errors", async () => { + const { circuit } = getTestFixture({ + platform: { + netlistDrcChecksDisabled: true, + }, + }) + + circuit.add( + + + + + , + ) + + await circuit.renderUntilSettled() + + expect( + getErrorTypes(circuit.getCircuitJson() as Array<{ type: string }>), + ).toEqual(new Set()) +}) + +test("platform placementDrcChecksDisabled disables placement DRC errors", async () => { + const { circuit } = getTestFixture({ + platform: { + placementDrcChecksDisabled: true, + }, + }) + + circuit.add( + + + + , + ) + + await circuit.renderUntilSettled() + + expect( + getErrorTypes(circuit.getCircuitJson() as Array<{ type: string }>), + ).toEqual(new Set()) +})