Skip to content

Provide cargo-generate templates #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
japaric opened this issue Aug 2, 2018 · 18 comments
Closed

Provide cargo-generate templates #146

japaric opened this issue Aug 2, 2018 · 18 comments
Labels
feb-2019-cleanup These issues are proposed to be closed, as part of a cleanup of issues in February 2019

Comments

@japaric
Copy link
Member

japaric commented Aug 2, 2018

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

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.

@korken89
Copy link
Contributor

korken89 commented Aug 4, 2018

I can fix this for cortex-m

@jamesmunns
Copy link
Member

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.

@Keats
Copy link

Keats commented Aug 4, 2018

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.

@korken89
Copy link
Contributor

korken89 commented Aug 5, 2018

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?

@ryankurte
Copy link
Contributor

@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.

@therealprof
Copy link
Contributor

@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.

@japaric japaric self-assigned this Aug 7, 2018
@korken89
Copy link
Contributor

korken89 commented Aug 7, 2018

@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.

@japaric
Copy link
Member Author

japaric commented Aug 7, 2018

@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 cargo-generate/cargo-generate#17 (comment) to port the msp430 / riscv templates to cargo-generate?

@japaric
Copy link
Member Author

japaric commented Aug 21, 2018

@dvc94ch @pftbest will you need more features than what's described in cargo-generate/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.

@therealprof
Copy link
Contributor

I created an issue in cargo-generate for the possibility to use presets: cargo-generate/cargo-generate#92

@japaric japaric removed this from the 2018 milestone Sep 18, 2018
@japaric
Copy link
Member Author

japaric commented Sep 18, 2018

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 japaric removed their assignment Jan 8, 2019
@jamesmunns
Copy link
Member

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

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

@jamesmunns jamesmunns added the feb-2019-cleanup These issues are proposed to be closed, as part of a cleanup of issues in February 2019 label Feb 4, 2019
@Disasm
Copy link
Member

Disasm commented Feb 14, 2019

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

@Disasm
Copy link
Member

Disasm commented Jul 16, 2019

Updated riscv-rust-quickstart.

@cr1901
Copy link

cr1901 commented Jan 2, 2020

@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
Copy link

cr1901 commented Jan 12, 2020

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

@taurr
Copy link

taurr commented Sep 19, 2021

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

@therealprof
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feb-2019-cleanup These issues are proposed to be closed, as part of a cleanup of issues in February 2019
Projects
None yet
Development

No branches or pull requests

9 participants