Add support for per-platform aliases - #173
Conversation
Aliases for first-party crates were unconditionally added to the shared alias data for a workspace crate. This does not work if a first-party dependency should only be added for specific targets (e.g. a tool can make network connections using a first-party dependency but only on certain platforms, and does not use the dependency crate otherwise). This change makes it so that we only add an alias for a first-party crate if it would also appear as a dependency for that specific target. Dependency data now has a new field called `aliases_by_platform`, and the generated aliases() helper emits a select expression if there are platform-specific aliases.
39b76fe to
ef52904
Compare
So fun fact, it used to be like this but then I convinced myself that aliases were lazy enough that it was fine to merge for simplicity (i.e. that it wouldn't actually add any inputs, only remap deps if they were selected). It sounds like that might have been an incorrect assumption, but can you show me a case where it breaks? (I saw you added a unit test, but I'd prefer an integration test for this) |
Aliases for first-party crates were unconditionally added to the shared alias data for a workspace crate. This does not work if a first-party dependency should only be added for specific targets (e.g. a tool can make network connections using a first-party dependency but only on certain platforms, and does not use the dependency crate otherwise).
This change makes it so that we only add an alias for a first-party crate if it would also appear as a dependency for that specific target. Dependency data now has a new field called
aliases_by_platform, and the generated aliases() helper emits a select expression if there are platform-specific aliases.