summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go48
1 files changed, 33 insertions, 15 deletions
diff --git a/java/java.go b/java/java.go
index a1addb38c..a2e9ab023 100644
--- a/java/java.go
+++ b/java/java.go
@@ -82,10 +82,6 @@ type CompilerProperties struct {
// list of files that should be excluded from java_resources and java_resource_dirs
Exclude_java_resources []string `android:"path,arch_variant"`
- // don't build against the default libraries (bootclasspath, ext, and framework for device
- // targets)
- No_standard_libs *bool
-
// don't build against the framework libraries (ext, and framework for device targets)
No_framework_libs *bool
@@ -440,6 +436,16 @@ type sdkDep struct {
jars android.Paths
aidl android.OptionalPath
+
+ noStandardLibs, noFrameworksLibs bool
+}
+
+func (s sdkDep) hasStandardLibs() bool {
+ return !s.noStandardLibs
+}
+
+func (s sdkDep) hasFrameworkLibs() bool {
+ return !s.noStandardLibs && !s.noFrameworksLibs
}
type jniLib struct {
@@ -476,14 +482,18 @@ func (j *Module) targetSdkVersion() string {
return j.sdkVersion()
}
+func (j *Module) noFrameworkLibs() bool {
+ return Bool(j.properties.No_framework_libs)
+}
+
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
if ctx.Device() {
- if !Bool(j.properties.No_standard_libs) {
- sdkDep := decodeSdkDep(ctx, sdkContext(j))
+ sdkDep := decodeSdkDep(ctx, sdkContext(j))
+ if sdkDep.hasStandardLibs() {
if sdkDep.useDefaultLibs {
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
- if !Bool(j.properties.No_framework_libs) {
+ if sdkDep.hasFrameworkLibs() {
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
}
} else if sdkDep.useModule {
@@ -495,8 +505,8 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
}
}
} else if j.deviceProperties.System_modules == nil {
- ctx.PropertyErrorf("no_standard_libs",
- "system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?")
+ ctx.PropertyErrorf("sdk_version",
+ `system_modules is required to be set when sdk_version is "none", did you mean no_framework_libs?`)
} else if *j.deviceProperties.System_modules != "none" {
ctx.AddVariationDependencies(nil, systemModulesTag, *j.deviceProperties.System_modules)
}
@@ -618,6 +628,7 @@ type deps struct {
srcs android.Paths
srcJars android.Paths
systemModules android.Path
+ systemModulesDeps android.Paths
aidlPreprocess android.OptionalPath
kotlinStdlib android.Paths
kotlinAnnotations android.Paths
@@ -664,7 +675,7 @@ func getLinkType(m *Module, name string) (ret linkType, stubs bool) {
return javaSdk, true
case ver == "current":
return javaSdk, false
- case ver == "":
+ case ver == "" || ver == "none" || ver == "core_platform":
return javaPlatform, false
default:
if _, err := strconv.Atoi(ver); err != nil {
@@ -825,10 +836,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
panic("Found two system module dependencies")
}
sm := module.(*SystemModules)
- if sm.outputFile == nil {
+ if sm.outputDir == nil || len(sm.outputDeps) == 0 {
panic("Missing directory for system module dependency")
}
- deps.systemModules = sm.outputFile
+ deps.systemModules = sm.outputDir
+ deps.systemModulesDeps = sm.outputDeps
}
}
})
@@ -842,7 +854,8 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
var ret string
v := sdkContext.sdkVersion()
// For PDK builds, use the latest SDK version instead of "current"
- if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
+ if ctx.Config().IsPdkBuild() &&
+ (v == "" || v == "none" || v == "core_platform" || v == "current") {
sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
latestSdkVersion := 0
if len(sdkVersions) > 0 {
@@ -861,7 +874,11 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
ret = "1.7"
} else if ctx.Device() && sdk <= 29 || !ctx.Config().TargetOpenJDK9() {
ret = "1.8"
- } else if ctx.Device() && sdkContext.sdkVersion() != "" && sdk == android.FutureApiLevel {
+ } else if ctx.Device() &&
+ sdkContext.sdkVersion() != "" &&
+ sdkContext.sdkVersion() != "none" &&
+ sdkContext.sdkVersion() != "core_platform" &&
+ sdk == android.FutureApiLevel {
// TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current"
ret = "1.8"
} else {
@@ -913,7 +930,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
flags.processor = strings.Join(deps.processorClasses, ",")
if len(flags.bootClasspath) == 0 && ctx.Host() && flags.javaVersion != "1.9" &&
- !Bool(j.properties.No_standard_libs) &&
+ decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() &&
inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) {
// Give host-side tools a version of OpenJDK's standard libraries
// close to what they're targeting. As of Dec 2017, AOSP is only
@@ -953,6 +970,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
// systemModules
if deps.systemModules != nil {
flags.systemModules = append(flags.systemModules, deps.systemModules)
+ flags.systemModulesDeps = append(flags.systemModulesDeps, deps.systemModulesDeps...)
}
// aidl flags.