Use android.Prebuilt for JavaPrebuilts

Test: java_test.go
Change-Id: Iabb75edbfee731578b5b9f547594613203cf9b79
This commit is contained in:
Colin Cross
2017-07-07 14:47:12 -07:00
parent 72bb363608
commit ec7a0424c3

View File

@@ -216,35 +216,45 @@ func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths
ctx.VisitDirectDeps(func(module blueprint.Module) {
otherName := ctx.OtherModuleName(module)
if javaDep, ok := module.(JavaDependency); ok {
if otherName == j.BootClasspath(ctx) {
bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile())
} else if inList(otherName, config.DefaultLibraries) {
classpath = append(classpath, javaDep.ClasspathFile())
} else if inList(otherName, j.properties.Java_libs) {
classpath = append(classpath, javaDep.ClasspathFile())
} else if inList(otherName, j.properties.Java_static_libs) {
classpath = append(classpath, javaDep.ClasspathFile())
classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...)
resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...)
} else if otherName == "framework-res" {
if ctx.ModuleName() == "framework" {
// framework.jar has a one-off dependency on the R.java and Manifest.java files
// generated by framework-res.apk
srcFileLists = append(srcFileLists, module.(*AndroidApp).aaptJavaFileList)
}
} else {
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
tag := ctx.OtherModuleDependencyTag(module)
javaDep, _ := module.(JavaDependency)
if javaDep == nil {
switch tag {
case android.DefaultsDepTag, android.SourceDepTag:
default:
ctx.ModuleErrorf("depends on non-java module %q", otherName)
}
aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
if sdkDep, ok := module.(sdkDependency); ok {
if sdkDep.AidlPreprocessed().Valid() {
if aidlPreprocess.Valid() {
ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
aidlPreprocess, sdkDep.AidlPreprocessed())
} else {
aidlPreprocess = sdkDep.AidlPreprocessed()
}
return
}
if otherName == j.BootClasspath(ctx) {
bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile())
} else if inList(otherName, config.DefaultLibraries) {
classpath = append(classpath, javaDep.ClasspathFile())
} else if inList(otherName, j.properties.Java_libs) {
classpath = append(classpath, javaDep.ClasspathFile())
} else if inList(otherName, j.properties.Java_static_libs) {
classpath = append(classpath, javaDep.ClasspathFile())
classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...)
resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...)
} else if otherName == "framework-res" {
if ctx.ModuleName() == "framework" {
// framework.jar has a one-off dependency on the R.java and Manifest.java files
// generated by framework-res.apk
srcFileLists = append(srcFileLists, module.(*AndroidApp).aaptJavaFileList)
}
} else {
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
}
aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
if sdkDep, ok := module.(sdkDependency); ok {
if sdkDep.AidlPreprocessed().Valid() {
if aidlPreprocess.Valid() {
ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
aidlPreprocess, sdkDep.AidlPreprocessed())
} else {
aidlPreprocess = sdkDep.AidlPreprocessed()
}
}
}
@@ -500,19 +510,24 @@ func JavaBinaryHostFactory() android.Module {
// Java prebuilts
//
type javaPrebuiltProperties struct {
type JavaPrebuiltProperties struct {
Srcs []string
}
type JavaPrebuilt struct {
android.ModuleBase
prebuilt android.Prebuilt
properties javaPrebuiltProperties
properties JavaPrebuiltProperties
classpathFile android.Path
classJarSpecs, resourceJarSpecs []jarSpec
}
func (j *JavaPrebuilt) Prebuilt() *android.Prebuilt {
return &j.prebuilt
}
func (j *JavaPrebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
}
@@ -552,7 +567,9 @@ func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths {
func JavaPrebuiltFactory() android.Module {
module := &JavaPrebuilt{}
module.AddProperties(&module.properties)
module.AddProperties(
&module.properties,
&module.prebuilt.Properties)
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
return module