feat(cli): gateware build pass-through and peripheral build/deploy subcommands#184
Open
vishnutskumar wants to merge 21 commits into
Open
feat(cli): gateware build pass-through and peripheral build/deploy subcommands#184vishnutskumar wants to merge 21 commits into
vishnutskumar wants to merge 21 commits into
Conversation
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.
…tity with git hash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Integrates the axon-peripheral-sdk gateware flow into
synapsectl:synapsectl gatewarepass-through to the axon-peripheral-sdk build, resolving the gateware project fromsrc/gateware, supporting leading options, colored output, and an optional Lattice Radiant license (host MAC detection for node-locked licenses).--pdc/--implflags from the gateware build command.Test plan
test_gateware_passthrough.py,test_gateware_runner.py,test_half_selectors.py,test_license_mode.py(~2,500 lines of adversarial coverage).