Move SDK prebuilts to new prebuilt_sdk module type
SDK prebuilts need to be treated differently than other prebuilts.
They are used like a normal Java prebuilts when compiling java files,
but they are also used as aapt includes when compiling apps, and they
provide prebuilt aidl files when compiling aidl sources. Create a
new module type so dependers can determine what kind of dependency
they are.
Change-Id: If426da63cfadcb4b14abda58c7b346554912a07a
diff --git a/java/java.go b/java/java.go
index a23ca9a..bbec5b5 100644
--- a/java/java.go
+++ b/java/java.go
@@ -121,7 +121,6 @@
ClassJarSpecs() []jarSpec
ResourceJarSpecs() []jarSpec
AidlIncludeDirs() []string
- AidlPreprocessed() string
}
func NewJavaBase(base *javaBase, module JavaModuleType, hod common.HostOrDeviceSupported,
@@ -209,13 +208,15 @@
} else {
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
}
- aidlIncludeDirs = append(aidlIncludeDirs, j.AidlIncludeDirs()...)
- if j.AidlPreprocessed() != "" {
- if aidlPreprocess != "" {
- ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
- aidlPreprocess, j.AidlPreprocessed())
- } else {
- aidlPreprocess = j.AidlPreprocessed()
+ aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
+ if sdkDep, ok := module.(sdkDependency); ok {
+ if sdkDep.AidlPreprocessed() != "" {
+ if aidlPreprocess != "" {
+ ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
+ aidlPreprocess, sdkDep.AidlPreprocessed())
+ } else {
+ aidlPreprocess = sdkDep.AidlPreprocessed()
+ }
}
}
} else {
@@ -358,10 +359,6 @@
return j.exportAidlIncludeDirs
}
-func (j *javaBase) AidlPreprocessed() string {
- return ""
-}
-
var _ logtagsProducer = (*javaBase)(nil)
func (j *javaBase) logtags() []string {
@@ -434,11 +431,9 @@
common.AndroidModuleBase
properties struct {
- Srcs []string
- Aidl_preprocessed string
+ Srcs []string
}
- aidlPreprocessed string
classpathFile string
classJarSpecs, resourceJarSpecs []jarSpec
}
@@ -455,9 +450,6 @@
j.classpathFile = prebuilt
j.classJarSpecs = []jarSpec{classJarSpec}
j.resourceJarSpecs = []jarSpec{resourceJarSpec}
- if j.properties.Aidl_preprocessed != "" {
- j.aidlPreprocessed = filepath.Join(common.ModuleSrcDir(ctx), j.properties.Aidl_preprocessed)
- }
ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.classpathFile)
}
@@ -479,10 +471,6 @@
return nil
}
-func (j *JavaPrebuilt) AidlPreprocessed() string {
- return j.aidlPreprocessed
-}
-
func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
module := &JavaPrebuilt{}
@@ -490,6 +478,46 @@
common.MultilibCommon, &module.properties)
}
+//
+// SDK java prebuilts (.jar containing resources plus framework.aidl)
+//
+
+type sdkDependency interface {
+ JavaDependency
+ AidlPreprocessed() string
+}
+
+var _ sdkDependency = (*sdkPrebuilt)(nil)
+
+type sdkPrebuilt struct {
+ JavaPrebuilt
+
+ sdkProperties struct {
+ Aidl_preprocessed string
+ }
+
+ aidlPreprocessed string
+}
+
+func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
+ j.JavaPrebuilt.GenerateAndroidBuildActions(ctx)
+
+ if j.sdkProperties.Aidl_preprocessed != "" {
+ j.aidlPreprocessed = filepath.Join(common.ModuleSrcDir(ctx), j.sdkProperties.Aidl_preprocessed)
+ }
+}
+
+func (j *sdkPrebuilt) AidlPreprocessed() string {
+ return j.aidlPreprocessed
+}
+
+func SdkPrebuiltFactory() (blueprint.Module, []interface{}) {
+ module := &sdkPrebuilt{}
+
+ return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
+ common.MultilibCommon, &module.properties, &module.sdkProperties)
+}
+
func inList(s string, l []string) bool {
for _, e := range l {
if e == s {