summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorBrandon Lee <bralee@google.com>2018-08-15 15:35:38 -0700
committerColin Cross <ccross@android.com>2018-09-18 17:44:10 +0000
commit5d45c6f6f83b6a9b360c392b9fdfdeb2b935de7d (patch)
tree5d184abb38bc6ecc7b69510ea07b79a4d2c93917 /java/java.go
parentcfbea98a57a8d8fd314a3e2ebc08eb53eab328ef (diff)
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
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go
index 4bf5880bc..ae7a6e02c 100644
--- a/java/java.go
+++ b/java/java.go
@@ -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 {