-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incompatible_make_rust_providers_target_independent #966
Comments
What's the use case for compiling files in aspects? Just out of curiosity |
A typical example is code generation from some format into multiple languages. Imagine protobuf, where the data format is defined in a language independent .proto file, and you generate language specific implementation for the format. If the data format specification was standalone, meaning one target fully defined the format, you don't need aspect, you can just fine live with rules:
But once your data format allows for reuse and for dependencies, you need an aspect:
|
Motivation
Currently
CrateInfo.deps
andCrateInfo.proc_macro_deps
have the typedepset[Target]
. Inrustc_compile_action
the Targets are inspected when creating the target’sDepInfo
.This is inconvenient if we want to compile a Rust source file from an aspect (that depends on other Rust source files compiled by the aspect), as there is no concrete target that we could put into the
CrateInfo.{deps|proc_macro_deps}
fields. The aspect will instead return a custom provider that will contain aCrateInfo
andDepInfo.
Incompatible changes
Instead of
depset[Target],
we’ll makeCrateInfo.deps
andCrateInfo.proc_macro_deps
be of typedepset[DepVariantInfo]
.DepVariantInfo
is a new provider that wraps the providers a crate’s dependency may have. We’ll also need an additional field inCrateInfo
:CrateInfo.owner
, which will contain the label that theCrateInfo
was created from. This is because we need to know the label so we can memorize the alias for the crate.The
//rustc/settings:incompatible_make_rust_providers_target_indepent
guards this incompatible change. Once flipped,rustc_compile_action
will check that theCrateInfo.owner
field is present, and also thatCrateInfo.deps
andCrateInfo.proc_macro_deps
havedepset[DepVariantInfo]
type.Migration steps
One should pass a
depset[DepVariantInfo]
toCrateInfo.deps
andCrateInfo.proc_macro_deps
, as well as the owner label:The text was updated successfully, but these errors were encountered: