Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 1 | // Copyright 2017 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package config |
| 16 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 17 | import ( |
Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 18 | "path/filepath" |
| 19 | "runtime" |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 20 | "strings" |
| 21 | |
| 22 | _ "github.com/google/blueprint/bootstrap" |
| 23 | |
| 24 | "android/soong/android" |
| 25 | ) |
Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 26 | |
| 27 | var ( |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 28 | pctx = android.NewPackageContext("android/soong/java/config") |
| 29 | |
Neil Fuller | 6095259 | 2018-08-24 14:45:18 +0100 | [diff] [blame] | 30 | DefaultBootclasspathLibraries = []string{"core-oj", "core-libart", "core-simple"} |
Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 31 | DefaultSystemModules = "core-system-modules" |
Colin Cross | cb2c929 | 2017-09-23 19:57:16 -0700 | [diff] [blame] | 32 | DefaultLibraries = []string{"ext", "framework", "okhttp"} |
Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 33 | DefaultLambdaStubsLibrary = "core-lambda-stubs" |
| 34 | SdkLambdaStubsPath = "prebuilts/sdk/tools/core-lambda-stubs.jar" |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 35 | |
| 36 | DefaultJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"} |
| 37 | |
| 38 | InstrumentFrameworkModules = []string{ |
| 39 | "framework", |
| 40 | "telephony-common", |
| 41 | "services", |
| 42 | "android.car", |
| 43 | "android.car7", |
Pete Gillin | 7868a09 | 2017-12-19 15:01:39 +0000 | [diff] [blame] | 44 | "core-oj", |
Pete Gillin | 5d13354 | 2018-02-13 15:23:14 +0000 | [diff] [blame] | 45 | "core-libart", |
Neil Fuller | 6095259 | 2018-08-24 14:45:18 +0100 | [diff] [blame] | 46 | "core-simple", |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 47 | } |
Colin Cross | cfae5a6 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 48 | |
| 49 | ManifestMergerClasspath = []string{ |
| 50 | "prebuilts/gradle-plugin/com/android/tools/build/manifest-merger/26.1.0/manifest-merger-26.1.0.jar", |
| 51 | "prebuilts/gradle-plugin/com/android/tools/common/26.1.0/common-26.1.0.jar", |
| 52 | "prebuilts/gradle-plugin/com/android/tools/sdk-common/26.1.0/sdk-common-26.1.0.jar", |
| 53 | "prebuilts/gradle-plugin/com/android/tools/sdklib/26.1.0/sdklib-26.1.0.jar", |
| 54 | "prebuilts/gradle-plugin/org/jetbrains/kotlin/kotlin-runtime/1.0.5/kotlin-runtime-1.0.5.jar", |
| 55 | "prebuilts/gradle-plugin/org/jetbrains/kotlin/kotlin-stdlib/1.1.3/kotlin-stdlib-1.1.3.jar", |
| 56 | "prebuilts/misc/common/guava/guava-21.0.jar", |
| 57 | } |
Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 58 | ) |
| 59 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 60 | func init() { |
| 61 | pctx.Import("github.com/google/blueprint/bootstrap") |
| 62 | |
Colin Cross | fee57cb | 2017-09-05 13:16:45 -0700 | [diff] [blame] | 63 | pctx.StaticVariable("JavacHeapSize", "2048M") |
| 64 | pctx.StaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}") |
Colin Cross | 3203dde | 2017-08-28 17:23:21 -0700 | [diff] [blame] | 65 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 66 | pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{ |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 67 | `-Xmaxerrs 9999999`, |
| 68 | `-encoding UTF-8`, |
| 69 | `-sourcepath ""`, |
| 70 | `-g`, |
Colin Cross | 945c000 | 2017-09-19 10:52:23 -0700 | [diff] [blame] | 71 | // Turbine leaves out bridges which can cause javac to unnecessarily insert them into |
| 72 | // subclasses (b/65645120). Setting this flag causes our custom javac to assume that |
| 73 | // the missing bridges will exist at runtime and not recreate them in subclasses. |
| 74 | // If a different javac is used the flag will be ignored and extra bridges will be inserted. |
| 75 | // The flag is implemented by https://android-review.googlesource.com/c/486427 |
| 76 | `-XDskipDuplicateBridges=true`, |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 77 | |
Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 78 | // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9 |
| 79 | `-XDstringConcat=inline`, |
| 80 | }, " ")) |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 81 | |
| 82 | pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS) |
| 83 | |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 84 | pctx.VariableFunc("JavaHome", func(ctx android.PackageVarContext) string { |
Dan Willemsen | d9e8f0a | 2017-10-30 13:42:06 -0700 | [diff] [blame] | 85 | // This is set up and guaranteed by soong_ui |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 86 | return ctx.Config().Getenv("ANDROID_JAVA_HOME") |
Colin Cross | e2ad230 | 2017-10-05 16:48:56 -0700 | [diff] [blame] | 87 | }) |
| 88 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 89 | pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin") |
| 90 | pctx.SourcePathVariableWithEnvOverride("JavacCmd", |
| 91 | "${JavaToolchain}/javac", "ALTERNATE_JAVAC") |
| 92 | pctx.SourcePathVariable("JavaCmd", "${JavaToolchain}/java") |
| 93 | pctx.SourcePathVariable("JarCmd", "${JavaToolchain}/jar") |
| 94 | pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc") |
Tobias Thierer | 77d0b41 | 2017-08-31 16:08:39 +0100 | [diff] [blame] | 95 | pctx.SourcePathVariable("JlinkCmd", "${JavaToolchain}/jlink") |
| 96 | pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod") |
Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 97 | pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar") |
Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 98 | pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime") |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 99 | |
Przemyslaw Szczepaniak | 4b5fe9d | 2018-02-13 14:32:54 +0000 | [diff] [blame] | 100 | pctx.SourcePathVariable("GenKotlinBuildFileCmd", "build/soong/scripts/gen-kotlin-build-file.sh") |
| 101 | |
Colin Cross | b852a58 | 2017-08-10 17:58:12 -0700 | [diff] [blame] | 102 | pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh") |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 103 | pctx.HostBinToolVariable("ExtractJarPackagesCmd", "extract_jar_packages") |
Colin Cross | a482065 | 2017-10-17 13:56:52 -0700 | [diff] [blame] | 104 | pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") |
| 105 | pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips") |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 106 | pctx.HostBinToolVariable("Zip2ZipCmd", "zip2zip") |
Colin Cross | 436b765 | 2018-03-15 16:24:10 -0700 | [diff] [blame] | 107 | pctx.HostBinToolVariable("ZipSyncCmd", "zipsync") |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 108 | pctx.HostBinToolVariable("ApiCheckCmd", "apicheck") |
Colin Cross | f0056cb | 2017-12-22 15:56:08 -0800 | [diff] [blame] | 109 | pctx.HostBinToolVariable("D8Cmd", "d8") |
Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 110 | pctx.HostBinToolVariable("R8Cmd", "r8-compat-proguard") |
Colin Cross | f0056cb | 2017-12-22 15:56:08 -0800 | [diff] [blame] | 111 | |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 112 | pctx.VariableFunc("TurbineJar", func(ctx android.PackageVarContext) string { |
Nan Zhang | 9a36418 | 2017-10-25 11:11:37 -0700 | [diff] [blame] | 113 | turbine := "turbine.jar" |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 114 | if ctx.Config().UnbundledBuild() { |
| 115 | return "prebuilts/build-tools/common/framework/" + turbine |
Nan Zhang | 9a36418 | 2017-10-25 11:11:37 -0700 | [diff] [blame] | 116 | } else { |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 117 | return pctx.HostJavaToolPath(ctx, turbine).String() |
Nan Zhang | 9a36418 | 2017-10-25 11:11:37 -0700 | [diff] [blame] | 118 | } |
| 119 | }) |
Alan Leung | 1d476fc | 2017-10-17 18:50:50 -0700 | [diff] [blame] | 120 | |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 121 | pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar") |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 122 | pctx.HostJavaToolVariable("JsilverJar", "jsilver.jar") |
| 123 | pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar") |
Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 124 | pctx.HostJavaToolVariable("MetalavaJar", "metalava.jar") |
Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 125 | pctx.HostJavaToolVariable("DokkaJar", "dokka.jar") |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 126 | |
Colin Cross | a482065 | 2017-10-17 13:56:52 -0700 | [diff] [blame] | 127 | pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper") |
| 128 | |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 129 | pctx.VariableFunc("JavacWrapper", func(ctx android.PackageVarContext) string { |
| 130 | if override := ctx.Config().Getenv("JAVAC_WRAPPER"); override != "" { |
| 131 | return override + " " |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 132 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 133 | return "" |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 134 | }) |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 135 | |
| 136 | pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar") |
Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 137 | |
| 138 | hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) { |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 139 | pctx.VariableFunc(name, func(ctx android.PackageVarContext) string { |
| 140 | if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() { |
| 141 | return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool) |
Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 142 | } else { |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 143 | return pctx.HostBinToolPath(ctx, tool).String() |
Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 144 | } |
| 145 | }) |
| 146 | } |
| 147 | |
Colin Cross | 42f3a76 | 2017-12-02 16:14:26 -0800 | [diff] [blame] | 148 | hostBinToolVariableWithPrebuilt("Aapt2Cmd", "prebuilts/sdk/tools", "aapt2") |
Colin Cross | 8bb10e8 | 2018-06-07 16:46:02 -0700 | [diff] [blame] | 149 | |
| 150 | pctx.SourcePathVariable("ManifestFixerCmd", "build/soong/scripts/manifest_fixer.py") |
Colin Cross | cfae5a6 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 151 | |
| 152 | pctx.SourcePathsVariable("ManifestMergerJars", " ", ManifestMergerClasspath...) |
| 153 | pctx.SourcePathsVariable("ManifestMergerClasspath", ":", ManifestMergerClasspath...) |
Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 154 | } |