main
John Lauer Three revisions with per-experiment write-ups, inline 3D viewers, sources, fab files, open-science scorecard 091a7c9 12d ago
#!/usr/bin/env bash
# Layout sweep: build the board once per (PARTS_X offset, R_OFFSET) pair in parallel scratch
# copies and report DRC errors and split nets for each, so a clean layout can be picked by
# evidence rather than by eye. Run from the project root (the folder holding lib/index.tsx).
#
#   bash scripts/sweep.sh "9:1.6 10:1.6 11:1.6 12:1.6"
#
# Each entry is <support-part offset from USB_X>:<resistor offset below its LED, mm>.
set -euo pipefail
PAIRS=${1:-"9:1.6 10:1.6 11:1.6 10:1.65"}
ROOT=$(pwd); TMP=$(mktemp -d)
run() {
  local parts=${1%%:*}
  local roff=${1##*:}
  local d="$TMP/p$parts-r$roff"
  mkdir -p "$d"; cp -a "$ROOT"/{lib,package.json,tscircuit.config.json,tsconfig.json,scripts} "$d"/
  [ -f "$ROOT/.npmrc" ] && cp "$ROOT/.npmrc" "$d"/; ln -s "$ROOT/node_modules" "$d/node_modules"
  sed -i "s/^const PARTS_X = USB_X - [0-9.]*/const PARTS_X = USB_X - $parts/; s/^const R_OFFSET = [0-9.]*/const R_OFFSET = $roff/" "$d/lib/index.tsx"
  (cd "$d" && bunx tsci build lib/index.tsx --svgs > build.log 2>&1 || true
   errs=$(python3 -c "import json; c=json.load(open('dist/lib/index/circuit.json')); print(sum(1 for x in c if x['type'].endswith('_error')))" 2>/dev/null || echo "build failed")
   conn=$(python3 scripts/check-connectivity.py 2>/dev/null | tail -1 || true)
   echo "PARTS_X=USB_X-$parts R_OFFSET=$roff | DRC errors: $errs | $conn")
}
for p in $PAIRS; do run "$p" & done; wait
echo "scratch builds left in $TMP"