I have a project that consists of a number of logical units (a dozen or more).
- I don't think there's much benefit to publishing them individually.
- I don't need to version the packages individually (and don't want to do it manually).
- I don't want all the logical units to see each other, just specific ones. I want to prevent accidental coupling.
- It would make sense for dependencies on external crates to be per logical unit.
My question is: which solution should I prefer?
- Make each of them a submodule
- Make each of them a crate
- Something else I'm not aware of
(Dependencies between the parts are not a clean tree structure, but rather an acyclic graph, a rather sparse one).
EDIT: For the crates approach, I'm also having a lot of duplicated build configuration, and trouble using local versions of crates.
The biggest project I work on is Amethyst. What they do is divide their project into many local crates with one parent crate, so they have a way of decoupling and keeping every part small and clean. I really like that structure, because it makes sense and in the end, they can release one product without having to release the internal crates.
However, decoupling a game engine is easy and that approach might not be the right way for every project. For example, for my game, I don't have huge independent pieces of software. I have a lot of different systems, running side-by-side on the same ECS. So I use modules in order to decouple my code, which allows a tighter collaboration. For example, I can put the character code into a module and reference stuff in the monster module without making everything pub to the crate somehow. Things, like error handling and logging are easier that way, too.