rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.59k stars 2.39k forks source link

Expose manifest.rs as a standalone crate #4614

Open sagiegurari opened 6 years ago

sagiegurari commented 6 years ago

The manifest.rs has the structs and enums that define most of the Cargo.toml That could be really helpful for other build/dev tools like cargo-make For now, I also have internally mapped the relevant items in an internal data structs and enums, but would be happier if I would have just had a standard crate to use to pull those definitions from (naturally with serde support). The manifest.rs seems like exactly the thing I was looking for but I would prefer a standalone lightweight crate only holding definitions instead of depending on entire cargo crate. It would also help making your codebase more modular and reusable.

alexcrichton commented 6 years ago

Sounds like a good idea to me!

carols10cents commented 6 years ago

cc @joshtriplett, is this the toml crate you were talking about in the cargo meeting today or is that different?

joshtriplett commented 6 years ago

@carols10cents This is different, but also very useful. I'd love to have this available for all sorts of metabuild scripts that want to parse Cargo.toml.

sagiegurari commented 4 years ago

bump... just wondering if this is on any todo list...

epage commented 9 months ago

We've now closed #12801 by providing cargo_util_schemas::manifest::TomlManifest.

This does not do any high level processing, like inheriting from a workspace, reading defaults, or complex validation. This Issue is remaining open for that work. The challenge is a lot of that logic is more tightly coupled to the internals of cargo (see #12801 for how much work it was just to do serde types). Personally, I don't see this Issue being resolved but I'm open to being surprised.

weihanglo commented 7 months ago

Problem

We have cargo-util-schemas for low-level type definitions in Cargo, and cargo_util_schemas::manifest::TomlManifest is the core one for serialization and deserialzation for Cargo.toml. However, since it is only a type definition, there is no high-level Cargo business logic in the library, which people still need to copy from or reimplement Cargo.

There are multi-layer needs people like to see in a cargo-util-manifest package. Here is a list of these layer:

For the latter two needs, they are too coupled to the entire Cargo internals, not something easy to expose. For the first two, it seems like a fairly limited scope "normalized" version of Cargo.toml. So probably we can provide a library meetings what cargo-toml/cargo-manifest needs? I do have concerns around it.

Concerns

Here are necessary works for breaking out a crate to provide the "normalized" manifest.

Plan

I don't really have a concrete plan. Here is just a rough ideas in my mind.

epage commented 7 months ago

For most people, they just need a normalized form and cargo metadata works great for that, especially for dealing with old/new cargo (see "edition as number" topic).

In less common cases, they need the low level details and cargo-util-schema works well for that.

So what use cases are left that we are aiming for? This is important for us to know to evaluate how worthwhile this is in the first place, how much to compromise cargo development for this, etc.

I know crates.io is in a weird middle ground. They need a normalized form but aren't in an environment to run cargo metadata. Granted, cargo publish normalizes Cargo.toml files sufficiently that they likely can still get away with cargo-util-schema.