From 242faad1116b0337d785552bb240b05538527906 Mon Sep 17 00:00:00 2001 From: patricktu Date: Tue, 24 Sep 2019 15:41:30 +0800 Subject: [PATCH] AIDEGen: Remove the duplicate *.srcjar from srcs AIDEGen collects the complied sources which are generated from build system, the sources includes not only java/kt files but also srcjar files. Since the srcjar files are record in srcjars parameter in json file, we should keep only java or kt files in the srcs parameter. The size diff of module_bp_java_deps.json: Without this patch: 15,298,369 Bytes With this patch: 15,044,804 Bytes The build time diff: Without this patch: 2m31.345 With this patch: 2m32.662 Bug: 141528361 Test: 1. m clean -j 2. aidegen tradefed 3. Open out/soong/module_bp_java_deps.json 4. Find the module CtsSyncManagerCommon and check the sync_manager_cts.srcjar files doesn't exist in srcs but exists in srcjars section. Change-Id: I43fc5c05b657473054e632cae4795220907dc711 --- java/java.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/java/java.go b/java/java.go index b0fc9db6c..9c7f845ac 100644 --- a/java/java.go +++ b/java/java.go @@ -350,8 +350,8 @@ type Module struct { // list of SDK lib names that this java moudule is exporting exportedSdkLibs []string - // list of source files, collected from compiledJavaSrcs and compiledSrcJars - // filter out Exclude_srcs, will be used by android.IDEInfo struct + // list of source files, collected from srcFiles with uniqie java and all kt files, + // will be used by android.IDEInfo struct expandIDEInfoCompiledSrcs []string // expanded Jarjar_rules @@ -1039,9 +1039,6 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { srcJars = append(srcJars, aaptSrcJar) } - // Collect source files and filter out Exclude_srcs that IDEInfo struct will use - j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.Strings()...) - if j.properties.Jarjar_rules != nil { j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules) } @@ -1058,6 +1055,9 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { } } + // Collect .java files for AIDEGen + j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, uniqueSrcFiles.Strings()...) + var kotlinJars android.Paths if srcFiles.HasExt(".kt") { @@ -1082,6 +1082,9 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { kotlinSrcFiles = append(kotlinSrcFiles, uniqueSrcFiles...) kotlinSrcFiles = append(kotlinSrcFiles, srcFiles.FilterByExt(".kt")...) + // Collect .kt files for AIDEGen + j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.FilterByExt(".kt").Strings()...) + flags.classpath = append(flags.classpath, deps.kotlinStdlib...) flags.classpath = append(flags.classpath, deps.kotlinAnnotations...)