Use transitive header jars in classpaths
Skip combining jars into turbine-combined, combined, and withres jars
and instead collect transitive jars to use in the classpath and to
produce the final dexed jar.
This reduces the size of a `m checkbuild` in git_main by 11%, from
1300 KiB to 1154 KiB. It may also improve caching and reduce uplink
network bandwidth when building with RBE, as now the classpath inputs
to rules are themselves outputs of previous rules and so already in
the RBE CAS.
The downside is that the classpath inputs to each rule are now much
longer, increasing the Soong ninja file size 11%, from 4.6 GiB to
5.1 GiB. This could be mitigated in the future by supporting something
like depsets in the generated ninja file to reduce duplication.
Bug: 308016794
Test: TestSimple, TestKotlin, TestClasspath
Flag: build.RELEASE_USE_TRANSITIVE_JARS_IN_CLASSPATH
Change-Id: I2b7b4261375494370da70f98597c8719f1d561cf
diff --git a/java/system_modules.go b/java/system_modules.go
index f89bf9e..d9430b2 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -127,6 +127,9 @@
OutputDir android.Path
OutputDirDeps android.Paths
+
+ // depset of header jars for this module and all transitive static dependencies
+ TransitiveStaticLibsHeaderJars *android.DepSet[android.Path]
}
var SystemModulesProvider = blueprint.NewProvider[*SystemModulesProviderInfo]()
@@ -149,18 +152,23 @@
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var jars android.Paths
+ var transitiveStaticLibsHeaderJars []*android.DepSet[android.Path]
ctx.VisitDirectDepsWithTag(systemModulesLibsTag, func(module android.Module) {
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
jars = append(jars, dep.HeaderJars...)
+ if dep.TransitiveStaticLibsHeaderJars != nil {
+ transitiveStaticLibsHeaderJars = append(transitiveStaticLibsHeaderJars, dep.TransitiveStaticLibsHeaderJars)
+ }
}
})
system.outputDir, system.outputDeps = TransformJarsToSystemModules(ctx, jars)
android.SetProvider(ctx, SystemModulesProvider, &SystemModulesProviderInfo{
- HeaderJars: jars,
- OutputDir: system.outputDir,
- OutputDirDeps: system.outputDeps,
+ HeaderJars: jars,
+ OutputDir: system.outputDir,
+ OutputDirDeps: system.outputDeps,
+ TransitiveStaticLibsHeaderJars: android.NewDepSet(android.PREORDER, nil, transitiveStaticLibsHeaderJars),
})
}