You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
eventually we want to use defmt-test (requires probe-rs), for now we'll do something bespoke: like the solution for benchmarking (only support one off tests, have the xtask` look for a sigil, etc.)
This is a prerequisite to testing/benchmarking on the board in CI.
steps
(Runner) The above is essentially describing a custom runner with the following modes:
flash (no arguments)
needs to:
find/grab lm4flash
find llvm-objcopy or similar
process the ELF
flash it
run (--debug as a potential arg)
needs to:
run flash
if --debug:
find gdb, find openocd, launch it with the right platform specific stuff
otherwise:
open picocom if available, otherwise run the built-in output only console viewer
bench (--capture as a potential arg)
this is just run but with special post-processing
test
this is alsorun but with special post-processing
add aliases for the above to .cargo/config
add the above as VSCode build tasks
[ ]
where
branch: feat-dx
open questions
xtask crate
We have some options as to how we "add" these tasks to Cargo in a developer friendly way.
unfortunately this isn't a great fit for embedded because we don't have a way to tell Cargo to build a particular crate for the host platform while also having our embedded device crates build for embedded (i.e. thumbv7em-none-eabihf) by default
the knurling-rs folks get around this by introducing nested workspaces, with the inner one targeting embedded (this definitely works but is a little involved; developers also need to be aware of which workspace they are currently in when running commands)
this also means developers need to learn a set of aliases and it opens the door for the main build depending on xtask specific flows which in turn means that cargo subcommands (i.e. cargo-asm, cargo-bloat, etc.) will no longer work
For our use case, I think introducing an xtask style crate in our workspace that we explicitly use as the cargo runner makes the most sense. This:
keeps the potential scope of the crate limited
lets us reuse existing cargo subcommands like build, run, test, and bench
The downside to this approach is that we cannot use a default build.target. After trying a bunch of other potential solutions (outer workspace with host tools like xtask + some glue to try to proxy subcommands (but not custom subcommands) into the main workspace, trying to explicitly set the target of the xtask crate in aliases, trying to otherwise hide the .cargo/config from the xtask crate, having the xtask crate be outside of the workspace, using unstable cargo features that let us specify config options in args, etc.) this seems like the least-worst option, mostly because:
this lets subcommands work
we can paper over the pain by shadowing the common Cargo aliases (b, r, t) to include the target triple (but we cannot shadow the subcommands)
we can introduce a compile_error!() into the main crate that's gated on the target triple so that it's apparent to users that they just need to add a flag to fix the errors they're seeing
once forced-target is stable, it'll be easy to switch over and we're not introducing any other complexity that we'd want to remove at that point (i.e. nested workspaces)
VSCode and what we will support
As described here, this xtask crate will be doing a fair bit of work to find/grab host tools. Would we want to update the VSCode configuration to lean on this somehow? Alternatively, do we want to take the stance that: we'll support running cargo ... with minimal effort on all the major platforms but for VSCode support you either have to use nix or you're on your own? (I'm leaning towards yes)
The text was updated successfully, but these errors were encountered:
what
Targets:
run
-> flash and open a consoleflash
-> just flash (lm4flash
)bench
-> flash + post-process serial outputµbench
debug
-> usual gdb + openocd debug flowtest
-> ...defmt-test
(requiresprobe-rs), for now we'll do something bespoke: like the solution for benchmarking (only support one off tests, have the
xtask` look for a sigil, etc.)This is a prerequisite to testing/benchmarking on the board in CI.
steps
flash
(no arguments)lm4flash
llvm-objcopy
or similarrun
(--debug
as a potential arg)flash
--debug
:gdb
, findopenocd
, launch it with the right platform specific stuffpicocom
if available, otherwise run the built-in output only console viewerbench
(--capture
as a potential arg)run
but with special post-processingtest
run
but with special post-processing.cargo/config
where
branch:
feat-dx
open questions
xtask
crateWe have some options as to how we "add" these tasks to Cargo in a developer friendly way.
xtask
pattern: a separate crate in your repo's workspace that you effectively use as a runner by introducing aliases that prefix commands withrun -p xtask --
thumbv7em-none-eabihf
) by defaultforced-target
would solve this problem but unfortunately it is not yet stable (Tracking Issue for per-package-target rust-lang/cargo#9406) and we'd rather not move to nightly Rustknurling-rs
folks get around this by introducing nested workspaces, with the inner one targeting embedded (this definitely works but is a little involved; developers also need to be aware of which workspace they are currently in when running commands)xtask
specific flows which in turn means that cargo subcommands (i.e.cargo-asm
,cargo-bloat
, etc.) will no longer workFor our use case, I think introducing an
xtask
style crate in our workspace that we explicitly use as the cargo runner makes the most sense. This:build
,run
,test
, andbench
The downside to this approach is that we cannot use a default
build.target
. After trying a bunch of other potential solutions (outer workspace with host tools likextask
+ some glue to try to proxy subcommands (but not custom subcommands) into the main workspace, trying to explicitly set the target of thextask
crate in aliases, trying to otherwise hide the.cargo/config
from thextask
crate, having thextask
crate be outside of the workspace, using unstable cargo features that let us specify config options in args, etc.) this seems like the least-worst option, mostly because:b
,r
,t
) to include the target triple (but we cannot shadow the subcommands)compile_error!()
into the main crate that's gated on the target triple so that it's apparent to users that they just need to add a flag to fix the errors they're seeingforced-target
is stable, it'll be easy to switch over and we're not introducing any other complexity that we'd want to remove at that point (i.e. nested workspaces)VSCode and what we will support
As described here, this
xtask
crate will be doing a fair bit of work to find/grab host tools. Would we want to update the VSCode configuration to lean on this somehow? Alternatively, do we want to take the stance that: we'll support runningcargo ...
with minimal effort on all the major platforms but for VSCode support you either have to usenix
or you're on your own? (I'm leaning towards yes)The text was updated successfully, but these errors were encountered: