Skip to content

better dependency handling/profile management/etc. for workspaces #2916

@froydnj

Description

@froydnj

Some projects (my context is Firefox, but I can imagine others) may want to manage multiple in-tree Rust libraries (one Rust staticlib per shared library the project generates, some libraries for inclusion in shared libaries and some for inclusion in binaries, etc. etc.). You can do this today with multiple Cargo.toml files and tying them together with workspaces.

There are some things about this which are not ideal. Consider:

  • Dependencies have to be re-specified in every sub-Cargo.toml. I think if you're going to trouble yourself to use workspaces, it's reasonable that you can list all the dependencies that you need in the root Cargo.toml file and go from there. This issue is particularly acute for codebases (such as Firefox) where all the Rust code must live in-tree, as path specifications are needed for every dependency in every sub-library. It would be much simpler to specify everything once in the root Cargo.toml. I can certainly imagine issues where a particular sub-library might want to use a different version, though...
  • Likewise, profile settings have to be re-specified for every library.

It would be super-helpful if settings such as the above (and probably others that I'm not thinking of because they haven't come up in my context) could somehow be shared between library-generating crates.

What would solve the problems above for me would be permitting multiple [lib] sections in a Cargo.toml; I wouldn't need to use workspaces at all if multiple libraries could be specified in the root Cargo.toml! I can understand that it might not be practical to change that at this point, despite the consistency benefits it would bring...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions