diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 83205ba41..d17fbed5a 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -67,6 +67,7 @@ func main() { ctx.RegisterModuleType("java_binary", java.JavaBinaryFactory) ctx.RegisterModuleType("java_binary_host", java.JavaBinaryHostFactory) ctx.RegisterModuleType("prebuilt_java_library", java.JavaPrebuiltFactory) + ctx.RegisterModuleType("prebuilt_sdk", java.SdkPrebuiltFactory) // Mutators ctx.RegisterEarlyMutator("arch", common.ArchMutator) diff --git a/java/java.go b/java/java.go index a23ca9a64..bbec5b56e 100644 --- a/java/java.go +++ b/java/java.go @@ -121,7 +121,6 @@ type JavaDependency interface { ClassJarSpecs() []jarSpec ResourceJarSpecs() []jarSpec AidlIncludeDirs() []string - AidlPreprocessed() string } func NewJavaBase(base *javaBase, module JavaModuleType, hod common.HostOrDeviceSupported, @@ -209,13 +208,15 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []str } 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 @@ func (j *javaBase) AidlIncludeDirs() []string { return j.exportAidlIncludeDirs } -func (j *javaBase) AidlPreprocessed() string { - return "" -} - var _ logtagsProducer = (*javaBase)(nil) func (j *javaBase) logtags() []string { @@ -434,11 +431,9 @@ type JavaPrebuilt struct { common.AndroidModuleBase properties struct { - Srcs []string - Aidl_preprocessed string + Srcs []string } - aidlPreprocessed string classpathFile string classJarSpecs, resourceJarSpecs []jarSpec } @@ -455,9 +450,6 @@ func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleConte 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 @@ func (j *JavaPrebuilt) AidlIncludeDirs() []string { return nil } -func (j *JavaPrebuilt) AidlPreprocessed() string { - return j.aidlPreprocessed -} - func JavaPrebuiltFactory() (blueprint.Module, []interface{}) { module := &JavaPrebuilt{} @@ -490,6 +478,46 @@ func JavaPrebuiltFactory() (blueprint.Module, []interface{}) { 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 {