Add boxsim CLI: pure Python codec, netlist extraction, KiCad project generation
Replaces the bpj2ini.py prototype with a packaged tool. The A2F codec is now reimplemented in Python, so neither Boxsim.exe nor a CPU emulator is needed to decode a container; the emulator survives as a development-only oracle that the codec is differentially tested against. Verified: - 134 containers decode byte-identically to Boxsim's own decoder, 270 pre-2.0 files rejected by both implementations (tools/difftest.py --self-test) - Default.BPJ: 22 components, 14 nets, no dangling terminal - 22 of 22 parts resolve to library symbols; one series inferred from a sibling, two DC resistance deviations reported - ERC clean and the netlist KiCad extracts from the generated sheet is an identical partition to the one derived from the Boxsim grid - container build byte-identical to the host build - 32 tests passing, ruff clean Decode time went 69 s -> 14.5 s (binding emulator hooks to trap addresses) -> 1.6 s (pure Python). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb81ca61cb
commit
4737a5bae8
28 files changed
+4459
-122
No files matched your search
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the boxsim image, staging the Visaton library and parts catalogue.
|
||||
#
|
||||
# Both live outside this repository, so they are copied into a staging directory
|
||||
# inside the build context first. Nothing proprietary is baked in: the Visaton
|
||||
# library is our own, and the catalogue is a plain text parts list.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
LIB_DIR="${BOXSIM_KICAD_LIB_DIR:-/home/magdev/workspaces/other/kicad-visaton-lib}"
|
||||
CATALOG="${BOXSIM_CATALOG:-$ROOT/boxsim_dl/BoxSim 2.1 DE (Stand 12.2025)/Weichenbauteile/Visatonteile.txt}"
|
||||
IMAGE="${IMAGE:-boxsim:0.1.0}"
|
||||
|
||||
SYM="$LIB_DIR/symbols/Visaton.kicad_sym"
|
||||
FP="$LIB_DIR/footprints/Visaton.pretty"
|
||||
|
||||
# A missing input must stop the build, never silently produce an image without
|
||||
# its library.
|
||||
for path in "$SYM" "$FP" "$CATALOG"; do
|
||||
if [[ ! -e "$path" ]]; then
|
||||
echo "build-image: required input missing: $path" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# The library must already be in the current KiCad format, otherwise the symbols
|
||||
# cannot be embedded into a KiCad 10 schematic.
|
||||
version="$(sed -n 's/.*(version \([0-9]\+\)).*/\1/p' "$SYM" | head -1)"
|
||||
if [[ -z "$version" || "$version" -lt 20211014 ]]; then
|
||||
echo "build-image: $SYM is in the legacy format (version ${version:-none})." >&2
|
||||
echo " Run: kicad-cli sym upgrade --force '$SYM'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf stage
|
||||
mkdir -p stage
|
||||
cp "$SYM" stage/Visaton.kicad_sym
|
||||
cp "$CATALOG" stage/Visatonteile.txt
|
||||
cp -r "$FP" stage/footprints
|
||||
|
||||
echo "staged: symbol library (version $version), catalogue, $(ls stage/footprints | wc -l) footprints"
|
||||
|
||||
docker build -t "$IMAGE" .
|
||||
rm -rf stage
|
||||
|
||||
echo "built $IMAGE"
|
||||
Reference in new issue
Block a user