Add a trace_references_from dex optimization property
Introduce a new property `trace_references_from` in the optimize block.
This field allows specifying a set of downstream targets from which to
trace references when optimizing the current target.
In practice, this requires explicit breaking of any cycles that might
occur. A follow-up effort will explore doing this dynamically and
implicitly for `libs` references onto an optimized target that
enables this feature.
Bug: 212737576
Test: m nothing
Test: go test ./java
Flag: EXEMPT bugfix
Change-Id: I088bd8bf89403661a084a43b2822a6efbbc0294d
diff --git a/java/base.go b/java/base.go
index 0833831..d49a9bc 100644
--- a/java/base.go
+++ b/java/base.go
@@ -888,6 +888,10 @@
// Add dependency on libraries that provide additional hidden api annotations.
ctx.AddVariationDependencies(nil, hiddenApiAnnotationsTag, j.properties.Hiddenapi_additional_annotations...)
+ // Add dependency on (soft) downstream libs from which to trace references during optimization.
+ traceRefs := j.dexProperties.Optimize.Trace_references_from.GetOrDefault(ctx, []string{})
+ ctx.AddVariationDependencies(nil, traceReferencesTag, traceRefs...)
+
// For library dependencies that are component libraries (like stubs), add the implementation
// as a dependency (dexpreopt needs to be against the implementation library, not stubs).
for _, dep := range libDeps {