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"
|
|
|
|
)
|
2017-06-23 02:20:19 +02:00
|
|
|
|
|
|
|
var (
|
2017-08-08 22:17:59 +02:00
|
|
|
pctx = android.NewPackageContext("android/soong/java/config")
|
|
|
|
|
2017-09-24 04:57:16 +02:00
|
|
|
DefaultBootclasspathLibraries = []string{"core-oj", "core-libart"}
|
2017-09-30 02:58:17 +02:00
|
|
|
DefaultSystemModules = "core-system-modules"
|
2017-09-24 04:57:16 +02:00
|
|
|
DefaultLibraries = []string{"ext", "framework", "okhttp"}
|
2017-11-22 22:49:43 +01:00
|
|
|
|
|
|
|
DefaultJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"}
|
|
|
|
|
|
|
|
InstrumentFrameworkModules = []string{
|
|
|
|
"framework",
|
|
|
|
"telephony-common",
|
|
|
|
"services",
|
|
|
|
"android.car",
|
|
|
|
"android.car7",
|
|
|
|
}
|
2017-06-23 02:20:19 +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}")
|
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`,
|
|
|
|
}, " "))
|
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
|
|
|
})
|
|
|
|
|
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")
|
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
|
|
|
|
2018-02-13 15:32:54 +01:00
|
|
|
pctx.SourcePathVariable("GenKotlinBuildFileCmd", "build/soong/scripts/gen-kotlin-build-file.sh")
|
|
|
|
|
2017-08-11 02:58:12 +02:00
|
|
|
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
|
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-03-12 21:24:09 +01:00
|
|
|
pctx.VariableFunc("DxCmd", func(ctx android.PackageVarContext) string {
|
|
|
|
config := ctx.Config()
|
2017-11-29 02:34:01 +01:00
|
|
|
if config.IsEnvFalse("USE_D8") {
|
|
|
|
if config.UnbundledBuild() || config.IsPdkBuild() {
|
2018-03-12 21:24:09 +01:00
|
|
|
return "prebuilts/build-tools/common/bin/dx"
|
2017-10-23 14:55:05 +02:00
|
|
|
} else {
|
2018-03-12 21:24:09 +01:00
|
|
|
return pctx.HostBinToolPath(ctx, "dx").String()
|
2017-10-23 14:55:05 +02:00
|
|
|
}
|
2017-10-18 03:50:50 +02:00
|
|
|
} else {
|
2018-03-12 21:24:09 +01:00
|
|
|
return pctx.HostBinToolPath(ctx, "d8-compat-dx").String()
|
2017-10-18 03:50:50 +02:00
|
|
|
}
|
|
|
|
})
|
2017-12-23 00:56:08 +01:00
|
|
|
pctx.HostBinToolVariable("D8Cmd", "d8")
|
2017-12-28 21:23:20 +01:00
|
|
|
pctx.HostBinToolVariable("R8Cmd", "r8-compat-proguard")
|
2017-12-23 00:56:08 +01:00
|
|
|
|
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"
|
2018-03-12 21:24:09 +01:00
|
|
|
if ctx.Config().UnbundledBuild() {
|
|
|
|
return "prebuilts/build-tools/common/framework/" + turbine
|
2017-10-25 20:11:37 +02:00
|
|
|
} else {
|
2018-03-12 21:24:09 +01:00
|
|
|
return pctx.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")
|
2017-09-15 22:00:47 +02:00
|
|
|
pctx.HostJavaToolVariable("DesugarJar", "desugar.jar")
|
2018-01-11 01:06:12 +01:00
|
|
|
pctx.HostJavaToolVariable("JsilverJar", "jsilver.jar")
|
|
|
|
pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar")
|
2017-08-08 22:17:59 +02:00
|
|
|
|
2017-10-17 22:56:52 +02:00
|
|
|
pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper")
|
|
|
|
|
2018-03-12 21:24:09 +01:00
|
|
|
pctx.VariableFunc("JavacWrapper", func(ctx android.PackageVarContext) string {
|
|
|
|
if override := ctx.Config().Getenv("JAVAC_WRAPPER"); override != "" {
|
|
|
|
return override + " "
|
2017-08-08 22:17:59 +02:00
|
|
|
}
|
2018-03-12 21:24:09 +01:00
|
|
|
return ""
|
2017-08-08 22:17:59 +02:00
|
|
|
})
|
2017-11-22 22:49:43 +01:00
|
|
|
|
|
|
|
pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
|
2017-11-23 01:19:37 +01:00
|
|
|
|
|
|
|
hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) {
|
2018-03-12 21:24:09 +01:00
|
|
|
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
|
|
|
|
if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
|
|
|
|
return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool)
|
2017-11-23 01:19:37 +01:00
|
|
|
} else {
|
2018-03-12 21:24:09 +01:00
|
|
|
return pctx.HostBinToolPath(ctx, tool).String()
|
2017-11-23 01:19:37 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-12-03 01:14:26 +01:00
|
|
|
hostBinToolVariableWithPrebuilt("Aapt2Cmd", "prebuilts/sdk/tools", "aapt2")
|
2017-08-08 22:17:59 +02:00
|
|
|
}
|