2017-06-23 02:20:19 +02:00
|
|
|
// Copyright 2017 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package config
|
|
|
|
|
2017-08-08 22:17:59 +02:00
|
|
|
import (
|
2017-11-23 01:19:37 +01:00
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
2017-08-08 22:17:59 +02:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
_ "github.com/google/blueprint/bootstrap"
|
|
|
|
|
|
|
|
"android/soong/android"
|
2020-04-22 03:36:23 +02:00
|
|
|
"android/soong/remoteexec"
|
2017-08-08 22:17:59 +02:00
|
|
|
)
|
2017-06-23 02:20:19 +02:00
|
|
|
|
|
|
|
var (
|
2017-08-08 22:17:59 +02:00
|
|
|
pctx = android.NewPackageContext("android/soong/java/config")
|
|
|
|
|
2020-07-01 11:48:14 +02:00
|
|
|
LegacyCorePlatformBootclasspathLibraries = []string{"legacy.core.platform.api.stubs", "core-lambda-stubs"}
|
|
|
|
LegacyCorePlatformSystemModules = "legacy-core-platform-api-stubs-system-modules"
|
2020-07-09 19:03:41 +02:00
|
|
|
StableCorePlatformBootclasspathLibraries = []string{"stable.core.platform.api.stubs", "core-lambda-stubs"}
|
|
|
|
StableCorePlatformSystemModules = "stable-core-platform-api-stubs-system-modules"
|
2020-07-01 11:48:14 +02:00
|
|
|
FrameworkLibraries = []string{"ext", "framework"}
|
|
|
|
DefaultLambdaStubsLibrary = "core-lambda-stubs"
|
|
|
|
SdkLambdaStubsPath = "prebuilts/sdk/tools/core-lambda-stubs.jar"
|
2017-11-22 22:49:43 +01:00
|
|
|
|
2020-06-24 22:36:59 +02:00
|
|
|
DefaultMakeJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"}
|
|
|
|
DefaultJacocoExcludeFilter = []string{"org.junit.**", "org.jacoco.**", "org.mockito.**"}
|
2017-11-22 22:49:43 +01:00
|
|
|
|
|
|
|
InstrumentFrameworkModules = []string{
|
|
|
|
"framework",
|
2019-11-08 00:09:15 +01:00
|
|
|
"framework-minus-apex",
|
2017-11-22 22:49:43 +01:00
|
|
|
"telephony-common",
|
|
|
|
"services",
|
|
|
|
"android.car",
|
|
|
|
"android.car7",
|
2019-03-08 15:46:36 +01:00
|
|
|
"conscrypt",
|
2019-08-06 17:57:40 +02:00
|
|
|
"core-icu4j",
|
2017-12-19 16:01:39 +01:00
|
|
|
"core-oj",
|
2018-02-13 16:23:14 +01:00
|
|
|
"core-libart",
|
2020-01-17 10:55:03 +01:00
|
|
|
// TODO: Could this be all updatable bootclasspath jars?
|
2019-01-24 12:46:28 +01:00
|
|
|
"updatable-media",
|
2019-12-16 06:05:02 +01:00
|
|
|
"framework-mediaprovider",
|
2020-01-17 10:55:03 +01:00
|
|
|
"framework-sdkextensions",
|
2020-02-25 00:02:02 +01:00
|
|
|
"android.net.ipsec.ike",
|
2017-11-22 22:49:43 +01:00
|
|
|
}
|
2017-06-23 02:20:19 +02:00
|
|
|
)
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
const (
|
|
|
|
JavaVmFlags = `-XX:OnError="cat hs_err_pid%p.log" -XX:CICompilerCount=6 -XX:+UseDynamicNumberOfGCThreads`
|
2022-01-28 20:30:16 +01:00
|
|
|
JavacVmFlags = `-J-XX:OnError="cat hs_err_pid%p.log" -J-XX:CICompilerCount=6 -J-XX:+UseDynamicNumberOfGCThreads -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1`
|
2019-07-11 20:01:22 +02:00
|
|
|
)
|
|
|
|
|
2017-08-08 22:17:59 +02:00
|
|
|
func init() {
|
|
|
|
pctx.Import("github.com/google/blueprint/bootstrap")
|
|
|
|
|
2017-09-05 22:16:45 +02:00
|
|
|
pctx.StaticVariable("JavacHeapSize", "2048M")
|
|
|
|
pctx.StaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}")
|
2019-07-09 20:26:20 +02:00
|
|
|
pctx.StaticVariable("DexFlags", "-JXX:OnError='cat hs_err_pid%p.log' -JXX:CICompilerCount=6 -JXX:+UseDynamicNumberOfGCThreads")
|
2017-08-29 02:23:21 +02:00
|
|
|
|
2017-08-08 22:17:59 +02:00
|
|
|
pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{
|
|
|
|
`-Xmaxerrs 9999999`,
|
|
|
|
`-encoding UTF-8`,
|
|
|
|
`-sourcepath ""`,
|
|
|
|
`-g`,
|
2017-09-19 19:52:23 +02:00
|
|
|
// Turbine leaves out bridges which can cause javac to unnecessarily insert them into
|
|
|
|
// subclasses (b/65645120). Setting this flag causes our custom javac to assume that
|
|
|
|
// the missing bridges will exist at runtime and not recreate them in subclasses.
|
|
|
|
// If a different javac is used the flag will be ignored and extra bridges will be inserted.
|
|
|
|
// The flag is implemented by https://android-review.googlesource.com/c/486427
|
|
|
|
`-XDskipDuplicateBridges=true`,
|
2017-08-08 22:17:59 +02:00
|
|
|
|
2017-09-30 02:58:17 +02:00
|
|
|
// b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9
|
|
|
|
`-XDstringConcat=inline`,
|
|
|
|
}, " "))
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
pctx.StaticVariable("JavaVmFlags", JavaVmFlags)
|
|
|
|
pctx.StaticVariable("JavacVmFlags", JavacVmFlags)
|
2017-08-08 22:17:59 +02:00
|
|
|
|
|
|
|
pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS)
|
|
|
|
|
2018-03-12 21:24:09 +01:00
|
|
|
pctx.VariableFunc("JavaHome", func(ctx android.PackageVarContext) string {
|
2017-10-30 21:42:06 +01:00
|
|
|
// This is set up and guaranteed by soong_ui
|
2018-03-12 21:24:09 +01:00
|
|
|
return ctx.Config().Getenv("ANDROID_JAVA_HOME")
|
2017-10-06 01:48:56 +02:00
|
|
|
})
|
2019-10-09 18:10:08 +02:00
|
|
|
pctx.VariableFunc("JlinkVersion", func(ctx android.PackageVarContext) string {
|
2019-11-07 19:55:53 +01:00
|
|
|
if override := ctx.Config().Getenv("OVERRIDE_JLINK_VERSION_NUMBER"); override != "" {
|
|
|
|
return override
|
|
|
|
}
|
2019-11-07 19:58:42 +01:00
|
|
|
return "11"
|
2019-10-09 18:10:08 +02:00
|
|
|
})
|
2017-10-06 01:48:56 +02:00
|
|
|
|
2017-08-08 22:17:59 +02:00
|
|
|
pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin")
|
|
|
|
pctx.SourcePathVariableWithEnvOverride("JavacCmd",
|
|
|
|
"${JavaToolchain}/javac", "ALTERNATE_JAVAC")
|
|
|
|
pctx.SourcePathVariable("JavaCmd", "${JavaToolchain}/java")
|
|
|
|
pctx.SourcePathVariable("JarCmd", "${JavaToolchain}/jar")
|
|
|
|
pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc")
|
2017-08-31 17:08:39 +02:00
|
|
|
pctx.SourcePathVariable("JlinkCmd", "${JavaToolchain}/jlink")
|
|
|
|
pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod")
|
2017-09-30 02:58:17 +02:00
|
|
|
pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar")
|
2018-11-06 01:49:08 +01:00
|
|
|
pctx.SourcePathVariable("JavaKytheExtractorJar", "prebuilts/build-tools/common/framework/javac_extractor.jar")
|
2017-10-19 22:06:22 +02:00
|
|
|
pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime")
|
2017-08-08 22:17:59 +02:00
|
|
|
|
2020-06-26 02:12:28 +02:00
|
|
|
pctx.HostBinToolVariable("GenKotlinBuildFileCmd", "gen-kotlin-build-file.py")
|
2018-02-13 15:32:54 +01:00
|
|
|
|
2017-08-11 02:58:12 +02:00
|
|
|
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
|
2019-04-02 11:29:55 +02:00
|
|
|
pctx.SourcePathVariable("PackageCheckCmd", "build/soong/scripts/package-check.sh")
|
2018-05-02 21:58:28 +02:00
|
|
|
pctx.HostBinToolVariable("ExtractJarPackagesCmd", "extract_jar_packages")
|
2017-10-17 22:56:52 +02:00
|
|
|
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
|
|
|
pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
|
2017-11-22 22:49:43 +01:00
|
|
|
pctx.HostBinToolVariable("Zip2ZipCmd", "zip2zip")
|
2018-03-16 00:24:10 +01:00
|
|
|
pctx.HostBinToolVariable("ZipSyncCmd", "zipsync")
|
2018-05-05 03:49:16 +02:00
|
|
|
pctx.HostBinToolVariable("ApiCheckCmd", "apicheck")
|
2021-11-04 18:25:20 +01:00
|
|
|
pctx.HostBinToolVariable("D8Cmd", "d8")
|
|
|
|
pctx.HostBinToolVariable("R8Cmd", "r8-compat-proguard")
|
2019-01-31 23:12:44 +01:00
|
|
|
pctx.HostBinToolVariable("HiddenAPICmd", "hiddenapi")
|
2020-04-23 18:49:59 +02:00
|
|
|
pctx.HostBinToolVariable("ExtractApksCmd", "extract_apks")
|
2018-03-12 21:24:09 +01:00
|
|
|
pctx.VariableFunc("TurbineJar", func(ctx android.PackageVarContext) string {
|
2017-10-25 20:11:37 +02:00
|
|
|
turbine := "turbine.jar"
|
2020-07-07 18:09:23 +02:00
|
|
|
if ctx.Config().AlwaysUsePrebuiltSdks() {
|
2018-03-12 21:24:09 +01:00
|
|
|
return "prebuilts/build-tools/common/framework/" + turbine
|
2017-10-25 20:11:37 +02:00
|
|
|
} else {
|
2019-12-09 22:47:14 +01:00
|
|
|
return ctx.Config().HostJavaToolPath(ctx, turbine).String()
|
2017-10-25 20:11:37 +02:00
|
|
|
}
|
|
|
|
})
|
2017-10-18 03:50:50 +02:00
|
|
|
|
2017-08-08 22:17:59 +02:00
|
|
|
pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar")
|
2018-01-11 01:06:12 +01:00
|
|
|
pctx.HostJavaToolVariable("JsilverJar", "jsilver.jar")
|
|
|
|
pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar")
|
2018-04-20 03:03:39 +02:00
|
|
|
pctx.HostJavaToolVariable("MetalavaJar", "metalava.jar")
|
2018-08-10 00:33:27 +02:00
|
|
|
pctx.HostJavaToolVariable("DokkaJar", "dokka.jar")
|
2018-08-28 03:31:46 +02:00
|
|
|
pctx.HostJavaToolVariable("JetifierJar", "jetifier.jar")
|
2020-04-22 03:36:23 +02:00
|
|
|
pctx.HostJavaToolVariable("R8Jar", "r8-compat-proguard.jar")
|
|
|
|
pctx.HostJavaToolVariable("D8Jar", "d8.jar")
|
2017-08-08 22:17:59 +02:00
|
|
|
|
2017-10-17 22:56:52 +02:00
|
|
|
pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper")
|
2018-11-12 19:13:39 +01:00
|
|
|
pctx.HostBinToolVariable("DexpreoptGen", "dexpreopt_gen")
|
2017-10-17 22:56:52 +02:00
|
|
|
|
2021-03-12 20:28:25 +01:00
|
|
|
pctx.StaticVariableWithEnvOverride("REJavaPool", "RBE_JAVA_POOL", "java16")
|
|
|
|
pctx.StaticVariableWithEnvOverride("REJavacExecStrategy", "RBE_JAVAC_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy)
|
|
|
|
pctx.StaticVariableWithEnvOverride("RED8ExecStrategy", "RBE_D8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy)
|
|
|
|
pctx.StaticVariableWithEnvOverride("RER8ExecStrategy", "RBE_R8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy)
|
|
|
|
pctx.StaticVariableWithEnvOverride("RETurbineExecStrategy", "RBE_TURBINE_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
|
|
|
pctx.StaticVariableWithEnvOverride("RESignApkExecStrategy", "RBE_SIGNAPK_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
|
|
|
pctx.StaticVariableWithEnvOverride("REJarExecStrategy", "RBE_JAR_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
|
|
|
pctx.StaticVariableWithEnvOverride("REZipExecStrategy", "RBE_ZIP_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
2020-01-27 20:19:44 +01:00
|
|
|
|
2017-11-22 22:49:43 +01:00
|
|
|
pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
|
2017-11-23 01:19:37 +01:00
|
|
|
|
2019-05-20 22:14:18 +02:00
|
|
|
pctx.HostBinToolVariable("ManifestCheckCmd", "manifest_check")
|
2019-05-16 22:16:29 +02:00
|
|
|
pctx.HostBinToolVariable("ManifestFixerCmd", "manifest_fixer")
|
2018-05-25 01:11:20 +02:00
|
|
|
|
2019-02-27 07:14:04 +01:00
|
|
|
pctx.HostBinToolVariable("ManifestMergerCmd", "manifest-merger")
|
2018-11-12 19:13:39 +01:00
|
|
|
|
2020-08-12 17:48:23 +02:00
|
|
|
pctx.HostBinToolVariable("Class2NonSdkList", "class2nonsdklist")
|
2019-01-17 00:15:52 +01:00
|
|
|
pctx.HostBinToolVariable("HiddenAPI", "hiddenapi")
|
2019-08-08 21:56:34 +02:00
|
|
|
|
|
|
|
hostBinToolVariableWithSdkToolsPrebuilt("Aapt2Cmd", "aapt2")
|
|
|
|
hostBinToolVariableWithBuildToolsPrebuilt("AidlCmd", "aidl")
|
|
|
|
hostBinToolVariableWithBuildToolsPrebuilt("ZipAlign", "zipalign")
|
|
|
|
|
|
|
|
hostJavaToolVariableWithSdkToolsPrebuilt("SignapkCmd", "signapk")
|
|
|
|
// TODO(ccross): this should come from the signapk dependencies, but we don't have any way
|
|
|
|
// to express host JNI dependencies yet.
|
|
|
|
hostJNIToolVariableWithSdkToolsPrebuilt("SignapkJniLibrary", "libconscrypt_openjdk_jni")
|
|
|
|
}
|
|
|
|
|
|
|
|
func hostBinToolVariableWithSdkToolsPrebuilt(name, tool string) {
|
|
|
|
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
|
2020-05-29 00:28:00 +02:00
|
|
|
if ctx.Config().AlwaysUsePrebuiltSdks() {
|
2019-08-08 21:56:34 +02:00
|
|
|
return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin", tool)
|
|
|
|
} else {
|
2019-12-09 22:47:14 +01:00
|
|
|
return ctx.Config().HostToolPath(ctx, tool).String()
|
2019-08-08 21:56:34 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func hostJavaToolVariableWithSdkToolsPrebuilt(name, tool string) {
|
|
|
|
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
|
2020-05-29 00:28:00 +02:00
|
|
|
if ctx.Config().AlwaysUsePrebuiltSdks() {
|
2019-08-08 21:56:34 +02:00
|
|
|
return filepath.Join("prebuilts/sdk/tools/lib", tool+".jar")
|
|
|
|
} else {
|
2019-12-09 22:47:14 +01:00
|
|
|
return ctx.Config().HostJavaToolPath(ctx, tool+".jar").String()
|
2019-08-08 21:56:34 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func hostJNIToolVariableWithSdkToolsPrebuilt(name, tool string) {
|
|
|
|
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
|
2020-05-29 00:28:00 +02:00
|
|
|
if ctx.Config().AlwaysUsePrebuiltSdks() {
|
2019-08-08 21:56:34 +02:00
|
|
|
ext := ".so"
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
ext = ".dylib"
|
|
|
|
}
|
|
|
|
return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "lib64", tool+ext)
|
|
|
|
} else {
|
2019-12-09 22:47:14 +01:00
|
|
|
return ctx.Config().HostJNIToolPath(ctx, tool).String()
|
2019-08-08 21:56:34 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func hostBinToolVariableWithBuildToolsPrebuilt(name, tool string) {
|
|
|
|
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
|
2020-05-29 00:28:00 +02:00
|
|
|
if ctx.Config().AlwaysUsePrebuiltSdks() {
|
2019-08-08 21:56:34 +02:00
|
|
|
return filepath.Join("prebuilts/build-tools", ctx.Config().PrebuiltOS(), "bin", tool)
|
|
|
|
} else {
|
2019-12-09 22:47:14 +01:00
|
|
|
return ctx.Config().HostToolPath(ctx, tool).String()
|
2019-08-08 21:56:34 +02:00
|
|
|
}
|
|
|
|
})
|
2017-08-08 22:17:59 +02:00
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
// JavaCmd returns a SourcePath object with the path to the java command.
|
|
|
|
func JavaCmd(ctx android.PathContext) android.SourcePath {
|
|
|
|
return javaTool(ctx, "java")
|
|
|
|
}
|
|
|
|
|
|
|
|
// JavadocCmd returns a SourcePath object with the path to the java command.
|
|
|
|
func JavadocCmd(ctx android.PathContext) android.SourcePath {
|
|
|
|
return javaTool(ctx, "javadoc")
|
|
|
|
}
|
|
|
|
|
|
|
|
func javaTool(ctx android.PathContext, tool string) android.SourcePath {
|
|
|
|
type javaToolKey string
|
|
|
|
|
|
|
|
key := android.NewCustomOnceKey(javaToolKey(tool))
|
|
|
|
|
|
|
|
return ctx.Config().OnceSourcePath(key, func() android.SourcePath {
|
|
|
|
return javaToolchain(ctx).Join(ctx, tool)
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var javaToolchainKey = android.NewOnceKey("javaToolchain")
|
|
|
|
|
|
|
|
func javaToolchain(ctx android.PathContext) android.SourcePath {
|
|
|
|
return ctx.Config().OnceSourcePath(javaToolchainKey, func() android.SourcePath {
|
|
|
|
return javaHome(ctx).Join(ctx, "bin")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
var javaHomeKey = android.NewOnceKey("javaHome")
|
|
|
|
|
|
|
|
func javaHome(ctx android.PathContext) android.SourcePath {
|
|
|
|
return ctx.Config().OnceSourcePath(javaHomeKey, func() android.SourcePath {
|
|
|
|
// This is set up and guaranteed by soong_ui
|
|
|
|
return android.PathForSource(ctx, ctx.Config().Getenv("ANDROID_JAVA_HOME"))
|
|
|
|
})
|
|
|
|
}
|