aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-04-16 14:09:14 -0700
committerColin Cross <ccross@android.com>2015-04-20 13:55:27 -0700
commitb7a63247ed0cd69266da52561edc0f620f6379cd (patch)
tree9df182c851753504b137307c41f6f5a0bf287af1 /java
parentefb9ebe14fdb29c9f1cdb35297d9250976720dcf (diff)
downloadbuild_soong-b7a63247ed0cd69266da52561edc0f620f6379cd.tar.gz
build_soong-b7a63247ed0cd69266da52561edc0f620f6379cd.tar.bz2
build_soong-b7a63247ed0cd69266da52561edc0f620f6379cd.zip
java: modify base java rules for android app builds
Store the jar output file for the app build to use. Allow module types built on top of javaBase to provide filelist files containing source files. Allow module types built on top of javaBase to insert dependencies through JavaDynamicDependencies. Allow any java module to depend on framework-res.apk. Move the install rule from javaBase to JavaLibrary. Change-Id: I46e7e80139845ef7cc89daf180bddbdf77125555
Diffstat (limited to 'java')
-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{}