| 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" | 
| Ramy Medhat | 1dcc27e | 2020-04-21 21:36:23 -0400 | [diff] [blame] | 25 | "android/soong/remoteexec" | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 26 | ) | 
| Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 27 |  | 
|  | 28 | var ( | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 29 | pctx = android.NewPackageContext("android/soong/java/config") | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 30 |  | 
| Pete Gillin | 0638dfc | 2020-07-01 10:48:14 +0100 | [diff] [blame] | 31 | LegacyCorePlatformBootclasspathLibraries = []string{"legacy.core.platform.api.stubs", "core-lambda-stubs"} | 
|  | 32 | LegacyCorePlatformSystemModules          = "legacy-core-platform-api-stubs-system-modules" | 
| Pete Gillin | 84c3807 | 2020-07-09 18:03:41 +0100 | [diff] [blame] | 33 | StableCorePlatformBootclasspathLibraries = []string{"stable.core.platform.api.stubs", "core-lambda-stubs"} | 
|  | 34 | StableCorePlatformSystemModules          = "stable-core-platform-api-stubs-system-modules" | 
| Pete Gillin | 0638dfc | 2020-07-01 10:48:14 +0100 | [diff] [blame] | 35 | FrameworkLibraries                       = []string{"ext", "framework"} | 
|  | 36 | DefaultLambdaStubsLibrary                = "core-lambda-stubs" | 
|  | 37 | SdkLambdaStubsPath                       = "prebuilts/sdk/tools/core-lambda-stubs.jar" | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 38 |  | 
| Chris Gross | 2f74869 | 2020-06-24 20:36:59 +0000 | [diff] [blame] | 39 | DefaultMakeJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"} | 
|  | 40 | DefaultJacocoExcludeFilter     = []string{"org.junit.**", "org.jacoco.**", "org.mockito.**"} | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 41 |  | 
|  | 42 | InstrumentFrameworkModules = []string{ | 
|  | 43 | "framework", | 
| Allen Hair | 74cd286 | 2019-11-07 15:09:15 -0800 | [diff] [blame] | 44 | "framework-minus-apex", | 
| Qing Shen | 871c6f3 | 2022-11-04 22:39:37 +0000 | [diff] [blame] | 45 | "ims-common", | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 46 | "telephony-common", | 
|  | 47 | "services", | 
|  | 48 | "android.car", | 
|  | 49 | "android.car7", | 
| Jihoon Kang | 6de6d72 | 2024-08-14 16:39:57 +0000 | [diff] [blame] | 50 | "android.car.builtin.impl", | 
| Adam Vartanian | fa62cfc | 2019-03-08 14:46:36 +0000 | [diff] [blame] | 51 | "conscrypt", | 
| Victor Chang | 07b5b4c | 2019-08-06 16:57:40 +0100 | [diff] [blame] | 52 | "core-icu4j", | 
| Pete Gillin | 7868a09 | 2017-12-19 15:01:39 +0000 | [diff] [blame] | 53 | "core-oj", | 
| Pete Gillin | 5d13354 | 2018-02-13 15:23:14 +0000 | [diff] [blame] | 54 | "core-libart", | 
| yangfan deng | a90cd1e | 2023-09-05 23:52:49 +0000 | [diff] [blame] | 55 | "wear-sdk.impl", | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 56 | } | 
| Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 57 | ) | 
|  | 58 |  | 
| Sam Delmerico | 932c01c | 2022-03-25 16:33:26 +0000 | [diff] [blame] | 59 | var ( | 
|  | 60 | JavacVmFlags    = strings.Join(javacVmFlagsList, " ") | 
|  | 61 | javaVmFlagsList = []string{ | 
|  | 62 | `-XX:OnError="cat hs_err_pid%p.log"`, | 
|  | 63 | "-XX:CICompilerCount=6", | 
|  | 64 | "-XX:+UseDynamicNumberOfGCThreads", | 
|  | 65 | } | 
|  | 66 | javacVmFlagsList = []string{ | 
|  | 67 | `-J-XX:OnError="cat hs_err_pid%p.log"`, | 
|  | 68 | "-J-XX:CICompilerCount=6", | 
|  | 69 | "-J-XX:+UseDynamicNumberOfGCThreads", | 
|  | 70 | "-J-XX:+TieredCompilation", | 
|  | 71 | "-J-XX:TieredStopAtLevel=1", | 
|  | 72 | } | 
| Ian Zerny | 727ab90 | 2022-04-22 11:41:36 +0200 | [diff] [blame] | 73 | dexerJavaVmFlagsList = []string{ | 
|  | 74 | `-JXX:OnError="cat hs_err_pid%p.log"`, | 
|  | 75 | "-JXX:CICompilerCount=6", | 
|  | 76 | "-JXX:+UseDynamicNumberOfGCThreads", | 
|  | 77 | } | 
| Colin Cross | 33961b5 | 2019-07-11 11:01:22 -0700 | [diff] [blame] | 78 | ) | 
|  | 79 |  | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 80 | func init() { | 
|  | 81 | pctx.Import("github.com/google/blueprint/bootstrap") | 
|  | 82 |  | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 83 | pctx.StaticVariable("JavacHeapSize", "4096M") | 
|  | 84 | pctx.StaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}") | 
| Colin Cross | 8bf6cad | 2022-02-28 13:07:03 -0800 | [diff] [blame] | 85 |  | 
|  | 86 | // ErrorProne can use significantly more memory than javac alone, give it a higher heap | 
|  | 87 | // size (b/221480398). | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 88 | pctx.StaticVariable("ErrorProneHeapSize", "8192M") | 
|  | 89 | pctx.StaticVariable("ErrorProneHeapFlags", "-J-Xmx${ErrorProneHeapSize}") | 
| Colin Cross | 8bf6cad | 2022-02-28 13:07:03 -0800 | [diff] [blame] | 90 |  | 
| Jared Duke | 0cf7c96 | 2022-04-20 20:28:33 +0000 | [diff] [blame] | 91 | // D8 invocations are shorter lived, so we restrict their JIT tiering relative to R8. | 
|  | 92 | // Note that the `-JXX` prefix syntax is specific to the R8/D8 invocation wrappers. | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 93 | pctx.StaticVariable("D8Flags", strings.Join(append([]string{ | 
| Jordan Demeulenaere | c33f799 | 2022-08-08 11:40:15 +0200 | [diff] [blame] | 94 | "-JXmx4096M", | 
| Jared Duke | 0cf7c96 | 2022-04-20 20:28:33 +0000 | [diff] [blame] | 95 | "-JXX:+TieredCompilation", | 
|  | 96 | "-JXX:TieredStopAtLevel=1", | 
| Sorin Basca | cc9eee0 | 2022-09-13 15:05:47 +0100 | [diff] [blame] | 97 | "-JDcom.android.tools.r8.emitRecordAnnotationsInDex", | 
| Sorin Basca | de8d7a2 | 2022-07-13 08:41:50 +0100 | [diff] [blame] | 98 | "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex", | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 99 | }, dexerJavaVmFlagsList...), " ")) | 
|  | 100 | pctx.StaticVariable("R8Flags", strings.Join(append([]string{ | 
| Jared Duke | 3e65f2a | 2023-05-23 17:32:30 +0000 | [diff] [blame] | 101 | "-JXmx4096M", | 
| Sorin Basca | cc9eee0 | 2022-09-13 15:05:47 +0100 | [diff] [blame] | 102 | "-JDcom.android.tools.r8.emitRecordAnnotationsInDex", | 
| Sorin Basca | de8d7a2 | 2022-07-13 08:41:50 +0100 | [diff] [blame] | 103 | "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex", | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 104 | }, dexerJavaVmFlagsList...), " ")) | 
| Colin Cross | 3203dde | 2017-08-28 17:23:21 -0700 | [diff] [blame] | 105 |  | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 106 | pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{ | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 107 | `-Xmaxerrs 9999999`, | 
|  | 108 | `-encoding UTF-8`, | 
|  | 109 | `-sourcepath ""`, | 
|  | 110 | `-g`, | 
| Colin Cross | 945c000 | 2017-09-19 10:52:23 -0700 | [diff] [blame] | 111 | // Turbine leaves out bridges which can cause javac to unnecessarily insert them into | 
|  | 112 | // subclasses (b/65645120).  Setting this flag causes our custom javac to assume that | 
|  | 113 | // the missing bridges will exist at runtime and not recreate them in subclasses. | 
|  | 114 | // If a different javac is used the flag will be ignored and extra bridges will be inserted. | 
|  | 115 | // The flag is implemented by https://android-review.googlesource.com/c/486427 | 
|  | 116 | `-XDskipDuplicateBridges=true`, | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 117 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 118 | // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9 | 
|  | 119 | `-XDstringConcat=inline`, | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 120 | }, " ")) | 
| Colin Cross | 33961b5 | 2019-07-11 11:01:22 -0700 | [diff] [blame] | 121 |  | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 122 | pctx.StaticVariable("JavaVmFlags", strings.Join(javaVmFlagsList, " ")) | 
|  | 123 | pctx.StaticVariable("JavacVmFlags", strings.Join(javacVmFlagsList, " ")) | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 124 |  | 
|  | 125 | pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS) | 
|  | 126 |  | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 127 | pctx.VariableFunc("JavaHome", func(ctx android.PackageVarContext) string { | 
| Dan Willemsen | d9e8f0a | 2017-10-30 13:42:06 -0700 | [diff] [blame] | 128 | // This is set up and guaranteed by soong_ui | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 129 | return ctx.Config().Getenv("ANDROID_JAVA_HOME") | 
| Colin Cross | e2ad230 | 2017-10-05 16:48:56 -0700 | [diff] [blame] | 130 | }) | 
| Pete Gillin | 1f52e93 | 2019-10-09 17:10:08 +0100 | [diff] [blame] | 131 | pctx.VariableFunc("JlinkVersion", func(ctx android.PackageVarContext) string { | 
| Pete Gillin | a2affbb | 2019-11-07 18:55:53 +0000 | [diff] [blame] | 132 | if override := ctx.Config().Getenv("OVERRIDE_JLINK_VERSION_NUMBER"); override != "" { | 
|  | 133 | return override | 
|  | 134 | } | 
| Sorin Basca | 6c47e66 | 2024-03-11 17:23:06 +0000 | [diff] [blame] | 135 | return "21" | 
| Pete Gillin | 1f52e93 | 2019-10-09 17:10:08 +0100 | [diff] [blame] | 136 | }) | 
| Colin Cross | e2ad230 | 2017-10-05 16:48:56 -0700 | [diff] [blame] | 137 |  | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 138 | pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin") | 
|  | 139 | pctx.SourcePathVariableWithEnvOverride("JavacCmd", | 
|  | 140 | "${JavaToolchain}/javac", "ALTERNATE_JAVAC") | 
|  | 141 | pctx.SourcePathVariable("JavaCmd", "${JavaToolchain}/java") | 
|  | 142 | pctx.SourcePathVariable("JarCmd", "${JavaToolchain}/jar") | 
| Sorin Basca | 4ad3dc6 | 2022-10-12 19:57:42 +0000 | [diff] [blame] | 143 | pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc") | 
| Tobias Thierer | 77d0b41 | 2017-08-31 16:08:39 +0100 | [diff] [blame] | 144 | pctx.SourcePathVariable("JlinkCmd", "${JavaToolchain}/jlink") | 
|  | 145 | pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod") | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 146 | pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar") | 
| Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 147 | pctx.SourcePathVariable("JavaKytheExtractorJar", "prebuilts/build-tools/common/framework/javac_extractor.jar") | 
| Spandan Das | 1028d5a | 2024-08-19 21:45:48 +0000 | [diff] [blame] | 148 | pctx.SourcePathVariable("KotlinKytheExtractor", "prebuilts/build-tools/${hostPrebuiltTag}/bin/kotlinc_extractor") | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 149 | pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime") | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 150 |  | 
| Colin Cross | 4eae06d | 2023-06-20 22:40:02 -0700 | [diff] [blame] | 151 | pctx.SourcePathVariable("ResourceProcessorBusyBox", "prebuilts/bazel/common/android_tools/android_tools/all_android_tools_deploy.jar") | 
|  | 152 |  | 
| Cole Faust | bcc3d05 | 2022-09-01 15:20:00 -0700 | [diff] [blame] | 153 | pctx.HostBinToolVariable("GenKotlinBuildFileCmd", "gen-kotlin-build-file") | 
| Przemyslaw Szczepaniak | 4b5fe9d | 2018-02-13 14:32:54 +0000 | [diff] [blame] | 154 |  | 
| Colin Cross | b852a58 | 2017-08-10 17:58:12 -0700 | [diff] [blame] | 155 | pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh") | 
| Vladimir Marko | 0975ee0 | 2019-04-02 10:29:55 +0100 | [diff] [blame] | 156 | pctx.SourcePathVariable("PackageCheckCmd", "build/soong/scripts/package-check.sh") | 
| Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 157 | pctx.HostBinToolVariable("ExtractJarPackagesCmd", "extract_jar_packages") | 
| Colin Cross | a482065 | 2017-10-17 13:56:52 -0700 | [diff] [blame] | 158 | pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") | 
|  | 159 | pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips") | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 160 | pctx.HostBinToolVariable("Zip2ZipCmd", "zip2zip") | 
| Colin Cross | 436b765 | 2018-03-15 16:24:10 -0700 | [diff] [blame] | 161 | pctx.HostBinToolVariable("ZipSyncCmd", "zipsync") | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 162 | pctx.HostBinToolVariable("ApiCheckCmd", "apicheck") | 
| Colin Cross | c899d78 | 2021-11-04 10:25:20 -0700 | [diff] [blame] | 163 | pctx.HostBinToolVariable("D8Cmd", "d8") | 
| Ian Zerny | dc2893a | 2022-06-20 09:53:04 +0200 | [diff] [blame] | 164 | pctx.HostBinToolVariable("R8Cmd", "r8") | 
| Rico Wind | 351bac9 | 2022-09-22 10:41:42 +0200 | [diff] [blame] | 165 | pctx.HostBinToolVariable("ResourceShrinkerCmd", "resourceshrinker") | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 166 | pctx.HostBinToolVariable("HiddenAPICmd", "hiddenapi") | 
| Sasha Smundak | a7856c0 | 2020-04-23 09:49:59 -0700 | [diff] [blame] | 167 | pctx.HostBinToolVariable("ExtractApksCmd", "extract_apks") | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 168 | pctx.VariableFunc("TurbineJar", func(ctx android.PackageVarContext) string { | 
| Nan Zhang | 9a36418 | 2017-10-25 11:11:37 -0700 | [diff] [blame] | 169 | turbine := "turbine.jar" | 
| Jeongik Cha | 816a23a | 2020-07-08 01:09:23 +0900 | [diff] [blame] | 170 | if ctx.Config().AlwaysUsePrebuiltSdks() { | 
| Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 171 | return "prebuilts/build-tools/common/framework/" + turbine | 
| Nan Zhang | 9a36418 | 2017-10-25 11:11:37 -0700 | [diff] [blame] | 172 | } else { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 173 | return ctx.Config().HostJavaToolPath(ctx, turbine).String() | 
| Nan Zhang | 9a36418 | 2017-10-25 11:11:37 -0700 | [diff] [blame] | 174 | } | 
|  | 175 | }) | 
| Alan Leung | 1d476fc | 2017-10-17 18:50:50 -0700 | [diff] [blame] | 176 |  | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 177 | pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar") | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 178 | pctx.HostJavaToolVariable("JsilverJar", "jsilver.jar") | 
|  | 179 | pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar") | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 180 | pctx.HostJavaToolVariable("MetalavaJar", "metalava.jar") | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 181 | pctx.HostJavaToolVariable("DokkaJar", "dokka.jar") | 
| Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 182 | pctx.HostJavaToolVariable("JetifierJar", "jetifier.jar") | 
| Ian Zerny | dc2893a | 2022-06-20 09:53:04 +0200 | [diff] [blame] | 183 | pctx.HostJavaToolVariable("R8Jar", "r8.jar") | 
| Ramy Medhat | 1dcc27e | 2020-04-21 21:36:23 -0400 | [diff] [blame] | 184 | pctx.HostJavaToolVariable("D8Jar", "d8.jar") | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 185 |  | 
| Colin Cross | a482065 | 2017-10-17 13:56:52 -0700 | [diff] [blame] | 186 | pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 187 | pctx.HostBinToolVariable("DexpreoptGen", "dexpreopt_gen") | 
| Colin Cross | a482065 | 2017-10-17 13:56:52 -0700 | [diff] [blame] | 188 |  | 
| Colin Cross | 77cdcfd | 2021-03-12 11:28:25 -0800 | [diff] [blame] | 189 | pctx.StaticVariableWithEnvOverride("REJavaPool", "RBE_JAVA_POOL", "java16") | 
|  | 190 | pctx.StaticVariableWithEnvOverride("REJavacExecStrategy", "RBE_JAVAC_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy) | 
|  | 191 | pctx.StaticVariableWithEnvOverride("RED8ExecStrategy", "RBE_D8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy) | 
|  | 192 | pctx.StaticVariableWithEnvOverride("RER8ExecStrategy", "RBE_R8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy) | 
|  | 193 | pctx.StaticVariableWithEnvOverride("RETurbineExecStrategy", "RBE_TURBINE_EXEC_STRATEGY", remoteexec.LocalExecStrategy) | 
|  | 194 | pctx.StaticVariableWithEnvOverride("RESignApkExecStrategy", "RBE_SIGNAPK_EXEC_STRATEGY", remoteexec.LocalExecStrategy) | 
|  | 195 | pctx.StaticVariableWithEnvOverride("REJarExecStrategy", "RBE_JAR_EXEC_STRATEGY", remoteexec.LocalExecStrategy) | 
|  | 196 | pctx.StaticVariableWithEnvOverride("REZipExecStrategy", "RBE_ZIP_EXEC_STRATEGY", remoteexec.LocalExecStrategy) | 
| Ramy Medhat | 8ea054a | 2020-01-27 14:19:44 -0500 | [diff] [blame] | 197 |  | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 198 | pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar") | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 199 |  | 
| Colin Cross | 7211910 | 2019-05-20 13:14:18 -0700 | [diff] [blame] | 200 | pctx.HostBinToolVariable("ManifestCheckCmd", "manifest_check") | 
| Colin Cross | 4af387c | 2019-05-16 13:16:29 -0700 | [diff] [blame] | 201 | pctx.HostBinToolVariable("ManifestFixerCmd", "manifest_fixer") | 
| Colin Cross | cfae5a6 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 202 |  | 
| Colin Cross | 87ecbfe | 2019-02-26 22:14:04 -0800 | [diff] [blame] | 203 | pctx.HostBinToolVariable("ManifestMergerCmd", "manifest-merger") | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 204 |  | 
| Andrei Onea | 23fea04 | 2020-08-12 16:48:23 +0100 | [diff] [blame] | 205 | pctx.HostBinToolVariable("Class2NonSdkList", "class2nonsdklist") | 
| Cole Faust | a5f64f0 | 2023-02-14 17:50:31 -0800 | [diff] [blame] | 206 | pctx.HostBinToolVariable("MergeCsvCommand", "merge_csv") | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 207 | pctx.HostBinToolVariable("HiddenAPI", "hiddenapi") | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 208 |  | 
|  | 209 | hostBinToolVariableWithSdkToolsPrebuilt("Aapt2Cmd", "aapt2") | 
|  | 210 | hostBinToolVariableWithBuildToolsPrebuilt("AidlCmd", "aidl") | 
|  | 211 | hostBinToolVariableWithBuildToolsPrebuilt("ZipAlign", "zipalign") | 
|  | 212 |  | 
|  | 213 | hostJavaToolVariableWithSdkToolsPrebuilt("SignapkCmd", "signapk") | 
|  | 214 | // TODO(ccross): this should come from the signapk dependencies, but we don't have any way | 
|  | 215 | // to express host JNI dependencies yet. | 
|  | 216 | hostJNIToolVariableWithSdkToolsPrebuilt("SignapkJniLibrary", "libconscrypt_openjdk_jni") | 
|  | 217 | } | 
|  | 218 |  | 
|  | 219 | func hostBinToolVariableWithSdkToolsPrebuilt(name, tool string) { | 
|  | 220 | pctx.VariableFunc(name, func(ctx android.PackageVarContext) string { | 
| Dan Willemsen | 9f43597 | 2020-05-28 15:28:00 -0700 | [diff] [blame] | 221 | if ctx.Config().AlwaysUsePrebuiltSdks() { | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 222 | return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin", tool) | 
|  | 223 | } else { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 224 | return ctx.Config().HostToolPath(ctx, tool).String() | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 225 | } | 
|  | 226 | }) | 
|  | 227 | } | 
|  | 228 |  | 
|  | 229 | func hostJavaToolVariableWithSdkToolsPrebuilt(name, tool string) { | 
|  | 230 | pctx.VariableFunc(name, func(ctx android.PackageVarContext) string { | 
| Dan Willemsen | 9f43597 | 2020-05-28 15:28:00 -0700 | [diff] [blame] | 231 | if ctx.Config().AlwaysUsePrebuiltSdks() { | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 232 | return filepath.Join("prebuilts/sdk/tools/lib", tool+".jar") | 
|  | 233 | } else { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 234 | return ctx.Config().HostJavaToolPath(ctx, tool+".jar").String() | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 235 | } | 
|  | 236 | }) | 
|  | 237 | } | 
|  | 238 |  | 
|  | 239 | func hostJNIToolVariableWithSdkToolsPrebuilt(name, tool string) { | 
|  | 240 | pctx.VariableFunc(name, func(ctx android.PackageVarContext) string { | 
| Dan Willemsen | 9f43597 | 2020-05-28 15:28:00 -0700 | [diff] [blame] | 241 | if ctx.Config().AlwaysUsePrebuiltSdks() { | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 242 | ext := ".so" | 
|  | 243 | if runtime.GOOS == "darwin" { | 
|  | 244 | ext = ".dylib" | 
|  | 245 | } | 
|  | 246 | return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "lib64", tool+ext) | 
|  | 247 | } else { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 248 | return ctx.Config().HostJNIToolPath(ctx, tool).String() | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 249 | } | 
|  | 250 | }) | 
|  | 251 | } | 
|  | 252 |  | 
|  | 253 | func hostBinToolVariableWithBuildToolsPrebuilt(name, tool string) { | 
|  | 254 | pctx.VariableFunc(name, func(ctx android.PackageVarContext) string { | 
| Dan Willemsen | 9f43597 | 2020-05-28 15:28:00 -0700 | [diff] [blame] | 255 | if ctx.Config().AlwaysUsePrebuiltSdks() { | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 256 | return filepath.Join("prebuilts/build-tools", ctx.Config().PrebuiltOS(), "bin", tool) | 
|  | 257 | } else { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 258 | return ctx.Config().HostToolPath(ctx, tool).String() | 
| Colin Cross | bdf9514 | 2019-08-08 12:56:34 -0700 | [diff] [blame] | 259 | } | 
|  | 260 | }) | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 261 | } | 
| Colin Cross | 33961b5 | 2019-07-11 11:01:22 -0700 | [diff] [blame] | 262 |  | 
|  | 263 | // JavaCmd returns a SourcePath object with the path to the java command. | 
|  | 264 | func JavaCmd(ctx android.PathContext) android.SourcePath { | 
|  | 265 | return javaTool(ctx, "java") | 
|  | 266 | } | 
|  | 267 |  | 
|  | 268 | // JavadocCmd returns a SourcePath object with the path to the java command. | 
|  | 269 | func JavadocCmd(ctx android.PathContext) android.SourcePath { | 
| Sorin Basca | 4ad3dc6 | 2022-10-12 19:57:42 +0000 | [diff] [blame] | 270 | return javaTool(ctx, "javadoc") | 
| Colin Cross | 33961b5 | 2019-07-11 11:01:22 -0700 | [diff] [blame] | 271 | } | 
|  | 272 |  | 
|  | 273 | func javaTool(ctx android.PathContext, tool string) android.SourcePath { | 
|  | 274 | type javaToolKey string | 
|  | 275 |  | 
|  | 276 | key := android.NewCustomOnceKey(javaToolKey(tool)) | 
|  | 277 |  | 
|  | 278 | return ctx.Config().OnceSourcePath(key, func() android.SourcePath { | 
|  | 279 | return javaToolchain(ctx).Join(ctx, tool) | 
|  | 280 | }) | 
|  | 281 |  | 
|  | 282 | } | 
|  | 283 |  | 
|  | 284 | var javaToolchainKey = android.NewOnceKey("javaToolchain") | 
|  | 285 |  | 
|  | 286 | func javaToolchain(ctx android.PathContext) android.SourcePath { | 
|  | 287 | return ctx.Config().OnceSourcePath(javaToolchainKey, func() android.SourcePath { | 
|  | 288 | return javaHome(ctx).Join(ctx, "bin") | 
|  | 289 | }) | 
|  | 290 | } | 
|  | 291 |  | 
|  | 292 | var javaHomeKey = android.NewOnceKey("javaHome") | 
|  | 293 |  | 
|  | 294 | func javaHome(ctx android.PathContext) android.SourcePath { | 
|  | 295 | return ctx.Config().OnceSourcePath(javaHomeKey, func() android.SourcePath { | 
|  | 296 | // This is set up and guaranteed by soong_ui | 
|  | 297 | return android.PathForSource(ctx, ctx.Config().Getenv("ANDROID_JAVA_HOME")) | 
|  | 298 | }) | 
|  | 299 | } |