Support a shared build directory for multi-package projects.
Continuing work for https://github.com/gleam-lang/gleam/pull/2153.
Add a way to create a collection of projects which all use a single manifest and pin the same version of any given package. This would allow the compiler to share build caches between local dependencies, potentially increasing compile speed for large projects.
For sure! I'd like to avoid the term umbrella for now as I believe it has a specific meaning in OTP and we may not want to follow that design exactly.
Perhaps this can be accomplished as part of #2134? If we are already searching the parent directories for a gleam.toml we can be exhaustive and pick the highest config found as root. Then for multi-package projects we can introduce a [workspace] entry with paths to the sub-projects. Just like how Rust handles things.
Something like that sounds good. Exact details we'll need to think about.
One think I want to do is to make it opt-in, otherwise things like example projects within the repo could conflict with each other. I think the Rust design covers this, though I've not studies the rules for it yet.
Let normal gleam.toml files have a workspace section which contains a map of sub-projects and paths, where the paths are required to be children of the project root.
name = "example"
[dependencies]
aaa = "~> 1.0.0"
[workspace]
sub_project = "./subproject"
other_project = "./path/to/project"
When sub-projects detect the parent config and see that they are listed in it they used the shared manifest and /build directory.
Not sure if workspaces should be allowed to be packages or not. Also, I misspoke, this is actually a little different from rust which is opt-out by default.
Alternatively, we could allow each package to point to the root where the shared build info is kept. But I think not having a central list of members might be an issue.
Sounds sensible, but I've not looked at many systems like these so I'm not speaking with any particular authority or confidence. I'd like to do a bit of research and see what other tools do here.