Use dependency tags for java modules
Test: java_test.go Change-Id: Id265a2acd6e6c4ce7764f77c888e22b1fddc02c4
This commit is contained in:
@@ -68,17 +68,14 @@ type AndroidApp struct {
|
|||||||
func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
a.Module.deps(ctx)
|
a.Module.deps(ctx)
|
||||||
|
|
||||||
var deps []string
|
|
||||||
if !a.properties.No_standard_libraries {
|
if !a.properties.No_standard_libraries {
|
||||||
switch a.deviceProperties.Sdk_version { // TODO: Res_sdk_version?
|
switch a.deviceProperties.Sdk_version { // TODO: Res_sdk_version?
|
||||||
case "current", "system_current", "":
|
case "current", "system_current", "":
|
||||||
deps = append(deps, "framework-res")
|
ctx.AddDependency(ctx.Module(), frameworkResTag, "framework-res")
|
||||||
default:
|
default:
|
||||||
// We'll already have a dependency on an sdk prebuilt android.jar
|
// We'll already have a dependency on an sdk prebuilt android.jar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.AddDependency(ctx.Module(), nil, deps...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
103
java/java.go
103
java/java.go
@@ -147,45 +147,46 @@ type JavaDependency interface {
|
|||||||
AidlIncludeDirs() android.Paths
|
AidlIncludeDirs() android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) BootClasspath(ctx android.BaseContext) string {
|
type dependencyTag struct {
|
||||||
if ctx.Device() {
|
blueprint.BaseDependencyTag
|
||||||
switch j.deviceProperties.Sdk_version {
|
name string
|
||||||
case "":
|
|
||||||
return "core-libart"
|
|
||||||
case "current":
|
|
||||||
// TODO: !TARGET_BUILD_APPS
|
|
||||||
// TODO: export preprocessed framework.aidl from android_stubs_current
|
|
||||||
return "android_stubs_current"
|
|
||||||
case "system_current":
|
|
||||||
return "android_system_stubs_current"
|
|
||||||
default:
|
|
||||||
return "sdk_v" + j.deviceProperties.Sdk_version
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if j.deviceProperties.Dex {
|
|
||||||
return "core-libart"
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
var (
|
||||||
var deps []string
|
javaStaticLibTag = dependencyTag{name: "staticlib"}
|
||||||
|
javaLibTag = dependencyTag{name: "javalib"}
|
||||||
|
bootClasspathTag = dependencyTag{name: "bootclasspath"}
|
||||||
|
frameworkResTag = dependencyTag{name: "framework-res"}
|
||||||
|
sdkDependencyTag = dependencyTag{name: "sdk"}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||||
if !j.properties.No_standard_libraries {
|
if !j.properties.No_standard_libraries {
|
||||||
bootClasspath := j.BootClasspath(ctx)
|
if ctx.Device() {
|
||||||
if bootClasspath != "" {
|
switch j.deviceProperties.Sdk_version {
|
||||||
deps = append(deps, bootClasspath)
|
case "":
|
||||||
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, "core-libart")
|
||||||
|
case "current":
|
||||||
|
// TODO: !TARGET_BUILD_APPS
|
||||||
|
// TODO: export preprocessed framework.aidl from android_stubs_current
|
||||||
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, "android_stubs_current")
|
||||||
|
case "system_current":
|
||||||
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, "android_system_stubs_current")
|
||||||
|
default:
|
||||||
|
ctx.AddDependency(ctx.Module(), sdkDependencyTag, "sdk_v"+j.deviceProperties.Sdk_version)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if j.deviceProperties.Dex {
|
||||||
|
ctx.AddDependency(ctx.Module(), bootClasspathTag, "core-libart")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Device() && j.deviceProperties.Sdk_version == "" {
|
if ctx.Device() && j.deviceProperties.Sdk_version == "" {
|
||||||
deps = append(deps, config.DefaultLibraries...)
|
ctx.AddDependency(ctx.Module(), javaLibTag, config.DefaultLibraries...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deps = append(deps, j.properties.Java_libs...)
|
ctx.AddDependency(ctx.Module(), javaLibTag, j.properties.Java_libs...)
|
||||||
deps = append(deps, j.properties.Java_static_libs...)
|
ctx.AddDependency(ctx.Module(), javaStaticLibTag, j.properties.Java_static_libs...)
|
||||||
|
|
||||||
ctx.AddDependency(ctx.Module(), nil, deps...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
||||||
@@ -228,27 +229,23 @@ func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if otherName == j.BootClasspath(ctx) {
|
switch tag {
|
||||||
|
case bootClasspathTag:
|
||||||
bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile())
|
bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile())
|
||||||
} else if inList(otherName, config.DefaultLibraries) {
|
case javaLibTag:
|
||||||
classpath = append(classpath, javaDep.ClasspathFile())
|
classpath = append(classpath, javaDep.ClasspathFile())
|
||||||
} else if inList(otherName, j.properties.Java_libs) {
|
case javaStaticLibTag:
|
||||||
classpath = append(classpath, javaDep.ClasspathFile())
|
|
||||||
} else if inList(otherName, j.properties.Java_static_libs) {
|
|
||||||
classpath = append(classpath, javaDep.ClasspathFile())
|
classpath = append(classpath, javaDep.ClasspathFile())
|
||||||
classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...)
|
classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...)
|
||||||
resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...)
|
resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...)
|
||||||
} else if otherName == "framework-res" {
|
case frameworkResTag:
|
||||||
if ctx.ModuleName() == "framework" {
|
if ctx.ModuleName() == "framework" {
|
||||||
// framework.jar has a one-off dependency on the R.java and Manifest.java files
|
// framework.jar has a one-off dependency on the R.java and Manifest.java files
|
||||||
// generated by framework-res.apk
|
// generated by framework-res.apk
|
||||||
srcFileLists = append(srcFileLists, module.(*AndroidApp).aaptJavaFileList)
|
srcFileLists = append(srcFileLists, module.(*AndroidApp).aaptJavaFileList)
|
||||||
}
|
}
|
||||||
} else {
|
case sdkDependencyTag:
|
||||||
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
sdkDep := module.(sdkDependency)
|
||||||
}
|
|
||||||
aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
|
|
||||||
if sdkDep, ok := module.(sdkDependency); ok {
|
|
||||||
if sdkDep.AidlPreprocessed().Valid() {
|
if sdkDep.AidlPreprocessed().Valid() {
|
||||||
if aidlPreprocess.Valid() {
|
if aidlPreprocess.Valid() {
|
||||||
ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
|
ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
|
||||||
@@ -257,7 +254,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths
|
|||||||
aidlPreprocess = sdkDep.AidlPreprocessed()
|
aidlPreprocess = sdkDep.AidlPreprocessed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
|
||||||
})
|
})
|
||||||
|
|
||||||
return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
|
return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
|
||||||
@@ -510,16 +511,10 @@ func JavaBinaryHostFactory() android.Module {
|
|||||||
// Java prebuilts
|
// Java prebuilts
|
||||||
//
|
//
|
||||||
|
|
||||||
type JavaPrebuiltProperties struct {
|
|
||||||
Srcs []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type JavaPrebuilt struct {
|
type JavaPrebuilt struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
prebuilt android.Prebuilt
|
prebuilt android.Prebuilt
|
||||||
|
|
||||||
properties JavaPrebuiltProperties
|
|
||||||
|
|
||||||
classpathFile android.Path
|
classpathFile android.Path
|
||||||
classJarSpecs, resourceJarSpecs []jarSpec
|
classJarSpecs, resourceJarSpecs []jarSpec
|
||||||
}
|
}
|
||||||
@@ -532,11 +527,7 @@ func (j *JavaPrebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
if len(j.properties.Srcs) != 1 {
|
prebuilt := j.prebuilt.Path(ctx)
|
||||||
ctx.ModuleErrorf("expected exactly one jar in srcs")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
prebuilt := android.PathForModuleSrc(ctx, j.properties.Srcs[0])
|
|
||||||
|
|
||||||
classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
|
classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
|
||||||
|
|
||||||
@@ -567,9 +558,7 @@ func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths {
|
|||||||
func JavaPrebuiltFactory() android.Module {
|
func JavaPrebuiltFactory() android.Module {
|
||||||
module := &JavaPrebuilt{}
|
module := &JavaPrebuilt{}
|
||||||
|
|
||||||
module.AddProperties(
|
module.AddProperties(&module.prebuilt.Properties)
|
||||||
&module.properties,
|
|
||||||
&module.prebuilt.Properties)
|
|
||||||
|
|
||||||
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
||||||
return module
|
return module
|
||||||
@@ -612,7 +601,7 @@ func SdkPrebuiltFactory() android.Module {
|
|||||||
module := &sdkPrebuilt{}
|
module := &sdkPrebuilt{}
|
||||||
|
|
||||||
module.AddProperties(
|
module.AddProperties(
|
||||||
&module.properties,
|
&module.prebuilt.Properties,
|
||||||
&module.sdkProperties)
|
&module.sdkProperties)
|
||||||
|
|
||||||
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
||||||
|
Reference in New Issue
Block a user