Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1 | // Copyright 2015 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 java |
| 16 | |
| 17 | // This file contains the module types for compiling Java for Android, and converts the properties |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 18 | // into the flags and filenames necessary to pass to the Module. The final creation of the rules |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 19 | // is handled in builder.go |
| 20 | |
| 21 | import ( |
Colin Cross | f19b9bb | 2018-03-26 14:42:44 -0700 | [diff] [blame] | 22 | "fmt" |
Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 23 | "path/filepath" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 24 | "strings" |
| 25 | |
| 26 | "github.com/google/blueprint" |
Colin Cross | 76b5f0c | 2017-08-29 16:02:06 -0700 | [diff] [blame] | 27 | "github.com/google/blueprint/proptools" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 28 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 29 | "android/soong/android" |
Ulya Trafimovich | 31e444e | 2020-08-14 17:32:16 +0100 | [diff] [blame] | 30 | "android/soong/dexpreopt" |
Colin Cross | 3e3e72d | 2017-06-22 17:20:19 -0700 | [diff] [blame] | 31 | "android/soong/java/config" |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 32 | "android/soong/tradefed" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 33 | ) |
| 34 | |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 35 | func init() { |
Paul Duffin | 535e0a1 | 2021-03-30 23:34:32 +0100 | [diff] [blame] | 36 | registerJavaBuildComponents(android.InitRegistrationContext) |
Paul Duffin | 255f18e | 2019-12-13 11:22:16 +0000 | [diff] [blame] | 37 | |
Jaewoong Jung | bc15e3a | 2021-03-10 17:02:43 -0800 | [diff] [blame] | 38 | RegisterJavaSdkMemberTypes() |
| 39 | } |
| 40 | |
Paul Duffin | 535e0a1 | 2021-03-30 23:34:32 +0100 | [diff] [blame] | 41 | func registerJavaBuildComponents(ctx android.RegistrationContext) { |
Jaewoong Jung | bc15e3a | 2021-03-10 17:02:43 -0800 | [diff] [blame] | 42 | ctx.RegisterModuleType("java_defaults", DefaultsFactory) |
| 43 | |
| 44 | ctx.RegisterModuleType("java_library", LibraryFactory) |
| 45 | ctx.RegisterModuleType("java_library_static", LibraryStaticFactory) |
| 46 | ctx.RegisterModuleType("java_library_host", LibraryHostFactory) |
| 47 | ctx.RegisterModuleType("java_binary", BinaryFactory) |
| 48 | ctx.RegisterModuleType("java_binary_host", BinaryHostFactory) |
| 49 | ctx.RegisterModuleType("java_test", TestFactory) |
| 50 | ctx.RegisterModuleType("java_test_helper_library", TestHelperLibraryFactory) |
| 51 | ctx.RegisterModuleType("java_test_host", TestHostFactory) |
| 52 | ctx.RegisterModuleType("java_test_import", JavaTestImportFactory) |
| 53 | ctx.RegisterModuleType("java_import", ImportFactory) |
| 54 | ctx.RegisterModuleType("java_import_host", ImportFactoryHost) |
| 55 | ctx.RegisterModuleType("java_device_for_host", DeviceForHostFactory) |
| 56 | ctx.RegisterModuleType("java_host_for_device", HostForDeviceFactory) |
| 57 | ctx.RegisterModuleType("dex_import", DexImportFactory) |
| 58 | |
| 59 | ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 60 | ctx.BottomUp("dexpreopt_tool_deps", dexpreoptToolDepsMutator).Parallel() |
| 61 | }) |
| 62 | |
| 63 | ctx.RegisterSingletonType("logtags", LogtagsSingleton) |
| 64 | ctx.RegisterSingletonType("kythe_java_extract", kytheExtractJavaFactory) |
| 65 | } |
| 66 | |
| 67 | func RegisterJavaSdkMemberTypes() { |
Paul Duffin | 255f18e | 2019-12-13 11:22:16 +0000 | [diff] [blame] | 68 | // Register sdk member types. |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 69 | android.RegisterSdkMemberType(javaHeaderLibsSdkMemberType) |
Paul Duffin | 255f18e | 2019-12-13 11:22:16 +0000 | [diff] [blame] | 70 | |
Paul Duffin | 22ff0aa | 2021-02-04 11:15:34 +0000 | [diff] [blame] | 71 | // Export implementation classes jar as part of the sdk. |
| 72 | exportImplementationClassesJar := func(_ android.SdkMemberContext, j *Library) android.Path { |
| 73 | implementationJars := j.ImplementationAndResourcesJars() |
| 74 | if len(implementationJars) != 1 { |
| 75 | panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name())) |
| 76 | } |
| 77 | return implementationJars[0] |
| 78 | } |
| 79 | |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 80 | // Register java implementation libraries for use only in module_exports (not sdk). |
Paul Duffin | f5c0a9c | 2020-02-28 14:39:53 +0000 | [diff] [blame] | 81 | android.RegisterSdkMemberType(&librarySdkMemberType{ |
| 82 | android.SdkMemberTypeBase{ |
| 83 | PropertyName: "java_libs", |
| 84 | }, |
Paul Duffin | 22ff0aa | 2021-02-04 11:15:34 +0000 | [diff] [blame] | 85 | exportImplementationClassesJar, |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 86 | sdkSnapshotFilePathForJar, |
| 87 | copyEverythingToSnapshot, |
Paul Duffin | 255f18e | 2019-12-13 11:22:16 +0000 | [diff] [blame] | 88 | }) |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 89 | |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 90 | // Register java boot libraries for use in sdk. |
| 91 | // |
| 92 | // The build has some implicit dependencies (via the boot jars configuration) on a number of |
| 93 | // modules, e.g. core-oj, apache-xml, that are part of the java boot class path and which are |
| 94 | // provided by mainline modules (e.g. art, conscrypt, runtime-i18n) but which are not otherwise |
| 95 | // used outside those mainline modules. |
| 96 | // |
| 97 | // As they are not needed outside the mainline modules adding them to the sdk/module-exports as |
| 98 | // either java_libs, or java_header_libs would end up exporting more information than was strictly |
| 99 | // necessary. The java_boot_libs property to allow those modules to be exported as part of the |
| 100 | // sdk/module_exports without exposing any unnecessary information. |
| 101 | android.RegisterSdkMemberType(&librarySdkMemberType{ |
| 102 | android.SdkMemberTypeBase{ |
| 103 | PropertyName: "java_boot_libs", |
| 104 | SupportsSdk: true, |
| 105 | }, |
Paul Duffin | 22ff0aa | 2021-02-04 11:15:34 +0000 | [diff] [blame] | 106 | // Temporarily export implementation classes jar for java_boot_libs as it is required for the |
| 107 | // hiddenapi processing. |
| 108 | // TODO(b/179354495): Revert once hiddenapi processing has been modularized. |
| 109 | exportImplementationClassesJar, |
| 110 | sdkSnapshotFilePathForJar, |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 111 | onlyCopyJarToSnapshot, |
| 112 | }) |
| 113 | |
| 114 | // Register java test libraries for use only in module_exports (not sdk). |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 115 | android.RegisterSdkMemberType(&testSdkMemberType{ |
| 116 | SdkMemberTypeBase: android.SdkMemberTypeBase{ |
| 117 | PropertyName: "java_tests", |
| 118 | }, |
| 119 | }) |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 120 | |
Jeongik Cha | 538c0d0 | 2019-07-11 15:54:27 +0900 | [diff] [blame] | 121 | } |
| 122 | |
Colin Cross | dcf71b2 | 2021-02-01 13:59:03 -0800 | [diff] [blame] | 123 | // JavaInfo contains information about a java module for use by modules that depend on it. |
| 124 | type JavaInfo struct { |
| 125 | // HeaderJars is a list of jars that can be passed as the javac classpath in order to link |
| 126 | // against this module. If empty, ImplementationJars should be used instead. |
| 127 | HeaderJars android.Paths |
| 128 | |
| 129 | // ImplementationAndResourceJars is a list of jars that contain the implementations of classes |
| 130 | // in the module as well as any resources included in the module. |
| 131 | ImplementationAndResourcesJars android.Paths |
| 132 | |
| 133 | // ImplementationJars is a list of jars that contain the implementations of classes in the |
| 134 | //module. |
| 135 | ImplementationJars android.Paths |
| 136 | |
| 137 | // ResourceJars is a list of jars that contain the resources included in the module. |
| 138 | ResourceJars android.Paths |
| 139 | |
| 140 | // AidlIncludeDirs is a list of directories that should be passed to the aidl tool when |
| 141 | // depending on this module. |
| 142 | AidlIncludeDirs android.Paths |
| 143 | |
| 144 | // SrcJarArgs is a list of arguments to pass to soong_zip to package the sources of this |
| 145 | // module. |
| 146 | SrcJarArgs []string |
| 147 | |
| 148 | // SrcJarDeps is a list of paths to depend on when packaging the sources of this module. |
| 149 | SrcJarDeps android.Paths |
| 150 | |
| 151 | // ExportedPlugins is a list of paths that should be used as annotation processors for any |
| 152 | // module that depends on this module. |
| 153 | ExportedPlugins android.Paths |
| 154 | |
| 155 | // ExportedPluginClasses is a list of classes that should be run as annotation processors for |
| 156 | // any module that depends on this module. |
| 157 | ExportedPluginClasses []string |
| 158 | |
| 159 | // ExportedPluginDisableTurbine is true if this module's annotation processors generate APIs, |
| 160 | // requiring disbling turbine for any modules that depend on it. |
| 161 | ExportedPluginDisableTurbine bool |
| 162 | |
| 163 | // JacocoReportClassesFile is the path to a jar containing uninstrumented classes that will be |
| 164 | // instrumented by jacoco. |
| 165 | JacocoReportClassesFile android.Path |
| 166 | } |
| 167 | |
| 168 | var JavaInfoProvider = blueprint.NewProvider(JavaInfo{}) |
| 169 | |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 170 | // SyspropPublicStubInfo contains info about the sysprop public stub library that corresponds to |
| 171 | // the sysprop implementation library. |
| 172 | type SyspropPublicStubInfo struct { |
| 173 | // JavaInfo is the JavaInfoProvider of the sysprop public stub library that corresponds to |
| 174 | // the sysprop implementation library. |
| 175 | JavaInfo JavaInfo |
| 176 | } |
| 177 | |
| 178 | var SyspropPublicStubInfoProvider = blueprint.NewProvider(SyspropPublicStubInfo{}) |
| 179 | |
Paul Duffin | 44b481b | 2020-06-17 16:59:43 +0100 | [diff] [blame] | 180 | // Methods that need to be implemented for a module that is added to apex java_libs property. |
| 181 | type ApexDependency interface { |
Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 182 | HeaderJars() android.Paths |
Paul Duffin | 44b481b | 2020-06-17 16:59:43 +0100 | [diff] [blame] | 183 | ImplementationAndResourcesJars() android.Paths |
| 184 | } |
| 185 | |
Ulya Trafimovich | 31e444e | 2020-08-14 17:32:16 +0100 | [diff] [blame] | 186 | // Provides build path and install path to DEX jars. |
| 187 | type UsesLibraryDependency interface { |
Ulyana Trafimovich | 5539e7b | 2020-06-04 14:08:17 +0000 | [diff] [blame] | 188 | DexJarBuildPath() android.Path |
Ulya Trafimovich | 9f3052c | 2020-06-09 14:31:19 +0100 | [diff] [blame] | 189 | DexJarInstallPath() android.Path |
Ulya Trafimovich | dbf3166 | 2020-12-17 12:07:54 +0000 | [diff] [blame] | 190 | ClassLoaderContexts() dexpreopt.ClassLoaderContextMap |
Ulya Trafimovich | 31e444e | 2020-08-14 17:32:16 +0100 | [diff] [blame] | 191 | } |
| 192 | |
Jaewoong Jung | 2634264 | 2021-03-17 15:56:23 -0700 | [diff] [blame] | 193 | // TODO(jungjw): Move this to kythe.go once it's created. |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 194 | type xref interface { |
| 195 | XrefJavaFiles() android.Paths |
| 196 | } |
| 197 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 198 | func (j *Module) XrefJavaFiles() android.Paths { |
| 199 | return j.kytheFiles |
| 200 | } |
| 201 | |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 202 | type dependencyTag struct { |
| 203 | blueprint.BaseDependencyTag |
| 204 | name string |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Colin Cross | e9fe294 | 2020-11-10 18:12:15 -0800 | [diff] [blame] | 207 | // installDependencyTag is a dependency tag that is annotated to cause the installed files of the |
| 208 | // dependency to be installed when the parent module is installed. |
| 209 | type installDependencyTag struct { |
| 210 | blueprint.BaseDependencyTag |
| 211 | android.InstallAlwaysNeededDependencyTag |
| 212 | name string |
| 213 | } |
| 214 | |
Ulya Trafimovich | b521811 | 2020-10-07 15:11:32 +0100 | [diff] [blame] | 215 | type usesLibraryDependencyTag struct { |
| 216 | dependencyTag |
| 217 | sdkVersion int // SDK version in which the library appared as a standalone library. |
| 218 | } |
| 219 | |
| 220 | func makeUsesLibraryDependencyTag(sdkVersion int) usesLibraryDependencyTag { |
| 221 | return usesLibraryDependencyTag{ |
| 222 | dependencyTag: dependencyTag{name: fmt.Sprintf("uses-library-%d", sdkVersion)}, |
| 223 | sdkVersion: sdkVersion, |
| 224 | } |
| 225 | } |
| 226 | |
Jiyong Park | 8be103b | 2019-11-08 15:53:48 +0900 | [diff] [blame] | 227 | func IsJniDepTag(depTag blueprint.DependencyTag) bool { |
Colin Cross | de78d13 | 2020-10-09 18:59:49 -0700 | [diff] [blame] | 228 | return depTag == jniLibTag |
Jiyong Park | 8be103b | 2019-11-08 15:53:48 +0900 | [diff] [blame] | 229 | } |
| 230 | |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 231 | var ( |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 232 | dataNativeBinsTag = dependencyTag{name: "dataNativeBins"} |
| 233 | staticLibTag = dependencyTag{name: "staticlib"} |
| 234 | libTag = dependencyTag{name: "javalib"} |
| 235 | java9LibTag = dependencyTag{name: "java9lib"} |
| 236 | pluginTag = dependencyTag{name: "plugin"} |
| 237 | errorpronePluginTag = dependencyTag{name: "errorprone-plugin"} |
| 238 | exportedPluginTag = dependencyTag{name: "exported-plugin"} |
| 239 | bootClasspathTag = dependencyTag{name: "bootclasspath"} |
| 240 | systemModulesTag = dependencyTag{name: "system modules"} |
| 241 | frameworkResTag = dependencyTag{name: "framework-res"} |
| 242 | kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib"} |
| 243 | kotlinAnnotationsTag = dependencyTag{name: "kotlin-annotations"} |
| 244 | proguardRaiseTag = dependencyTag{name: "proguard-raise"} |
| 245 | certificateTag = dependencyTag{name: "certificate"} |
| 246 | instrumentationForTag = dependencyTag{name: "instrumentation_for"} |
| 247 | extraLintCheckTag = dependencyTag{name: "extra-lint-check"} |
| 248 | jniLibTag = dependencyTag{name: "jnilib"} |
| 249 | syspropPublicStubDepTag = dependencyTag{name: "sysprop public stub"} |
| 250 | jniInstallTag = installDependencyTag{name: "jni install"} |
| 251 | binaryInstallTag = installDependencyTag{name: "binary install"} |
| 252 | usesLibTag = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion) |
| 253 | usesLibCompat28Tag = makeUsesLibraryDependencyTag(28) |
| 254 | usesLibCompat29Tag = makeUsesLibraryDependencyTag(29) |
| 255 | usesLibCompat30Tag = makeUsesLibraryDependencyTag(30) |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 256 | ) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 257 | |
Jiyong Park | 83dc74b | 2020-01-14 18:38:44 +0900 | [diff] [blame] | 258 | func IsLibDepTag(depTag blueprint.DependencyTag) bool { |
| 259 | return depTag == libTag |
| 260 | } |
| 261 | |
| 262 | func IsStaticLibDepTag(depTag blueprint.DependencyTag) bool { |
| 263 | return depTag == staticLibTag |
| 264 | } |
| 265 | |
Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 266 | type sdkDep struct { |
Pete Gillin | e3d44b2 | 2020-06-29 11:28:51 +0100 | [diff] [blame] | 267 | useModule, useFiles, invalidVersion bool |
Colin Cross | 47ff252 | 2017-10-02 14:22:08 -0700 | [diff] [blame] | 268 | |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 269 | // The modules that will be added to the bootclasspath when targeting 1.8 or lower |
| 270 | bootclasspath []string |
Paul Duffin | e25c644 | 2019-10-11 13:50:28 +0100 | [diff] [blame] | 271 | |
| 272 | // The default system modules to use. Will be an empty string if no system |
| 273 | // modules are to be used. |
Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 274 | systemModules string |
| 275 | |
Pete Gillin | e3d44b2 | 2020-06-29 11:28:51 +0100 | [diff] [blame] | 276 | // The modules that will be added to the classpath regardless of the Java language level targeted |
| 277 | classpath []string |
| 278 | |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 279 | // The modules that will be added ot the classpath when targeting 1.9 or higher |
Pete Gillin | e3d44b2 | 2020-06-29 11:28:51 +0100 | [diff] [blame] | 280 | // (normally these will be on the bootclasspath when targeting 1.8 or lower) |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 281 | java9Classpath []string |
| 282 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 283 | frameworkResModule string |
| 284 | |
Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 285 | jars android.Paths |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 286 | aidl android.OptionalPath |
Paul Duffin | 250e619 | 2019-06-07 10:44:37 +0100 | [diff] [blame] | 287 | |
| 288 | noStandardLibs, noFrameworksLibs bool |
| 289 | } |
| 290 | |
| 291 | func (s sdkDep) hasStandardLibs() bool { |
| 292 | return !s.noStandardLibs |
| 293 | } |
| 294 | |
| 295 | func (s sdkDep) hasFrameworkLibs() bool { |
| 296 | return !s.noStandardLibs && !s.noFrameworksLibs |
Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 299 | type jniLib struct { |
Colin Cross | 403cc15 | 2020-07-06 14:15:24 -0700 | [diff] [blame] | 300 | name string |
| 301 | path android.Path |
| 302 | target android.Target |
| 303 | coverageFile android.OptionalPath |
| 304 | unstrippedFile android.Path |
Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 307 | func sdkDeps(ctx android.BottomUpMutatorContext, sdkContext android.SdkContext, d dexer) { |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 308 | sdkDep := decodeSdkDep(ctx, sdkContext) |
| 309 | if sdkDep.useModule { |
| 310 | ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...) |
| 311 | ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...) |
| 312 | ctx.AddVariationDependencies(nil, libTag, sdkDep.classpath...) |
| 313 | if d.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() { |
| 314 | ctx.AddVariationDependencies(nil, proguardRaiseTag, config.LegacyCorePlatformBootclasspathLibraries...) |
| 315 | } |
| 316 | if d.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() { |
| 317 | ctx.AddVariationDependencies(nil, proguardRaiseTag, config.FrameworkLibraries...) |
| 318 | } |
| 319 | } |
| 320 | if sdkDep.systemModules != "" { |
| 321 | ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) |
| 322 | } |
| 323 | } |
| 324 | |
Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 325 | type deps struct { |
Colin Cross | 748b2d8 | 2020-11-19 13:52:06 -0800 | [diff] [blame] | 326 | classpath classpath |
| 327 | java9Classpath classpath |
| 328 | bootClasspath classpath |
| 329 | processorPath classpath |
| 330 | errorProneProcessorPath classpath |
| 331 | processorClasses []string |
| 332 | staticJars android.Paths |
| 333 | staticHeaderJars android.Paths |
| 334 | staticResourceJars android.Paths |
| 335 | aidlIncludeDirs android.Paths |
| 336 | srcs android.Paths |
| 337 | srcJars android.Paths |
| 338 | systemModules *systemModules |
| 339 | aidlPreprocess android.OptionalPath |
| 340 | kotlinStdlib android.Paths |
| 341 | kotlinAnnotations android.Paths |
Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 342 | |
| 343 | disableTurbine bool |
Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 344 | } |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 345 | |
Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 346 | func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer) { |
| 347 | for _, f := range dep.Srcs() { |
| 348 | if f.Ext() != ".jar" { |
| 349 | ctx.ModuleErrorf("genrule %q must generate files ending with .jar to be used as a libs or static_libs dependency", |
| 350 | ctx.OtherModuleName(dep.(blueprint.Module))) |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 355 | func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext android.SdkContext) javaVersion { |
Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 356 | if javaVersion != "" { |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 357 | return normalizeJavaVersion(ctx, javaVersion) |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 358 | } else if ctx.Device() { |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 359 | return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx)) |
Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 360 | } else { |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 361 | return JAVA_VERSION_9 |
Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 362 | } |
Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 365 | type javaVersion int |
| 366 | |
| 367 | const ( |
| 368 | JAVA_VERSION_UNSUPPORTED = 0 |
| 369 | JAVA_VERSION_6 = 6 |
| 370 | JAVA_VERSION_7 = 7 |
| 371 | JAVA_VERSION_8 = 8 |
| 372 | JAVA_VERSION_9 = 9 |
| 373 | ) |
| 374 | |
| 375 | func (v javaVersion) String() string { |
| 376 | switch v { |
| 377 | case JAVA_VERSION_6: |
| 378 | return "1.6" |
| 379 | case JAVA_VERSION_7: |
| 380 | return "1.7" |
| 381 | case JAVA_VERSION_8: |
| 382 | return "1.8" |
| 383 | case JAVA_VERSION_9: |
| 384 | return "1.9" |
| 385 | default: |
| 386 | return "unsupported" |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | // Returns true if javac targeting this version uses system modules instead of a bootclasspath. |
| 391 | func (v javaVersion) usesJavaModules() bool { |
| 392 | return v >= 9 |
| 393 | } |
| 394 | |
| 395 | func normalizeJavaVersion(ctx android.BaseModuleContext, javaVersion string) javaVersion { |
Pete Gillin | 4e8b48a | 2019-07-12 13:16:17 +0100 | [diff] [blame] | 396 | switch javaVersion { |
| 397 | case "1.6", "6": |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 398 | return JAVA_VERSION_6 |
Pete Gillin | 4e8b48a | 2019-07-12 13:16:17 +0100 | [diff] [blame] | 399 | case "1.7", "7": |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 400 | return JAVA_VERSION_7 |
Pete Gillin | 4e8b48a | 2019-07-12 13:16:17 +0100 | [diff] [blame] | 401 | case "1.8", "8": |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 402 | return JAVA_VERSION_8 |
Pete Gillin | 4e8b48a | 2019-07-12 13:16:17 +0100 | [diff] [blame] | 403 | case "1.9", "9": |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 404 | return JAVA_VERSION_9 |
Pete Gillin | 4e8b48a | 2019-07-12 13:16:17 +0100 | [diff] [blame] | 405 | case "10", "11": |
| 406 | ctx.PropertyErrorf("java_version", "Java language levels above 9 are not supported") |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 407 | return JAVA_VERSION_UNSUPPORTED |
Pete Gillin | 4e8b48a | 2019-07-12 13:16:17 +0100 | [diff] [blame] | 408 | default: |
| 409 | ctx.PropertyErrorf("java_version", "Unrecognized Java language level") |
Colin Cross | 1e74385 | 2019-10-28 11:37:20 -0700 | [diff] [blame] | 410 | return JAVA_VERSION_UNSUPPORTED |
Pete Gillin | 4e8b48a | 2019-07-12 13:16:17 +0100 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 414 | // |
| 415 | // Java libraries (.jar file) |
| 416 | // |
| 417 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 418 | type Library struct { |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 419 | Module |
Colin Cross | f0f2e2c | 2019-10-15 16:36:40 -0700 | [diff] [blame] | 420 | |
| 421 | InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 422 | } |
| 423 | |
Jiyong Park | 45bf82e | 2020-12-15 22:29:02 +0900 | [diff] [blame] | 424 | var _ android.ApexModule = (*Library)(nil) |
| 425 | |
Paul Duffin | e739f1e | 2020-05-29 11:24:51 +0100 | [diff] [blame] | 426 | // Provides access to the list of permitted packages from updatable boot jars. |
| 427 | type PermittedPackagesForUpdatableBootJars interface { |
| 428 | PermittedPackagesForUpdatableBootJars() []string |
| 429 | } |
| 430 | |
| 431 | var _ PermittedPackagesForUpdatableBootJars = (*Library)(nil) |
| 432 | |
| 433 | func (j *Library) PermittedPackagesForUpdatableBootJars() []string { |
| 434 | return j.properties.Permitted_packages |
| 435 | } |
| 436 | |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 437 | func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bool { |
Ulya Trafimovich | f491dde | 2020-01-24 12:19:45 +0000 | [diff] [blame] | 438 | // Store uncompressed (and aligned) any dex files from jars in APEXes. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 439 | if apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo); !apexInfo.IsForPlatform() { |
Ulya Trafimovich | f491dde | 2020-01-24 12:19:45 +0000 | [diff] [blame] | 440 | return true |
| 441 | } |
| 442 | |
Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 443 | // Store uncompressed (and do not strip) dex files from boot class path jars. |
| 444 | if inList(ctx.ModuleName(), ctx.Config().BootJars()) { |
| 445 | return true |
| 446 | } |
| 447 | |
| 448 | // Store uncompressed dex files that are preopted on /system. |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 449 | if !dexpreopter.dexpreoptDisabled(ctx) && (ctx.Host() || !odexOnSystemOther(ctx, dexpreopter.installPath)) { |
Vladimir Marko | e8b00d6 | 2018-12-21 15:54:16 +0000 | [diff] [blame] | 450 | return true |
| 451 | } |
Colin Cross | 083a2aa | 2019-02-06 16:37:12 -0800 | [diff] [blame] | 452 | if ctx.Config().UncompressPrivAppDex() && |
| 453 | inList(ctx.ModuleName(), ctx.Config().ModulesLoadedByPrivilegedModules()) { |
| 454 | return true |
| 455 | } |
| 456 | |
Colin Cross | 2fc72f6 | 2018-12-21 12:59:54 -0800 | [diff] [blame] | 457 | return false |
| 458 | } |
| 459 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 460 | func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Paul Duffin | 4103e92 | 2021-02-01 19:01:34 +0000 | [diff] [blame] | 461 | // Initialize the hiddenapi structure. Pass in the configuration name rather than the module name |
| 462 | // so the hidden api will encode the <x>.impl java_ library created by java_sdk_library just as it |
| 463 | // would the <x> library if <x> was configured as a boot jar. |
| 464 | j.initHiddenAPI(ctx, j.ConfigurationName()) |
| 465 | |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 466 | j.sdkVersion = j.SdkVersion(ctx) |
| 467 | j.minSdkVersion = j.MinSdkVersion(ctx) |
| 468 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 469 | apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) |
| 470 | if !apexInfo.IsForPlatform() { |
| 471 | j.hideApexVariantFromMake = true |
| 472 | } |
| 473 | |
Artur Satayev | 2db1c3f | 2020-04-08 19:09:30 +0100 | [diff] [blame] | 474 | j.checkSdkVersions(ctx) |
Jiyong Park | 0b23875 | 2019-10-29 11:23:10 +0900 | [diff] [blame] | 475 | j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar") |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 476 | j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary |
Liz Kammer | a7a64f3 | 2020-07-09 15:16:41 -0700 | [diff] [blame] | 477 | if j.dexProperties.Uncompress_dex == nil { |
David Srbecky | e033cba | 2020-05-20 22:20:28 +0100 | [diff] [blame] | 478 | // If the value was not force-set by the user, use reasonable default based on the module. |
Liz Kammer | a7a64f3 | 2020-07-09 15:16:41 -0700 | [diff] [blame] | 479 | j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter)) |
David Srbecky | e033cba | 2020-05-20 22:20:28 +0100 | [diff] [blame] | 480 | } |
Liz Kammer | a7a64f3 | 2020-07-09 15:16:41 -0700 | [diff] [blame] | 481 | j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex |
Ulya Trafimovich | b23d28c | 2020-10-08 12:53:58 +0100 | [diff] [blame] | 482 | j.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap) |
Jaewoong Jung | a24af3b | 2019-05-13 09:23:20 -0700 | [diff] [blame] | 483 | j.compile(ctx, nil) |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 484 | |
bralee | 1fbf440 | 2020-05-21 10:11:59 +0800 | [diff] [blame] | 485 | // Collect the module directory for IDE info in java/jdeps.go. |
| 486 | j.modulePaths = append(j.modulePaths, ctx.ModuleDir()) |
| 487 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 488 | exclusivelyForApex := !apexInfo.IsForPlatform() |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 489 | if (Bool(j.properties.Installable) || ctx.Host()) && !exclusivelyForApex { |
Colin Cross | f0f2e2c | 2019-10-15 16:36:40 -0700 | [diff] [blame] | 490 | var extraInstallDeps android.Paths |
| 491 | if j.InstallMixin != nil { |
| 492 | extraInstallDeps = j.InstallMixin(ctx, j.outputFile) |
| 493 | } |
Colin Cross | 2c429dc | 2017-08-31 16:45:16 -0700 | [diff] [blame] | 494 | j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), |
Jiyong Park | a62aa23 | 2020-05-28 23:46:55 +0900 | [diff] [blame] | 495 | j.Stem()+".jar", j.outputFile, extraInstallDeps...) |
Colin Cross | 2c429dc | 2017-08-31 16:45:16 -0700 | [diff] [blame] | 496 | } |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 497 | } |
| 498 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 499 | func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 500 | j.deps(ctx) |
| 501 | } |
| 502 | |
Paul Duffin | 0e0cf1d | 2019-11-12 19:39:25 +0000 | [diff] [blame] | 503 | const ( |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 504 | aidlIncludeDir = "aidl" |
| 505 | javaDir = "java" |
| 506 | jarFileSuffix = ".jar" |
| 507 | testConfigSuffix = "-AndroidTest.xml" |
Paul Duffin | 0e0cf1d | 2019-11-12 19:39:25 +0000 | [diff] [blame] | 508 | ) |
| 509 | |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 510 | // path to the jar file of a java library. Relative to <sdk_root>/<api_dir> |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 511 | func sdkSnapshotFilePathForJar(osPrefix, name string) string { |
| 512 | return sdkSnapshotFilePathForMember(osPrefix, name, jarFileSuffix) |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 513 | } |
| 514 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 515 | func sdkSnapshotFilePathForMember(osPrefix, name string, suffix string) string { |
| 516 | return filepath.Join(javaDir, osPrefix, name+suffix) |
Paul Duffin | 0e0cf1d | 2019-11-12 19:39:25 +0000 | [diff] [blame] | 517 | } |
| 518 | |
Paul Duffin | 1387957 | 2019-11-28 14:31:38 +0000 | [diff] [blame] | 519 | type librarySdkMemberType struct { |
Paul Duffin | 255f18e | 2019-12-13 11:22:16 +0000 | [diff] [blame] | 520 | android.SdkMemberTypeBase |
Paul Duffin | f5c0a9c | 2020-02-28 14:39:53 +0000 | [diff] [blame] | 521 | |
| 522 | // Function to retrieve the appropriate output jar (implementation or header) from |
| 523 | // the library. |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 524 | jarToExportGetter func(ctx android.SdkMemberContext, j *Library) android.Path |
| 525 | |
| 526 | // Function to compute the snapshot relative path to which the named library's |
| 527 | // jar should be copied. |
| 528 | snapshotPathGetter func(osPrefix, name string) string |
| 529 | |
| 530 | // True if only the jar should be copied to the snapshot, false if the jar plus any additional |
| 531 | // files like aidl files should also be copied. |
| 532 | onlyCopyJarToSnapshot bool |
Paul Duffin | 1387957 | 2019-11-28 14:31:38 +0000 | [diff] [blame] | 533 | } |
| 534 | |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 535 | const ( |
| 536 | onlyCopyJarToSnapshot = true |
| 537 | copyEverythingToSnapshot = false |
| 538 | ) |
| 539 | |
Paul Duffin | 1387957 | 2019-11-28 14:31:38 +0000 | [diff] [blame] | 540 | func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) { |
| 541 | mctx.AddVariationDependencies(nil, dependencyTag, names...) |
| 542 | } |
| 543 | |
| 544 | func (mt *librarySdkMemberType) IsInstance(module android.Module) bool { |
| 545 | _, ok := module.(*Library) |
| 546 | return ok |
| 547 | } |
| 548 | |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 549 | func (mt *librarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { |
| 550 | return ctx.SnapshotBuilder().AddPrebuiltModule(member, "java_import") |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 551 | } |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 552 | |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 553 | func (mt *librarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 554 | return &librarySdkMemberProperties{} |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | type librarySdkMemberProperties struct { |
| 558 | android.SdkMemberPropertiesBase |
| 559 | |
Paul Duffin | 864e1b4 | 2020-05-06 10:23:19 +0100 | [diff] [blame] | 560 | JarToExport android.Path `android:"arch_variant"` |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 561 | AidlIncludeDirs android.Paths |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 564 | func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { |
Paul Duffin | 1387957 | 2019-11-28 14:31:38 +0000 | [diff] [blame] | 565 | j := variant.(*Library) |
| 566 | |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 567 | p.JarToExport = ctx.MemberType().(*librarySdkMemberType).jarToExportGetter(ctx, j) |
| 568 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 569 | p.AidlIncludeDirs = j.AidlIncludeDirs() |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 570 | } |
Paul Duffin | 0e0cf1d | 2019-11-12 19:39:25 +0000 | [diff] [blame] | 571 | |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 572 | func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 573 | builder := ctx.SnapshotBuilder() |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 574 | |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 575 | memberType := ctx.MemberType().(*librarySdkMemberType) |
| 576 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 577 | exportedJar := p.JarToExport |
| 578 | if exportedJar != nil { |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 579 | // Delegate the creation of the snapshot relative path to the member type. |
| 580 | snapshotRelativeJavaLibPath := memberType.snapshotPathGetter(p.OsPrefix(), ctx.Name()) |
| 581 | |
| 582 | // Copy the exported jar to the snapshot. |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 583 | builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath) |
| 584 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 585 | propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath}) |
| 586 | } |
| 587 | |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 588 | // Do not copy anything else to the snapshot. |
| 589 | if memberType.onlyCopyJarToSnapshot { |
| 590 | return |
| 591 | } |
| 592 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 593 | aidlIncludeDirs := p.AidlIncludeDirs |
| 594 | if len(aidlIncludeDirs) != 0 { |
| 595 | sdkModuleContext := ctx.SdkModuleContext() |
| 596 | for _, dir := range aidlIncludeDirs { |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 597 | // TODO(jiyong): copy parcelable declarations only |
| 598 | aidlFiles, _ := sdkModuleContext.GlobWithDeps(dir.String()+"/**/*.aidl", nil) |
| 599 | for _, file := range aidlFiles { |
| 600 | builder.CopyToSnapshot(android.PathForSource(sdkModuleContext, file), filepath.Join(aidlIncludeDir, file)) |
| 601 | } |
Paul Duffin | 0e0cf1d | 2019-11-12 19:39:25 +0000 | [diff] [blame] | 602 | } |
Paul Duffin | 0e0cf1d | 2019-11-12 19:39:25 +0000 | [diff] [blame] | 603 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 604 | // TODO(b/151933053) - add aidl include dirs property |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 605 | } |
Paul Duffin | 0e0cf1d | 2019-11-12 19:39:25 +0000 | [diff] [blame] | 606 | } |
| 607 | |
Paul Duffin | f5c0a9c | 2020-02-28 14:39:53 +0000 | [diff] [blame] | 608 | var javaHeaderLibsSdkMemberType android.SdkMemberType = &librarySdkMemberType{ |
| 609 | android.SdkMemberTypeBase{ |
| 610 | PropertyName: "java_header_libs", |
| 611 | SupportsSdk: true, |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 612 | }, |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 613 | func(_ android.SdkMemberContext, j *Library) android.Path { |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 614 | headerJars := j.HeaderJars() |
| 615 | if len(headerJars) != 1 { |
| 616 | panic(fmt.Errorf("there must be only one header jar from %q", j.Name())) |
| 617 | } |
| 618 | |
| 619 | return headerJars[0] |
Paul Duffin | f5c0a9c | 2020-02-28 14:39:53 +0000 | [diff] [blame] | 620 | }, |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 621 | sdkSnapshotFilePathForJar, |
| 622 | copyEverythingToSnapshot, |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 623 | } |
| 624 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 625 | // java_library builds and links sources into a `.jar` file for the device, and possibly for the host as well. |
| 626 | // |
| 627 | // By default, a java_library has a single variant that produces a `.jar` file containing `.class` files that were |
| 628 | // compiled against the device bootclasspath. This jar is not suitable for installing on a device, but can be used |
| 629 | // as a `static_libs` dependency of another module. |
| 630 | // |
| 631 | // Specifying `installable: true` will product a `.jar` file containing `classes.dex` files, suitable for installing on |
| 632 | // a device. |
| 633 | // |
| 634 | // Specifying `host_supported: true` will produce two variants, one compiled against the device bootclasspath and one |
| 635 | // compiled against the host bootclasspath. |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 636 | func LibraryFactory() android.Module { |
| 637 | module := &Library{} |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 638 | |
Colin Cross | ce6734e | 2020-06-15 16:09:53 -0700 | [diff] [blame] | 639 | module.addHostAndDeviceProperties() |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 640 | |
Paul Duffin | 859fe96 | 2020-05-15 10:20:31 +0100 | [diff] [blame] | 641 | module.initModuleAndImport(&module.ModuleBase) |
| 642 | |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 643 | android.InitApexModule(module) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 644 | android.InitSdkAwareModule(module) |
Jooyung Han | 18020ea | 2019-11-13 10:50:48 +0900 | [diff] [blame] | 645 | InitJavaModule(module, android.HostAndDeviceSupported) |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 646 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 647 | } |
| 648 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 649 | // java_library_static is an obsolete alias for java_library. |
| 650 | func LibraryStaticFactory() android.Module { |
| 651 | return LibraryFactory() |
| 652 | } |
| 653 | |
| 654 | // java_library_host builds and links sources into a `.jar` file for the host. |
| 655 | // |
| 656 | // A java_library_host has a single variant that produces a `.jar` file containing `.class` files that were |
| 657 | // compiled against the host bootclasspath. |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 658 | func LibraryHostFactory() android.Module { |
| 659 | module := &Library{} |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 660 | |
Colin Cross | ce6734e | 2020-06-15 16:09:53 -0700 | [diff] [blame] | 661 | module.addHostProperties() |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 662 | |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 663 | module.Module.properties.Installable = proptools.BoolPtr(true) |
| 664 | |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 665 | android.InitApexModule(module) |
Jooyung Han | 18020ea | 2019-11-13 10:50:48 +0900 | [diff] [blame] | 666 | InitJavaModule(module, android.HostSupported) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 667 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | // |
Colin Cross | b628ea5 | 2018-08-14 16:42:33 -0700 | [diff] [blame] | 671 | // Java Tests |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 672 | // |
| 673 | |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 674 | // Test option struct. |
| 675 | type TestOptions struct { |
| 676 | // a list of extra test configuration files that should be installed with the module. |
| 677 | Extra_test_configs []string `android:"path,arch_variant"` |
Dan Shi | d79572f | 2020-11-13 14:33:46 -0800 | [diff] [blame] | 678 | |
| 679 | // If the test is a hostside(no device required) unittest that shall be run during presubmit check. |
| 680 | Unit_test *bool |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 681 | } |
| 682 | |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 683 | type testProperties struct { |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 684 | // list of compatibility suites (for example "cts", "vts") that the module should be |
| 685 | // installed into. |
| 686 | Test_suites []string `android:"arch_variant"` |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 687 | |
| 688 | // the name of the test configuration (for example "AndroidTest.xml") that should be |
| 689 | // installed with the module. |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 690 | Test_config *string `android:"path,arch_variant"` |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 691 | |
Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 692 | // the name of the test configuration template (for example "AndroidTestTemplate.xml") that |
| 693 | // should be installed with the module. |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 694 | Test_config_template *string `android:"path,arch_variant"` |
Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 695 | |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 696 | // list of files or filegroup modules that provide data that should be installed alongside |
| 697 | // the test |
Jiyong Park | 2b0e490 | 2021-02-16 06:52:39 +0900 | [diff] [blame] | 698 | Data []string `android:"path"` |
Dan Shi | 6ffaaa8 | 2019-09-26 11:41:36 -0700 | [diff] [blame] | 699 | |
| 700 | // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml |
| 701 | // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true |
| 702 | // explicitly. |
| 703 | Auto_gen_config *bool |
easoncylee | 5bcff5d | 2020-04-30 14:57:06 +0800 | [diff] [blame] | 704 | |
| 705 | // Add parameterized mainline modules to auto generated test config. The options will be |
| 706 | // handled by TradeFed to do downloading and installing the specified modules on the device. |
| 707 | Test_mainline_modules []string |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 708 | |
| 709 | // Test options. |
| 710 | Test_options TestOptions |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 711 | } |
| 712 | |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 713 | type hostTestProperties struct { |
| 714 | // list of native binary modules that should be installed alongside the test |
| 715 | Data_native_bins []string `android:"arch_variant"` |
| 716 | } |
| 717 | |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 718 | type testHelperLibraryProperties struct { |
| 719 | // list of compatibility suites (for example "cts", "vts") that the module should be |
| 720 | // installed into. |
| 721 | Test_suites []string `android:"arch_variant"` |
| 722 | } |
| 723 | |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 724 | type prebuiltTestProperties struct { |
| 725 | // list of compatibility suites (for example "cts", "vts") that the module should be |
| 726 | // installed into. |
| 727 | Test_suites []string `android:"arch_variant"` |
| 728 | |
| 729 | // the name of the test configuration (for example "AndroidTest.xml") that should be |
| 730 | // installed with the module. |
| 731 | Test_config *string `android:"path,arch_variant"` |
| 732 | } |
| 733 | |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 734 | type Test struct { |
| 735 | Library |
| 736 | |
| 737 | testProperties testProperties |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 738 | |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 739 | testConfig android.Path |
| 740 | extraTestConfigs android.Paths |
| 741 | data android.Paths |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 742 | } |
| 743 | |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 744 | type TestHost struct { |
| 745 | Test |
| 746 | |
| 747 | testHostProperties hostTestProperties |
| 748 | } |
| 749 | |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 750 | type TestHelperLibrary struct { |
| 751 | Library |
| 752 | |
| 753 | testHelperLibraryProperties testHelperLibraryProperties |
| 754 | } |
| 755 | |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 756 | type JavaTestImport struct { |
| 757 | Import |
| 758 | |
| 759 | prebuiltTestProperties prebuiltTestProperties |
| 760 | |
| 761 | testConfig android.Path |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 762 | dexJarFile android.Path |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 763 | } |
| 764 | |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 765 | func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 766 | if len(j.testHostProperties.Data_native_bins) > 0 { |
| 767 | for _, target := range ctx.MultiTargets() { |
| 768 | ctx.AddVariationDependencies(target.Variations(), dataNativeBinsTag, j.testHostProperties.Data_native_bins...) |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | j.deps(ctx) |
| 773 | } |
| 774 | |
Yuexi Ma | 627263f | 2021-03-04 13:47:56 -0800 | [diff] [blame] | 775 | func (j *TestHost) AddExtraResource(p android.Path) { |
| 776 | j.extraResources = append(j.extraResources, p) |
| 777 | } |
| 778 | |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 779 | func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Julien Desprez | b216661 | 2021-03-05 18:08:36 +0000 | [diff] [blame] | 780 | if j.testProperties.Test_options.Unit_test == nil && ctx.Host() { |
| 781 | // TODO(b/): Clean temporary heuristic to avoid unexpected onboarding. |
Julien Desprez | f666b15 | 2021-03-15 13:07:53 -0700 | [diff] [blame] | 782 | defaultUnitTest := !inList("tradefed", j.properties.Libs) && !inList("cts", j.testProperties.Test_suites) |
Julien Desprez | b216661 | 2021-03-05 18:08:36 +0000 | [diff] [blame] | 783 | j.testProperties.Test_options.Unit_test = proptools.BoolPtr(defaultUnitTest) |
| 784 | } |
Dan Shi | 6ffaaa8 | 2019-09-26 11:41:36 -0700 | [diff] [blame] | 785 | j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, |
Julien Desprez | 70898c4 | 2020-11-19 09:43:45 -0800 | [diff] [blame] | 786 | j.testProperties.Test_suites, j.testProperties.Auto_gen_config, j.testProperties.Test_options.Unit_test) |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 787 | |
Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 788 | j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data) |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 789 | |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 790 | j.extraTestConfigs = android.PathsForModuleSrc(ctx, j.testProperties.Test_options.Extra_test_configs) |
| 791 | |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 792 | ctx.VisitDirectDepsWithTag(dataNativeBinsTag, func(dep android.Module) { |
| 793 | j.data = append(j.data, android.OutputFileForModule(ctx, dep, "")) |
| 794 | }) |
| 795 | |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 796 | j.Library.GenerateAndroidBuildActions(ctx) |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 797 | } |
| 798 | |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 799 | func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 800 | j.Library.GenerateAndroidBuildActions(ctx) |
| 801 | } |
| 802 | |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 803 | func (j *JavaTestImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 804 | j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.prebuiltTestProperties.Test_config, nil, |
Julien Desprez | 70898c4 | 2020-11-19 09:43:45 -0800 | [diff] [blame] | 805 | j.prebuiltTestProperties.Test_suites, nil, nil) |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 806 | |
| 807 | j.Import.GenerateAndroidBuildActions(ctx) |
| 808 | } |
| 809 | |
| 810 | type testSdkMemberType struct { |
| 811 | android.SdkMemberTypeBase |
| 812 | } |
| 813 | |
| 814 | func (mt *testSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) { |
| 815 | mctx.AddVariationDependencies(nil, dependencyTag, names...) |
| 816 | } |
| 817 | |
| 818 | func (mt *testSdkMemberType) IsInstance(module android.Module) bool { |
| 819 | _, ok := module.(*Test) |
| 820 | return ok |
| 821 | } |
| 822 | |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 823 | func (mt *testSdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { |
| 824 | return ctx.SnapshotBuilder().AddPrebuiltModule(member, "java_test_import") |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 825 | } |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 826 | |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 827 | func (mt *testSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { |
| 828 | return &testSdkMemberProperties{} |
| 829 | } |
| 830 | |
| 831 | type testSdkMemberProperties struct { |
| 832 | android.SdkMemberPropertiesBase |
| 833 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 834 | JarToExport android.Path |
| 835 | TestConfig android.Path |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 836 | } |
| 837 | |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 838 | func (p *testSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 839 | test := variant.(*Test) |
| 840 | |
| 841 | implementationJars := test.ImplementationJars() |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 842 | if len(implementationJars) != 1 { |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 843 | panic(fmt.Errorf("there must be only one implementation jar from %q", test.Name())) |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 844 | } |
| 845 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 846 | p.JarToExport = implementationJars[0] |
| 847 | p.TestConfig = test.testConfig |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 848 | } |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 849 | |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 850 | func (p *testSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 851 | builder := ctx.SnapshotBuilder() |
Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 852 | |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 853 | exportedJar := p.JarToExport |
| 854 | if exportedJar != nil { |
| 855 | snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), ctx.Name()) |
| 856 | builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath) |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 857 | |
| 858 | propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath}) |
Paul Duffin | a551a1c | 2020-03-17 21:04:24 +0000 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | testConfig := p.TestConfig |
| 862 | if testConfig != nil { |
| 863 | snapshotRelativeTestConfigPath := sdkSnapshotFilePathForMember(p.OsPrefix(), ctx.Name(), testConfigSuffix) |
| 864 | builder.CopyToSnapshot(testConfig, snapshotRelativeTestConfigPath) |
Paul Duffin | 14eb467 | 2020-03-02 11:33:02 +0000 | [diff] [blame] | 865 | propertySet.AddProperty("test_config", snapshotRelativeTestConfigPath) |
| 866 | } |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 867 | } |
| 868 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 869 | // java_test builds a and links sources into a `.jar` file for the device, and possibly for the host as well, and |
| 870 | // creates an `AndroidTest.xml` file to allow running the test with `atest` or a `TEST_MAPPING` file. |
| 871 | // |
| 872 | // By default, a java_test has a single variant that produces a `.jar` file containing `classes.dex` files that were |
| 873 | // compiled against the device bootclasspath. |
| 874 | // |
| 875 | // Specifying `host_supported: true` will produce two variants, one compiled against the device bootclasspath and one |
| 876 | // compiled against the host bootclasspath. |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 877 | func TestFactory() android.Module { |
| 878 | module := &Test{} |
| 879 | |
Colin Cross | ce6734e | 2020-06-15 16:09:53 -0700 | [diff] [blame] | 880 | module.addHostAndDeviceProperties() |
| 881 | module.AddProperties(&module.testProperties) |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 882 | |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 883 | module.Module.properties.Installable = proptools.BoolPtr(true) |
Colin Cross | e302687 | 2019-01-05 22:30:13 -0800 | [diff] [blame] | 884 | module.Module.dexpreopter.isTest = true |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 885 | module.Module.linter.test = true |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 886 | |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 887 | InitJavaModule(module, android.HostAndDeviceSupported) |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 888 | return module |
| 889 | } |
| 890 | |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 891 | // java_test_helper_library creates a java library and makes sure that it is added to the appropriate test suite. |
| 892 | func TestHelperLibraryFactory() android.Module { |
| 893 | module := &TestHelperLibrary{} |
| 894 | |
Colin Cross | ce6734e | 2020-06-15 16:09:53 -0700 | [diff] [blame] | 895 | module.addHostAndDeviceProperties() |
| 896 | module.AddProperties(&module.testHelperLibraryProperties) |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 897 | |
Colin Cross | 9a4abed | 2019-04-24 13:19:28 -0700 | [diff] [blame] | 898 | module.Module.properties.Installable = proptools.BoolPtr(true) |
| 899 | module.Module.dexpreopter.isTest = true |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 900 | module.Module.linter.test = true |
Colin Cross | 9a4abed | 2019-04-24 13:19:28 -0700 | [diff] [blame] | 901 | |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 902 | InitJavaModule(module, android.HostAndDeviceSupported) |
| 903 | return module |
| 904 | } |
| 905 | |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 906 | // java_test_import imports one or more `.jar` files into the build graph as if they were built by a java_test module |
| 907 | // and makes sure that it is added to the appropriate test suite. |
| 908 | // |
| 909 | // By default, a java_test_import has a single variant that expects a `.jar` file containing `.class` files that were |
| 910 | // compiled against an Android classpath. |
| 911 | // |
| 912 | // Specifying `host_supported: true` will produce two variants, one for use as a dependency of device modules and one |
| 913 | // for host modules. |
| 914 | func JavaTestImportFactory() android.Module { |
| 915 | module := &JavaTestImport{} |
| 916 | |
| 917 | module.AddProperties( |
| 918 | &module.Import.properties, |
| 919 | &module.prebuiltTestProperties) |
| 920 | |
| 921 | module.Import.properties.Installable = proptools.BoolPtr(true) |
| 922 | |
| 923 | android.InitPrebuiltModule(module, &module.properties.Jars) |
| 924 | android.InitApexModule(module) |
| 925 | android.InitSdkAwareModule(module) |
| 926 | InitJavaModule(module, android.HostAndDeviceSupported) |
| 927 | return module |
| 928 | } |
| 929 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 930 | // java_test_host builds a and links sources into a `.jar` file for the host, and creates an `AndroidTest.xml` file to |
| 931 | // allow running the test with `atest` or a `TEST_MAPPING` file. |
| 932 | // |
| 933 | // A java_test_host has a single variant that produces a `.jar` file containing `.class` files that were |
| 934 | // compiled against the host bootclasspath. |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 935 | func TestHostFactory() android.Module { |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 936 | module := &TestHost{} |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 937 | |
Colin Cross | ce6734e | 2020-06-15 16:09:53 -0700 | [diff] [blame] | 938 | module.addHostProperties() |
| 939 | module.AddProperties(&module.testProperties) |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 940 | module.AddProperties(&module.testHostProperties) |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 941 | |
Yuexi Ma | 627263f | 2021-03-04 13:47:56 -0800 | [diff] [blame] | 942 | InitTestHost( |
| 943 | module, |
| 944 | proptools.BoolPtr(true), |
| 945 | nil, |
| 946 | nil) |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 947 | |
Liz Kammer | dd849a8 | 2020-06-12 16:38:45 -0700 | [diff] [blame] | 948 | InitJavaModuleMultiTargets(module, android.HostSupported) |
Julien Desprez | b216661 | 2021-03-05 18:08:36 +0000 | [diff] [blame] | 949 | |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 950 | return module |
| 951 | } |
| 952 | |
Yuexi Ma | 627263f | 2021-03-04 13:47:56 -0800 | [diff] [blame] | 953 | func InitTestHost(th *TestHost, installable *bool, testSuites []string, autoGenConfig *bool) { |
| 954 | th.properties.Installable = installable |
| 955 | th.testProperties.Auto_gen_config = autoGenConfig |
| 956 | th.testProperties.Test_suites = testSuites |
| 957 | } |
| 958 | |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 959 | // |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 960 | // Java Binaries (.jar file plus wrapper script) |
| 961 | // |
| 962 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 963 | type binaryProperties struct { |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 964 | // installable script to execute the resulting jar |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 965 | Wrapper *string `android:"path"` |
Colin Cross | 094054a | 2018-10-17 15:10:48 -0700 | [diff] [blame] | 966 | |
| 967 | // Name of the class containing main to be inserted into the manifest as Main-Class. |
| 968 | Main_class *string |
Colin Cross | 89226d9 | 2020-10-09 19:00:54 -0700 | [diff] [blame] | 969 | |
| 970 | // Names of modules containing JNI libraries that should be installed alongside the host |
| 971 | // variant of the binary. |
| 972 | Jni_libs []string |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 973 | } |
| 974 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 975 | type Binary struct { |
| 976 | Library |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 977 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 978 | binaryProperties binaryProperties |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 979 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 980 | isWrapperVariant bool |
| 981 | |
Colin Cross | c331599 | 2017-12-08 19:12:36 -0800 | [diff] [blame] | 982 | wrapperFile android.Path |
Colin Cross | 70dda7e | 2019-10-01 22:05:35 -0700 | [diff] [blame] | 983 | binaryFile android.InstallPath |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 984 | } |
| 985 | |
Alex Light | 2423717 | 2017-10-26 09:46:21 -0700 | [diff] [blame] | 986 | func (j *Binary) HostToolPath() android.OptionalPath { |
| 987 | return android.OptionalPathForPath(j.binaryFile) |
| 988 | } |
| 989 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 990 | func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 991 | if ctx.Arch().ArchType == android.Common { |
| 992 | // Compile the jar |
Colin Cross | 094054a | 2018-10-17 15:10:48 -0700 | [diff] [blame] | 993 | if j.binaryProperties.Main_class != nil { |
| 994 | if j.properties.Manifest != nil { |
| 995 | ctx.PropertyErrorf("main_class", "main_class cannot be used when manifest is set") |
| 996 | } |
| 997 | manifestFile := android.PathForModuleOut(ctx, "manifest.txt") |
| 998 | GenerateMainClassManifest(ctx, manifestFile, String(j.binaryProperties.Main_class)) |
| 999 | j.overrideManifest = android.OptionalPathForPath(manifestFile) |
| 1000 | } |
| 1001 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1002 | j.Library.GenerateAndroidBuildActions(ctx) |
Nan Zhang | 3c807db | 2017-11-03 14:53:31 -0700 | [diff] [blame] | 1003 | } else { |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1004 | // Handle the binary wrapper |
| 1005 | j.isWrapperVariant = true |
| 1006 | |
Colin Cross | 366938f | 2017-12-11 16:29:02 -0800 | [diff] [blame] | 1007 | if j.binaryProperties.Wrapper != nil { |
Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 1008 | j.wrapperFile = android.PathForModuleSrc(ctx, *j.binaryProperties.Wrapper) |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1009 | } else { |
| 1010 | j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh") |
| 1011 | } |
| 1012 | |
Colin Cross | c179ea6 | 2020-10-09 10:54:15 -0700 | [diff] [blame] | 1013 | // The host installation rules make the installed wrapper depend on all the dependencies |
Colin Cross | 89226d9 | 2020-10-09 19:00:54 -0700 | [diff] [blame] | 1014 | // of the wrapper variant, which will include the common variant's jar file and any JNI |
| 1015 | // libraries. This is verified by TestBinary. |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1016 | j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"), |
Colin Cross | c179ea6 | 2020-10-09 10:54:15 -0700 | [diff] [blame] | 1017 | ctx.ModuleName(), j.wrapperFile) |
Nan Zhang | 3c807db | 2017-11-03 14:53:31 -0700 | [diff] [blame] | 1018 | } |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1021 | func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) { |
Liz Kammer | 356f7d4 | 2021-01-26 09:18:53 -0500 | [diff] [blame] | 1022 | if ctx.Arch().ArchType == android.Common || ctx.BazelConversionMode() { |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1023 | j.deps(ctx) |
Liz Kammer | 356f7d4 | 2021-01-26 09:18:53 -0500 | [diff] [blame] | 1024 | } |
| 1025 | if ctx.Arch().ArchType != android.Common || ctx.BazelConversionMode() { |
Colin Cross | e9fe294 | 2020-11-10 18:12:15 -0800 | [diff] [blame] | 1026 | // These dependencies ensure the host installation rules will install the jar file and |
| 1027 | // the jni libraries when the wrapper is installed. |
| 1028 | ctx.AddVariationDependencies(nil, jniInstallTag, j.binaryProperties.Jni_libs...) |
| 1029 | ctx.AddVariationDependencies( |
| 1030 | []blueprint.Variation{{Mutator: "arch", Variation: android.CommonArch.String()}}, |
| 1031 | binaryInstallTag, ctx.ModuleName()) |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1032 | } |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1033 | } |
| 1034 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1035 | // java_binary builds a `.jar` file and a shell script that executes it for the device, and possibly for the host |
| 1036 | // as well. |
| 1037 | // |
| 1038 | // By default, a java_binary has a single variant that produces a `.jar` file containing `classes.dex` files that were |
| 1039 | // compiled against the device bootclasspath. |
| 1040 | // |
| 1041 | // Specifying `host_supported: true` will produce two variants, one compiled against the device bootclasspath and one |
| 1042 | // compiled against the host bootclasspath. |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1043 | func BinaryFactory() android.Module { |
| 1044 | module := &Binary{} |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1045 | |
Colin Cross | ce6734e | 2020-06-15 16:09:53 -0700 | [diff] [blame] | 1046 | module.addHostAndDeviceProperties() |
| 1047 | module.AddProperties(&module.binaryProperties) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1048 | |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1049 | module.Module.properties.Installable = proptools.BoolPtr(true) |
| 1050 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1051 | android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommonFirst) |
| 1052 | android.InitDefaultableModule(module) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1053 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1056 | // java_binary_host builds a `.jar` file and a shell script that executes it for the host. |
| 1057 | // |
| 1058 | // A java_binary_host has a single variant that produces a `.jar` file containing `.class` files that were |
| 1059 | // compiled against the host bootclasspath. |
Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1060 | func BinaryHostFactory() android.Module { |
| 1061 | module := &Binary{} |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1062 | |
Colin Cross | ce6734e | 2020-06-15 16:09:53 -0700 | [diff] [blame] | 1063 | module.addHostProperties() |
| 1064 | module.AddProperties(&module.binaryProperties) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1065 | |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1066 | module.Module.properties.Installable = proptools.BoolPtr(true) |
| 1067 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1068 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommonFirst) |
| 1069 | android.InitDefaultableModule(module) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1070 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | // |
| 1074 | // Java prebuilts |
| 1075 | // |
| 1076 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1077 | type ImportProperties struct { |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 1078 | Jars []string `android:"path,arch_variant"` |
Colin Cross | 461bd1a | 2017-10-20 13:59:18 -0700 | [diff] [blame] | 1079 | |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1080 | // The version of the SDK that the source prebuilt file was built against. Defaults to the |
| 1081 | // current version if not specified. |
Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 1082 | Sdk_version *string |
Colin Cross | 535e2cf | 2017-10-20 17:57:49 -0700 | [diff] [blame] | 1083 | |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1084 | // The minimum version of the SDK that this module supports. Defaults to sdk_version if not |
| 1085 | // specified. |
| 1086 | Min_sdk_version *string |
| 1087 | |
Colin Cross | 535e2cf | 2017-10-20 17:57:49 -0700 | [diff] [blame] | 1088 | Installable *bool |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1089 | |
| 1090 | // List of shared java libs that this module has dependencies to |
| 1091 | Libs []string |
Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1092 | |
| 1093 | // List of files to remove from the jar file(s) |
| 1094 | Exclude_files []string |
| 1095 | |
| 1096 | // List of directories to remove from the jar file(s) |
| 1097 | Exclude_dirs []string |
Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 1098 | |
| 1099 | // if set to true, run Jetifier against .jar file. Defaults to false. |
Colin Cross | 1001a79 | 2019-03-21 22:21:39 -0700 | [diff] [blame] | 1100 | Jetifier *bool |
Jiyong Park | 4c4c024 | 2019-10-21 14:53:15 +0900 | [diff] [blame] | 1101 | |
| 1102 | // set the name of the output |
| 1103 | Stem *string |
Jiyong Park | 19604de | 2020-03-24 16:44:11 +0900 | [diff] [blame] | 1104 | |
| 1105 | Aidl struct { |
| 1106 | // directories that should be added as include directories for any aidl sources of modules |
| 1107 | // that depend on this module, as well as to aidl for this module. |
| 1108 | Export_include_dirs []string |
| 1109 | } |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1110 | } |
| 1111 | |
| 1112 | type Import struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1113 | android.ModuleBase |
Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 1114 | android.DefaultableModuleBase |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 1115 | android.ApexModuleBase |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 1116 | prebuilt android.Prebuilt |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1117 | android.SdkBase |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1118 | |
Paul Duffin | 0d3c2e1 | 2020-05-17 08:34:50 +0100 | [diff] [blame] | 1119 | // Functionality common to Module and Import. |
| 1120 | embeddableInModuleAndImport |
| 1121 | |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1122 | hiddenAPI |
| 1123 | dexer |
Bill Peckham | ff89ffa | 2020-12-23 16:13:04 -0800 | [diff] [blame] | 1124 | dexpreopter |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1125 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1126 | properties ImportProperties |
| 1127 | |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1128 | // output file containing classes.dex and resources |
| 1129 | dexJarFile android.Path |
| 1130 | |
Colin Cross | 0a6e007 | 2017-08-30 14:24:55 -0700 | [diff] [blame] | 1131 | combinedClasspathFile android.Path |
Ulya Trafimovich | b23d28c | 2020-10-08 12:53:58 +0100 | [diff] [blame] | 1132 | classLoaderContexts dexpreopt.ClassLoaderContextMap |
Jiyong Park | 19604de | 2020-03-24 16:44:11 +0900 | [diff] [blame] | 1133 | exportAidlIncludeDirs android.Paths |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1134 | |
| 1135 | hideApexVariantFromMake bool |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1136 | |
| 1137 | sdkVersion android.SdkSpec |
| 1138 | minSdkVersion android.SdkSpec |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1139 | } |
| 1140 | |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1141 | func (j *Import) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { |
| 1142 | return android.SdkSpecFrom(ctx, String(j.properties.Sdk_version)) |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 1143 | } |
| 1144 | |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 1145 | func (j *Import) SystemModules() string { |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1146 | return "none" |
| 1147 | } |
| 1148 | |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1149 | func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1150 | if j.properties.Min_sdk_version != nil { |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1151 | return android.SdkSpecFrom(ctx, *j.properties.Min_sdk_version) |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1152 | } |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1153 | return j.SdkVersion(ctx) |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 1154 | } |
| 1155 | |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1156 | func (j *Import) TargetSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { |
| 1157 | return j.SdkVersion(ctx) |
Artur Satayev | 480e25b | 2020-04-27 18:53:18 +0100 | [diff] [blame] | 1158 | } |
| 1159 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1160 | func (j *Import) Prebuilt() *android.Prebuilt { |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 1161 | return &j.prebuilt |
| 1162 | } |
| 1163 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1164 | func (j *Import) PrebuiltSrcs() []string { |
| 1165 | return j.properties.Jars |
| 1166 | } |
| 1167 | |
| 1168 | func (j *Import) Name() string { |
Colin Cross | 5ea9bcc | 2017-07-27 15:41:32 -0700 | [diff] [blame] | 1169 | return j.prebuilt.Name(j.ModuleBase.Name()) |
| 1170 | } |
| 1171 | |
Jiyong Park | 0b23875 | 2019-10-29 11:23:10 +0900 | [diff] [blame] | 1172 | func (j *Import) Stem() string { |
| 1173 | return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name()) |
| 1174 | } |
| 1175 | |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1176 | func (a *Import) JacocoReportClassesFile() android.Path { |
| 1177 | return nil |
| 1178 | } |
| 1179 | |
Bill Peckham | a41a696 | 2021-01-11 10:58:54 -0800 | [diff] [blame] | 1180 | func (j *Import) LintDepSets() LintDepSets { |
| 1181 | return LintDepSets{} |
| 1182 | } |
| 1183 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1184 | func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) { |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 1185 | ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...) |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1186 | |
| 1187 | if ctx.Device() && Bool(j.dexProperties.Compile_dex) { |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 1188 | sdkDeps(ctx, android.SdkContext(j), j.dexer) |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1189 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 1190 | } |
| 1191 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1192 | func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1193 | j.sdkVersion = j.SdkVersion(ctx) |
| 1194 | j.minSdkVersion = j.MinSdkVersion(ctx) |
| 1195 | |
Paul Duffin | 4103e92 | 2021-02-01 19:01:34 +0000 | [diff] [blame] | 1196 | // Initialize the hiddenapi structure. |
| 1197 | j.initHiddenAPI(ctx, j.BaseModuleName()) |
| 1198 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1199 | if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() { |
| 1200 | j.hideApexVariantFromMake = true |
| 1201 | } |
| 1202 | |
Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 1203 | jars := android.PathsForModuleSrc(ctx, j.properties.Jars) |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 1204 | |
Jiyong Park | 0b23875 | 2019-10-29 11:23:10 +0900 | [diff] [blame] | 1205 | jarName := j.Stem() + ".jar" |
Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 1206 | outputFile := android.PathForModuleOut(ctx, "combined", jarName) |
Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1207 | TransformJarsToJar(ctx, outputFile, "for prebuilts", jars, android.OptionalPath{}, |
| 1208 | false, j.properties.Exclude_files, j.properties.Exclude_dirs) |
Colin Cross | 1001a79 | 2019-03-21 22:21:39 -0700 | [diff] [blame] | 1209 | if Bool(j.properties.Jetifier) { |
Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 1210 | inputFile := outputFile |
| 1211 | outputFile = android.PathForModuleOut(ctx, "jetifier", jarName) |
| 1212 | TransformJetifier(ctx, outputFile, inputFile) |
| 1213 | } |
Colin Cross | e9a275b | 2017-10-16 17:09:48 -0700 | [diff] [blame] | 1214 | j.combinedClasspathFile = outputFile |
Ulya Trafimovich | b23d28c | 2020-10-08 12:53:58 +0100 | [diff] [blame] | 1215 | j.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap) |
Paul Duffin | 859fe96 | 2020-05-15 10:20:31 +0100 | [diff] [blame] | 1216 | |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1217 | var flags javaBuilderFlags |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1218 | var deapexerModule android.Module |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1219 | |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1220 | ctx.VisitDirectDeps(func(module android.Module) { |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1221 | tag := ctx.OtherModuleDependencyTag(module) |
| 1222 | |
Colin Cross | dcf71b2 | 2021-02-01 13:59:03 -0800 | [diff] [blame] | 1223 | if ctx.OtherModuleHasProvider(module, JavaInfoProvider) { |
| 1224 | dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo) |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1225 | switch tag { |
| 1226 | case libTag, staticLibTag: |
Colin Cross | dcf71b2 | 2021-02-01 13:59:03 -0800 | [diff] [blame] | 1227 | flags.classpath = append(flags.classpath, dep.HeaderJars...) |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1228 | case bootClasspathTag: |
Colin Cross | dcf71b2 | 2021-02-01 13:59:03 -0800 | [diff] [blame] | 1229 | flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars...) |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1230 | } |
Colin Cross | dcf71b2 | 2021-02-01 13:59:03 -0800 | [diff] [blame] | 1231 | } else if dep, ok := module.(SdkLibraryDependency); ok { |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1232 | switch tag { |
| 1233 | case libTag: |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1234 | flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))...) |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1235 | } |
| 1236 | } |
Ulya Trafimovich | 65b0319 | 2020-12-03 16:50:22 +0000 | [diff] [blame] | 1237 | |
Ulya Trafimovich | 88bb6f6 | 2020-12-16 16:16:11 +0000 | [diff] [blame] | 1238 | addCLCFromDep(ctx, module, j.classLoaderContexts) |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1239 | |
| 1240 | // Save away the `deapexer` module on which this depends, if any. |
| 1241 | if tag == android.DeapexerTag { |
| 1242 | deapexerModule = module |
| 1243 | } |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1244 | }) |
| 1245 | |
Nan Zhang | 4973ecf | 2018-08-10 13:42:12 -0700 | [diff] [blame] | 1246 | if Bool(j.properties.Installable) { |
Ulya Trafimovich | 88bb6f6 | 2020-12-16 16:16:11 +0000 | [diff] [blame] | 1247 | ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), |
Jiyong Park | 4c4c024 | 2019-10-21 14:53:15 +0900 | [diff] [blame] | 1248 | jarName, outputFile) |
Nan Zhang | 4973ecf | 2018-08-10 13:42:12 -0700 | [diff] [blame] | 1249 | } |
Jiyong Park | 19604de | 2020-03-24 16:44:11 +0900 | [diff] [blame] | 1250 | |
| 1251 | j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs) |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1252 | |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1253 | if ctx.Device() { |
| 1254 | // If this is a variant created for a prebuilt_apex then use the dex implementation jar |
| 1255 | // obtained from the associated deapexer module. |
| 1256 | ai := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) |
| 1257 | if ai.ForPrebuiltApex { |
| 1258 | if deapexerModule == nil { |
| 1259 | // This should never happen as a variant for a prebuilt_apex is only created if the |
| 1260 | // deapxer module has been configured to export the dex implementation jar for this module. |
| 1261 | ctx.ModuleErrorf("internal error: module %q does not depend on a `deapexer` module for prebuilt_apex %q", |
| 1262 | j.Name(), ai.ApexVariationName) |
| 1263 | } |
| 1264 | |
| 1265 | // Get the path of the dex implementation jar from the `deapexer` module. |
| 1266 | di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) |
Paul Duffin | 9d67ca6 | 2021-02-03 20:06:33 +0000 | [diff] [blame] | 1267 | if dexOutputPath := di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar"); dexOutputPath != nil { |
| 1268 | j.dexJarFile = dexOutputPath |
Paul Duffin | f75e527 | 2021-02-09 14:34:25 +0000 | [diff] [blame] | 1269 | j.hiddenAPIExtractInformation(ctx, dexOutputPath, outputFile) |
Paul Duffin | 9d67ca6 | 2021-02-03 20:06:33 +0000 | [diff] [blame] | 1270 | } else { |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1271 | // This should never happen as a variant for a prebuilt_apex is only created if the |
| 1272 | // prebuilt_apex has been configured to export the java library dex file. |
| 1273 | ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt_apex %q", deapexerModule.Name()) |
| 1274 | } |
| 1275 | } else if Bool(j.dexProperties.Compile_dex) { |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 1276 | sdkDep := decodeSdkDep(ctx, android.SdkContext(j)) |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1277 | if sdkDep.invalidVersion { |
| 1278 | ctx.AddMissingDependencies(sdkDep.bootclasspath) |
| 1279 | ctx.AddMissingDependencies(sdkDep.java9Classpath) |
| 1280 | } else if sdkDep.useFiles { |
| 1281 | // sdkDep.jar is actually equivalent to turbine header.jar. |
| 1282 | flags.classpath = append(flags.classpath, sdkDep.jars...) |
| 1283 | } |
| 1284 | |
| 1285 | // Dex compilation |
| 1286 | |
| 1287 | j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", jarName) |
| 1288 | if j.dexProperties.Uncompress_dex == nil { |
| 1289 | // If the value was not force-set by the user, use reasonable default based on the module. |
| 1290 | j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter)) |
| 1291 | } |
| 1292 | j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex |
| 1293 | |
Paul Duffin | 612e610 | 2021-02-02 13:38:13 +0000 | [diff] [blame] | 1294 | var dexOutputFile android.OutputPath |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1295 | dexOutputFile = j.dexer.compileDex(ctx, flags, j.MinSdkVersion(ctx), outputFile, jarName) |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1296 | if ctx.Failed() { |
| 1297 | return |
| 1298 | } |
| 1299 | |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1300 | // Hidden API CSV generation and dex encoding |
Paul Duffin | f75e527 | 2021-02-09 14:34:25 +0000 | [diff] [blame] | 1301 | dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, dexOutputFile, outputFile, |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1302 | proptools.Bool(j.dexProperties.Uncompress_dex)) |
| 1303 | |
| 1304 | j.dexJarFile = dexOutputFile |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1305 | } |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1306 | } |
Colin Cross | dcf71b2 | 2021-02-01 13:59:03 -0800 | [diff] [blame] | 1307 | |
| 1308 | ctx.SetProvider(JavaInfoProvider, JavaInfo{ |
| 1309 | HeaderJars: android.PathsIfNonNil(j.combinedClasspathFile), |
| 1310 | ImplementationAndResourcesJars: android.PathsIfNonNil(j.combinedClasspathFile), |
| 1311 | ImplementationJars: android.PathsIfNonNil(j.combinedClasspathFile), |
| 1312 | AidlIncludeDirs: j.exportAidlIncludeDirs, |
| 1313 | }) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1314 | } |
| 1315 | |
Paul Duffin | aa55f74 | 2020-10-06 17:20:13 +0100 | [diff] [blame] | 1316 | func (j *Import) OutputFiles(tag string) (android.Paths, error) { |
| 1317 | switch tag { |
Saeid Farivar Asanjan | 128fe5c | 2020-10-15 17:54:40 +0000 | [diff] [blame] | 1318 | case "", ".jar": |
Paul Duffin | aa55f74 | 2020-10-06 17:20:13 +0100 | [diff] [blame] | 1319 | return android.Paths{j.combinedClasspathFile}, nil |
| 1320 | default: |
| 1321 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | var _ android.OutputFileProducer = (*Import)(nil) |
| 1326 | |
Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1327 | func (j *Import) HeaderJars() android.Paths { |
albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1328 | if j.combinedClasspathFile == nil { |
| 1329 | return nil |
| 1330 | } |
Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1331 | return android.Paths{j.combinedClasspathFile} |
Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1332 | } |
| 1333 | |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1334 | func (j *Import) ImplementationAndResourcesJars() android.Paths { |
albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1335 | if j.combinedClasspathFile == nil { |
| 1336 | return nil |
| 1337 | } |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1338 | return android.Paths{j.combinedClasspathFile} |
| 1339 | } |
| 1340 | |
Ulyana Trafimovich | 5539e7b | 2020-06-04 14:08:17 +0000 | [diff] [blame] | 1341 | func (j *Import) DexJarBuildPath() android.Path { |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1342 | return j.dexJarFile |
Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 1343 | } |
| 1344 | |
Ulya Trafimovich | 9f3052c | 2020-06-09 14:31:19 +0100 | [diff] [blame] | 1345 | func (j *Import) DexJarInstallPath() android.Path { |
| 1346 | return nil |
| 1347 | } |
| 1348 | |
Ulya Trafimovich | b23d28c | 2020-10-08 12:53:58 +0100 | [diff] [blame] | 1349 | func (j *Import) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap { |
| 1350 | return j.classLoaderContexts |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1351 | } |
| 1352 | |
Jiyong Park | 45bf82e | 2020-12-15 22:29:02 +0900 | [diff] [blame] | 1353 | var _ android.ApexModule = (*Import)(nil) |
| 1354 | |
| 1355 | // Implements android.ApexModule |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1356 | func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
Paul Duffin | 0d3c2e1 | 2020-05-17 08:34:50 +0100 | [diff] [blame] | 1357 | return j.depIsInSameApex(ctx, dep) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1358 | } |
| 1359 | |
Jiyong Park | 45bf82e | 2020-12-15 22:29:02 +0900 | [diff] [blame] | 1360 | // Implements android.ApexModule |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1361 | func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, |
| 1362 | sdkVersion android.ApiLevel) error { |
Jiyong Park | 9231537 | 2021-04-02 08:45:46 +0900 | [diff] [blame^] | 1363 | sdkSpec := j.MinSdkVersion(ctx) |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 1364 | if !sdkSpec.Specified() { |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1365 | return fmt.Errorf("min_sdk_version is not specified") |
| 1366 | } |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 1367 | if sdkSpec.Kind == android.SdkCore { |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1368 | return nil |
| 1369 | } |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame] | 1370 | ver, err := sdkSpec.EffectiveVersion(ctx) |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1371 | if err != nil { |
| 1372 | return err |
| 1373 | } |
Jiyong Park | 54105c4 | 2021-03-31 18:17:53 +0900 | [diff] [blame] | 1374 | if ver.GreaterThan(sdkVersion) { |
Jaewoong Jung | 56e12db | 2021-04-02 00:38:25 +0000 | [diff] [blame] | 1375 | return fmt.Errorf("newer SDK(%v)", ver) |
| 1376 | } |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1377 | return nil |
| 1378 | } |
| 1379 | |
albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1380 | // Add compile time check for interface implementation |
| 1381 | var _ android.IDEInfo = (*Import)(nil) |
| 1382 | var _ android.IDECustomizedModuleName = (*Import)(nil) |
| 1383 | |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 1384 | // Collect information for opening IDE project files in java/jdeps.go. |
| 1385 | const ( |
| 1386 | removedPrefix = "prebuilt_" |
| 1387 | ) |
| 1388 | |
| 1389 | func (j *Import) IDEInfo(dpInfo *android.IdeInfo) { |
| 1390 | dpInfo.Jars = append(dpInfo.Jars, j.PrebuiltSrcs()...) |
| 1391 | } |
| 1392 | |
| 1393 | func (j *Import) IDECustomizedModuleName() string { |
| 1394 | // TODO(b/113562217): Extract the base module name from the Import name, often the Import name |
| 1395 | // has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better |
| 1396 | // solution to get the Import name. |
| 1397 | name := j.Name() |
| 1398 | if strings.HasPrefix(name, removedPrefix) { |
patricktu | bb640e0 | 2018-10-11 18:33:16 +0800 | [diff] [blame] | 1399 | name = strings.TrimPrefix(name, removedPrefix) |
Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 1400 | } |
| 1401 | return name |
| 1402 | } |
| 1403 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1404 | var _ android.PrebuiltInterface = (*Import)(nil) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1405 | |
Bill Peckham | ff89ffa | 2020-12-23 16:13:04 -0800 | [diff] [blame] | 1406 | func (j *Import) IsInstallable() bool { |
| 1407 | return Bool(j.properties.Installable) |
| 1408 | } |
| 1409 | |
| 1410 | var _ dexpreopterInterface = (*Import)(nil) |
| 1411 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1412 | // java_import imports one or more `.jar` files into the build graph as if they were built by a java_library module. |
| 1413 | // |
| 1414 | // By default, a java_import has a single variant that expects a `.jar` file containing `.class` files that were |
| 1415 | // compiled against an Android classpath. |
| 1416 | // |
| 1417 | // Specifying `host_supported: true` will produce two variants, one for use as a dependency of device modules and one |
| 1418 | // for host modules. |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1419 | func ImportFactory() android.Module { |
| 1420 | module := &Import{} |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1421 | |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1422 | module.AddProperties( |
| 1423 | &module.properties, |
| 1424 | &module.dexer.dexProperties, |
| 1425 | ) |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1426 | |
Paul Duffin | 859fe96 | 2020-05-15 10:20:31 +0100 | [diff] [blame] | 1427 | module.initModuleAndImport(&module.ModuleBase) |
| 1428 | |
Liz Kammer | d6c31d2 | 2020-08-05 15:40:41 -0700 | [diff] [blame] | 1429 | module.dexProperties.Optimize.EnabledByDefault = false |
| 1430 | |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1431 | android.InitPrebuiltModule(module, &module.properties.Jars) |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 1432 | android.InitApexModule(module) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1433 | android.InitSdkAwareModule(module) |
Jooyung Han | 18020ea | 2019-11-13 10:50:48 +0900 | [diff] [blame] | 1434 | InitJavaModule(module, android.HostAndDeviceSupported) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1435 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1436 | } |
| 1437 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1438 | // java_import imports one or more `.jar` files into the build graph as if they were built by a java_library_host |
| 1439 | // module. |
| 1440 | // |
| 1441 | // A java_import_host has a single variant that expects a `.jar` file containing `.class` files that were |
| 1442 | // compiled against a host bootclasspath. |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1443 | func ImportFactoryHost() android.Module { |
| 1444 | module := &Import{} |
| 1445 | |
| 1446 | module.AddProperties(&module.properties) |
| 1447 | |
| 1448 | android.InitPrebuiltModule(module, &module.properties.Jars) |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 1449 | android.InitApexModule(module) |
Jooyung Han | 18020ea | 2019-11-13 10:50:48 +0900 | [diff] [blame] | 1450 | InitJavaModule(module, android.HostSupported) |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1451 | return module |
| 1452 | } |
| 1453 | |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1454 | // dex_import module |
| 1455 | |
| 1456 | type DexImportProperties struct { |
Colin Cross | 5cfc70d | 2019-07-15 13:36:55 -0700 | [diff] [blame] | 1457 | Jars []string `android:"path"` |
Jiyong Park | 4c4c024 | 2019-10-21 14:53:15 +0900 | [diff] [blame] | 1458 | |
| 1459 | // set the name of the output |
| 1460 | Stem *string |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1461 | } |
| 1462 | |
| 1463 | type DexImport struct { |
| 1464 | android.ModuleBase |
| 1465 | android.DefaultableModuleBase |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 1466 | android.ApexModuleBase |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1467 | prebuilt android.Prebuilt |
| 1468 | |
| 1469 | properties DexImportProperties |
| 1470 | |
Colin Cross | b014f07 | 2021-02-26 14:54:36 -0800 | [diff] [blame] | 1471 | dexJarFile android.Path |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1472 | |
| 1473 | dexpreopter |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1474 | |
| 1475 | hideApexVariantFromMake bool |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | func (j *DexImport) Prebuilt() *android.Prebuilt { |
| 1479 | return &j.prebuilt |
| 1480 | } |
| 1481 | |
| 1482 | func (j *DexImport) PrebuiltSrcs() []string { |
| 1483 | return j.properties.Jars |
| 1484 | } |
| 1485 | |
| 1486 | func (j *DexImport) Name() string { |
| 1487 | return j.prebuilt.Name(j.ModuleBase.Name()) |
| 1488 | } |
| 1489 | |
Jiyong Park | 0b23875 | 2019-10-29 11:23:10 +0900 | [diff] [blame] | 1490 | func (j *DexImport) Stem() string { |
| 1491 | return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name()) |
| 1492 | } |
| 1493 | |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1494 | func (a *DexImport) JacocoReportClassesFile() android.Path { |
| 1495 | return nil |
| 1496 | } |
| 1497 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 1498 | func (a *DexImport) LintDepSets() LintDepSets { |
| 1499 | return LintDepSets{} |
| 1500 | } |
| 1501 | |
Martin Stjernholm | 6d41527 | 2020-01-31 17:10:36 +0000 | [diff] [blame] | 1502 | func (j *DexImport) IsInstallable() bool { |
| 1503 | return true |
| 1504 | } |
| 1505 | |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1506 | func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 1507 | if len(j.properties.Jars) != 1 { |
| 1508 | ctx.PropertyErrorf("jars", "exactly one jar must be provided") |
| 1509 | } |
| 1510 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1511 | apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) |
| 1512 | if !apexInfo.IsForPlatform() { |
| 1513 | j.hideApexVariantFromMake = true |
| 1514 | } |
| 1515 | |
Jiyong Park | 0b23875 | 2019-10-29 11:23:10 +0900 | [diff] [blame] | 1516 | j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar") |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1517 | j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter) |
| 1518 | |
| 1519 | inputJar := ctx.ExpandSource(j.properties.Jars[0], "jars") |
| 1520 | dexOutputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".jar") |
| 1521 | |
| 1522 | if j.dexpreopter.uncompressedDex { |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 1523 | rule := android.NewRuleBuilder(pctx, ctx) |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1524 | |
| 1525 | temporary := android.PathForModuleOut(ctx, ctx.ModuleName()+".jar.unaligned") |
| 1526 | rule.Temporary(temporary) |
| 1527 | |
| 1528 | // use zip2zip to uncompress classes*.dex files |
| 1529 | rule.Command(). |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 1530 | BuiltTool("zip2zip"). |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1531 | FlagWithInput("-i ", inputJar). |
| 1532 | FlagWithOutput("-o ", temporary). |
| 1533 | FlagWithArg("-0 ", "'classes*.dex'") |
| 1534 | |
| 1535 | // use zipalign to align uncompressed classes*.dex files |
| 1536 | rule.Command(). |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 1537 | BuiltTool("zipalign"). |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1538 | Flag("-f"). |
| 1539 | Text("4"). |
| 1540 | Input(temporary). |
| 1541 | Output(dexOutputFile) |
| 1542 | |
| 1543 | rule.DeleteTemporaryFiles() |
| 1544 | |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 1545 | rule.Build("uncompress_dex", "uncompress dex") |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1546 | } else { |
| 1547 | ctx.Build(pctx, android.BuildParams{ |
| 1548 | Rule: android.Cp, |
| 1549 | Input: inputJar, |
| 1550 | Output: dexOutputFile, |
| 1551 | }) |
| 1552 | } |
| 1553 | |
| 1554 | j.dexJarFile = dexOutputFile |
| 1555 | |
Jaewoong Jung | 4b97a56 | 2020-12-17 09:43:28 -0800 | [diff] [blame] | 1556 | j.dexpreopt(ctx, dexOutputFile) |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1557 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1558 | if apexInfo.IsForPlatform() { |
Jiyong Park | 01bca75 | 2020-06-08 19:24:09 +0900 | [diff] [blame] | 1559 | ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), |
| 1560 | j.Stem()+".jar", dexOutputFile) |
| 1561 | } |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1562 | } |
| 1563 | |
Ulyana Trafimovich | 5539e7b | 2020-06-04 14:08:17 +0000 | [diff] [blame] | 1564 | func (j *DexImport) DexJarBuildPath() android.Path { |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1565 | return j.dexJarFile |
| 1566 | } |
| 1567 | |
Jiyong Park | 45bf82e | 2020-12-15 22:29:02 +0900 | [diff] [blame] | 1568 | var _ android.ApexModule = (*DexImport)(nil) |
| 1569 | |
| 1570 | // Implements android.ApexModule |
Dan Albert | c806053 | 2020-07-22 22:32:17 -0700 | [diff] [blame] | 1571 | func (j *DexImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, |
| 1572 | sdkVersion android.ApiLevel) error { |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1573 | // we don't check prebuilt modules for sdk_version |
| 1574 | return nil |
| 1575 | } |
| 1576 | |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1577 | // dex_import imports a `.jar` file containing classes.dex files. |
| 1578 | // |
| 1579 | // A dex_import module cannot be used as a dependency of a java_* or android_* module, it can only be installed |
| 1580 | // to the device. |
| 1581 | func DexImportFactory() android.Module { |
| 1582 | module := &DexImport{} |
| 1583 | |
| 1584 | module.AddProperties(&module.properties) |
| 1585 | |
| 1586 | android.InitPrebuiltModule(module, &module.properties.Jars) |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 1587 | android.InitApexModule(module) |
Jooyung Han | 18020ea | 2019-11-13 10:50:48 +0900 | [diff] [blame] | 1588 | InitJavaModule(module, android.DeviceSupported) |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1589 | return module |
| 1590 | } |
| 1591 | |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 1592 | // |
| 1593 | // Defaults |
| 1594 | // |
| 1595 | type Defaults struct { |
| 1596 | android.ModuleBase |
| 1597 | android.DefaultsModuleBase |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 1598 | android.ApexModuleBase |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 1599 | } |
| 1600 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1601 | // java_defaults provides a set of properties that can be inherited by other java or android modules. |
| 1602 | // |
| 1603 | // A module can use the properties from a java_defaults module using `defaults: ["defaults_module_name"]`. Each |
| 1604 | // property in the defaults module that exists in the depending module will be prepended to the depending module's |
| 1605 | // value for that property. |
| 1606 | // |
| 1607 | // Example: |
| 1608 | // |
| 1609 | // java_defaults { |
| 1610 | // name: "example_defaults", |
| 1611 | // srcs: ["common/**/*.java"], |
| 1612 | // javacflags: ["-Xlint:all"], |
| 1613 | // aaptflags: ["--auto-add-overlay"], |
| 1614 | // } |
| 1615 | // |
| 1616 | // java_library { |
| 1617 | // name: "example", |
| 1618 | // defaults: ["example_defaults"], |
| 1619 | // srcs: ["example/**/*.java"], |
| 1620 | // } |
| 1621 | // |
| 1622 | // is functionally identical to: |
| 1623 | // |
| 1624 | // java_library { |
| 1625 | // name: "example", |
| 1626 | // srcs: [ |
| 1627 | // "common/**/*.java", |
| 1628 | // "example/**/*.java", |
| 1629 | // ], |
| 1630 | // javacflags: ["-Xlint:all"], |
| 1631 | // } |
Paul Duffin | 4735766 | 2019-12-05 14:07:14 +0000 | [diff] [blame] | 1632 | func DefaultsFactory() android.Module { |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 1633 | module := &Defaults{} |
| 1634 | |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 1635 | module.AddProperties( |
Jaewoong Jung | bc15e3a | 2021-03-10 17:02:43 -0800 | [diff] [blame] | 1636 | &CommonProperties{}, |
| 1637 | &DeviceProperties{}, |
Liz Kammer | a7a64f3 | 2020-07-09 15:16:41 -0700 | [diff] [blame] | 1638 | &DexProperties{}, |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1639 | &DexpreoptProperties{}, |
Dan Willemsen | 6424d17 | 2018-03-08 13:27:59 -0800 | [diff] [blame] | 1640 | &android.ProtoProperties{}, |
Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 1641 | &aaptProperties{}, |
| 1642 | &androidLibraryProperties{}, |
| 1643 | &appProperties{}, |
| 1644 | &appTestProperties{}, |
Jaewoong Jung | 525443a | 2019-02-28 15:35:54 -0800 | [diff] [blame] | 1645 | &overridableAppProperties{}, |
Roland Levillain | b5b0ff3 | 2020-02-04 15:45:49 +0000 | [diff] [blame] | 1646 | &testProperties{}, |
Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 1647 | &ImportProperties{}, |
| 1648 | &AARImportProperties{}, |
| 1649 | &sdkLibraryProperties{}, |
Paul Duffin | 1b1e806 | 2020-05-08 13:44:43 +0100 | [diff] [blame] | 1650 | &commonToSdkLibraryAndImportProperties{}, |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1651 | &DexImportProperties{}, |
Jooyung Han | 18020ea | 2019-11-13 10:50:48 +0900 | [diff] [blame] | 1652 | &android.ApexProperties{}, |
Jaewoong Jung | bf13546 | 2020-04-26 15:10:51 -0700 | [diff] [blame] | 1653 | &RuntimeResourceOverlayProperties{}, |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 1654 | &LintProperties{}, |
Colin Cross | cbce0b0 | 2021-02-09 10:38:30 -0800 | [diff] [blame] | 1655 | &appTestHelperAppProperties{}, |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 1656 | ) |
| 1657 | |
| 1658 | android.InitDefaultsModule(module) |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 1659 | return module |
| 1660 | } |
Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 1661 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1662 | func kytheExtractJavaFactory() android.Singleton { |
| 1663 | return &kytheExtractJavaSingleton{} |
| 1664 | } |
| 1665 | |
| 1666 | type kytheExtractJavaSingleton struct { |
| 1667 | } |
| 1668 | |
| 1669 | func (ks *kytheExtractJavaSingleton) GenerateBuildActions(ctx android.SingletonContext) { |
| 1670 | var xrefTargets android.Paths |
| 1671 | ctx.VisitAllModules(func(module android.Module) { |
| 1672 | if javaModule, ok := module.(xref); ok { |
| 1673 | xrefTargets = append(xrefTargets, javaModule.XrefJavaFiles()...) |
| 1674 | } |
| 1675 | }) |
| 1676 | // TODO(asmundak): perhaps emit a rule to output a warning if there were no xrefTargets |
| 1677 | if len(xrefTargets) > 0 { |
Colin Cross | c3d87d3 | 2020-06-04 13:25:17 -0700 | [diff] [blame] | 1678 | ctx.Phony("xref_java", xrefTargets...) |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1679 | } |
| 1680 | } |
| 1681 | |
Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 1682 | var Bool = proptools.Bool |
Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 1683 | var BoolDefault = proptools.BoolDefault |
Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 1684 | var String = proptools.String |
Colin Cross | 0d0ba59 | 2018-02-20 13:33:42 -0800 | [diff] [blame] | 1685 | var inList = android.InList |
Ulya Trafimovich | 65b0319 | 2020-12-03 16:50:22 +0000 | [diff] [blame] | 1686 | |
Ulya Trafimovich | 88bb6f6 | 2020-12-16 16:16:11 +0000 | [diff] [blame] | 1687 | // Add class loader context (CLC) of a given dependency to the current CLC. |
| 1688 | func addCLCFromDep(ctx android.ModuleContext, depModule android.Module, |
| 1689 | clcMap dexpreopt.ClassLoaderContextMap) { |
| 1690 | |
| 1691 | dep, ok := depModule.(UsesLibraryDependency) |
| 1692 | if !ok { |
| 1693 | return |
| 1694 | } |
| 1695 | |
| 1696 | // Find out if the dependency is either an SDK library or an ordinary library that is disguised |
| 1697 | // as an SDK library by the means of `provides_uses_lib` property. If yes, the library is itself |
| 1698 | // a <uses-library> and should be added as a node in the CLC tree, and its CLC should be added |
| 1699 | // as subtree of that node. Otherwise the library is not a <uses_library> and should not be |
| 1700 | // added to CLC, but the transitive <uses-library> dependencies from its CLC should be added to |
| 1701 | // the current CLC. |
| 1702 | var implicitSdkLib *string |
| 1703 | comp, isComp := depModule.(SdkLibraryComponentDependency) |
| 1704 | if isComp { |
| 1705 | implicitSdkLib = comp.OptionalImplicitSdkLibrary() |
| 1706 | // OptionalImplicitSdkLibrary() may be nil so need to fall through to ProvidesUsesLib(). |
| 1707 | } |
| 1708 | if implicitSdkLib == nil { |
| 1709 | if ulib, ok := depModule.(ProvidesUsesLib); ok { |
| 1710 | implicitSdkLib = ulib.ProvidesUsesLib() |
Ulya Trafimovich | 65b0319 | 2020-12-03 16:50:22 +0000 | [diff] [blame] | 1711 | } |
| 1712 | } |
Ulya Trafimovich | 88bb6f6 | 2020-12-16 16:16:11 +0000 | [diff] [blame] | 1713 | |
| 1714 | depTag := ctx.OtherModuleDependencyTag(depModule) |
| 1715 | if depTag == libTag || depTag == usesLibTag { |
| 1716 | // Ok, propagate <uses-library> through non-static library dependencies. |
| 1717 | } else if depTag == staticLibTag { |
| 1718 | // Propagate <uses-library> through static library dependencies, unless it is a component |
| 1719 | // library (such as stubs). Component libraries have a dependency on their SDK library, |
| 1720 | // which should not be pulled just because of a static component library. |
| 1721 | if implicitSdkLib != nil { |
| 1722 | return |
| 1723 | } |
| 1724 | } else { |
| 1725 | // Don't propagate <uses-library> for other dependency tags. |
| 1726 | return |
| 1727 | } |
| 1728 | |
| 1729 | if implicitSdkLib != nil { |
Ulya Trafimovich | 7bc1cf5 | 2021-01-05 15:41:55 +0000 | [diff] [blame] | 1730 | clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *implicitSdkLib, |
Ulya Trafimovich | 88bb6f6 | 2020-12-16 16:16:11 +0000 | [diff] [blame] | 1731 | dep.DexJarBuildPath(), dep.DexJarInstallPath(), dep.ClassLoaderContexts()) |
| 1732 | } else { |
| 1733 | depName := ctx.OtherModuleName(depModule) |
| 1734 | clcMap.AddContextMap(dep.ClassLoaderContexts(), depName) |
| 1735 | } |
Ulya Trafimovich | 65b0319 | 2020-12-03 16:50:22 +0000 | [diff] [blame] | 1736 | } |