From ec7a0424c37289762107ce8ecd7e3be83d00eb34 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 7 Jul 2017 14:47:12 -0700 Subject: Use android.Prebuilt for JavaPrebuilts Test: java_test.go Change-Id: Iabb75edbfee731578b5b9f547594613203cf9b79 --- java/java.go | 79 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/java/java.go b/java/java.go index adb3d7bd..195a0783 100644 --- a/java/java.go +++ b/java/java.go @@ -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) + } + 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) } - 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() - } + } 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 -- cgit v1.2.3