Collect modules' info to create IDE project file.

- Register a singleton and implement GenerateBuildActions func in java/jdeps.go.
- Declare a interface and a struct to collect info in android/module.go.
- Implement IDEInfo for Library & Import module in java/jdeps.go.
- Implement IDEInfo for Genrule module in genrule/genrule.go.
- Implement IDEInfo for fileGroup module in android/filegroup.go.
- Test codes for jdeps.go in java/jdeps_test.go.

Bug: 111044346

Test: export SOONG_COLLECT_JAVA_DEPS=1;mmm packages/apps/Settings
      out/soong/module_bp_java_deps.json will be generated

Change-Id: If61da77b4d7614c2c5da438b6af4c725ceccc5c3
This commit is contained in:
Brandon Lee
2018-08-15 15:35:38 -07:00
committed by Colin Cross
parent cfbea98a57
commit 5d45c6f6f8
6 changed files with 278 additions and 0 deletions

View File

@@ -311,6 +311,10 @@ 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
expandIDEInfoCompiledSrcs []string
}
func (j *Module) Srcs() android.Paths {
@@ -1010,6 +1014,10 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
srcJars = append(srcJars, deps.srcJars...)
srcJars = append(srcJars, extraSrcJars...)
// Collect source files from compiledJavaSrcs, compiledSrcJars and filter out Exclude_srcs
// that IDEInfo struct will use
j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.Strings()...)
jarName := ctx.ModuleName() + ".jar"
javaSrcFiles := srcFiles.FilterByExt(".java")
@@ -1362,6 +1370,23 @@ func (j *Module) logtags() android.Paths {
return j.logtagsSrcs
}
// Collect information for opening IDE project files in java/jdeps.go.
func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, j.CompilerDeps()...)
dpInfo.Srcs = append(dpInfo.Srcs, j.expandIDEInfoCompiledSrcs...)
dpInfo.Aidl_include_dirs = append(dpInfo.Aidl_include_dirs, j.deviceProperties.Aidl.Include_dirs...)
if j.properties.Jarjar_rules != nil {
dpInfo.Jarjar_rules = append(dpInfo.Jarjar_rules, *j.properties.Jarjar_rules)
}
}
func (j *Module) CompilerDeps() []string {
jdeps := []string{}
jdeps = append(jdeps, j.properties.Libs...)
jdeps = append(jdeps, j.properties.Static_libs...)
return jdeps
}
//
// Java libraries (.jar file)
//
@@ -1691,6 +1716,26 @@ func (j *Import) ExportedSdkLibs() []string {
return j.exportedSdkLibs
}
// Collect information for opening IDE project files in java/jdeps.go.
const (
removedPrefix = "prebuilt_"
)
func (j *Import) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Jars = append(dpInfo.Jars, j.PrebuiltSrcs()...)
}
func (j *Import) IDECustomizedModuleName() string {
// TODO(b/113562217): Extract the base module name from the Import name, often the Import name
// has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better
// solution to get the Import name.
name := j.Name()
if strings.HasPrefix(name, removedPrefix) {
name = strings.Trim(name, removedPrefix)
}
return name
}
var _ android.PrebuiltInterface = (*Import)(nil)
func ImportFactory() android.Module {