wg icon indicating copy to clipboard operation
wg copied to clipboard

Provide cargo-generate templates

Open japaric opened this issue 7 years ago • 17 comments

Triage(2018-08-20)

The Cortex-M team has requested features to the cargo-generate folks. Implementation is blocked on cargo-generate gaining the features we need.


cargo-generate is going to be the official solution for Cargo templates. The domain WGs are expected to provide cargo-generate templates for applications in their domain.

Let's move the existing templates ({cortex-m,msp430,riscv}-quickstart) to the cargo-generate format. If you need any feature to be added to cargo-generate to port your template open an issue or leave a comment about your use case in one of the existing ones.

Submit feature requests ASAP so there's enough time for them to be implemented. Also let's collect all the embedded WG feature requests in this issue so we can have the cargo-generate team prioritize them.

Feature requests

  • cortex-m-quickstart, custom variables and validation. https://github.com/ashleygwilliams/cargo-generate/issues/17#issuecomment-409987029

cc ~@rust-embedded/cortex-m~ @adamgreig @korken89 @therealprof cc ~@rust-embedded/msp430~ @cr1901 @pftbest cc ~@rust-embedded/riscv~ @bradjc @danc86 @dvc94ch

I'm going to tentatively assign this to the RC1 milestone.

japaric avatar Aug 02 '18 16:08 japaric

I can fix this for cortex-m

korken89 avatar Aug 04 '18 10:08 korken89

Has kickstart been considered? It seems to have the features we require around custom variables and validation of those variables.

If nothing else, it may be relevant for how to implement these features, if use of cargo-generate is really desired.

jamesmunns avatar Aug 04 '18 11:08 jamesmunns

Just saw this thread while looking at the cargo-generate issues and thank you @jamesmunns for mentionning kickstart. I believe kickstart would fit the bill, except the validation of overlapping of memory as validation in kickstart is currently only regex based.

Keats avatar Aug 04 '18 12:08 Keats

I was talking to a colleague of mine, and one thing that came up as missing is the extra help with MCU selection (initial setup), and weeding out all the chip crates. For example, one would like to do something like this and get the extra help (strawman syntax):

$ cargo [my_generator] [mcu] [optional chip crate] [optional extra crates]

Where it could be used as, and give the following help:

$ cargo generate --mcu cortex-m --chip stm32
Error: Cortex-M is not specific enough.
Maybe you meant: cortex-m0, cortex-m0p, cortex-m3, cortex-m4, cortex-m7

Okey, lets improve (I know there is an stm32 crate, but bear with me):

$ cargo generate --mcu cortex-m4 --chip stm32
Error: Too many matches for chip crates:
Maybe you meant: [list of crates]

I think a guiding feature like this could really help new users a lot and solve a real pain within embedded, and specifically setting up new project therein. Most of it would come from good suggestions. Moreover, it would help new users in that they would not need to place the target in the .cargo/config file (small thing but easy to miss). However I am not sure how much of an extension would be needed to the two linked generators here to make something like this work.

Any comments/further ideas/thoughts?

korken89 avatar Aug 05 '18 13:08 korken89

@korken89 seems like an excellent idea!

I don't know how much control over cargo generate we have, but, mbed-cli has a list of supported micros and boards you can ask it for which has come in handy for me. Also the addition of a --board eg. --board=blue-pill as a meta description that selects the other components could be neat.

ryankurte avatar Aug 06 '18 23:08 ryankurte

@korken89 Sounds great but the syntax is a bit wonky. Why would you specify the core type as --mcu? And why would you specify it at all if you have the specific chip?

@ryankurte You mean like https://platformio.org/ for Rust? That sounds like a terrific idea.

therealprof avatar Aug 07 '18 07:08 therealprof

@ryankurte
Thanks! I was thinking something similar! The whole issue is probably where all the metadata will come from, so that the system more or less becomes automated in additions and does not become a maintaining nightmare.

@therealprof Yeah, I agree that the syntax is wonky, it was mostly the overall idea I wanted to put forward. Any syntax can be bikesheded when/if it comes closer :)

And why would you specify it at all if you have the specific chip?

Exactly, if this metadata is available the system could say that the core is not needed. The syntax could be a bit more hierarchical:

  • If you have board, MCU and Core is not needed.
  • If you have MCU, Core is not needed
  • Else specify core only

Or something similar.

The core idea is simply to have the system be more automated and easy for beginners and advanced alike. I am however not sure where to propose and push it, as the selection of generator seems to happen now, but it can also be extended later.

korken89 avatar Aug 07 '18 17:08 korken89

@jamesmunns @Keats I don't have much insight into how cargo-generate will get the features we need; that would be up to the Cargo team. At this stage our job is to submit feature requests.

@therealprof @ryankurte @korken89 that sounds interesting but could you leave a comment or open an issue in the cargo-generate issue tracker to make sure the use case doesn't get lost?

@dvc94ch @pftbest will you need more features than what's described in https://github.com/ashleygwilliams/cargo-generate/issues/17#issuecomment-409987029 to port the msp430 / riscv templates to cargo-generate?

japaric avatar Aug 07 '18 18:08 japaric

@dvc94ch @pftbest will you need more features than what's described in ashleygwilliams/cargo-generate#17 (comment) to port the msp430 / riscv templates to cargo-generate?

@rust-embedded/msp430 @rust-embedded/riscv did you get a chance to try this?


Triage: implementation is blocked on cargo-generate gaining the features we need.

japaric avatar Aug 21 '18 13:08 japaric

I created an issue in cargo-generate for the possibility to use presets: https://github.com/ashleygwilliams/cargo-generate/issues/92

therealprof avatar Aug 25 '18 12:08 therealprof

cortex-m-quickstart has moved to the cargo-generate format. As that's what we'll be using the embedded Rust book I'm going to remove this issue from the 2018 milestone to signal that the work required for the 2018 edition is done.

I'm going to leave this open to track the other arches (msp430 and rsicv) moving to / testing cargo-generate.

japaric avatar Sep 18 '18 14:09 japaric

@rust-embedded/msp430 @rust-embedded/riscv

Are there any plans to update your quickstarts to cargo-generate? Can this issue be closed?

jamesmunns avatar Feb 04 '19 00:02 jamesmunns

@jamesmunns I have this in my roadmap for RISC-V.

Disasm avatar Feb 14 '19 18:02 Disasm

Updated riscv-rust-quickstart.

Disasm avatar Jul 16 '19 22:07 Disasm

@jamesmunns

Are there any plans to update your quickstarts to cargo-generate? Can this issue be closed?

Once v0.2.0 crates are published, I will update msp430-quickstart to use cargo-generate; publishing is imminent.

cr1901 avatar Jan 02 '20 06:01 cr1901

@jamesmunns Long overdue, but msp430-quickstart has been updated to use cargo-generate. This issue can be closed I believe.

cr1901 avatar Jan 12 '20 03:01 cr1901

I just landed https://github.com/cargo-generate/cargo-generate/pull/445, which should solve the missing issues for this issue. Please take a look as it'll be part of next cargo-generate release

taurr avatar Sep 19 '21 11:09 taurr

There have been a variety of templates available now including https://github.com/rust-embedded/cortex-m-quickstart and https://github.com/rust-embedded/msp430-quickstart under the WG umbrella.

therealprof avatar Jun 11 '24 18:06 therealprof