-
Notifications
You must be signed in to change notification settings - Fork 247
feat: initial implementation of project file format #2510
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
base: main
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,11 @@ | |||
|
|
|||
| [package] | |||
| name = "my-account-note" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From #1919:
The Rust tooling uses/reproduces much of this information in Cargo.toml - we could move most of that to miden-project.toml instead, or alternatively, simply merge the relevant sections from Cargo.toml into an in-memory miden-project.toml manifest. Much of what I've laid out here is in fact the parts we already define/maintain in Cargo.toml for Rust-based projects today
I wonder what our plan is for Rust projects?
Currently we store all Miden-related fields in the [package.metadata.miden] section of the Cargo.toml. See a P2ID example.
Do we want to require miden-project.toml and move the Miden fields currently residing in the Cargo.toml there? Multiple fields end up duplicated (name, version, etc.). Plus, the developer would have package dependencies defined in the miden-project.toml and the crate dependencies in the Cargo.toml.
I'd suggest to keep storing all Miden fields in Cargo.toml. The cargo miden build can embed generated miden-project.toml in the compiled Miden package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue with storing everything in Cargo.toml has a few issues:
- We will have tooling, and there will be third-party tooling, built around Miden projects, and storing project information in
Cargo.tomlrequires those tools to understand not onlymiden-project.toml, but alsoCargo.tomland however we choose to encodemiden-projet.tomlinformation inside of it. - In the future, other languages that can compile to Miden may not have a TOML configuration file (or at least one that can be piggy-backed on like
Cargo.toml), in which case they would need to usemiden-project.tomland would face the same dilemma of duplication between language-specific project config and Miden project config. Being consistent about the boundary between language-specific config and Miden config up front will lead to less confusion IMO. - It complicates IDE/LSP integration, since
Cargo.tomlis already used as a language marker for Rust, it would require parsingCargo.tomlto determine if the directory is a Miden/Rust project, or just a Rust project. In some editors it may not be a problem, if extensions are provided an opportunity to do this when a worktree is opened in the editor (e.g. Zed), but I don't believe that is always the case. - Even if we were to use
Cargo.tomlfor Miden+Rust projects, we still have a situation where we are specifying dependencies in two places inCargo.toml- one for normal crates, and then one for Miden packages under ([package.metadata.miden.dependencies]). IMO, it's more likely to confuse users that both sets of dependencies are specified in different places in the same file. If Miden package dependencies are inmiden-project.tomland pure Rust dependencies are inCargo.toml, the delineation between the two is a lot more clear (and easier to explain). - Rust crates which are compiled to Miden will not be published to crates.io - so virtually all of the metadata that would typically go in
Cargo.tomlcan be specified inmiden-project.tomlinstead, aside fromnameandversion. GIven that, it isn't clear to me how much information would actually be duplicated, or how much of a pain that would be in practice. Changing thenameis going to be very rare. Changingversionis more frequent, so if it is considered painful enough to have to maintain it in two places, we could provide a solution there that allows specifying inmiden-project.tomlthat the version is to be inferred from external/language-specific tooling, something likeversion = { external = true, language = "rust" } | { external = true, path = "VERSION" }. TBH, I don't think it is actually a significant enough pain point for that, but 🤷. Aside fromversionthough - there just isn't overlap betweenCargo.tomlandmiden-project.tomlto combine them IMO.
I'm not saying I couldn't be persuaded on this point, but it does feel like preemptively addressing an issue that we don't actually know is going to be an issue in practice. I would want to see how much duplication there actually is (given the constraints I outlined above, e.g. defining description in Cargo.toml doesn't make any sense), and from there determine if it is a significant enough problem to warrant complicating project handling by allowing Rust projects to piggy-back on Cargo.toml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair points. I'm sold on the project-level miden-project.toml.
The workspace-level miden-project.toml still bothers me due to the members and profile duplication with Cargo.toml. Assuming they have to be maintained by the user.
|
I like the version-or-digest approach and that we'll store it in the same field. Apart from my question about the workspace level in Rust projects at #2510 (comment) everything sounds good. |
|
This is ready for review, though I expect to add a few more tests still, and write up a README doc that describes the usage and syntax of the project file. A few design details to note during your review:
If you have any questions about specific details, leave a comment here or ping me to discuss, I'm happy to walk through any of this, since there is a lot of context that isn't easy to glean from just the source code or its documentation. |
The duplication is hard to avoid at the workspace level. We could derive the Regardless, we need the workspace-level project file for workspace management of Miden Assembly projects anyway, so the issue of duplication with |
82b1d44 to
feea354
Compare
feea354 to
e252ca3
Compare
This PR implements a new crate,
miden-project, which implements the data structures for representing Miden projects, along with the AST representation of themiden-project.tomlfile initially sketched out in #1919. Note that the actual syntax ofmiden-project.tomlas implemented in this PR differs from that initial sketch in a few ways. See the example project layouts incrates/project/examplesfor the syntax of workspace-based and standalone project files.I'm still making a few small adjustments, and implementing tests for the parsing/validation bits, but this should be more or less reviewable as-is, at least in terms of the high-level design.
Links
miden-project.tomlcan be found in RFC: Introducemiden-project.tomlmanifest file #1919TODO
pubgrubplumbing for package selection during dependency resolution