Merge "Adding option to include sources only for Java 11 builds" am: 55f84a74c5
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1927441 Change-Id: Ib8c7fe813e635e5c973b6ac56117b5bc6168804f
This commit is contained in:
@@ -658,6 +658,10 @@ func (c *config) IsEnvFalse(key string) bool {
|
|||||||
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
|
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) TargetsJava11() bool {
|
||||||
|
return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_11")
|
||||||
|
}
|
||||||
|
|
||||||
// EnvDeps returns the environment variables this build depends on. The first
|
// EnvDeps returns the environment variables this build depends on. The first
|
||||||
// call to this function blocks future reads from the environment.
|
// call to this function blocks future reads from the environment.
|
||||||
func (c *config) EnvDeps() map[string]string {
|
func (c *config) EnvDeps() map[string]string {
|
||||||
|
12
java/base.go
12
java/base.go
@@ -122,6 +122,14 @@ type CommonProperties struct {
|
|||||||
Javacflags []string
|
Javacflags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Openjdk11 struct {
|
||||||
|
// List of source files that should only be used when passing -source 1.9 or higher
|
||||||
|
Srcs []string `android:"path"`
|
||||||
|
|
||||||
|
// List of javac flags that should only be used when passing -source 1.9 or higher
|
||||||
|
Javacflags []string
|
||||||
|
}
|
||||||
|
|
||||||
// When compiling language level 9+ .java code in packages that are part of
|
// When compiling language level 9+ .java code in packages that are part of
|
||||||
// a system module, patch_module names the module that your sources and
|
// a system module, patch_module names the module that your sources and
|
||||||
// dependencies should be patched into. The Android runtime currently
|
// dependencies should be patched into. The Android runtime currently
|
||||||
@@ -959,6 +967,10 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
if flags.javaVersion.usesJavaModules() {
|
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...)
|
||||||
}
|
}
|
||||||
|
if ctx.Config().TargetsJava11() {
|
||||||
|
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk11.Srcs...)
|
||||||
|
}
|
||||||
|
|
||||||
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
||||||
if hasSrcExt(srcFiles.Strings(), ".proto") {
|
if hasSrcExt(srcFiles.Strings(), ".proto") {
|
||||||
flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags)
|
flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags)
|
||||||
|
@@ -449,7 +449,7 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext an
|
|||||||
return normalizeJavaVersion(ctx, javaVersion)
|
return normalizeJavaVersion(ctx, javaVersion)
|
||||||
} else if ctx.Device() {
|
} else if ctx.Device() {
|
||||||
return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
|
return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
|
||||||
} else if ctx.Config().IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_11") {
|
} else if ctx.Config().TargetsJava11() {
|
||||||
// Temporary experimental flag to be able to try and build with
|
// Temporary experimental flag to be able to try and build with
|
||||||
// java version 11 options. The flag, if used, just sets Java
|
// java version 11 options. The flag, if used, just sets Java
|
||||||
// 11 as the default version, leaving any components that
|
// 11 as the default version, leaving any components that
|
||||||
|
@@ -55,7 +55,7 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe
|
|||||||
return JAVA_VERSION_7
|
return JAVA_VERSION_7
|
||||||
} else if sdk.FinalOrFutureInt() <= 29 {
|
} else if sdk.FinalOrFutureInt() <= 29 {
|
||||||
return JAVA_VERSION_8
|
return JAVA_VERSION_8
|
||||||
} else if ctx.Config().IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_11") {
|
} else if ctx.Config().TargetsJava11() {
|
||||||
// Temporary experimental flag to be able to try and build with
|
// Temporary experimental flag to be able to try and build with
|
||||||
// java version 11 options. The flag, if used, just sets Java
|
// java version 11 options. The flag, if used, just sets Java
|
||||||
// 11 as the default version, leaving any components that
|
// 11 as the default version, leaving any components that
|
||||||
|
@@ -1392,6 +1392,10 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
|
|||||||
Srcs []string
|
Srcs []string
|
||||||
Javacflags []string
|
Javacflags []string
|
||||||
}
|
}
|
||||||
|
Openjdk11 struct {
|
||||||
|
Srcs []string
|
||||||
|
Javacflags []string
|
||||||
|
}
|
||||||
Dist struct {
|
Dist struct {
|
||||||
Targets []string
|
Targets []string
|
||||||
Dest *string
|
Dest *string
|
||||||
@@ -1418,6 +1422,8 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
|
|||||||
}
|
}
|
||||||
props.Openjdk9.Srcs = module.properties.Openjdk9.Srcs
|
props.Openjdk9.Srcs = module.properties.Openjdk9.Srcs
|
||||||
props.Openjdk9.Javacflags = module.properties.Openjdk9.Javacflags
|
props.Openjdk9.Javacflags = module.properties.Openjdk9.Javacflags
|
||||||
|
props.Openjdk11.Srcs = module.properties.Openjdk11.Srcs
|
||||||
|
props.Openjdk11.Javacflags = module.properties.Openjdk11.Javacflags
|
||||||
// We compile the stubs for 1.8 in line with the main android.jar stubs, and potential
|
// We compile the stubs for 1.8 in line with the main android.jar stubs, and potential
|
||||||
// interop with older developer tools that don't support 1.9.
|
// interop with older developer tools that don't support 1.9.
|
||||||
props.Java_version = proptools.StringPtr("1.8")
|
props.Java_version = proptools.StringPtr("1.8")
|
||||||
|
Reference in New Issue
Block a user