java: add one-off build logic for frameworks/base
framework.jar needs to compile against R.java and Manifest.java from framework-res.apk. Rather than complicating the Blueprints properties with values that will only be used once, add one-off logic to collectDeps to extract the rJarSpec out of the framework-res module. Change-Id: I1195b1b5e07badc583703479382ceba35300b8fd
This commit is contained in:
parent
276284f577
commit
e7a9f3f7ed
2 changed files with 15 additions and 7 deletions
|
@ -111,19 +111,23 @@ func (j jarSpec) soongJarArgs() string {
|
|||
return "-C " + j.dir + " -l " + j.fileList
|
||||
}
|
||||
|
||||
func TransformJavaToClasses(ctx common.AndroidModuleContext, srcFiles []string,
|
||||
func TransformJavaToClasses(ctx common.AndroidModuleContext, srcFiles []string, srcFileLists []string,
|
||||
flags javaBuilderFlags, deps []string) jarSpec {
|
||||
|
||||
classDir := filepath.Join(common.ModuleOutDir(ctx), "classes")
|
||||
classFileList := filepath.Join(common.ModuleOutDir(ctx), "classes.list")
|
||||
|
||||
javacFlags := flags.javacFlags + common.JoinWithPrefix(srcFileLists, "@")
|
||||
|
||||
deps = append(deps, srcFileLists...)
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: javac,
|
||||
Outputs: []string{classFileList},
|
||||
Inputs: srcFiles,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"javacFlags": flags.javacFlags,
|
||||
"javacFlags": javacFlags,
|
||||
"bootClasspath": flags.bootClasspath,
|
||||
"classpath": flags.classpath,
|
||||
"outDir": classDir,
|
||||
|
|
14
java/java.go
14
java/java.go
|
@ -31,7 +31,6 @@ import (
|
|||
|
||||
// TODO:
|
||||
// Autogenerated files:
|
||||
// AIDL
|
||||
// Proto
|
||||
// Renderscript
|
||||
// Post-jar passes:
|
||||
|
@ -192,7 +191,7 @@ func (j *javaBase) aidlFlags(ctx common.AndroidModuleContext, aidlPreprocess str
|
|||
|
||||
func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []string,
|
||||
bootClasspath string, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess string,
|
||||
aidlIncludeDirs []string) {
|
||||
aidlIncludeDirs []string, srcFileLists []string) {
|
||||
|
||||
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
||||
otherName := ctx.OtherModuleName(module)
|
||||
|
@ -205,6 +204,10 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []str
|
|||
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 {
|
||||
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
||||
}
|
||||
|
@ -224,7 +227,8 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []str
|
|||
}
|
||||
})
|
||||
|
||||
return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, aidlIncludeDirs
|
||||
return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
|
||||
aidlIncludeDirs, srcFileLists
|
||||
}
|
||||
|
||||
func (j *javaBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
|
||||
|
@ -237,7 +241,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
|||
common.ModuleSrcDir(ctx))
|
||||
|
||||
classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
|
||||
aidlIncludeDirs := j.collectDeps(ctx)
|
||||
aidlIncludeDirs, srcFileLists := j.collectDeps(ctx)
|
||||
|
||||
var flags javaBuilderFlags
|
||||
|
||||
|
@ -271,7 +275,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
|
|||
|
||||
if len(srcFiles) > 0 {
|
||||
// Compile java sources into .class files
|
||||
classes := TransformJavaToClasses(ctx, srcFiles, flags, javacDeps)
|
||||
classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps)
|
||||
if ctx.Failed() {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue