aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/java.go36
1 files changed, 30 insertions, 6 deletions
diff --git a/java/java.go b/java/java.go
index 6ad53072..292e258f 100644
--- a/java/java.go
+++ b/java/java.go
@@ -97,6 +97,9 @@ type javaBase struct {
// output file suitable for inserting into the classpath of another compile
classpathFile string
+ // output file suitable for installing or running
+ outputFile string
+
// jarSpecs suitable for inserting classes from a static library into another jar
classJarSpecs []jarSpec
@@ -107,12 +110,17 @@ type javaBase struct {
logtagsSrcs []string
+ // filelists of extra source files that should be included in the javac command line,
+ // for example R.java generated by aapt for android apps
+ ExtraSrcLists []string
+
// installed file for binary dependency
installFile string
}
type JavaModuleType interface {
GenerateJavaBuildActions(ctx common.AndroidModuleContext)
+ JavaDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string
}
type JavaDependency interface {
@@ -157,6 +165,10 @@ func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string {
var defaultJavaLibraries = []string{"core-libart", "core-junit", "ext", "framework"}
func (j *javaBase) AndroidDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string {
+ return j.module.JavaDynamicDependencies(ctx)
+}
+
+func (j *javaBase) JavaDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string {
var deps []string
if !j.properties.No_standard_libraries {
@@ -203,16 +215,20 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []str
if javaDep, ok := module.(JavaDependency); ok {
if otherName == j.BootClasspath(ctx) {
bootClasspath = javaDep.ClasspathFile()
+ } else if inList(otherName, defaultJavaLibraries) {
+ 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 ctx.ModuleName() == "framework" && otherName == "framework-res" {
- // framework.jar has a one-off dependency on the R.java and Manifest.java files
- // generated by framework-res.apk
- srcFileLists = append(srcFileLists, module.(*javaBase).module.(*AndroidApp).rJarSpec.fileList)
+ } 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.(*javaBase).module.(*AndroidApp).aaptJavaFileList)
+ }
} else {
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
}
@@ -278,6 +294,8 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
srcFiles = j.genSources(ctx, srcFiles, flags)
+ srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
+
if len(srcFiles) > 0 {
// Compile java sources into .class files
classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps)
@@ -356,8 +374,8 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
// Combine classes.dex + resources into javalib.jar
outputFile = TransformDexToJavaLib(ctx, resourceJarSpecs, dexJarSpec)
}
-
- j.installFile = ctx.InstallFileName("framework", ctx.ModuleName()+".jar", outputFile)
+ ctx.CheckbuildFile(outputFile)
+ j.outputFile = outputFile
}
var _ JavaDependency = (*JavaLibrary)(nil)
@@ -392,6 +410,12 @@ type JavaLibrary struct {
javaBase
}
+func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
+ j.javaBase.GenerateJavaBuildActions(ctx)
+
+ j.installFile = ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.outputFile)
+}
+
func JavaLibraryFactory() (blueprint.Module, []interface{}) {
module := &JavaLibrary{}