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
This commit is contained in:
patricktu 2019-09-24 15:41:30 +08:00
parent 04de8b5ca5
commit 242faad111
1 changed files with 8 additions and 5 deletions

View File

@ -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...)