Skip to content

feat(cli): gateware build pass-through and peripheral build/deploy subcommands#184

Open
vishnutskumar wants to merge 21 commits into
mainfrom
vts/axon-peripheral-sdk
Open

feat(cli): gateware build pass-through and peripheral build/deploy subcommands#184
vishnutskumar wants to merge 21 commits into
mainfrom
vts/axon-peripheral-sdk

Conversation

@vishnutskumar

Copy link
Copy Markdown

Summary

Integrates the axon-peripheral-sdk gateware flow into synapsectl:

  • Add synapsectl gateware pass-through to the axon-peripheral-sdk build, resolving the gateware project from src/gateware, supporting leading options, colored output, and an optional Lattice Radiant license (host MAC detection for node-locked licenses).
  • Split peripheral build/deploy half-selectors into proper subcommands and tell axon-peripheral-sdk it was launched via synapsectl.
  • Drop the unsupported --pdc/--impl flags from the gateware build command.

Test plan

  • New CLI test suites: test_gateware_passthrough.py, test_gateware_runner.py, test_half_selectors.py, test_license_mode.py (~2,500 lines of adversarial coverage).
  • CI must pass before merge.

vishnutskumar and others added 16 commits May 25, 2026 19:21
Replace the mutually-exclusive --driver/--gateware flags on
`synapsectl peripherals build` and `... deploy` with explicit
driver/gateware/both subcommands:

  synapsectl peripherals build  driver|gateware|both [dir] [--clean]
  synapsectl peripherals deploy driver|gateware|both [dir] [--package P]

A new `_add_half_subcommands` helper wires the three leaf subparsers,
each setting `half` via set_defaults — the value build_cmd/deploy_cmd
already branch on, so the handlers are unchanged. A bare `build`/`deploy`
prints help; an unknown target gives argparse's "invalid choice". The
`peripherals gateware <verb>` SDK pass-through is untouched.

Also fixes pre-existing lint surfaced while editing:
- validate_manifest return type dict|bool -> dict|Literal[False] (it
  never returns True), clearing spurious Literal[True] type errors at
  every call site.
- staging-time maintainer scripts chmod 0o755 -> 0o644 (fpm embeds the
  contents and dpkg sets the exec bit at install; the staging mode never
  ships).

Adds the peripheral-CLI unit test suite under synapse/tests/cli/.
…sectl

The gateware passthrough forwards 'synapsectl peripherals gateware <verb>'
verbatim to 'axon-peripheral-sdk <verb>' inside the container. Export
AXON_PERIPHERAL_SDK_FRONTEND='synapsectl peripherals gateware' on that docker
run so the SDK brands its 'next steps' hints and --help examples with the
command the user actually typed, not the forwarded binary name. Added a test
asserting the -e marker is present, precedes the image tag, and does not leak
into the forwarded SDK argv tail.
The axon-peripheral-sdk removed the --pdc and --impl build options. Drop them
from _SDK_BUILD_CMD so 'synapsectl peripherals build gateware' keeps working
against the updated SDK. The flags were optional (defaulting to devkit/impl_1),
so 'build --project src/gateware' is equivalent and also works against the
prior SDK — backward-compatible. Updated the runner test's pinned command
string and docstrings to match.
…through

`synapsectl peripherals gateware <verb>` run from a peripheral repo root
failed for project-scoped SDK verbs (e.g. `generate`: "peripheral.yaml not
found in /home/workspace"). The pass-through mounted the repo root at
/home/workspace and ran the SDK there, but the SDK resolves its project from
cwd, and peripheral.yaml lives in src/gateware/.

Injecting `--project src/gateware` is not viable: validate/regenerate/
add-peripheral have no --project flag at all, and doctor/list-profiles/new
reject it. Instead, when cwd has manifest.json AND src/gateware/, set the
container working dir to /home/workspace/src/gateware. The bind-mount stays
the repo root so `build` keeps full-repo visibility. The decision is
directory-driven, not verb-driven, so argv is still forwarded verbatim with
no verb allowlist; doctor/list-profiles/new are unaffected.

Extract a shared _GATEWARE_PROJECT_SUBDIR constant (also used by the
structured build command).

Tests: 3 new pass-through cases (redirect when manifest+subdir present;
stays root when src/gateware absent; stays root when manifest.json absent).
…lors, license-optional)

Several refinements to `synapsectl peripherals gateware <verb>`:

- Leading SDK options now forwarded. argparse.REMAINDER only captures from the
  first positional, so `gateware --install-completion` (a top-level SDK flag)
  was rejected. parse_args_with_passthrough() folds leftover tokens into the
  pass-through argv (gated by a `_passthrough_extra` marker on the subparser);
  other commands still hard-error on unknown args. __main__ uses it.
- Colors preserved. Allocate a docker `-t` when stdout is a tty so the SDK's
  rich/typer output keeps its colors; omitted when piped/CI.
- License made optional for the pass-through. Forward LM_LICENSE_FILE when set,
  omit when unset; a set-but-missing file path (FileNotFoundError) warns and
  continues instead of crashing. Only Radiant verbs (`build`) need a license,
  enforced SDK-side — so help/doctor/generate/validate/sim work without one.
- Tests renamed from test_case_<N>_* to descriptive names; added coverage for
  leading options, tty/-t, and the unset / set-but-missing license paths.
Switch build_cmd and deploy_cmd to the two-deb flow via _build_debs:
driver deb (so + SDK runtime, fpm input "usr") is built first, then a
separate -gateware deb (bit + manifest fragment under opt/scifi/bitstreams/custom/).
build_peripheral_deb is now driver-only (so_path required, bit_path removed,
_expected_bit_filename deleted). _run_fpm extracts the shared docker/fpm/verify
block used by both packagers. _gateware_usb_pid wraps gateware.read_usb_pid
and aborts cleanly when the .summary.json is absent. Test harness gains
build_gateware_deb recorder, summary-writing fake_run_gateware, and two-arg
find_deb_package stub; cases M/N/O rewritten for two-deb layout; P1-P7 deleted;
Q and R added for deploy streaming and missing-summary abort path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants