I’m starting to look at adding support for a) code...
# development
I’m starting to look at adding support for a) codegen to synthetically inject runtime dependencies, and b) “dependency inference” (meaning you can leave off
in your BUILD file and Pants will do the right thing based on import statements) -- We need to convert
from a
so that the engine can do its magic. Call sites would look like:
Copy code
await Get[Addresses](DependenciesRequest(tgt.get(Dependencies))
This means we have one rule to go from
DependenciesRequest -> Addresses
, just like we have one rule to go from
HydrateSourcesRequest -> HydratedSources
. Fine and good. -- The challenge is with codegen dependency injection. Specifically, that that injection will need to access subsystem options, e.g.
. It will need a
. But, we can’t have our generic
DependenciesRequest -> Addresses
rule request that subsystem because it has no idea it’s needed. Instead, in the rule, we need a way to say something like “If there are any injected dependencies for this
field, run the rule to inject those.” This is unions, right? Something like:
Copy code
injected_deps = await Get[InjectedDependencies](InjectDependenciesRequest, dependencies_field)
And then the Protoc backend would define a rule that goes from
(ProtocDependencies, Protoc) -> InjectedDependencies
, where
belongs to the union?