Merge changes Icfd32d0a,Icc9ff4d4,Ieee07502,I559eeb1f,Iaf2a6f6d, ...
* changes: Use java language 1.9 for sdk_version: "current" Remove special case for sdk_version: "none" Use system modules for turbine Make javaVersion an enum Move TestConfig sdk versions forward Split java 8 and 9 classpaths in TestClasspath
This commit is contained in:
commit
ec90e44ce7
|
@ -212,9 +212,9 @@ func TestConfig(buildDir string, env map[string]string) Config {
|
||||||
config := &config{
|
config := &config{
|
||||||
productVariables: productVariables{
|
productVariables: productVariables{
|
||||||
DeviceName: stringPtr("test_device"),
|
DeviceName: stringPtr("test_device"),
|
||||||
Platform_sdk_version: intPtr(26),
|
Platform_sdk_version: intPtr(30),
|
||||||
DeviceSystemSdkVersions: []string{"14", "15"},
|
DeviceSystemSdkVersions: []string{"14", "15"},
|
||||||
Platform_systemsdk_versions: []string{"25", "26"},
|
Platform_systemsdk_versions: []string{"29", "30"},
|
||||||
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
||||||
AAPTPreferredConfig: stringPtr("xhdpi"),
|
AAPTPreferredConfig: stringPtr("xhdpi"),
|
||||||
AAPTCharacteristics: stringPtr("nosdcard"),
|
AAPTCharacteristics: stringPtr("nosdcard"),
|
||||||
|
|
|
@ -538,6 +538,10 @@ func (a *AARImport) targetSdkVersion() string {
|
||||||
return a.sdkVersion()
|
return a.sdkVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AARImport) javaVersion() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
var _ AndroidLibraryDependency = (*AARImport)(nil)
|
var _ AndroidLibraryDependency = (*AARImport)(nil)
|
||||||
|
|
||||||
func (a *AARImport) ExportPackage() android.Path {
|
func (a *AARImport) ExportPackage() android.Path {
|
||||||
|
|
|
@ -182,15 +182,16 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
type javaBuilderFlags struct {
|
type javaBuilderFlags struct {
|
||||||
javacFlags string
|
javacFlags string
|
||||||
bootClasspath classpath
|
bootClasspath classpath
|
||||||
classpath classpath
|
classpath classpath
|
||||||
processorPath classpath
|
java9Classpath classpath
|
||||||
processor string
|
processorPath classpath
|
||||||
systemModules *systemModules
|
processor string
|
||||||
aidlFlags string
|
systemModules *systemModules
|
||||||
aidlDeps android.Paths
|
aidlFlags string
|
||||||
javaVersion string
|
aidlDeps android.Paths
|
||||||
|
javaVersion javaVersion
|
||||||
|
|
||||||
errorProneExtraJavacFlags string
|
errorProneExtraJavacFlags string
|
||||||
errorProneProcessorPath classpath
|
errorProneProcessorPath classpath
|
||||||
|
@ -239,7 +240,7 @@ func emitXrefRule(ctx android.ModuleContext, xrefFile android.WritablePath, idx
|
||||||
deps = append(deps, srcJars...)
|
deps = append(deps, srcJars...)
|
||||||
|
|
||||||
var bootClasspath string
|
var bootClasspath string
|
||||||
if flags.javaVersion == "1.9" {
|
if flags.javaVersion.usesJavaModules() {
|
||||||
var systemModuleDeps android.Paths
|
var systemModuleDeps android.Paths
|
||||||
bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device())
|
bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device())
|
||||||
deps = append(deps, systemModuleDeps...)
|
deps = append(deps, systemModuleDeps...)
|
||||||
|
@ -279,7 +280,7 @@ func emitXrefRule(ctx android.ModuleContext, xrefFile android.WritablePath, idx
|
||||||
"bootClasspath": bootClasspath,
|
"bootClasspath": bootClasspath,
|
||||||
"classpath": flags.classpath.FormJavaClassPath("-classpath"),
|
"classpath": flags.classpath.FormJavaClassPath("-classpath"),
|
||||||
"javacFlags": flags.javacFlags,
|
"javacFlags": flags.javacFlags,
|
||||||
"javaVersion": flags.javaVersion,
|
"javaVersion": flags.javaVersion.String(),
|
||||||
"outDir": android.PathForModuleOut(ctx, "javac", "classes.xref").String(),
|
"outDir": android.PathForModuleOut(ctx, "javac", "classes.xref").String(),
|
||||||
"processorpath": flags.processorPath.FormJavaClassPath("-processorpath"),
|
"processorpath": flags.processorPath.FormJavaClassPath("-processorpath"),
|
||||||
"processor": processor,
|
"processor": processor,
|
||||||
|
@ -294,18 +295,29 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
|
||||||
|
|
||||||
var deps android.Paths
|
var deps android.Paths
|
||||||
deps = append(deps, srcJars...)
|
deps = append(deps, srcJars...)
|
||||||
deps = append(deps, flags.bootClasspath...)
|
|
||||||
deps = append(deps, flags.classpath...)
|
classpath := flags.classpath
|
||||||
|
|
||||||
var bootClasspath string
|
var bootClasspath string
|
||||||
if len(flags.bootClasspath) == 0 && ctx.Device() {
|
if flags.javaVersion.usesJavaModules() {
|
||||||
// explicitly specify -bootclasspath "" if the bootclasspath is empty to
|
var systemModuleDeps android.Paths
|
||||||
// ensure java does not fall back to the default bootclasspath.
|
bootClasspath, systemModuleDeps = flags.systemModules.FormTurbineSystemModulesPath(ctx.Device())
|
||||||
bootClasspath = `--bootclasspath ""`
|
deps = append(deps, systemModuleDeps...)
|
||||||
|
classpath = append(flags.java9Classpath, classpath...)
|
||||||
} else {
|
} else {
|
||||||
bootClasspath = strings.Join(flags.bootClasspath.FormTurbineClasspath("--bootclasspath "), " ")
|
deps = append(deps, flags.bootClasspath...)
|
||||||
|
if len(flags.bootClasspath) == 0 && ctx.Device() {
|
||||||
|
// explicitly specify -bootclasspath "" if the bootclasspath is empty to
|
||||||
|
// ensure turbine does not fall back to the default bootclasspath.
|
||||||
|
bootClasspath = `--bootclasspath ""`
|
||||||
|
} else {
|
||||||
|
bootClasspath = strings.Join(flags.bootClasspath.FormTurbineClasspath("--bootclasspath "), " ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deps = append(deps, classpath...)
|
||||||
|
deps = append(deps, flags.processorPath...)
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: turbine,
|
Rule: turbine,
|
||||||
Description: "turbine",
|
Description: "turbine",
|
||||||
|
@ -316,9 +328,9 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
|
||||||
"javacFlags": flags.javacFlags,
|
"javacFlags": flags.javacFlags,
|
||||||
"bootClasspath": bootClasspath,
|
"bootClasspath": bootClasspath,
|
||||||
"srcJars": strings.Join(srcJars.Strings(), " "),
|
"srcJars": strings.Join(srcJars.Strings(), " "),
|
||||||
"classpath": strings.Join(flags.classpath.FormTurbineClasspath("--classpath "), " "),
|
"classpath": strings.Join(classpath.FormTurbineClasspath("--classpath "), " "),
|
||||||
"outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(),
|
"outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(),
|
||||||
"javaVersion": flags.javaVersion,
|
"javaVersion": flags.javaVersion.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -339,11 +351,14 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
|
||||||
|
|
||||||
deps = append(deps, srcJars...)
|
deps = append(deps, srcJars...)
|
||||||
|
|
||||||
|
classpath := flags.classpath
|
||||||
|
|
||||||
var bootClasspath string
|
var bootClasspath string
|
||||||
if flags.javaVersion == "1.9" {
|
if flags.javaVersion.usesJavaModules() {
|
||||||
var systemModuleDeps android.Paths
|
var systemModuleDeps android.Paths
|
||||||
bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device())
|
bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device())
|
||||||
deps = append(deps, systemModuleDeps...)
|
deps = append(deps, systemModuleDeps...)
|
||||||
|
classpath = append(flags.java9Classpath, classpath...)
|
||||||
} else {
|
} else {
|
||||||
deps = append(deps, flags.bootClasspath...)
|
deps = append(deps, flags.bootClasspath...)
|
||||||
if len(flags.bootClasspath) == 0 && ctx.Device() {
|
if len(flags.bootClasspath) == 0 && ctx.Device() {
|
||||||
|
@ -355,7 +370,7 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deps = append(deps, flags.classpath...)
|
deps = append(deps, classpath...)
|
||||||
deps = append(deps, flags.processorPath...)
|
deps = append(deps, flags.processorPath...)
|
||||||
|
|
||||||
processor := "-proc:none"
|
processor := "-proc:none"
|
||||||
|
@ -381,14 +396,14 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"javacFlags": flags.javacFlags,
|
"javacFlags": flags.javacFlags,
|
||||||
"bootClasspath": bootClasspath,
|
"bootClasspath": bootClasspath,
|
||||||
"classpath": flags.classpath.FormJavaClassPath("-classpath"),
|
"classpath": classpath.FormJavaClassPath("-classpath"),
|
||||||
"processorpath": flags.processorPath.FormJavaClassPath("-processorpath"),
|
"processorpath": flags.processorPath.FormJavaClassPath("-processorpath"),
|
||||||
"processor": processor,
|
"processor": processor,
|
||||||
"srcJars": strings.Join(srcJars.Strings(), " "),
|
"srcJars": strings.Join(srcJars.Strings(), " "),
|
||||||
"srcJarDir": android.PathForModuleOut(ctx, intermediatesDir, srcJarDir).String(),
|
"srcJarDir": android.PathForModuleOut(ctx, intermediatesDir, srcJarDir).String(),
|
||||||
"outDir": android.PathForModuleOut(ctx, intermediatesDir, outDir).String(),
|
"outDir": android.PathForModuleOut(ctx, intermediatesDir, outDir).String(),
|
||||||
"annoDir": android.PathForModuleOut(ctx, intermediatesDir, annoDir).String(),
|
"annoDir": android.PathForModuleOut(ctx, intermediatesDir, annoDir).String(),
|
||||||
"javaVersion": flags.javaVersion,
|
"javaVersion": flags.javaVersion.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -550,9 +565,9 @@ type systemModules struct {
|
||||||
deps android.Paths
|
deps android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a --system argument in the form javac expects with -source 1.9. If forceEmpty is true,
|
// Returns a --system argument in the form javac expects with -source 1.9 and the list of files to
|
||||||
// returns --system=none if the list is empty to ensure javac does not fall back to the default
|
// depend on. If forceEmpty is true, returns --system=none if the list is empty to ensure javac
|
||||||
// system modules.
|
// does not fall back to the default system modules.
|
||||||
func (x *systemModules) FormJavaSystemModulesPath(forceEmpty bool) (string, android.Paths) {
|
func (x *systemModules) FormJavaSystemModulesPath(forceEmpty bool) (string, android.Paths) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return "--system=" + x.dir.String(), x.deps
|
return "--system=" + x.dir.String(), x.deps
|
||||||
|
@ -562,3 +577,16 @@ func (x *systemModules) FormJavaSystemModulesPath(forceEmpty bool) (string, andr
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a --system argument in the form turbine expects with -source 1.9 and the list of files to
|
||||||
|
// depend on. If forceEmpty is true, returns --bootclasspath "" if the list is empty to ensure turbine
|
||||||
|
// does not fall back to the default bootclasspath.
|
||||||
|
func (x *systemModules) FormTurbineSystemModulesPath(forceEmpty bool) (string, android.Paths) {
|
||||||
|
if x != nil {
|
||||||
|
return "--system " + x.dir.String(), x.deps
|
||||||
|
} else if forceEmpty {
|
||||||
|
return `--bootclasspath ""`, nil
|
||||||
|
} else {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -422,21 +422,16 @@ func (j *Javadoc) targetSdkVersion() string {
|
||||||
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
if sdkDep.hasStandardLibs() {
|
if sdkDep.useDefaultLibs {
|
||||||
if sdkDep.useDefaultLibs {
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
if sdkDep.hasFrameworkLibs() {
|
||||||
if sdkDep.hasFrameworkLibs() {
|
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
||||||
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
|
||||||
}
|
|
||||||
} else if sdkDep.useModule {
|
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
|
|
||||||
}
|
}
|
||||||
} else if sdkDep.systemModules != "" {
|
} else if sdkDep.useModule {
|
||||||
// Add the system modules to both the system modules and bootclasspath.
|
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.systemModules)
|
ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +506,8 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
||||||
|
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
if sdkDep.invalidVersion {
|
if sdkDep.invalidVersion {
|
||||||
ctx.AddMissingDependencies(sdkDep.modules)
|
ctx.AddMissingDependencies(sdkDep.bootclasspath)
|
||||||
|
ctx.AddMissingDependencies(sdkDep.java9Classpath)
|
||||||
} else if sdkDep.useFiles {
|
} else if sdkDep.useFiles {
|
||||||
deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...)
|
deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...)
|
||||||
}
|
}
|
||||||
|
@ -544,6 +540,13 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
||||||
default:
|
default:
|
||||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||||
}
|
}
|
||||||
|
case java9LibTag:
|
||||||
|
switch dep := module.(type) {
|
||||||
|
case Dependency:
|
||||||
|
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...)
|
||||||
|
default:
|
||||||
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||||
|
}
|
||||||
case systemModulesTag:
|
case systemModulesTag:
|
||||||
if deps.systemModules != nil {
|
if deps.systemModules != nil {
|
||||||
panic("Found two system module dependencies")
|
panic("Found two system module dependencies")
|
||||||
|
@ -665,7 +668,7 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
cmd := javadocSystemModulesCmd(ctx, rule, j.srcFiles, outDir, srcJarDir, srcJarList,
|
cmd := javadocSystemModulesCmd(ctx, rule, j.srcFiles, outDir, srcJarDir, srcJarList,
|
||||||
deps.systemModules, deps.classpath, j.sourcepaths)
|
deps.systemModules, deps.classpath, j.sourcepaths)
|
||||||
|
|
||||||
cmd.FlagWithArg("-source ", javaVersion).
|
cmd.FlagWithArg("-source ", javaVersion.String()).
|
||||||
Flag("-J-Xmx1024m").
|
Flag("-J-Xmx1024m").
|
||||||
Flag("-XDignore.symbol.file").
|
Flag("-XDignore.symbol.file").
|
||||||
Flag("-Xdoclint:none")
|
Flag("-Xdoclint:none")
|
||||||
|
@ -1432,12 +1435,12 @@ func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion string, srcs android.Paths,
|
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
|
||||||
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
||||||
cmd := rule.Command().BuiltTool(ctx, "metalava").
|
cmd := rule.Command().BuiltTool(ctx, "metalava").
|
||||||
Flag(config.JavacVmFlags).
|
Flag(config.JavacVmFlags).
|
||||||
FlagWithArg("-encoding ", "UTF-8").
|
FlagWithArg("-encoding ", "UTF-8").
|
||||||
FlagWithArg("-source ", javaVersion).
|
FlagWithArg("-source ", javaVersion.String()).
|
||||||
FlagWithRspFileInputList("@", srcs).
|
FlagWithRspFileInputList("@", srcs).
|
||||||
FlagWithInput("@", srcJarList)
|
FlagWithInput("@", srcJarList)
|
||||||
|
|
||||||
|
|
126
java/java.go
126
java/java.go
|
@ -140,10 +140,10 @@ type CompilerProperties struct {
|
||||||
Use_tools_jar *bool
|
Use_tools_jar *bool
|
||||||
|
|
||||||
Openjdk9 struct {
|
Openjdk9 struct {
|
||||||
// List of source files that should only be used when passing -source 1.9
|
// List of source files that should only be used when passing -source 1.9 or higher
|
||||||
Srcs []string `android:"path"`
|
Srcs []string `android:"path"`
|
||||||
|
|
||||||
// List of javac flags that should only be used when passing -source 1.9
|
// List of javac flags that should only be used when passing -source 1.9 or higher
|
||||||
Javacflags []string
|
Javacflags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,6 +433,7 @@ type jniDependencyTag struct {
|
||||||
var (
|
var (
|
||||||
staticLibTag = dependencyTag{name: "staticlib"}
|
staticLibTag = dependencyTag{name: "staticlib"}
|
||||||
libTag = dependencyTag{name: "javalib"}
|
libTag = dependencyTag{name: "javalib"}
|
||||||
|
java9LibTag = dependencyTag{name: "java9lib"}
|
||||||
pluginTag = dependencyTag{name: "plugin"}
|
pluginTag = dependencyTag{name: "plugin"}
|
||||||
bootClasspathTag = dependencyTag{name: "bootclasspath"}
|
bootClasspathTag = dependencyTag{name: "bootclasspath"}
|
||||||
systemModulesTag = dependencyTag{name: "system modules"}
|
systemModulesTag = dependencyTag{name: "system modules"}
|
||||||
|
@ -461,12 +462,16 @@ type checkVendorModuleContext interface {
|
||||||
type sdkDep struct {
|
type sdkDep struct {
|
||||||
useModule, useFiles, useDefaultLibs, invalidVersion bool
|
useModule, useFiles, useDefaultLibs, invalidVersion bool
|
||||||
|
|
||||||
modules []string
|
// The modules that will be added to the bootclasspath when targeting 1.8 or lower
|
||||||
|
bootclasspath []string
|
||||||
|
|
||||||
// The default system modules to use. Will be an empty string if no system
|
// The default system modules to use. Will be an empty string if no system
|
||||||
// modules are to be used.
|
// modules are to be used.
|
||||||
systemModules string
|
systemModules string
|
||||||
|
|
||||||
|
// The modules that will be added ot the classpath when targeting 1.9 or higher
|
||||||
|
java9Classpath []string
|
||||||
|
|
||||||
frameworkResModule string
|
frameworkResModule string
|
||||||
|
|
||||||
jars android.Paths
|
jars android.Paths
|
||||||
|
@ -524,26 +529,22 @@ func (j *Module) targetSdkVersion() string {
|
||||||
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
if sdkDep.hasStandardLibs() {
|
if sdkDep.useDefaultLibs {
|
||||||
if sdkDep.useDefaultLibs {
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
if sdkDep.hasFrameworkLibs() {
|
||||||
if sdkDep.hasFrameworkLibs() {
|
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
||||||
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
|
||||||
}
|
|
||||||
} else if sdkDep.useModule {
|
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
|
|
||||||
if j.deviceProperties.EffectiveOptimizeEnabled() {
|
|
||||||
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...)
|
|
||||||
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if sdkDep.systemModules != "" {
|
} else if sdkDep.useModule {
|
||||||
// Add the system modules to both the system modules and bootclasspath.
|
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.systemModules)
|
ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...)
|
||||||
|
if j.deviceProperties.EffectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
|
||||||
|
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...)
|
||||||
|
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.ModuleName() == "android_stubs_current" ||
|
if ctx.ModuleName() == "android_stubs_current" ||
|
||||||
ctx.ModuleName() == "android_system_stubs_current" ||
|
ctx.ModuleName() == "android_system_stubs_current" ||
|
||||||
ctx.ModuleName() == "android_test_stubs_current" {
|
ctx.ModuleName() == "android_test_stubs_current" {
|
||||||
|
@ -635,6 +636,7 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
|
||||||
|
|
||||||
type deps struct {
|
type deps struct {
|
||||||
classpath classpath
|
classpath classpath
|
||||||
|
java9Classpath classpath
|
||||||
bootClasspath classpath
|
bootClasspath classpath
|
||||||
processorPath classpath
|
processorPath classpath
|
||||||
processorClasses []string
|
processorClasses []string
|
||||||
|
@ -744,7 +746,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
if sdkDep.invalidVersion {
|
if sdkDep.invalidVersion {
|
||||||
ctx.AddMissingDependencies(sdkDep.modules)
|
ctx.AddMissingDependencies(sdkDep.bootclasspath)
|
||||||
|
ctx.AddMissingDependencies(sdkDep.java9Classpath)
|
||||||
} else if sdkDep.useFiles {
|
} else if sdkDep.useFiles {
|
||||||
// sdkDep.jar is actually equivalent to turbine header.jar.
|
// sdkDep.jar is actually equivalent to turbine header.jar.
|
||||||
deps.classpath = append(deps.classpath, sdkDep.jars...)
|
deps.classpath = append(deps.classpath, sdkDep.jars...)
|
||||||
|
@ -792,6 +795,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
// sdk lib names from dependencies are re-exported
|
// sdk lib names from dependencies are re-exported
|
||||||
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
||||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
||||||
|
case java9LibTag:
|
||||||
|
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...)
|
||||||
case staticLibTag:
|
case staticLibTag:
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
||||||
deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
|
deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
|
||||||
|
@ -865,8 +870,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) string {
|
func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) javaVersion {
|
||||||
var ret string
|
|
||||||
v := sdkContext.sdkVersion()
|
v := sdkContext.sdkVersion()
|
||||||
// For PDK builds, use the latest SDK version instead of "current"
|
// For PDK builds, use the latest SDK version instead of "current"
|
||||||
if ctx.Config().IsPdkBuild() &&
|
if ctx.Config().IsPdkBuild() &&
|
||||||
|
@ -884,41 +888,65 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
|
||||||
ctx.PropertyErrorf("sdk_version", "%s", err)
|
ctx.PropertyErrorf("sdk_version", "%s", err)
|
||||||
}
|
}
|
||||||
if javaVersion != "" {
|
if javaVersion != "" {
|
||||||
ret = normalizeJavaVersion(ctx, javaVersion)
|
return normalizeJavaVersion(ctx, javaVersion)
|
||||||
} else if ctx.Device() && sdk <= 23 {
|
} else if ctx.Device() && sdk <= 23 {
|
||||||
ret = "1.7"
|
return JAVA_VERSION_7
|
||||||
} else if ctx.Device() && sdk <= 29 {
|
} else if ctx.Device() && sdk <= 29 {
|
||||||
ret = "1.8"
|
return JAVA_VERSION_8
|
||||||
} else if ctx.Device() &&
|
} else if ctx.Device() && ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
sdkContext.sdkVersion() != "" &&
|
// TODO(b/142896162): once we have prebuilt system modules we can use 1.9 for unbundled builds
|
||||||
sdkContext.sdkVersion() != "none" &&
|
return JAVA_VERSION_8
|
||||||
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 {
|
} else {
|
||||||
ret = "1.9"
|
return JAVA_VERSION_9
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeJavaVersion(ctx android.ModuleContext, javaVersion string) string {
|
type javaVersion int
|
||||||
|
|
||||||
|
const (
|
||||||
|
JAVA_VERSION_UNSUPPORTED = 0
|
||||||
|
JAVA_VERSION_6 = 6
|
||||||
|
JAVA_VERSION_7 = 7
|
||||||
|
JAVA_VERSION_8 = 8
|
||||||
|
JAVA_VERSION_9 = 9
|
||||||
|
)
|
||||||
|
|
||||||
|
func (v javaVersion) String() string {
|
||||||
|
switch v {
|
||||||
|
case JAVA_VERSION_6:
|
||||||
|
return "1.6"
|
||||||
|
case JAVA_VERSION_7:
|
||||||
|
return "1.7"
|
||||||
|
case JAVA_VERSION_8:
|
||||||
|
return "1.8"
|
||||||
|
case JAVA_VERSION_9:
|
||||||
|
return "1.9"
|
||||||
|
default:
|
||||||
|
return "unsupported"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if javac targeting this version uses system modules instead of a bootclasspath.
|
||||||
|
func (v javaVersion) usesJavaModules() bool {
|
||||||
|
return v >= 9
|
||||||
|
}
|
||||||
|
|
||||||
|
func normalizeJavaVersion(ctx android.BaseModuleContext, javaVersion string) javaVersion {
|
||||||
switch javaVersion {
|
switch javaVersion {
|
||||||
case "1.6", "6":
|
case "1.6", "6":
|
||||||
return "1.6"
|
return JAVA_VERSION_6
|
||||||
case "1.7", "7":
|
case "1.7", "7":
|
||||||
return "1.7"
|
return JAVA_VERSION_7
|
||||||
case "1.8", "8":
|
case "1.8", "8":
|
||||||
return "1.8"
|
return JAVA_VERSION_8
|
||||||
case "1.9", "9":
|
case "1.9", "9":
|
||||||
return "1.9"
|
return JAVA_VERSION_9
|
||||||
case "10", "11":
|
case "10", "11":
|
||||||
ctx.PropertyErrorf("java_version", "Java language levels above 9 are not supported")
|
ctx.PropertyErrorf("java_version", "Java language levels above 9 are not supported")
|
||||||
return "unsupported"
|
return JAVA_VERSION_UNSUPPORTED
|
||||||
default:
|
default:
|
||||||
ctx.PropertyErrorf("java_version", "Unrecognized Java language level")
|
ctx.PropertyErrorf("java_version", "Unrecognized Java language level")
|
||||||
return "unrecognized"
|
return JAVA_VERSION_UNSUPPORTED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,7 +959,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
||||||
|
|
||||||
// javac flags.
|
// javac flags.
|
||||||
javacFlags := j.properties.Javacflags
|
javacFlags := j.properties.Javacflags
|
||||||
if flags.javaVersion == "1.9" {
|
if flags.javaVersion.usesJavaModules() {
|
||||||
javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
|
javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
|
||||||
}
|
}
|
||||||
if ctx.Config().MinimizeJavaDebugInfo() {
|
if ctx.Config().MinimizeJavaDebugInfo() {
|
||||||
|
@ -959,13 +987,13 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
||||||
// classpath
|
// classpath
|
||||||
flags.bootClasspath = append(flags.bootClasspath, deps.bootClasspath...)
|
flags.bootClasspath = append(flags.bootClasspath, deps.bootClasspath...)
|
||||||
flags.classpath = append(flags.classpath, deps.classpath...)
|
flags.classpath = append(flags.classpath, deps.classpath...)
|
||||||
|
flags.java9Classpath = append(flags.java9Classpath, deps.java9Classpath...)
|
||||||
flags.processorPath = append(flags.processorPath, deps.processorPath...)
|
flags.processorPath = append(flags.processorPath, deps.processorPath...)
|
||||||
|
|
||||||
flags.processor = strings.Join(deps.processorClasses, ",")
|
flags.processor = strings.Join(deps.processorClasses, ",")
|
||||||
|
|
||||||
if len(flags.bootClasspath) == 0 && ctx.Host() && flags.javaVersion != "1.9" &&
|
if len(flags.bootClasspath) == 0 && ctx.Host() && !flags.javaVersion.usesJavaModules() &&
|
||||||
decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() &&
|
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
|
// Give host-side tools a version of OpenJDK's standard libraries
|
||||||
// close to what they're targeting. As of Dec 2017, AOSP is only
|
// close to what they're targeting. As of Dec 2017, AOSP is only
|
||||||
// bundling OpenJDK 8 and 9, so nothing < 8 is available.
|
// bundling OpenJDK 8 and 9, so nothing < 8 is available.
|
||||||
|
@ -989,7 +1017,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if j.properties.Patch_module != nil && flags.javaVersion == "1.9" {
|
if j.properties.Patch_module != nil && flags.javaVersion.usesJavaModules() {
|
||||||
// Manually specify build directory in case it is not under the repo root.
|
// Manually specify build directory in case it is not under the repo root.
|
||||||
// (javac doesn't seem to expand into symbolc links when searching for patch-module targets, so
|
// (javac doesn't seem to expand into symbolc links when searching for patch-module targets, so
|
||||||
// just adding a symlink under the root doesn't help.)
|
// just adding a symlink under the root doesn't help.)
|
||||||
|
@ -1022,7 +1050,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
||||||
deps := j.collectDeps(ctx)
|
deps := j.collectDeps(ctx)
|
||||||
flags := j.collectBuilderFlags(ctx, deps)
|
flags := j.collectBuilderFlags(ctx, deps)
|
||||||
|
|
||||||
if flags.javaVersion == "1.9" {
|
if flags.javaVersion.usesJavaModules() {
|
||||||
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
|
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
|
||||||
}
|
}
|
||||||
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
||||||
|
|
|
@ -148,9 +148,9 @@ func testContext(bp string, fs map[string][]byte) *android.TestContext {
|
||||||
"prebuilts/sdk/17/public/android.jar": nil,
|
"prebuilts/sdk/17/public/android.jar": nil,
|
||||||
"prebuilts/sdk/17/public/framework.aidl": nil,
|
"prebuilts/sdk/17/public/framework.aidl": nil,
|
||||||
"prebuilts/sdk/17/system/android.jar": nil,
|
"prebuilts/sdk/17/system/android.jar": nil,
|
||||||
"prebuilts/sdk/25/public/android.jar": nil,
|
"prebuilts/sdk/29/public/android.jar": nil,
|
||||||
"prebuilts/sdk/25/public/framework.aidl": nil,
|
"prebuilts/sdk/29/public/framework.aidl": nil,
|
||||||
"prebuilts/sdk/25/system/android.jar": nil,
|
"prebuilts/sdk/29/system/android.jar": nil,
|
||||||
"prebuilts/sdk/current/core/android.jar": nil,
|
"prebuilts/sdk/current/core/android.jar": nil,
|
||||||
"prebuilts/sdk/current/public/android.jar": nil,
|
"prebuilts/sdk/current/public/android.jar": nil,
|
||||||
"prebuilts/sdk/current/public/framework.aidl": nil,
|
"prebuilts/sdk/current/public/framework.aidl": nil,
|
||||||
|
|
|
@ -141,8 +141,8 @@ func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedJavacFlags := kaptEncodeFlags([][2]string{
|
encodedJavacFlags := kaptEncodeFlags([][2]string{
|
||||||
{"-source", flags.javaVersion},
|
{"-source", flags.javaVersion.String()},
|
||||||
{"-target", flags.javaVersion},
|
{"-target", flags.javaVersion.String()},
|
||||||
})
|
})
|
||||||
|
|
||||||
kotlinName := filepath.Join(ctx.ModuleDir(), ctx.ModuleSubDir(), ctx.ModuleName())
|
kotlinName := filepath.Join(ctx.ModuleDir(), ctx.ModuleSubDir(), ctx.ModuleName())
|
||||||
|
|
23
java/sdk.go
23
java/sdk.go
|
@ -122,7 +122,7 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
||||||
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
|
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
|
||||||
return sdkDep{
|
return sdkDep{
|
||||||
invalidVersion: true,
|
invalidVersion: true,
|
||||||
modules: []string{fmt.Sprintf("sdk_%s_%s_android", api, v)},
|
bootclasspath: []string{fmt.Sprintf("sdk_%s_%s_android", api, v)},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,20 +144,14 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
||||||
}
|
}
|
||||||
|
|
||||||
toModule := func(m, r string, aidl android.Path) sdkDep {
|
toModule := func(m, r string, aidl android.Path) sdkDep {
|
||||||
ret := sdkDep{
|
return sdkDep{
|
||||||
useModule: true,
|
useModule: true,
|
||||||
modules: []string{m, config.DefaultLambdaStubsLibrary},
|
bootclasspath: []string{m, config.DefaultLambdaStubsLibrary},
|
||||||
systemModules: m + "_system_modules",
|
systemModules: "core-current-stubs-system-modules",
|
||||||
|
java9Classpath: []string{m},
|
||||||
frameworkResModule: r,
|
frameworkResModule: r,
|
||||||
aidl: android.OptionalPathForPath(aidl),
|
aidl: android.OptionalPathForPath(aidl),
|
||||||
}
|
}
|
||||||
|
|
||||||
if m == "core.current.stubs" {
|
|
||||||
ret.systemModules = "core-current-stubs-system-modules"
|
|
||||||
// core_current does not include framework classes.
|
|
||||||
ret.noFrameworksLibs = true
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensures that the specificed system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor apks)
|
// Ensures that the specificed system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor apks)
|
||||||
|
@ -192,13 +186,16 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
||||||
ctx.PropertyErrorf("sdk_version",
|
ctx.PropertyErrorf("sdk_version",
|
||||||
`system_modules is required to be set to a non-empty value when sdk_version is "none", did you mean sdk_version: "core_platform"?`)
|
`system_modules is required to be set to a non-empty value when sdk_version is "none", did you mean sdk_version: "core_platform"?`)
|
||||||
} else if systemModules == "none" {
|
} else if systemModules == "none" {
|
||||||
// Normalize no system modules to an empty string.
|
return sdkDep{
|
||||||
systemModules = ""
|
noStandardLibs: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sdkDep{
|
return sdkDep{
|
||||||
|
useModule: true,
|
||||||
noStandardLibs: true,
|
noStandardLibs: true,
|
||||||
systemModules: systemModules,
|
systemModules: systemModules,
|
||||||
|
bootclasspath: []string{systemModules},
|
||||||
}
|
}
|
||||||
case "core_platform":
|
case "core_platform":
|
||||||
return sdkDep{
|
return sdkDep{
|
||||||
|
|
300
java/sdk_test.go
300
java/sdk_test.go
|
@ -28,174 +28,188 @@ import (
|
||||||
|
|
||||||
func TestClasspath(t *testing.T) {
|
func TestClasspath(t *testing.T) {
|
||||||
var classpathTestcases = []struct {
|
var classpathTestcases = []struct {
|
||||||
name string
|
name string
|
||||||
unbundled bool
|
unbundled bool
|
||||||
pdk bool
|
pdk bool
|
||||||
moduleType string
|
moduleType string
|
||||||
host android.OsClass
|
host android.OsClass
|
||||||
properties string
|
properties string
|
||||||
bootclasspath []string
|
|
||||||
system string
|
// for java 8
|
||||||
classpath []string
|
bootclasspath []string
|
||||||
aidl string
|
java8classpath []string
|
||||||
|
|
||||||
|
// for java 9
|
||||||
|
system string
|
||||||
|
java9classpath []string
|
||||||
|
|
||||||
|
forces8 bool // if set, javac will always be called with java 8 arguments
|
||||||
|
|
||||||
|
aidl string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "default",
|
name: "default",
|
||||||
bootclasspath: config.DefaultBootclasspathLibraries,
|
bootclasspath: config.DefaultBootclasspathLibraries,
|
||||||
system: config.DefaultSystemModules,
|
system: config.DefaultSystemModules,
|
||||||
classpath: config.DefaultLibraries,
|
java8classpath: config.DefaultLibraries,
|
||||||
aidl: "-Iframework/aidl",
|
java9classpath: config.DefaultLibraries,
|
||||||
|
aidl: "-Iframework/aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `sdk_version:"core_platform"`,
|
name: `sdk_version:"core_platform"`,
|
||||||
properties: `sdk_version:"core_platform"`,
|
properties: `sdk_version:"core_platform"`,
|
||||||
bootclasspath: config.DefaultBootclasspathLibraries,
|
bootclasspath: config.DefaultBootclasspathLibraries,
|
||||||
system: config.DefaultSystemModules,
|
system: config.DefaultSystemModules,
|
||||||
classpath: []string{},
|
java8classpath: []string{},
|
||||||
aidl: "",
|
aidl: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "blank sdk version",
|
name: "blank sdk version",
|
||||||
properties: `sdk_version: "",`,
|
properties: `sdk_version: "",`,
|
||||||
bootclasspath: config.DefaultBootclasspathLibraries,
|
bootclasspath: config.DefaultBootclasspathLibraries,
|
||||||
system: config.DefaultSystemModules,
|
system: config.DefaultSystemModules,
|
||||||
classpath: config.DefaultLibraries,
|
java8classpath: config.DefaultLibraries,
|
||||||
aidl: "-Iframework/aidl",
|
java9classpath: config.DefaultLibraries,
|
||||||
|
aidl: "-Iframework/aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "sdk v25",
|
name: "sdk v29",
|
||||||
properties: `sdk_version: "25",`,
|
properties: `sdk_version: "29",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
forces8: true,
|
||||||
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "current",
|
name: "current",
|
||||||
properties: `sdk_version: "current",`,
|
properties: `sdk_version: "current",`,
|
||||||
bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
|
bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "core-current-stubs-system-modules",
|
||||||
aidl: "-p" + buildDir + "/framework.aidl",
|
java9classpath: []string{"android_stubs_current"},
|
||||||
|
aidl: "-p" + buildDir + "/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "system_current",
|
name: "system_current",
|
||||||
properties: `sdk_version: "system_current",`,
|
properties: `sdk_version: "system_current",`,
|
||||||
bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
|
bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "core-current-stubs-system-modules",
|
||||||
aidl: "-p" + buildDir + "/framework.aidl",
|
java9classpath: []string{"android_system_stubs_current"},
|
||||||
|
aidl: "-p" + buildDir + "/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "system_25",
|
name: "system_29",
|
||||||
properties: `sdk_version: "system_25",`,
|
properties: `sdk_version: "system_29",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
forces8: true,
|
||||||
classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
java8classpath: []string{"prebuilts/sdk/29/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "test_current",
|
name: "test_current",
|
||||||
properties: `sdk_version: "test_current",`,
|
properties: `sdk_version: "test_current",`,
|
||||||
bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
|
bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "core-current-stubs-system-modules",
|
||||||
aidl: "-p" + buildDir + "/framework.aidl",
|
java9classpath: []string{"android_test_stubs_current"},
|
||||||
|
aidl: "-p" + buildDir + "/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "core_current",
|
name: "core_current",
|
||||||
properties: `sdk_version: "core_current",`,
|
properties: `sdk_version: "core_current",`,
|
||||||
bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
|
bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
system: "core-current-stubs-system-modules",
|
||||||
|
java9classpath: []string{"core.current.stubs"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "nostdlib",
|
name: "nostdlib",
|
||||||
properties: `sdk_version: "none", system_modules: "none"`,
|
properties: `sdk_version: "none", system_modules: "none"`,
|
||||||
system: "none",
|
system: "none",
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
classpath: []string{},
|
java8classpath: []string{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "nostdlib system_modules",
|
name: "nostdlib system_modules",
|
||||||
properties: `sdk_version: "none", system_modules: "core-platform-api-stubs-system-modules"`,
|
properties: `sdk_version: "none", system_modules: "core-platform-api-stubs-system-modules"`,
|
||||||
system: "core-platform-api-stubs-system-modules",
|
system: "core-platform-api-stubs-system-modules",
|
||||||
bootclasspath: []string{"core-platform-api-stubs-system-modules-lib"},
|
bootclasspath: []string{"core-platform-api-stubs-system-modules-lib"},
|
||||||
classpath: []string{},
|
java8classpath: []string{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "host default",
|
name: "host default",
|
||||||
moduleType: "java_library_host",
|
moduleType: "java_library_host",
|
||||||
properties: ``,
|
properties: ``,
|
||||||
host: android.Host,
|
host: android.Host,
|
||||||
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
|
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
|
||||||
classpath: []string{},
|
java8classpath: []string{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "host supported default",
|
name: "host supported default",
|
||||||
host: android.Host,
|
host: android.Host,
|
||||||
properties: `host_supported: true,`,
|
properties: `host_supported: true,`,
|
||||||
classpath: []string{},
|
java8classpath: []string{},
|
||||||
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
|
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "host supported nostdlib",
|
name: "host supported nostdlib",
|
||||||
host: android.Host,
|
host: android.Host,
|
||||||
properties: `host_supported: true, sdk_version: "none", system_modules: "none"`,
|
properties: `host_supported: true, sdk_version: "none", system_modules: "none"`,
|
||||||
classpath: []string{},
|
java8classpath: []string{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "unbundled sdk v25",
|
name: "unbundled sdk v29",
|
||||||
unbundled: true,
|
unbundled: true,
|
||||||
properties: `sdk_version: "25",`,
|
properties: `sdk_version: "29",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
forces8: true,
|
||||||
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
name: "unbundled current",
|
name: "unbundled current",
|
||||||
unbundled: true,
|
unbundled: true,
|
||||||
properties: `sdk_version: "current",`,
|
properties: `sdk_version: "current",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
forces8: true,
|
||||||
classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "pdk default",
|
name: "pdk default",
|
||||||
pdk: true,
|
pdk: true,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
forces8: true,
|
||||||
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pdk current",
|
name: "pdk current",
|
||||||
pdk: true,
|
pdk: true,
|
||||||
properties: `sdk_version: "current",`,
|
properties: `sdk_version: "current",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
forces8: true,
|
||||||
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pdk 25",
|
name: "pdk 29",
|
||||||
pdk: true,
|
pdk: true,
|
||||||
properties: `sdk_version: "25",`,
|
properties: `sdk_version: "29",`,
|
||||||
bootclasspath: []string{`""`},
|
bootclasspath: []string{`""`},
|
||||||
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
|
forces8: true,
|
||||||
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
||||||
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +249,8 @@ func TestClasspath(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bootclasspath := convertModulesToPaths(testcase.bootclasspath)
|
bootclasspath := convertModulesToPaths(testcase.bootclasspath)
|
||||||
classpath := convertModulesToPaths(testcase.classpath)
|
java8classpath := convertModulesToPaths(testcase.java8classpath)
|
||||||
|
java9classpath := convertModulesToPaths(testcase.java9classpath)
|
||||||
|
|
||||||
bc := ""
|
bc := ""
|
||||||
var bcDeps []string
|
var bcDeps []string
|
||||||
|
@ -246,18 +261,20 @@ func TestClasspath(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c := ""
|
j8c := ""
|
||||||
if len(classpath) > 0 {
|
if len(java8classpath) > 0 {
|
||||||
c = "-classpath " + strings.Join(classpath, ":")
|
j8c = "-classpath " + strings.Join(java8classpath, ":")
|
||||||
|
}
|
||||||
|
|
||||||
|
j9c := ""
|
||||||
|
if len(java9classpath) > 0 {
|
||||||
|
j9c = "-classpath " + strings.Join(java9classpath, ":")
|
||||||
}
|
}
|
||||||
|
|
||||||
system := ""
|
system := ""
|
||||||
var systemDeps []string
|
var systemDeps []string
|
||||||
if testcase.system == "none" {
|
if testcase.system == "none" {
|
||||||
system = "--system=none"
|
system = "--system=none"
|
||||||
} else if testcase.system == "bootclasspath" {
|
|
||||||
system = bc
|
|
||||||
systemDeps = bcDeps
|
|
||||||
} else if testcase.system != "" {
|
} else if testcase.system != "" {
|
||||||
system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system")
|
system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system")
|
||||||
// The module-relative parts of these paths are hardcoded in system_modules.go:
|
// The module-relative parts of these paths are hardcoded in system_modules.go:
|
||||||
|
@ -280,7 +297,7 @@ func TestClasspath(t *testing.T) {
|
||||||
|
|
||||||
got := javac.Args["bootClasspath"]
|
got := javac.Args["bootClasspath"]
|
||||||
expected := ""
|
expected := ""
|
||||||
if isJava8 {
|
if isJava8 || testcase.forces8 {
|
||||||
expected = bc
|
expected = bc
|
||||||
deps = append(deps, bcDeps...)
|
deps = append(deps, bcDeps...)
|
||||||
} else {
|
} else {
|
||||||
|
@ -291,11 +308,17 @@ func TestClasspath(t *testing.T) {
|
||||||
t.Errorf("bootclasspath expected %q != got %q", expected, got)
|
t.Errorf("bootclasspath expected %q != got %q", expected, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
got = javac.Args["classpath"]
|
if isJava8 || testcase.forces8 {
|
||||||
if got != c {
|
expected = j8c
|
||||||
t.Errorf("classpath expected %q != got %q", c, got)
|
deps = append(deps, java8classpath...)
|
||||||
|
} else {
|
||||||
|
expected = j9c
|
||||||
|
deps = append(deps, java9classpath...)
|
||||||
|
}
|
||||||
|
got = javac.Args["classpath"]
|
||||||
|
if got != expected {
|
||||||
|
t.Errorf("classpath expected %q != got %q", expected, got)
|
||||||
}
|
}
|
||||||
deps = append(deps, classpath...)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
|
if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
|
||||||
t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())
|
t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())
|
||||||
|
@ -366,8 +389,23 @@ func TestClasspath(t *testing.T) {
|
||||||
checkClasspath(t, ctx, true /* isJava8 */)
|
checkClasspath(t, ctx, true /* isJava8 */)
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(b/142896162): Add a with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9, when that all works.
|
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9
|
||||||
|
t.Run("REL + Java language level 9", func(t *testing.T) {
|
||||||
|
config := testConfig(nil)
|
||||||
|
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL")
|
||||||
|
config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true)
|
||||||
|
|
||||||
|
if testcase.unbundled {
|
||||||
|
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
|
if testcase.pdk {
|
||||||
|
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
|
ctx := testContext(bp, nil)
|
||||||
|
run(t, ctx, config)
|
||||||
|
|
||||||
|
checkClasspath(t, ctx, false /* isJava8 */)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue