-
Notifications
You must be signed in to change notification settings - Fork 124
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
west init: CLI argument to automatically setup new workspace from template #673
Comments
This template location argument should not be just "handy" but required and it should be designed ready to support projects that don't use Zephyr at all. I know the location of the west documentation makes that confusing but From #408 (comment)
A bare EDIT: this of course means most of the template details should live in the Zephyr repo, not in the west repo. That caveat aside, the idea sounds good to me.
Indeed! Thanks for the offer, much appreciated. But please wait until @mbolivar-nordic / @mbolivar is back from vacation, I would hate you to write some code only to hear that it should be done but in a totally different way that he already had in his head for some time or even as a prototype in some branch. |
Ah I see - I wasn't aware of the efforts to make
I hadn't intended But if we want to explicitly specify what template to use (rather than defaulting to anything Zephyr-specific), we could add that as a required argument to In #261, @mbolivar-nordic mentioned the idea of deprecating the bare
And for Zephyr users, I think
Absolutely, no problem! |
I don't know about you specifically but there's one thing I'm afraid a lot of people don't realize[*]: when they run [*] because they don't care, and that's OK. |
I see that @mbolivar / @mbolivar-ampere is back now - what are your thoughts on the idea of being able to install workspace templates and initialize them with |
The general idea seems like a great way to save people time. I'd like to know more about how the "local directory of templates" should get set up and maintained and how the namespace will be controlled, though. Naively I too thought "this should be a URL", but I could easily be convinced otherwise with some more details about the ergonomics of that local directory! |
There's a lot of different ways that mapping between a name and a template could be handled. A package manager with a universal registry and controlled namespacing would likely just use some convention on top of their existing package namespacing scheme (like what Yarn does with But for West, I think the most logical approach is to just use a West workspace, since
Note that this flow doesn't actually run |
Very important question indeed.
I like this. You could also extend it to
Recursion is always sexy but I'm not convinced using For any registry like this I think the critical design decisions that must be right the first time (cause they're super hard to change later) are:
The hosting, download and caching technologies can be figured out later, maybe even enriched/diversified long after the first release. It should always be possible to override from the default locations using some "long" arguments with full URLs (e.g. I think the 1st, "registry" level should be hosted and owned by https://github.com/zephyrproject-rtos/west (what else? (c)). It would do this sort of mapping:
The 2nd, actual template level should be hosted and owned by https://github.com/zephyrproject-rtos/west
So in the end:
Thoughts? |
In a totally different issue I just mentioned https://docs.platformio.org/en/latest/frameworks/zephyr.html. Maybe they have good ideas on this topic. |
@marc-hb The namespacing structure you described makes sense to me, though we might be starting to discuss two different (though interrelated) features here.
If the namespace for the lookup is strictly local (eg. a particular user has
I created this issue with only feature 1 in mind, but feature 2 is pretty compelling as well and might inform our design for feature 1. But I think designing feature 2 properly would require a lot of effort and would get pretty heavy into "make West a universal package manager" territory, so if it's something that we're interested in, we should probably make a separate Github issue for it. |
But if you don't provide a default registry (which again, should be very easy to override on the command line), then you must provide instructions to download a "local" registry by following a... URL, so you just moved the URL problem one step further! Haven't you?
Your scalability concerns feel even more ambitious than mine considering
Yes, that's why I mentioned it. I agree you can start coding and testing with only a local registry as long as you keep the design open for a global one later. |
@jamie-bes please take a look at It's not directly related but it's in the same "area". |
There are three basic types of Zephyr applications: Zephyr repository applications, workspace applications, and freestanding applications.
The default behavior of
west init
without any arguments effectively creates a Zephyr repository application, as upstream Zephyr becomes the manifest repository. This is nice for building the samples included in the Zephyr source tree, but creating a new application within this structure typically requires forking Zephyr. The workspace application structure is often better for developing new applications, as the repo for your application only needs to contain the application itself while Zephyr gets pulled in as a module. But the workflow for creating a workspace application is a bit more verbose, as you need to provide an already-existing manifest repository with awest.yml
file and pass either its URL (with-m
) or a local file path (with-l
) to West.My proposal is to add a new argument that will automatically create a template manifest repository with
west.yml
and other required files, such that it can immediately be used as a workspace application. The idea comes from Rust'scargo init
, which automatically initializes a new Git repo withCargo.toml
,Cargo.lock
,.gitignore
and asrc/main.rs
with a basic "Hello World" function. This makes starting a new application extremely easy, especially for beginners, so I think it'd be a nice feature to replicate in West.I think
west init --template
orwest init -t
for short would be a decent name, though I'm open to other ideas. Since this probably couldn't be used in combination with-m
and--mr
due to the manifest repository being created from scratch, it'd be handy to have additional arguments to specify which version of Zephyr to include inwest.yml
(maybe something likewest init -t --base https://github.com/nrfconnect/sdk-nrf
andwest init -t --br v3.3.0
).As for what should be included in the template, I'd recommend this:
...where
.gitignore
ignores thebuild
directory,west.yml
imports the selectedbase
(defaulting to https://github.com/zephyrproject-rtos/zephyr) and nothing else, and the remaining files mimic the contents of the Hello World sample. I could also see an argument for using https://github.com/zephyrproject-rtos/example-application as the template, though it's a fairly maximalist template and provides more than the average user needs. So restricting the template to the bare minimum needed to run "Hello World" makes more sense to me.If it helps, I'd be happy to put together a PR for this feature, though I created this issue to get some feedback on the idea first.
The text was updated successfully, but these errors were encountered: