From efb6d602104fa70fef3aa3badde1ac33e7553f1b Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Fri, 27 Oct 2023 18:47:10 +0000 Subject: [PATCH] Update transitive lib propagation Only propagate transitive libs by way of library-like references. This avoids inclusion of transitive deps from tools like lint modules that are unncessary for R8. This yields build speedups for a number of targets, including: * services.jar: -22% (66s -> 51s) * telephony-common.jar: -27% (29s -> 21s) * updatable-media.jar: -41% (17s -> 10s) * framework-appsearch.jar: -46% (13s -> 7s) Bug: 302383328 Bug: 307273642 Test: m Change-Id: I60bb30e84dabe522ea9ac9333f00e739962ea91d --- java/base.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/java/base.go b/java/base.go index e1c2386ff..3d7d3de01 100644 --- a/java/base.go +++ b/java/base.go @@ -1946,19 +1946,22 @@ func (j *providesTransitiveHeaderJars) collectTransitiveHeaderJars(ctx android.M } dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo) - if dep.TransitiveLibsHeaderJars != nil { - transitiveLibs = append(transitiveLibs, dep.TransitiveLibsHeaderJars) - } - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveStaticLibs = append(transitiveStaticLibs, dep.TransitiveStaticLibsHeaderJars) - } - tag := ctx.OtherModuleDependencyTag(module) _, isUsesLibDep := tag.(usesLibraryDependencyTag) if tag == libTag || tag == r8LibraryJarTag || isUsesLibDep { directLibs = append(directLibs, dep.HeaderJars...) } else if tag == staticLibTag { directStaticLibs = append(directStaticLibs, dep.HeaderJars...) + } else { + // Don't propagate transitive libs for other kinds of dependencies. + return + } + + if dep.TransitiveLibsHeaderJars != nil { + transitiveLibs = append(transitiveLibs, dep.TransitiveLibsHeaderJars) + } + if dep.TransitiveStaticLibsHeaderJars != nil { + transitiveStaticLibs = append(transitiveStaticLibs, dep.TransitiveStaticLibsHeaderJars) } }) j.transitiveLibsHeaderJars = android.NewDepSet(android.POSTORDER, directLibs, transitiveLibs)