| 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 | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 24 | "strconv" | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 25 | "strings" | 
|  | 26 |  | 
|  | 27 | "github.com/google/blueprint" | 
| Colin Cross | 76b5f0c | 2017-08-29 16:02:06 -0700 | [diff] [blame] | 28 | "github.com/google/blueprint/proptools" | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 29 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 30 | "android/soong/android" | 
| 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() { | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 36 | android.RegisterModuleType("java_defaults", defaultsFactory) | 
|  | 37 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 38 | android.RegisterModuleType("java_library", LibraryFactory) | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 39 | android.RegisterModuleType("java_library_static", LibraryStaticFactory) | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 40 | android.RegisterModuleType("java_library_host", LibraryHostFactory) | 
|  | 41 | android.RegisterModuleType("java_binary", BinaryFactory) | 
|  | 42 | android.RegisterModuleType("java_binary_host", BinaryHostFactory) | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 43 | android.RegisterModuleType("java_test", TestFactory) | 
| Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 44 | android.RegisterModuleType("java_test_helper_library", TestHelperLibraryFactory) | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 45 | android.RegisterModuleType("java_test_host", TestHostFactory) | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 46 | android.RegisterModuleType("java_import", ImportFactory) | 
|  | 47 | android.RegisterModuleType("java_import_host", ImportFactoryHost) | 
| Colin Cross | 3d7c982 | 2019-03-01 13:46:24 -0800 | [diff] [blame] | 48 | android.RegisterModuleType("java_device_for_host", DeviceForHostFactory) | 
|  | 49 | android.RegisterModuleType("java_host_for_device", HostForDeviceFactory) | 
| Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 50 | android.RegisterModuleType("dex_import", DexImportFactory) | 
| Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 51 |  | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 52 | android.RegisterSingletonType("logtags", LogtagsSingleton) | 
| Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 53 | } | 
|  | 54 |  | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 55 | // TODO: | 
|  | 56 | // Autogenerated files: | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 57 | //  Renderscript | 
|  | 58 | // Post-jar passes: | 
|  | 59 | //  Proguard | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 60 | // Rmtypedefs | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 61 | // DroidDoc | 
|  | 62 | // Findbugs | 
|  | 63 |  | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 64 | type CompilerProperties struct { | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 65 | // list of source files used to compile the Java module.  May be .java, .logtags, .proto, | 
|  | 66 | // or .aidl files. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 67 | Srcs []string `android:"path,arch_variant"` | 
| Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 68 |  | 
|  | 69 | // list of source files that should not be used to build the Java module. | 
|  | 70 | // This is most useful in the arch/multilib variants to remove non-common files | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 71 | Exclude_srcs []string `android:"path,arch_variant"` | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 72 |  | 
|  | 73 | // list of directories containing Java resources | 
| Colin Cross | 86a63ff | 2017-09-27 17:33:10 -0700 | [diff] [blame] | 74 | Java_resource_dirs []string `android:"arch_variant"` | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 75 |  | 
| Colin Cross | 86a63ff | 2017-09-27 17:33:10 -0700 | [diff] [blame] | 76 | // list of directories that should be excluded from java_resource_dirs | 
|  | 77 | Exclude_java_resource_dirs []string `android:"arch_variant"` | 
| Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 78 |  | 
| Colin Cross | 0f37af0 | 2017-09-27 17:42:05 -0700 | [diff] [blame] | 79 | // list of files to use as Java resources | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 80 | Java_resources []string `android:"path,arch_variant"` | 
| Colin Cross | 0f37af0 | 2017-09-27 17:42:05 -0700 | [diff] [blame] | 81 |  | 
| Colin Cross | cedd476 | 2018-09-13 11:26:19 -0700 | [diff] [blame] | 82 | // list of files that should be excluded from java_resources and java_resource_dirs | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 83 | Exclude_java_resources []string `android:"path,arch_variant"` | 
| Colin Cross | 0f37af0 | 2017-09-27 17:42:05 -0700 | [diff] [blame] | 84 |  | 
| Paul Duffin | 2fbbfb8 | 2019-02-13 12:49:33 +0000 | [diff] [blame] | 85 | // don't build against the default libraries (bootclasspath, ext, and framework for device | 
|  | 86 | // targets) | 
| Colin Cross | 76b5f0c | 2017-08-29 16:02:06 -0700 | [diff] [blame] | 87 | No_standard_libs *bool | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 88 |  | 
| Paul Duffin | 2fbbfb8 | 2019-02-13 12:49:33 +0000 | [diff] [blame] | 89 | // don't build against the framework libraries (ext, and framework for device targets) | 
| Colin Cross | fa5eb23 | 2017-10-01 20:33:03 -0700 | [diff] [blame] | 90 | No_framework_libs *bool | 
|  | 91 |  | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 92 | // list of module-specific flags that will be used for javac compiles | 
|  | 93 | Javacflags []string `android:"arch_variant"` | 
|  | 94 |  | 
| Zoran Jovanovic | 8736ce2 | 2018-08-21 17:10:29 +0200 | [diff] [blame] | 95 | // list of module-specific flags that will be used for kotlinc compiles | 
|  | 96 | Kotlincflags []string `android:"arch_variant"` | 
|  | 97 |  | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 98 | // list of of java libraries that will be in the classpath | 
| Colin Cross | e8dc34a | 2017-07-19 11:22:16 -0700 | [diff] [blame] | 99 | Libs []string `android:"arch_variant"` | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 100 |  | 
|  | 101 | // list of java libraries that will be compiled into the resulting jar | 
| Colin Cross | e8dc34a | 2017-07-19 11:22:16 -0700 | [diff] [blame] | 102 | Static_libs []string `android:"arch_variant"` | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 103 |  | 
|  | 104 | // manifest file to be included in resulting jar | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 105 | Manifest *string `android:"path"` | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 106 |  | 
| Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 107 | // if not blank, run jarjar using the specified rules file | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 108 | Jarjar_rules *string `android:"path,arch_variant"` | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 109 |  | 
|  | 110 | // If not blank, set the java version passed to javac as -source and -target | 
|  | 111 | Java_version *string | 
| Colin Cross | 2c429dc | 2017-08-31 16:45:16 -0700 | [diff] [blame] | 112 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 113 | // If set to true, allow this module to be dexed and installed on devices.  Has no | 
|  | 114 | // effect on host modules, which are always considered installable. | 
| Colin Cross | 2c429dc | 2017-08-31 16:45:16 -0700 | [diff] [blame] | 115 | Installable *bool | 
| Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 116 |  | 
| Colin Cross | 0f37af0 | 2017-09-27 17:42:05 -0700 | [diff] [blame] | 117 | // If set to true, include sources used to compile the module in to the final jar | 
|  | 118 | Include_srcs *bool | 
|  | 119 |  | 
| Vladimir Marko | 0975ee0 | 2019-04-02 10:29:55 +0100 | [diff] [blame] | 120 | // If not empty, classes are restricted to the specified packages and their sub-packages. | 
|  | 121 | // This restriction is checked after applying jarjar rules and including static libs. | 
|  | 122 | Permitted_packages []string | 
|  | 123 |  | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 124 | // List of modules to use as annotation processors | 
|  | 125 | Plugins []string | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 126 |  | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 127 | // The number of Java source entries each Javac instance can process | 
|  | 128 | Javac_shard_size *int64 | 
|  | 129 |  | 
| Nan Zhang | 5f8cb42 | 2018-02-06 10:34:32 -0800 | [diff] [blame] | 130 | // Add host jdk tools.jar to bootclasspath | 
|  | 131 | Use_tools_jar *bool | 
|  | 132 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 133 | Openjdk9 struct { | 
|  | 134 | // List of source files that should only be used when passing -source 1.9 | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 135 | Srcs []string `android:"path"` | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 136 |  | 
|  | 137 | // List of javac flags that should only be used when passing -source 1.9 | 
|  | 138 | Javacflags []string | 
|  | 139 | } | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 140 |  | 
| Colin Cross | 8144008 | 2018-08-15 20:21:55 -0700 | [diff] [blame] | 141 | // When compiling language level 9+ .java code in packages that are part of | 
|  | 142 | // a system module, patch_module names the module that your sources and | 
|  | 143 | // dependencies should be patched into. The Android runtime currently | 
|  | 144 | // doesn't implement the JEP 261 module system so this option is only | 
|  | 145 | // supported at compile time. It should only be needed to compile tests in | 
|  | 146 | // packages that exist in libcore and which are inconvenient to move | 
|  | 147 | // elsewhere. | 
| Tobias Thierer | dda713d | 2018-09-19 16:16:19 +0100 | [diff] [blame] | 148 | Patch_module *string `android:"arch_variant"` | 
| Colin Cross | 8144008 | 2018-08-15 20:21:55 -0700 | [diff] [blame] | 149 |  | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 150 | Jacoco struct { | 
|  | 151 | // List of classes to include for instrumentation with jacoco to collect coverage | 
|  | 152 | // information at runtime when building with coverage enabled.  If unset defaults to all | 
|  | 153 | // classes. | 
|  | 154 | // Supports '*' as the last character of an entry in the list as a wildcard match. | 
|  | 155 | // If preceded by '.' it matches all classes in the package and subpackages, otherwise | 
|  | 156 | // it matches classes in the package that have the class name as a prefix. | 
|  | 157 | Include_filter []string | 
|  | 158 |  | 
|  | 159 | // List of classes to exclude from instrumentation with jacoco to collect coverage | 
|  | 160 | // information at runtime when building with coverage enabled.  Overrides classes selected | 
|  | 161 | // by the include_filter property. | 
|  | 162 | // Supports '*' as the last character of an entry in the list as a wildcard match. | 
|  | 163 | // If preceded by '.' it matches all classes in the package and subpackages, otherwise | 
|  | 164 | // it matches classes in the package that have the class name as a prefix. | 
|  | 165 | Exclude_filter []string | 
|  | 166 | } | 
|  | 167 |  | 
| Andreas Gampe | f3e5b55 | 2018-01-22 21:27:21 -0800 | [diff] [blame] | 168 | Errorprone struct { | 
|  | 169 | // List of javac flags that should only be used when running errorprone. | 
|  | 170 | Javacflags []string | 
|  | 171 | } | 
|  | 172 |  | 
| Colin Cross | 0f2ee15 | 2017-12-14 15:22:43 -0800 | [diff] [blame] | 173 | Proto struct { | 
|  | 174 | // List of extra options that will be passed to the proto generator. | 
|  | 175 | Output_params []string | 
|  | 176 | } | 
|  | 177 |  | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 178 | Instrument bool `blueprint:"mutated"` | 
| Alex Light | 7f004a7 | 2019-02-21 13:27:37 -0800 | [diff] [blame] | 179 |  | 
|  | 180 | // List of files to include in the META-INF/services folder of the resulting jar. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 181 | Services []string `android:"path,arch_variant"` | 
| Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 182 | } | 
|  | 183 |  | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 184 | type CompilerDeviceProperties struct { | 
| Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 185 | // list of module-specific flags that will be used for dex compiles | 
|  | 186 | Dxflags []string `android:"arch_variant"` | 
|  | 187 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 188 | // if not blank, set to the version of the sdk to compile against.  Defaults to compiling against the current | 
|  | 189 | // sdk if platform_apis is not set. | 
| Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 190 | Sdk_version *string | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 191 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 192 | // if not blank, set the minimum version of the sdk that the compiled artifacts will run against. | 
|  | 193 | // Defaults to sdk_version if not set. | 
|  | 194 | Min_sdk_version *string | 
|  | 195 |  | 
| Dan Willemsen | 419290a | 2018-10-31 15:28:47 -0700 | [diff] [blame] | 196 | // if not blank, set the targetSdkVersion in the AndroidManifest.xml. | 
|  | 197 | // Defaults to sdk_version if not set. | 
|  | 198 | Target_sdk_version *string | 
|  | 199 |  | 
| Colin Cross | 6af2e49 | 2018-05-22 11:12:33 -0700 | [diff] [blame] | 200 | // if true, compile against the platform APIs instead of an SDK. | 
|  | 201 | Platform_apis *bool | 
|  | 202 |  | 
| Colin Cross | ebe1a51 | 2017-11-14 13:12:14 -0800 | [diff] [blame] | 203 | Aidl struct { | 
|  | 204 | // Top level directories to pass to aidl tool | 
|  | 205 | Include_dirs []string | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 206 |  | 
| Colin Cross | ebe1a51 | 2017-11-14 13:12:14 -0800 | [diff] [blame] | 207 | // Directories rooted at the Android.bp file to pass to aidl tool | 
|  | 208 | Local_include_dirs []string | 
|  | 209 |  | 
|  | 210 | // directories that should be added as include directories for any aidl sources of modules | 
|  | 211 | // that depend on this module, as well as to aidl for this module. | 
|  | 212 | Export_include_dirs []string | 
| Martijn Coenen | eab1564 | 2018-03-09 09:29:59 +0100 | [diff] [blame] | 213 |  | 
|  | 214 | // whether to generate traces (for systrace) for this interface | 
|  | 215 | Generate_traces *bool | 
| Olivier Gaillard | 0a4cfbc | 2018-07-16 23:37:03 +0100 | [diff] [blame] | 216 |  | 
|  | 217 | // whether to generate Binder#GetTransaction name method. | 
|  | 218 | Generate_get_transaction_name *bool | 
| Colin Cross | ebe1a51 | 2017-11-14 13:12:14 -0800 | [diff] [blame] | 219 | } | 
| Colin Cross | 9243010 | 2017-10-09 14:59:32 -0700 | [diff] [blame] | 220 |  | 
|  | 221 | // If true, export a copy of the module as a -hostdex module for host testing. | 
|  | 222 | Hostdex *bool | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 223 |  | 
| David Brazdil | 17ef563 | 2018-06-27 10:27:45 +0100 | [diff] [blame] | 224 | // If set to true, compile dex regardless of installable.  Defaults to false. | 
|  | 225 | Compile_dex *bool | 
|  | 226 |  | 
| Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 227 | Optimize struct { | 
| Colin Cross | ae5caf5 | 2018-05-22 11:11:52 -0700 | [diff] [blame] | 228 | // If false, disable all optimization.  Defaults to true for android_app and android_test | 
|  | 229 | // modules, false for java_library and java_test modules. | 
| Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 230 | Enabled *bool | 
|  | 231 |  | 
|  | 232 | // If true, optimize for size by removing unused code.  Defaults to true for apps, | 
|  | 233 | // false for libraries and tests. | 
|  | 234 | Shrink *bool | 
|  | 235 |  | 
|  | 236 | // If true, optimize bytecode.  Defaults to false. | 
|  | 237 | Optimize *bool | 
|  | 238 |  | 
|  | 239 | // If true, obfuscate bytecode.  Defaults to false. | 
|  | 240 | Obfuscate *bool | 
|  | 241 |  | 
|  | 242 | // If true, do not use the flag files generated by aapt that automatically keep | 
|  | 243 | // classes referenced by the app manifest.  Defaults to false. | 
|  | 244 | No_aapt_flags *bool | 
|  | 245 |  | 
|  | 246 | // Flags to pass to proguard. | 
|  | 247 | Proguard_flags []string | 
|  | 248 |  | 
|  | 249 | // Specifies the locations of files containing proguard flags. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 250 | Proguard_flags_files []string `android:"path"` | 
| Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 251 | } | 
|  | 252 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 253 | // When targeting 1.9, override the modules to use with --system | 
|  | 254 | System_modules *string | 
| Colin Cross | 5a0dcd5 | 2018-10-05 14:20:06 -0700 | [diff] [blame] | 255 |  | 
|  | 256 | UncompressDex bool `blueprint:"mutated"` | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 257 | IsSDKLibrary  bool `blueprint:"mutated"` | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 258 | } | 
|  | 259 |  | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 260 | // Module contains the properties and members used by all java module types | 
|  | 261 | type Module struct { | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 262 | android.ModuleBase | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 263 | android.DefaultableModuleBase | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 264 |  | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 265 | properties       CompilerProperties | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 266 | protoProperties  android.ProtoProperties | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 267 | deviceProperties CompilerDeviceProperties | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 268 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 269 | // jar file containing header classes including static library dependencies, suitable for | 
|  | 270 | // inserting into the bootclasspath/classpath of another compile | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 271 | headerJarFile android.Path | 
|  | 272 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 273 | // jar file containing implementation classes including static library dependencies but no | 
|  | 274 | // resources | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 275 | implementationJarFile android.Path | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 276 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 277 | // jar file containing only resources including from static library dependencies | 
|  | 278 | resourceJar android.Path | 
|  | 279 |  | 
|  | 280 | // jar file containing implementation classes and resources including static library | 
|  | 281 | // dependencies | 
|  | 282 | implementationAndResourcesJar android.Path | 
|  | 283 |  | 
|  | 284 | // output file containing classes.dex and resources | 
| Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 285 | dexJarFile android.Path | 
|  | 286 |  | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 287 | // output file that contains classes.dex if it should be in the output file | 
|  | 288 | maybeStrippedDexJarFile android.Path | 
|  | 289 |  | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 290 | // output file containing uninstrumented classes that will be instrumented by jacoco | 
|  | 291 | jacocoReportClassesFile android.Path | 
|  | 292 |  | 
| Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 293 | // output file containing mapping of obfuscated names | 
|  | 294 | proguardDictionary android.Path | 
|  | 295 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 296 | // output file of the module, which may be a classes jar or a dex jar | 
| Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 297 | outputFile       android.Path | 
|  | 298 | extraOutputFiles android.Paths | 
| Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 299 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 300 | exportAidlIncludeDirs android.Paths | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 301 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 302 | logtagsSrcs android.Paths | 
| Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 303 |  | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 304 | // installed file for binary dependency | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 305 | installFile android.Path | 
| Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 306 |  | 
|  | 307 | // list of .java files and srcjars that was passed to javac | 
|  | 308 | compiledJavaSrcs android.Paths | 
|  | 309 | compiledSrcJars  android.Paths | 
| Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 310 |  | 
|  | 311 | // list of extra progurad flag files | 
|  | 312 | extraProguardFlagFiles android.Paths | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 313 |  | 
| Colin Cross | 094054a | 2018-10-17 15:10:48 -0700 | [diff] [blame] | 314 | // manifest file to use instead of properties.Manifest | 
|  | 315 | overrideManifest android.OptionalPath | 
|  | 316 |  | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 317 | // list of SDK lib names that this java moudule is exporting | 
|  | 318 | exportedSdkLibs []string | 
| Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 319 |  | 
|  | 320 | // list of source files, collected from compiledJavaSrcs and compiledSrcJars | 
|  | 321 | // filter out Exclude_srcs, will be used by android.IDEInfo struct | 
|  | 322 | expandIDEInfoCompiledSrcs []string | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 323 |  | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 324 | // expanded Jarjar_rules | 
|  | 325 | expandJarjarRules android.Path | 
|  | 326 |  | 
| Vladimir Marko | 0975ee0 | 2019-04-02 10:29:55 +0100 | [diff] [blame] | 327 | // list of additional targets for checkbuild | 
|  | 328 | additionalCheckedModules android.Paths | 
|  | 329 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 330 | hiddenAPI | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 331 | dexpreopter | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 332 | } | 
|  | 333 |  | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 334 | func (j *Module) Srcs() android.Paths { | 
| Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 335 | return append(android.Paths{j.outputFile}, j.extraOutputFiles...) | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 336 | } | 
|  | 337 |  | 
| Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 338 | func (j *Module) DexJarFile() android.Path { | 
|  | 339 | return j.dexJarFile | 
|  | 340 | } | 
|  | 341 |  | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 342 | var _ android.SourceFileProducer = (*Module)(nil) | 
|  | 343 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 344 | type Dependency interface { | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 345 | HeaderJars() android.Paths | 
|  | 346 | ImplementationJars() android.Paths | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 347 | ResourceJars() android.Paths | 
|  | 348 | ImplementationAndResourcesJars() android.Paths | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 349 | DexJar() android.Path | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 350 | AidlIncludeDirs() android.Paths | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 351 | ExportedSdkLibs() []string | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 352 | } | 
|  | 353 |  | 
| Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 354 | type SdkLibraryDependency interface { | 
| Colin Cross | 897d2ed | 2019-02-11 14:03:51 -0800 | [diff] [blame] | 355 | SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths | 
|  | 356 | SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths | 
| Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 357 | } | 
|  | 358 |  | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 359 | type SrcDependency interface { | 
|  | 360 | CompiledSrcs() android.Paths | 
|  | 361 | CompiledSrcJars() android.Paths | 
|  | 362 | } | 
|  | 363 |  | 
|  | 364 | func (j *Module) CompiledSrcs() android.Paths { | 
|  | 365 | return j.compiledJavaSrcs | 
|  | 366 | } | 
|  | 367 |  | 
|  | 368 | func (j *Module) CompiledSrcJars() android.Paths { | 
|  | 369 | return j.compiledSrcJars | 
|  | 370 | } | 
|  | 371 |  | 
|  | 372 | var _ SrcDependency = (*Module)(nil) | 
|  | 373 |  | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 374 | func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) { | 
|  | 375 | android.InitAndroidArchModule(module, hod, android.MultilibCommon) | 
|  | 376 | android.InitDefaultableModule(module) | 
|  | 377 | } | 
|  | 378 |  | 
| Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 379 | type dependencyTag struct { | 
|  | 380 | blueprint.BaseDependencyTag | 
|  | 381 | name string | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 382 | } | 
|  | 383 |  | 
| Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 384 | type jniDependencyTag struct { | 
|  | 385 | blueprint.BaseDependencyTag | 
|  | 386 | target android.Target | 
|  | 387 | } | 
|  | 388 |  | 
| Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 389 | var ( | 
| Colin Cross | 4b964c0 | 2018-10-15 16:18:06 -0700 | [diff] [blame] | 390 | staticLibTag          = dependencyTag{name: "staticlib"} | 
|  | 391 | libTag                = dependencyTag{name: "javalib"} | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 392 | pluginTag             = dependencyTag{name: "plugin"} | 
| Colin Cross | 4b964c0 | 2018-10-15 16:18:06 -0700 | [diff] [blame] | 393 | bootClasspathTag      = dependencyTag{name: "bootclasspath"} | 
|  | 394 | systemModulesTag      = dependencyTag{name: "system modules"} | 
|  | 395 | frameworkResTag       = dependencyTag{name: "framework-res"} | 
|  | 396 | frameworkApkTag       = dependencyTag{name: "framework-apk"} | 
|  | 397 | kotlinStdlibTag       = dependencyTag{name: "kotlin-stdlib"} | 
| Colin Cross | afbb173 | 2019-01-17 15:42:52 -0800 | [diff] [blame] | 398 | kotlinAnnotationsTag  = dependencyTag{name: "kotlin-annotations"} | 
| Colin Cross | 4b964c0 | 2018-10-15 16:18:06 -0700 | [diff] [blame] | 399 | proguardRaiseTag      = dependencyTag{name: "proguard-raise"} | 
|  | 400 | certificateTag        = dependencyTag{name: "certificate"} | 
|  | 401 | instrumentationForTag = dependencyTag{name: "instrumentation_for"} | 
| Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 402 | ) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 403 |  | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 404 | type sdkDep struct { | 
| Colin Cross | 47ff252 | 2017-10-02 14:22:08 -0700 | [diff] [blame] | 405 | useModule, useFiles, useDefaultLibs, invalidVersion bool | 
|  | 406 |  | 
| Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 407 | modules       []string | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 408 | systemModules string | 
|  | 409 |  | 
| Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 410 | frameworkResModule string | 
|  | 411 |  | 
| Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 412 | jars android.Paths | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 413 | aidl android.Path | 
|  | 414 | } | 
|  | 415 |  | 
| Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 416 | type jniLib struct { | 
|  | 417 | name   string | 
|  | 418 | path   android.Path | 
|  | 419 | target android.Target | 
|  | 420 | } | 
|  | 421 |  | 
| Colin Cross | 3144dfc | 2018-01-03 15:06:47 -0800 | [diff] [blame] | 422 | func (j *Module) shouldInstrument(ctx android.BaseContext) bool { | 
|  | 423 | return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") | 
|  | 424 | } | 
|  | 425 |  | 
|  | 426 | func (j *Module) shouldInstrumentStatic(ctx android.BaseContext) bool { | 
|  | 427 | return j.shouldInstrument(ctx) && | 
|  | 428 | (ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") || | 
|  | 429 | ctx.Config().UnbundledBuild()) | 
|  | 430 | } | 
|  | 431 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 432 | func (j *Module) sdkVersion() string { | 
|  | 433 | return String(j.deviceProperties.Sdk_version) | 
|  | 434 | } | 
|  | 435 |  | 
|  | 436 | func (j *Module) minSdkVersion() string { | 
|  | 437 | if j.deviceProperties.Min_sdk_version != nil { | 
|  | 438 | return *j.deviceProperties.Min_sdk_version | 
|  | 439 | } | 
|  | 440 | return j.sdkVersion() | 
|  | 441 | } | 
|  | 442 |  | 
| Dan Willemsen | 419290a | 2018-10-31 15:28:47 -0700 | [diff] [blame] | 443 | func (j *Module) targetSdkVersion() string { | 
|  | 444 | if j.deviceProperties.Target_sdk_version != nil { | 
|  | 445 | return *j.deviceProperties.Target_sdk_version | 
|  | 446 | } | 
|  | 447 | return j.sdkVersion() | 
|  | 448 | } | 
|  | 449 |  | 
| Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 450 | func (j *Module) deps(ctx android.BottomUpMutatorContext) { | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 451 | if ctx.Device() { | 
| Colin Cross | ff3ae9d | 2018-04-10 16:15:18 -0700 | [diff] [blame] | 452 | if !Bool(j.properties.No_standard_libs) { | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 453 | sdkDep := decodeSdkDep(ctx, sdkContext(j)) | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 454 | if sdkDep.useDefaultLibs { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 455 | ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...) | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 456 | ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules) | 
| Colin Cross | ff3ae9d | 2018-04-10 16:15:18 -0700 | [diff] [blame] | 457 | if !Bool(j.properties.No_framework_libs) { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 458 | ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) | 
| Colin Cross | fa5eb23 | 2017-10-01 20:33:03 -0700 | [diff] [blame] | 459 | } | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 460 | } else if sdkDep.useModule { | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 461 | ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 462 | ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) | 
| Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 463 | if Bool(j.deviceProperties.Optimize.Enabled) { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 464 | ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...) | 
|  | 465 | ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...) | 
| Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 466 | } | 
| Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame] | 467 | } | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 468 | } else if j.deviceProperties.System_modules == nil { | 
|  | 469 | ctx.PropertyErrorf("no_standard_libs", | 
|  | 470 | "system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?") | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 471 | } else if *j.deviceProperties.System_modules != "none" { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 472 | ctx.AddVariationDependencies(nil, systemModulesTag, *j.deviceProperties.System_modules) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 473 | } | 
| Mathew Inwood | ebe29ce | 2018-09-04 14:26:19 +0100 | [diff] [blame] | 474 | if (ctx.ModuleName() == "framework") || (ctx.ModuleName() == "framework-annotation-proc") { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 475 | ctx.AddVariationDependencies(nil, frameworkResTag, "framework-res") | 
| Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 476 | } | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 477 | if ctx.ModuleName() == "android_stubs_current" || | 
|  | 478 | ctx.ModuleName() == "android_system_stubs_current" || | 
| Nan Zhang | 863f05b | 2018-08-07 13:41:10 -0700 | [diff] [blame] | 479 | ctx.ModuleName() == "android_test_stubs_current" { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 480 | ctx.AddVariationDependencies(nil, frameworkApkTag, "framework-res") | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 481 | } | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 482 | } | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 483 |  | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 484 | ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...) | 
|  | 485 | ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...) | 
| Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 486 |  | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 487 | ctx.AddFarVariationDependencies([]blueprint.Variation{ | 
|  | 488 | {Mutator: "arch", Variation: ctx.Config().BuildOsCommonVariant}, | 
|  | 489 | }, pluginTag, j.properties.Plugins...) | 
|  | 490 |  | 
| Colin Cross | fe17f6f | 2019-03-28 19:30:56 -0700 | [diff] [blame] | 491 | android.ProtoDeps(ctx, &j.protoProperties) | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 492 | if j.hasSrcExt(".proto") { | 
|  | 493 | protoDeps(ctx, &j.protoProperties) | 
|  | 494 | } | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 495 |  | 
|  | 496 | if j.hasSrcExt(".kt") { | 
|  | 497 | // TODO(ccross): move this to a mutator pass that can tell if generated sources contain | 
|  | 498 | // Kotlin files | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 499 | ctx.AddVariationDependencies(nil, kotlinStdlibTag, "kotlin-stdlib") | 
| Colin Cross | 7788c12 | 2019-01-23 16:14:02 -0800 | [diff] [blame] | 500 | if len(j.properties.Plugins) > 0 { | 
| Colin Cross | afbb173 | 2019-01-17 15:42:52 -0800 | [diff] [blame] | 501 | ctx.AddVariationDependencies(nil, kotlinAnnotationsTag, "kotlin-annotations") | 
|  | 502 | } | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 503 | } | 
| Colin Cross | 3144dfc | 2018-01-03 15:06:47 -0800 | [diff] [blame] | 504 |  | 
|  | 505 | if j.shouldInstrumentStatic(ctx) { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 506 | ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent") | 
| Colin Cross | 3144dfc | 2018-01-03 15:06:47 -0800 | [diff] [blame] | 507 | } | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 508 | } | 
|  | 509 |  | 
|  | 510 | func hasSrcExt(srcs []string, ext string) bool { | 
|  | 511 | for _, src := range srcs { | 
|  | 512 | if filepath.Ext(src) == ext { | 
|  | 513 | return true | 
|  | 514 | } | 
|  | 515 | } | 
|  | 516 |  | 
|  | 517 | return false | 
|  | 518 | } | 
|  | 519 |  | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 520 | func shardPaths(paths android.Paths, shardSize int) []android.Paths { | 
|  | 521 | ret := make([]android.Paths, 0, (len(paths)+shardSize-1)/shardSize) | 
|  | 522 | for len(paths) > shardSize { | 
|  | 523 | ret = append(ret, paths[0:shardSize]) | 
|  | 524 | paths = paths[shardSize:] | 
|  | 525 | } | 
|  | 526 | if len(paths) > 0 { | 
|  | 527 | ret = append(ret, paths) | 
|  | 528 | } | 
|  | 529 | return ret | 
|  | 530 | } | 
|  | 531 |  | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 532 | func (j *Module) hasSrcExt(ext string) bool { | 
|  | 533 | return hasSrcExt(j.properties.Srcs, ext) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 534 | } | 
|  | 535 |  | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 536 | func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath, | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 537 | aidlIncludeDirs android.Paths) []string { | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 538 |  | 
| Colin Cross | ebe1a51 | 2017-11-14 13:12:14 -0800 | [diff] [blame] | 539 | aidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Local_include_dirs) | 
|  | 540 | aidlIncludes = append(aidlIncludes, | 
|  | 541 | android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)...) | 
|  | 542 | aidlIncludes = append(aidlIncludes, | 
|  | 543 | android.PathsForSource(ctx, j.deviceProperties.Aidl.Include_dirs)...) | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 544 |  | 
| Steven Moreland | 36b130f | 2019-02-05 17:02:55 -0800 | [diff] [blame] | 545 | flags := []string{} | 
| Steven Moreland | 667f688 | 2018-07-26 12:55:08 -0700 | [diff] [blame] | 546 |  | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 547 | if aidlPreprocess.Valid() { | 
|  | 548 | flags = append(flags, "-p"+aidlPreprocess.String()) | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 549 | } else { | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 550 | flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I")) | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 551 | } | 
|  | 552 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 553 | flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I")) | 
| Colin Cross | ebe1a51 | 2017-11-14 13:12:14 -0800 | [diff] [blame] | 554 | flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I")) | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 555 | flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String()) | 
| Colin Cross | 32f3898 | 2018-02-22 11:47:25 -0800 | [diff] [blame] | 556 | if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() { | 
| Colin Cross | d48633a | 2017-07-13 14:41:17 -0700 | [diff] [blame] | 557 | flags = append(flags, "-I"+src.String()) | 
|  | 558 | } | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 559 |  | 
| Martijn Coenen | eab1564 | 2018-03-09 09:29:59 +0100 | [diff] [blame] | 560 | if Bool(j.deviceProperties.Aidl.Generate_traces) { | 
|  | 561 | flags = append(flags, "-t") | 
|  | 562 | } | 
|  | 563 |  | 
| Olivier Gaillard | 0a4cfbc | 2018-07-16 23:37:03 +0100 | [diff] [blame] | 564 | if Bool(j.deviceProperties.Aidl.Generate_get_transaction_name) { | 
|  | 565 | flags = append(flags, "--transaction_names") | 
|  | 566 | } | 
|  | 567 |  | 
| Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 568 | return flags | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 569 | } | 
|  | 570 |  | 
| Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 571 | type deps struct { | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 572 | classpath          classpath | 
|  | 573 | bootClasspath      classpath | 
| Colin Cross | 6a77c98 | 2018-06-19 22:43:34 -0700 | [diff] [blame] | 574 | processorPath      classpath | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 575 | processorClasses   []string | 
| Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 576 | staticJars         android.Paths | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 577 | staticHeaderJars   android.Paths | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 578 | staticResourceJars android.Paths | 
| Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 579 | aidlIncludeDirs    android.Paths | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 580 | srcs               android.Paths | 
| Colin Cross | 59149b6 | 2017-10-16 18:07:29 -0700 | [diff] [blame] | 581 | srcJars            android.Paths | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 582 | systemModules      android.Path | 
| Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 583 | aidlPreprocess     android.OptionalPath | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 584 | kotlinStdlib       android.Paths | 
| Colin Cross | afbb173 | 2019-01-17 15:42:52 -0800 | [diff] [blame] | 585 | kotlinAnnotations  android.Paths | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 586 |  | 
|  | 587 | disableTurbine bool | 
| Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 588 | } | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 589 |  | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 590 | func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer) { | 
|  | 591 | for _, f := range dep.Srcs() { | 
|  | 592 | if f.Ext() != ".jar" { | 
|  | 593 | ctx.ModuleErrorf("genrule %q must generate files ending with .jar to be used as a libs or static_libs dependency", | 
|  | 594 | ctx.OtherModuleName(dep.(blueprint.Module))) | 
|  | 595 | } | 
|  | 596 | } | 
|  | 597 | } | 
|  | 598 |  | 
| Jiyong Park | 2d49294 | 2018-03-05 17:44:10 +0900 | [diff] [blame] | 599 | type linkType int | 
|  | 600 |  | 
|  | 601 | const ( | 
|  | 602 | javaCore linkType = iota | 
|  | 603 | javaSdk | 
|  | 604 | javaSystem | 
|  | 605 | javaPlatform | 
|  | 606 | ) | 
|  | 607 |  | 
| Jiyong Park | 46f78fb | 2018-10-20 16:33:17 +0900 | [diff] [blame] | 608 | func getLinkType(m *Module, name string) (ret linkType, stubs bool) { | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 609 | ver := m.sdkVersion() | 
| Colin Cross | f19b9bb | 2018-03-26 14:42:44 -0700 | [diff] [blame] | 610 | switch { | 
| Jiyong Park | 46f78fb | 2018-10-20 16:33:17 +0900 | [diff] [blame] | 611 | case name == "core.current.stubs" || name == "core.platform.api.stubs" || | 
|  | 612 | name == "stub-annotations" || name == "private-stub-annotations-jar" || | 
|  | 613 | name == "core-lambda-stubs": | 
|  | 614 | return javaCore, true | 
| Neil Fuller | 401eeba | 2018-10-18 19:48:58 +0100 | [diff] [blame] | 615 | case ver == "core_current": | 
| Jiyong Park | 46f78fb | 2018-10-20 16:33:17 +0900 | [diff] [blame] | 616 | return javaCore, false | 
|  | 617 | case name == "android_system_stubs_current": | 
|  | 618 | return javaSystem, true | 
|  | 619 | case strings.HasPrefix(ver, "system_"): | 
|  | 620 | return javaSystem, false | 
|  | 621 | case name == "android_test_stubs_current": | 
|  | 622 | return javaSystem, true | 
|  | 623 | case strings.HasPrefix(ver, "test_"): | 
|  | 624 | return javaPlatform, false | 
|  | 625 | case name == "android_stubs_current": | 
|  | 626 | return javaSdk, true | 
|  | 627 | case ver == "current": | 
|  | 628 | return javaSdk, false | 
| Colin Cross | f19b9bb | 2018-03-26 14:42:44 -0700 | [diff] [blame] | 629 | case ver == "": | 
| Jiyong Park | 46f78fb | 2018-10-20 16:33:17 +0900 | [diff] [blame] | 630 | return javaPlatform, false | 
| Colin Cross | f19b9bb | 2018-03-26 14:42:44 -0700 | [diff] [blame] | 631 | default: | 
|  | 632 | if _, err := strconv.Atoi(ver); err != nil { | 
|  | 633 | panic(fmt.Errorf("expected sdk_version to be a number, got %q", ver)) | 
|  | 634 | } | 
| Jiyong Park | 46f78fb | 2018-10-20 16:33:17 +0900 | [diff] [blame] | 635 | return javaSdk, false | 
| Jiyong Park | 2d49294 | 2018-03-05 17:44:10 +0900 | [diff] [blame] | 636 | } | 
|  | 637 | } | 
|  | 638 |  | 
| Jiyong Park | 750e557 | 2018-01-31 00:20:13 +0900 | [diff] [blame] | 639 | func checkLinkType(ctx android.ModuleContext, from *Module, to *Library, tag dependencyTag) { | 
| Colin Cross | f19b9bb | 2018-03-26 14:42:44 -0700 | [diff] [blame] | 640 | if ctx.Host() { | 
|  | 641 | return | 
|  | 642 | } | 
|  | 643 |  | 
| Jiyong Park | 46f78fb | 2018-10-20 16:33:17 +0900 | [diff] [blame] | 644 | myLinkType, stubs := getLinkType(from, ctx.ModuleName()) | 
|  | 645 | if stubs { | 
|  | 646 | return | 
|  | 647 | } | 
|  | 648 | otherLinkType, _ := getLinkType(&to.Module, ctx.OtherModuleName(to)) | 
| Jiyong Park | 2d49294 | 2018-03-05 17:44:10 +0900 | [diff] [blame] | 649 | commonMessage := "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source." | 
|  | 650 |  | 
|  | 651 | switch myLinkType { | 
|  | 652 | case javaCore: | 
|  | 653 | if otherLinkType != javaCore { | 
|  | 654 | ctx.ModuleErrorf("compiles against core Java API, but dependency %q is compiling against non-core Java APIs."+commonMessage, | 
| Jiyong Park | 750e557 | 2018-01-31 00:20:13 +0900 | [diff] [blame] | 655 | ctx.OtherModuleName(to)) | 
|  | 656 | } | 
| Jiyong Park | 2d49294 | 2018-03-05 17:44:10 +0900 | [diff] [blame] | 657 | break | 
|  | 658 | case javaSdk: | 
|  | 659 | if otherLinkType != javaCore && otherLinkType != javaSdk { | 
|  | 660 | ctx.ModuleErrorf("compiles against Android API, but dependency %q is compiling against non-public Android API."+commonMessage, | 
|  | 661 | ctx.OtherModuleName(to)) | 
|  | 662 | } | 
|  | 663 | break | 
|  | 664 | case javaSystem: | 
|  | 665 | if otherLinkType == javaPlatform { | 
|  | 666 | ctx.ModuleErrorf("compiles against system API, but dependency %q is compiling against private API."+commonMessage, | 
|  | 667 | ctx.OtherModuleName(to)) | 
|  | 668 | } | 
|  | 669 | break | 
|  | 670 | case javaPlatform: | 
|  | 671 | // no restriction on link-type | 
|  | 672 | break | 
| Jiyong Park | 750e557 | 2018-01-31 00:20:13 +0900 | [diff] [blame] | 673 | } | 
|  | 674 | } | 
|  | 675 |  | 
| Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 676 | func (j *Module) collectDeps(ctx android.ModuleContext) deps { | 
|  | 677 | var deps deps | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 678 |  | 
| Colin Cross | 300f038 | 2018-03-06 13:11:51 -0800 | [diff] [blame] | 679 | if ctx.Device() { | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 680 | sdkDep := decodeSdkDep(ctx, sdkContext(j)) | 
| Colin Cross | 300f038 | 2018-03-06 13:11:51 -0800 | [diff] [blame] | 681 | if sdkDep.invalidVersion { | 
| Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 682 | ctx.AddMissingDependencies(sdkDep.modules) | 
| Colin Cross | 300f038 | 2018-03-06 13:11:51 -0800 | [diff] [blame] | 683 | } else if sdkDep.useFiles { | 
|  | 684 | // sdkDep.jar is actually equivalent to turbine header.jar. | 
| Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 685 | deps.classpath = append(deps.classpath, sdkDep.jars...) | 
| Colin Cross | 300f038 | 2018-03-06 13:11:51 -0800 | [diff] [blame] | 686 | deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl) | 
|  | 687 | } | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 688 | } | 
|  | 689 |  | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 690 | ctx.VisitDirectDeps(func(module android.Module) { | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 691 | otherName := ctx.OtherModuleName(module) | 
| Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 692 | tag := ctx.OtherModuleDependencyTag(module) | 
|  | 693 |  | 
| Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 694 | if _, ok := tag.(*jniDependencyTag); ok { | 
| Colin Cross | bd01e2a | 2018-10-04 15:21:03 -0700 | [diff] [blame] | 695 | // Handled by AndroidApp.collectAppDeps | 
|  | 696 | return | 
|  | 697 | } | 
|  | 698 | if tag == certificateTag { | 
|  | 699 | // Handled by AndroidApp.collectAppDeps | 
| Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 700 | return | 
|  | 701 | } | 
|  | 702 |  | 
| Jiyong Park | 750e557 | 2018-01-31 00:20:13 +0900 | [diff] [blame] | 703 | if to, ok := module.(*Library); ok { | 
| Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 704 | switch tag { | 
|  | 705 | case bootClasspathTag, libTag, staticLibTag: | 
|  | 706 | checkLinkType(ctx, j, to, tag.(dependencyTag)) | 
|  | 707 | } | 
| Jiyong Park | 750e557 | 2018-01-31 00:20:13 +0900 | [diff] [blame] | 708 | } | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 709 | switch dep := module.(type) { | 
| Colin Cross | 897d2ed | 2019-02-11 14:03:51 -0800 | [diff] [blame] | 710 | case SdkLibraryDependency: | 
|  | 711 | switch tag { | 
|  | 712 | case libTag: | 
|  | 713 | deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...) | 
|  | 714 | // names of sdk libs that are directly depended are exported | 
|  | 715 | j.exportedSdkLibs = append(j.exportedSdkLibs, otherName) | 
|  | 716 | default: | 
|  | 717 | ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName) | 
|  | 718 | } | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 719 | case Dependency: | 
|  | 720 | switch tag { | 
|  | 721 | case bootClasspathTag: | 
|  | 722 | deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...) | 
| Colin Cross | 4b964c0 | 2018-10-15 16:18:06 -0700 | [diff] [blame] | 723 | case libTag, instrumentationForTag: | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 724 | deps.classpath = append(deps.classpath, dep.HeaderJars()...) | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 725 | // sdk lib names from dependencies are re-exported | 
|  | 726 | j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...) | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 727 | case staticLibTag: | 
|  | 728 | deps.classpath = append(deps.classpath, dep.HeaderJars()...) | 
|  | 729 | deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...) | 
|  | 730 | deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...) | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 731 | deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...) | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 732 | // sdk lib names from dependencies are re-exported | 
|  | 733 | j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...) | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 734 | case pluginTag: | 
|  | 735 | if plugin, ok := dep.(*Plugin); ok { | 
|  | 736 | deps.processorPath = append(deps.processorPath, dep.ImplementationAndResourcesJars()...) | 
|  | 737 | if plugin.pluginProperties.Processor_class != nil { | 
|  | 738 | deps.processorClasses = append(deps.processorClasses, *plugin.pluginProperties.Processor_class) | 
|  | 739 | } | 
|  | 740 | deps.disableTurbine = deps.disableTurbine || Bool(plugin.pluginProperties.Generates_api) | 
|  | 741 | } else { | 
|  | 742 | ctx.PropertyErrorf("plugins", "%q is not a java_plugin module", otherName) | 
|  | 743 | } | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 744 | case frameworkResTag: | 
| Mathew Inwood | ebe29ce | 2018-09-04 14:26:19 +0100 | [diff] [blame] | 745 | if (ctx.ModuleName() == "framework") || (ctx.ModuleName() == "framework-annotation-proc") { | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 746 | // framework.jar has a one-off dependency on the R.java and Manifest.java files | 
|  | 747 | // generated by framework-res.apk | 
|  | 748 | deps.srcJars = append(deps.srcJars, dep.(*AndroidApp).aaptSrcJar) | 
|  | 749 | } | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 750 | case frameworkApkTag: | 
|  | 751 | if ctx.ModuleName() == "android_stubs_current" || | 
|  | 752 | ctx.ModuleName() == "android_system_stubs_current" || | 
| Nan Zhang | 863f05b | 2018-08-07 13:41:10 -0700 | [diff] [blame] | 753 | ctx.ModuleName() == "android_test_stubs_current" { | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 754 | // framework stubs.jar need to depend on framework-res.apk, in order to pull the | 
|  | 755 | // resource files out of there for aapt. | 
|  | 756 | // | 
|  | 757 | // Normally the package rule runs aapt, which includes the resource, | 
|  | 758 | // but we're not running that in our package rule so just copy in the | 
|  | 759 | // resource files here. | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 760 | deps.staticResourceJars = append(deps.staticResourceJars, dep.(*AndroidApp).exportPackage) | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 761 | } | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 762 | case kotlinStdlibTag: | 
|  | 763 | deps.kotlinStdlib = dep.HeaderJars() | 
| Colin Cross | afbb173 | 2019-01-17 15:42:52 -0800 | [diff] [blame] | 764 | case kotlinAnnotationsTag: | 
|  | 765 | deps.kotlinAnnotations = dep.HeaderJars() | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 766 | } | 
|  | 767 |  | 
|  | 768 | deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...) | 
|  | 769 | case android.SourceFileProducer: | 
|  | 770 | switch tag { | 
|  | 771 | case libTag: | 
|  | 772 | checkProducesJars(ctx, dep) | 
|  | 773 | deps.classpath = append(deps.classpath, dep.Srcs()...) | 
|  | 774 | case staticLibTag: | 
|  | 775 | checkProducesJars(ctx, dep) | 
|  | 776 | deps.classpath = append(deps.classpath, dep.Srcs()...) | 
|  | 777 | deps.staticJars = append(deps.staticJars, dep.Srcs()...) | 
|  | 778 | deps.staticHeaderJars = append(deps.staticHeaderJars, dep.Srcs()...) | 
| Colin Cross | 5425090 | 2017-12-05 09:28:08 -0800 | [diff] [blame] | 779 | } | 
|  | 780 | default: | 
| Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 781 | switch tag { | 
|  | 782 | case android.DefaultsDepTag, android.SourceDepTag: | 
| Dan Willemsen | d6ba0d5 | 2017-09-13 15:46:47 -0700 | [diff] [blame] | 783 | // Nothing to do | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 784 | case systemModulesTag: | 
|  | 785 | if deps.systemModules != nil { | 
|  | 786 | panic("Found two system module dependencies") | 
|  | 787 | } | 
|  | 788 | sm := module.(*SystemModules) | 
|  | 789 | if sm.outputFile == nil { | 
|  | 790 | panic("Missing directory for system module dependency") | 
|  | 791 | } | 
|  | 792 | deps.systemModules = sm.outputFile | 
| Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 793 | default: | 
|  | 794 | ctx.ModuleErrorf("depends on non-java module %q", otherName) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 795 | } | 
| Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 796 | } | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 797 | }) | 
|  | 798 |  | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 799 | j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs) | 
|  | 800 |  | 
| Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 801 | return deps | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 802 | } | 
|  | 803 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 804 | func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) string { | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 805 | var ret string | 
| Colin Cross | 98fd574 | 2019-01-09 23:04:25 -0800 | [diff] [blame] | 806 | v := sdkContext.sdkVersion() | 
|  | 807 | // For PDK builds, use the latest SDK version instead of "current" | 
|  | 808 | if ctx.Config().IsPdkBuild() && (v == "" || v == "current") { | 
|  | 809 | sdkVersions := ctx.Config().Get(sdkSingletonKey).([]int) | 
|  | 810 | latestSdkVersion := 0 | 
|  | 811 | if len(sdkVersions) > 0 { | 
|  | 812 | latestSdkVersion = sdkVersions[len(sdkVersions)-1] | 
|  | 813 | } | 
|  | 814 | v = strconv.Itoa(latestSdkVersion) | 
|  | 815 | } | 
|  | 816 |  | 
|  | 817 | sdk, err := sdkVersionToNumber(ctx, v) | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 818 | if err != nil { | 
|  | 819 | ctx.PropertyErrorf("sdk_version", "%s", err) | 
|  | 820 | } | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 821 | if javaVersion != "" { | 
|  | 822 | ret = javaVersion | 
|  | 823 | } else if ctx.Device() && sdk <= 23 { | 
|  | 824 | ret = "1.7" | 
| Jiyong Park | 4584a8a | 2018-10-03 18:05:04 +0900 | [diff] [blame] | 825 | } else if ctx.Device() && sdk <= 28 || !ctx.Config().TargetOpenJDK9() { | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 826 | ret = "1.8" | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 827 | } else if ctx.Device() && sdkContext.sdkVersion() != "" && sdk == android.FutureApiLevel { | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 828 | // TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current" | 
|  | 829 | ret = "1.8" | 
|  | 830 | } else { | 
|  | 831 | ret = "1.9" | 
|  | 832 | } | 
|  | 833 |  | 
|  | 834 | return ret | 
|  | 835 | } | 
|  | 836 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 837 | func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaBuilderFlags { | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 838 |  | 
| Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 839 | var flags javaBuilderFlags | 
|  | 840 |  | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 841 | // javaVersion flag. | 
|  | 842 | flags.javaVersion = getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j)) | 
|  | 843 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 844 | // javac flags. | 
| Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 845 | javacFlags := j.properties.Javacflags | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 846 | if flags.javaVersion == "1.9" { | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 847 | javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...) | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 848 | } | 
| Colin Cross | 6510f91 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 849 | if ctx.Config().MinimizeJavaDebugInfo() { | 
| Colin Cross | 126a25c | 2017-10-31 13:55:34 -0700 | [diff] [blame] | 850 | // Override the -g flag passed globally to remove local variable debug info to reduce | 
|  | 851 | // disk and memory usage. | 
|  | 852 | javacFlags = append(javacFlags, "-g:source,lines") | 
|  | 853 | } | 
| Colin Cross | 6416271 | 2017-08-08 13:17:59 -0700 | [diff] [blame] | 854 |  | 
| Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 855 | if ctx.Config().RunErrorProne() { | 
|  | 856 | if config.ErrorProneClasspath == nil { | 
|  | 857 | ctx.ModuleErrorf("cannot build with Error Prone, missing external/error_prone?") | 
|  | 858 | } | 
|  | 859 |  | 
|  | 860 | errorProneFlags := []string{ | 
|  | 861 | "-Xplugin:ErrorProne", | 
|  | 862 | "${config.ErrorProneChecks}", | 
|  | 863 | } | 
|  | 864 | errorProneFlags = append(errorProneFlags, j.properties.Errorprone.Javacflags...) | 
|  | 865 |  | 
|  | 866 | flags.errorProneExtraJavacFlags = "${config.ErrorProneFlags} " + | 
|  | 867 | "'" + strings.Join(errorProneFlags, " ") + "'" | 
|  | 868 | flags.errorProneProcessorPath = classpath(android.PathsForSource(ctx, config.ErrorProneClasspath)) | 
| Andreas Gampe | f3e5b55 | 2018-01-22 21:27:21 -0800 | [diff] [blame] | 869 | } | 
|  | 870 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 871 | // classpath | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 872 | flags.bootClasspath = append(flags.bootClasspath, deps.bootClasspath...) | 
|  | 873 | flags.classpath = append(flags.classpath, deps.classpath...) | 
| Colin Cross | 6a77c98 | 2018-06-19 22:43:34 -0700 | [diff] [blame] | 874 | flags.processorPath = append(flags.processorPath, deps.processorPath...) | 
| Colin Cross | 7fdd2b7 | 2018-01-02 18:14:25 -0800 | [diff] [blame] | 875 |  | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 876 | flags.processor = strings.Join(deps.processorClasses, ",") | 
|  | 877 |  | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 878 | if len(flags.bootClasspath) == 0 && ctx.Host() && flags.javaVersion != "1.9" && | 
| Colin Cross | 7fdd2b7 | 2018-01-02 18:14:25 -0800 | [diff] [blame] | 879 | !Bool(j.properties.No_standard_libs) && | 
|  | 880 | inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) { | 
|  | 881 | // Give host-side tools a version of OpenJDK's standard libraries | 
|  | 882 | // close to what they're targeting. As of Dec 2017, AOSP is only | 
|  | 883 | // bundling OpenJDK 8 and 9, so nothing < 8 is available. | 
|  | 884 | // | 
|  | 885 | // When building with OpenJDK 8, the following should have no | 
|  | 886 | // effect since those jars would be available by default. | 
|  | 887 | // | 
|  | 888 | // When building with OpenJDK 9 but targeting a version < 1.8, | 
|  | 889 | // putting them on the bootclasspath means that: | 
|  | 890 | // a) code can't (accidentally) refer to OpenJDK 9 specific APIs | 
|  | 891 | // b) references to existing APIs are not reinterpreted in an | 
|  | 892 | //    OpenJDK 9-specific way, eg. calls to subclasses of | 
|  | 893 | //    java.nio.Buffer as in http://b/70862583 | 
|  | 894 | java8Home := ctx.Config().Getenv("ANDROID_JAVA8_HOME") | 
|  | 895 | flags.bootClasspath = append(flags.bootClasspath, | 
|  | 896 | android.PathForSource(ctx, java8Home, "jre/lib/jce.jar"), | 
|  | 897 | android.PathForSource(ctx, java8Home, "jre/lib/rt.jar")) | 
| Nan Zhang | 5f8cb42 | 2018-02-06 10:34:32 -0800 | [diff] [blame] | 898 | if Bool(j.properties.Use_tools_jar) { | 
|  | 899 | flags.bootClasspath = append(flags.bootClasspath, | 
|  | 900 | android.PathForSource(ctx, java8Home, "lib/tools.jar")) | 
|  | 901 | } | 
| Colin Cross | 7fdd2b7 | 2018-01-02 18:14:25 -0800 | [diff] [blame] | 902 | } | 
|  | 903 |  | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 904 | if j.properties.Patch_module != nil && flags.javaVersion == "1.9" { | 
| Jaewoong Jung | 38e4fb2 | 2018-12-12 09:01:34 -0800 | [diff] [blame] | 905 | // Manually specify build directory in case it is not under the repo root. | 
|  | 906 | // (javac doesn't seem to expand into symbolc links when searching for patch-module targets, so | 
|  | 907 | // just adding a symlink under the root doesn't help.) | 
|  | 908 | patchPaths := ".:" + ctx.Config().BuildDir() | 
|  | 909 | classPath := flags.classpath.FormJavaClassPath("") | 
|  | 910 | if classPath != "" { | 
|  | 911 | patchPaths += ":" + classPath | 
|  | 912 | } | 
|  | 913 | javacFlags = append(javacFlags, "--patch-module="+String(j.properties.Patch_module)+"="+patchPaths) | 
| Colin Cross | 8144008 | 2018-08-15 20:21:55 -0700 | [diff] [blame] | 914 | } | 
|  | 915 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 916 | // systemModules | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 917 | if deps.systemModules != nil { | 
|  | 918 | flags.systemModules = append(flags.systemModules, deps.systemModules) | 
|  | 919 | } | 
|  | 920 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 921 | // aidl flags. | 
| Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 922 | aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs) | 
| Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 923 | if len(aidlFlags) > 0 { | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 924 | // optimization. | 
| Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 925 | ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " ")) | 
|  | 926 | flags.aidlFlags = "$aidlFlags" | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 927 | } | 
|  | 928 |  | 
| Colin Cross | 8144008 | 2018-08-15 20:21:55 -0700 | [diff] [blame] | 929 | if len(javacFlags) > 0 { | 
|  | 930 | // optimization. | 
|  | 931 | ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " ")) | 
|  | 932 | flags.javacFlags = "$javacFlags" | 
|  | 933 | } | 
|  | 934 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 935 | return flags | 
|  | 936 | } | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 937 |  | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 938 | func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path) { | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 939 |  | 
| Colin Cross | ebe1a51 | 2017-11-14 13:12:14 -0800 | [diff] [blame] | 940 | j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs) | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 941 |  | 
|  | 942 | deps := j.collectDeps(ctx) | 
|  | 943 | flags := j.collectBuilderFlags(ctx, deps) | 
|  | 944 |  | 
| Tobias Thierer | 06dd04f | 2018-09-11 16:21:05 +0100 | [diff] [blame] | 945 | if flags.javaVersion == "1.9" { | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 946 | j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...) | 
|  | 947 | } | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 948 | srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs) | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 949 | if hasSrcExt(srcFiles.Strings(), ".proto") { | 
| Colin Cross | 0f2ee15 | 2017-12-14 15:22:43 -0800 | [diff] [blame] | 950 | flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags) | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 951 | } | 
|  | 952 |  | 
| Colin Cross | af05017 | 2017-11-15 23:01:59 -0800 | [diff] [blame] | 953 | srcFiles = j.genSources(ctx, srcFiles, flags) | 
|  | 954 |  | 
|  | 955 | srcJars := srcFiles.FilterByExt(".srcjar") | 
| Colin Cross | 59149b6 | 2017-10-16 18:07:29 -0700 | [diff] [blame] | 956 | srcJars = append(srcJars, deps.srcJars...) | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 957 | srcJars = append(srcJars, extraSrcJars...) | 
| Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 958 |  | 
| Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 959 | // Collect source files from compiledJavaSrcs, compiledSrcJars and filter out Exclude_srcs | 
|  | 960 | // that IDEInfo struct will use | 
|  | 961 | j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.Strings()...) | 
|  | 962 |  | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 963 | if j.properties.Jarjar_rules != nil { | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 964 | j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules) | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 965 | } | 
|  | 966 |  | 
| Colin Cross | 1ee2317 | 2017-10-18 14:44:18 -0700 | [diff] [blame] | 967 | jarName := ctx.ModuleName() + ".jar" | 
|  | 968 |  | 
| Przemyslaw Szczepaniak | 4b5fe9d | 2018-02-13 14:32:54 +0000 | [diff] [blame] | 969 | javaSrcFiles := srcFiles.FilterByExt(".java") | 
|  | 970 | var uniqueSrcFiles android.Paths | 
|  | 971 | set := make(map[string]bool) | 
|  | 972 | for _, v := range javaSrcFiles { | 
|  | 973 | if _, found := set[v.String()]; !found { | 
|  | 974 | set[v.String()] = true | 
|  | 975 | uniqueSrcFiles = append(uniqueSrcFiles, v) | 
|  | 976 | } | 
|  | 977 | } | 
|  | 978 |  | 
| Colin Cross | 55f63ea | 2018-08-27 12:37:09 -0700 | [diff] [blame] | 979 | var kotlinJars android.Paths | 
|  | 980 |  | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 981 | if srcFiles.HasExt(".kt") { | 
| Zoran Jovanovic | 8736ce2 | 2018-08-21 17:10:29 +0200 | [diff] [blame] | 982 | // user defined kotlin flags. | 
|  | 983 | kotlincFlags := j.properties.Kotlincflags | 
|  | 984 | CheckKotlincFlags(ctx, kotlincFlags) | 
|  | 985 |  | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 986 | // If there are kotlin files, compile them first but pass all the kotlin and java files | 
|  | 987 | // kotlinc will use the java files to resolve types referenced by the kotlin files, but | 
|  | 988 | // won't emit any classes for them. | 
| Zoran Jovanovic | 8736ce2 | 2018-08-21 17:10:29 +0200 | [diff] [blame] | 989 | kotlincFlags = append(kotlincFlags, "-no-stdlib") | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 990 | if ctx.Device() { | 
| Zoran Jovanovic | 8736ce2 | 2018-08-21 17:10:29 +0200 | [diff] [blame] | 991 | kotlincFlags = append(kotlincFlags, "-no-jdk") | 
|  | 992 | } | 
|  | 993 | if len(kotlincFlags) > 0 { | 
|  | 994 | // optimization. | 
|  | 995 | ctx.Variable(pctx, "kotlincFlags", strings.Join(kotlincFlags, " ")) | 
|  | 996 | flags.kotlincFlags += "$kotlincFlags" | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 997 | } | 
|  | 998 |  | 
| Przemyslaw Szczepaniak | 4b5fe9d | 2018-02-13 14:32:54 +0000 | [diff] [blame] | 999 | var kotlinSrcFiles android.Paths | 
|  | 1000 | kotlinSrcFiles = append(kotlinSrcFiles, uniqueSrcFiles...) | 
|  | 1001 | kotlinSrcFiles = append(kotlinSrcFiles, srcFiles.FilterByExt(".kt")...) | 
|  | 1002 |  | 
| Colin Cross | afbb173 | 2019-01-17 15:42:52 -0800 | [diff] [blame] | 1003 | flags.classpath = append(flags.classpath, deps.kotlinStdlib...) | 
|  | 1004 | flags.classpath = append(flags.classpath, deps.kotlinAnnotations...) | 
|  | 1005 |  | 
|  | 1006 | flags.kotlincClasspath = append(flags.kotlincClasspath, flags.bootClasspath...) | 
|  | 1007 | flags.kotlincClasspath = append(flags.kotlincClasspath, flags.classpath...) | 
|  | 1008 |  | 
|  | 1009 | if len(flags.processorPath) > 0 { | 
|  | 1010 | // Use kapt for annotation processing | 
|  | 1011 | kaptSrcJar := android.PathForModuleOut(ctx, "kapt", "kapt-sources.jar") | 
|  | 1012 | kotlinKapt(ctx, kaptSrcJar, kotlinSrcFiles, srcJars, flags) | 
|  | 1013 | srcJars = append(srcJars, kaptSrcJar) | 
|  | 1014 | // Disable annotation processing in javac, it's already been handled by kapt | 
|  | 1015 | flags.processorPath = nil | 
| Colin Cross | 3a3e94c | 2019-01-23 15:39:50 -0800 | [diff] [blame] | 1016 | flags.processor = "" | 
| Colin Cross | afbb173 | 2019-01-17 15:42:52 -0800 | [diff] [blame] | 1017 | } | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 1018 |  | 
| Colin Cross | 1ee2317 | 2017-10-18 14:44:18 -0700 | [diff] [blame] | 1019 | kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName) | 
| Colin Cross | 21fc9bb | 2019-01-18 15:05:09 -0800 | [diff] [blame] | 1020 | kotlinCompile(ctx, kotlinJar, kotlinSrcFiles, srcJars, flags) | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 1021 | if ctx.Failed() { | 
|  | 1022 | return | 
|  | 1023 | } | 
|  | 1024 |  | 
|  | 1025 | // Make javac rule depend on the kotlinc rule | 
|  | 1026 | flags.classpath = append(flags.classpath, kotlinJar) | 
| Przemyslaw Szczepaniak | 66c0c40 | 2018-03-08 13:21:55 +0000 | [diff] [blame] | 1027 |  | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 1028 | // Jar kotlin classes into the final jar after javac | 
| Colin Cross | 55f63ea | 2018-08-27 12:37:09 -0700 | [diff] [blame] | 1029 | kotlinJars = append(kotlinJars, kotlinJar) | 
| Colin Cross | 9b38aef | 2018-08-27 15:42:25 -0700 | [diff] [blame] | 1030 | kotlinJars = append(kotlinJars, deps.kotlinStdlib...) | 
| Colin Cross | 93e8595 | 2017-08-15 13:34:18 -0700 | [diff] [blame] | 1031 | } | 
|  | 1032 |  | 
| Colin Cross | 55f63ea | 2018-08-27 12:37:09 -0700 | [diff] [blame] | 1033 | jars := append(android.Paths(nil), kotlinJars...) | 
|  | 1034 |  | 
| Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 1035 | // Store the list of .java files that was passed to javac | 
|  | 1036 | j.compiledJavaSrcs = uniqueSrcFiles | 
|  | 1037 | j.compiledSrcJars = srcJars | 
|  | 1038 |  | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 1039 | enable_sharding := false | 
| Colin Cross | be9cdb8 | 2019-01-21 21:37:16 -0800 | [diff] [blame] | 1040 | if ctx.Device() && !ctx.Config().IsEnvFalse("TURBINE_ENABLED") && !deps.disableTurbine { | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 1041 | if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 { | 
|  | 1042 | enable_sharding = true | 
| Ashley Rose | e36efcf | 2019-01-16 17:34:08 -0500 | [diff] [blame] | 1043 | // Formerly, there was a check here that prevented annotation processors | 
|  | 1044 | // from being used when sharding was enabled, as some annotation processors | 
|  | 1045 | // do not function correctly in sharded environments. It was removed to | 
|  | 1046 | // allow for the use of annotation processors that do function correctly | 
|  | 1047 | // with sharding enabled. See: b/77284273. | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 1048 | } | 
| Colin Cross | 55f63ea | 2018-08-27 12:37:09 -0700 | [diff] [blame] | 1049 | j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName, kotlinJars) | 
| Colin Cross | f19b9bb | 2018-03-26 14:42:44 -0700 | [diff] [blame] | 1050 | if ctx.Failed() { | 
|  | 1051 | return | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1052 | } | 
|  | 1053 | } | 
| Colin Cross | 8eadbf0 | 2017-10-24 17:46:00 -0700 | [diff] [blame] | 1054 | if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 { | 
| Colin Cross | d689143 | 2017-09-27 17:39:56 -0700 | [diff] [blame] | 1055 | var extraJarDeps android.Paths | 
| Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 1056 | if ctx.Config().RunErrorProne() { | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 1057 | // If error-prone is enabled, add an additional rule to compile the java files into | 
|  | 1058 | // a separate set of classes (so that they don't overwrite the normal ones and require | 
| Colin Cross | d689143 | 2017-09-27 17:39:56 -0700 | [diff] [blame] | 1059 | // a rebuild when error-prone is turned off). | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 1060 | // TODO(ccross): Once we always compile with javac9 we may be able to conditionally | 
|  | 1061 | //    enable error-prone without affecting the output class files. | 
| Colin Cross | 1ee2317 | 2017-10-18 14:44:18 -0700 | [diff] [blame] | 1062 | errorprone := android.PathForModuleOut(ctx, "errorprone", jarName) | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 1063 | RunErrorProne(ctx, errorprone, uniqueSrcFiles, srcJars, flags) | 
| Colin Cross | c6bbef3 | 2017-08-14 14:16:06 -0700 | [diff] [blame] | 1064 | extraJarDeps = append(extraJarDeps, errorprone) | 
|  | 1065 | } | 
|  | 1066 |  | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 1067 | if enable_sharding { | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 1068 | flags.classpath = append(flags.classpath, j.headerJarFile) | 
| Nan Zhang | 61eaedb | 2017-11-02 13:28:15 -0700 | [diff] [blame] | 1069 | shardSize := int(*(j.properties.Javac_shard_size)) | 
|  | 1070 | var shardSrcs []android.Paths | 
|  | 1071 | if len(uniqueSrcFiles) > 0 { | 
|  | 1072 | shardSrcs = shardPaths(uniqueSrcFiles, shardSize) | 
|  | 1073 | for idx, shardSrc := range shardSrcs { | 
|  | 1074 | classes := android.PathForModuleOut(ctx, "javac", jarName+strconv.Itoa(idx)) | 
|  | 1075 | TransformJavaToClasses(ctx, classes, idx, shardSrc, nil, flags, extraJarDeps) | 
|  | 1076 | jars = append(jars, classes) | 
|  | 1077 | } | 
|  | 1078 | } | 
|  | 1079 | if len(srcJars) > 0 { | 
|  | 1080 | classes := android.PathForModuleOut(ctx, "javac", jarName+strconv.Itoa(len(shardSrcs))) | 
|  | 1081 | TransformJavaToClasses(ctx, classes, len(shardSrcs), nil, srcJars, flags, extraJarDeps) | 
|  | 1082 | jars = append(jars, classes) | 
|  | 1083 | } | 
|  | 1084 | } else { | 
|  | 1085 | classes := android.PathForModuleOut(ctx, "javac", jarName) | 
|  | 1086 | TransformJavaToClasses(ctx, classes, -1, uniqueSrcFiles, srcJars, flags, extraJarDeps) | 
|  | 1087 | jars = append(jars, classes) | 
|  | 1088 | } | 
| Colin Cross | d689143 | 2017-09-27 17:39:56 -0700 | [diff] [blame] | 1089 | if ctx.Failed() { | 
|  | 1090 | return | 
|  | 1091 | } | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1092 | } | 
|  | 1093 |  | 
| Colin Cross | cedd476 | 2018-09-13 11:26:19 -0700 | [diff] [blame] | 1094 | dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs, | 
|  | 1095 | j.properties.Exclude_java_resource_dirs, j.properties.Exclude_java_resources) | 
| Colin Cross | 0f37af0 | 2017-09-27 17:42:05 -0700 | [diff] [blame] | 1096 | fileArgs, fileDeps := ResourceFilesToJarArgs(ctx, j.properties.Java_resources, j.properties.Exclude_java_resources) | 
|  | 1097 |  | 
|  | 1098 | var resArgs []string | 
|  | 1099 | var resDeps android.Paths | 
|  | 1100 |  | 
|  | 1101 | resArgs = append(resArgs, dirArgs...) | 
|  | 1102 | resDeps = append(resDeps, dirDeps...) | 
|  | 1103 |  | 
|  | 1104 | resArgs = append(resArgs, fileArgs...) | 
|  | 1105 | resDeps = append(resDeps, fileDeps...) | 
|  | 1106 |  | 
| Colin Cross | ff3ae9d | 2018-04-10 16:15:18 -0700 | [diff] [blame] | 1107 | if Bool(j.properties.Include_srcs) { | 
| Colin Cross | 2372923 | 2017-10-03 13:14:07 -0700 | [diff] [blame] | 1108 | srcArgs, srcDeps := SourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs) | 
| Colin Cross | 0f37af0 | 2017-09-27 17:42:05 -0700 | [diff] [blame] | 1109 | resArgs = append(resArgs, srcArgs...) | 
|  | 1110 | resDeps = append(resDeps, srcDeps...) | 
|  | 1111 | } | 
| Colin Cross | 40a3671 | 2017-09-27 17:41:35 -0700 | [diff] [blame] | 1112 |  | 
|  | 1113 | if len(resArgs) > 0 { | 
| Colin Cross | 1ee2317 | 2017-10-18 14:44:18 -0700 | [diff] [blame] | 1114 | resourceJar := android.PathForModuleOut(ctx, "res", jarName) | 
| Colin Cross | e9a275b | 2017-10-16 17:09:48 -0700 | [diff] [blame] | 1115 | TransformResourcesToJar(ctx, resourceJar, resArgs, resDeps) | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1116 | j.resourceJar = resourceJar | 
| Colin Cross | 65bf4f2 | 2015-04-03 16:54:17 -0700 | [diff] [blame] | 1117 | if ctx.Failed() { | 
|  | 1118 | return | 
|  | 1119 | } | 
|  | 1120 | } | 
|  | 1121 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1122 | if len(deps.staticResourceJars) > 0 { | 
|  | 1123 | var jars android.Paths | 
|  | 1124 | if j.resourceJar != nil { | 
|  | 1125 | jars = append(jars, j.resourceJar) | 
|  | 1126 | } | 
|  | 1127 | jars = append(jars, deps.staticResourceJars...) | 
|  | 1128 |  | 
|  | 1129 | combinedJar := android.PathForModuleOut(ctx, "res-combined", jarName) | 
|  | 1130 | TransformJarsToJar(ctx, combinedJar, "for resources", jars, android.OptionalPath{}, | 
|  | 1131 | false, nil, nil) | 
|  | 1132 | j.resourceJar = combinedJar | 
|  | 1133 | } | 
|  | 1134 |  | 
| Colin Cross | 32f676a | 2017-09-06 13:41:06 -0700 | [diff] [blame] | 1135 | jars = append(jars, deps.staticJars...) | 
| Colin Cross | 0a6e007 | 2017-08-30 14:24:55 -0700 | [diff] [blame] | 1136 |  | 
| Colin Cross | 094054a | 2018-10-17 15:10:48 -0700 | [diff] [blame] | 1137 | manifest := j.overrideManifest | 
|  | 1138 | if !manifest.Valid() && j.properties.Manifest != nil { | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 1139 | manifest = android.OptionalPathForPath(android.PathForModuleSrc(ctx, *j.properties.Manifest)) | 
| Colin Cross | 366938f | 2017-12-11 16:29:02 -0800 | [diff] [blame] | 1140 | } | 
| Colin Cross | 635acc9 | 2017-09-12 22:50:46 -0700 | [diff] [blame] | 1141 |  | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 1142 | services := android.PathsForModuleSrc(ctx, j.properties.Services) | 
| Alex Light | 7f004a7 | 2019-02-21 13:27:37 -0800 | [diff] [blame] | 1143 | if len(services) > 0 { | 
|  | 1144 | servicesJar := android.PathForModuleOut(ctx, "services", jarName) | 
|  | 1145 | var zipargs []string | 
|  | 1146 | for _, file := range services { | 
|  | 1147 | serviceFile := file.String() | 
|  | 1148 | zipargs = append(zipargs, "-C", filepath.Dir(serviceFile), "-f", serviceFile) | 
|  | 1149 | } | 
|  | 1150 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1151 | Rule:      zip, | 
|  | 1152 | Output:    servicesJar, | 
|  | 1153 | Implicits: services, | 
|  | 1154 | Args: map[string]string{ | 
| Colin Cross | 0b9f31f | 2019-02-28 11:00:01 -0800 | [diff] [blame] | 1155 | "jarArgs": "-P META-INF/services/ " + strings.Join(proptools.NinjaAndShellEscapeList(zipargs), " "), | 
| Alex Light | 7f004a7 | 2019-02-21 13:27:37 -0800 | [diff] [blame] | 1156 | }, | 
|  | 1157 | }) | 
|  | 1158 | jars = append(jars, servicesJar) | 
|  | 1159 | } | 
|  | 1160 |  | 
| Colin Cross | 0a6e007 | 2017-08-30 14:24:55 -0700 | [diff] [blame] | 1161 | // Combine the classes built from sources, any manifests, and any static libraries into | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1162 | // classes.jar. If there is only one input jar this step will be skipped. | 
| Colin Cross | 3063b78 | 2018-08-15 11:19:12 -0700 | [diff] [blame] | 1163 | var outputFile android.ModuleOutPath | 
| Colin Cross | e9a275b | 2017-10-16 17:09:48 -0700 | [diff] [blame] | 1164 |  | 
|  | 1165 | if len(jars) == 1 && !manifest.Valid() { | 
| Colin Cross | 3063b78 | 2018-08-15 11:19:12 -0700 | [diff] [blame] | 1166 | if moduleOutPath, ok := jars[0].(android.ModuleOutPath); ok { | 
|  | 1167 | // Optimization: skip the combine step if there is nothing to do | 
|  | 1168 | // TODO(ccross): this leaves any module-info.class files, but those should only come from | 
|  | 1169 | // prebuilt dependencies until we support modules in the platform build, so there shouldn't be | 
|  | 1170 | // any if len(jars) == 1. | 
|  | 1171 | outputFile = moduleOutPath | 
|  | 1172 | } else { | 
|  | 1173 | combinedJar := android.PathForModuleOut(ctx, "combined", jarName) | 
|  | 1174 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1175 | Rule:   android.Cp, | 
|  | 1176 | Input:  jars[0], | 
|  | 1177 | Output: combinedJar, | 
|  | 1178 | }) | 
|  | 1179 | outputFile = combinedJar | 
|  | 1180 | } | 
| Colin Cross | e9a275b | 2017-10-16 17:09:48 -0700 | [diff] [blame] | 1181 | } else { | 
| Colin Cross | 1ee2317 | 2017-10-18 14:44:18 -0700 | [diff] [blame] | 1182 | combinedJar := android.PathForModuleOut(ctx, "combined", jarName) | 
| Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1183 | TransformJarsToJar(ctx, combinedJar, "for javac", jars, manifest, | 
| Colin Cross | 9b38aef | 2018-08-27 15:42:25 -0700 | [diff] [blame] | 1184 | false, nil, nil) | 
| Colin Cross | e9a275b | 2017-10-16 17:09:48 -0700 | [diff] [blame] | 1185 | outputFile = combinedJar | 
|  | 1186 | } | 
| Colin Cross | 0a6e007 | 2017-08-30 14:24:55 -0700 | [diff] [blame] | 1187 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1188 | // jarjar implementation jar if necessary | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 1189 | if j.expandJarjarRules != nil { | 
| Colin Cross | 8649b26 | 2017-09-27 18:03:17 -0700 | [diff] [blame] | 1190 | // Transform classes.jar into classes-jarjar.jar | 
| Colin Cross | 1ee2317 | 2017-10-18 14:44:18 -0700 | [diff] [blame] | 1191 | jarjarFile := android.PathForModuleOut(ctx, "jarjar", jarName) | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 1192 | TransformJarJar(ctx, jarjarFile, outputFile, j.expandJarjarRules) | 
| Colin Cross | e9a275b | 2017-10-16 17:09:48 -0700 | [diff] [blame] | 1193 | outputFile = jarjarFile | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1194 |  | 
|  | 1195 | // jarjar resource jar if necessary | 
|  | 1196 | if j.resourceJar != nil { | 
|  | 1197 | resourceJarJarFile := android.PathForModuleOut(ctx, "res-jarjar", jarName) | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 1198 | TransformJarJar(ctx, resourceJarJarFile, j.resourceJar, j.expandJarjarRules) | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1199 | j.resourceJar = resourceJarJarFile | 
|  | 1200 | } | 
|  | 1201 |  | 
| Colin Cross | 0a6e007 | 2017-08-30 14:24:55 -0700 | [diff] [blame] | 1202 | if ctx.Failed() { | 
|  | 1203 | return | 
|  | 1204 | } | 
|  | 1205 | } | 
| Vladimir Marko | 0975ee0 | 2019-04-02 10:29:55 +0100 | [diff] [blame] | 1206 |  | 
|  | 1207 | // Check package restrictions if necessary. | 
|  | 1208 | if len(j.properties.Permitted_packages) > 0 { | 
|  | 1209 | // Check packages and copy to package-checked file. | 
|  | 1210 | pkgckFile := android.PathForModuleOut(ctx, "package-check.stamp") | 
|  | 1211 | CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages) | 
|  | 1212 | j.additionalCheckedModules = append(j.additionalCheckedModules, pkgckFile) | 
|  | 1213 |  | 
|  | 1214 | if ctx.Failed() { | 
|  | 1215 | return | 
|  | 1216 | } | 
|  | 1217 | } | 
|  | 1218 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1219 | j.implementationJarFile = outputFile | 
|  | 1220 | if j.headerJarFile == nil { | 
|  | 1221 | j.headerJarFile = j.implementationJarFile | 
|  | 1222 | } | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1223 |  | 
| Colin Cross | 6510f91 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 1224 | if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 1225 | if inList(ctx.ModuleName(), config.InstrumentFrameworkModules) { | 
|  | 1226 | j.properties.Instrument = true | 
|  | 1227 | } | 
|  | 1228 | } | 
|  | 1229 |  | 
| Colin Cross | 3144dfc | 2018-01-03 15:06:47 -0800 | [diff] [blame] | 1230 | if j.shouldInstrument(ctx) { | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 1231 | outputFile = j.instrument(ctx, flags, outputFile, jarName) | 
|  | 1232 | } | 
|  | 1233 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1234 | // merge implementation jar with resources if necessary | 
|  | 1235 | implementationAndResourcesJar := outputFile | 
|  | 1236 | if j.resourceJar != nil { | 
|  | 1237 | jars := android.Paths{implementationAndResourcesJar, j.resourceJar} | 
|  | 1238 | combinedJar := android.PathForModuleOut(ctx, "withres", jarName) | 
|  | 1239 | TransformJarsToJar(ctx, combinedJar, "for resources", jars, android.OptionalPath{}, | 
|  | 1240 | false, nil, nil) | 
|  | 1241 | implementationAndResourcesJar = combinedJar | 
|  | 1242 | } | 
|  | 1243 |  | 
|  | 1244 | j.implementationAndResourcesJar = implementationAndResourcesJar | 
|  | 1245 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1246 | if ctx.Device() && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) { | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 1247 | // Dex compilation | 
| Colin Cross | 3063b78 | 2018-08-15 11:19:12 -0700 | [diff] [blame] | 1248 | var dexOutputFile android.ModuleOutPath | 
| David Brazdil | 17ef563 | 2018-06-27 10:27:45 +0100 | [diff] [blame] | 1249 | dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1250 | if ctx.Failed() { | 
|  | 1251 | return | 
|  | 1252 | } | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1253 |  | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 1254 | // Hidden API CSV generation and dex encoding | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 1255 | dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, dexOutputFile, j.implementationJarFile, | 
|  | 1256 | j.deviceProperties.UncompressDex) | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 1257 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1258 | // merge dex jar with resources if necessary | 
|  | 1259 | if j.resourceJar != nil { | 
|  | 1260 | jars := android.Paths{dexOutputFile, j.resourceJar} | 
|  | 1261 | combinedJar := android.PathForModuleOut(ctx, "dex-withres", jarName) | 
|  | 1262 | TransformJarsToJar(ctx, combinedJar, "for dex resources", jars, android.OptionalPath{}, | 
|  | 1263 | false, nil, nil) | 
| Nicolas Geoffray | f343872 | 2019-01-23 15:57:21 +0000 | [diff] [blame] | 1264 | if j.deviceProperties.UncompressDex { | 
|  | 1265 | combinedAlignedJar := android.PathForModuleOut(ctx, "dex-withres-aligned", jarName) | 
|  | 1266 | TransformZipAlign(ctx, combinedAlignedJar, combinedJar) | 
|  | 1267 | dexOutputFile = combinedAlignedJar | 
|  | 1268 | } else { | 
|  | 1269 | dexOutputFile = combinedJar | 
|  | 1270 | } | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1271 | } | 
|  | 1272 |  | 
|  | 1273 | j.dexJarFile = dexOutputFile | 
|  | 1274 |  | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 1275 | // Dexpreopting | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1276 | dexOutputFile = j.dexpreopt(ctx, dexOutputFile) | 
|  | 1277 |  | 
|  | 1278 | j.maybeStrippedDexJarFile = dexOutputFile | 
|  | 1279 |  | 
| Colin Cross | 3063b78 | 2018-08-15 11:19:12 -0700 | [diff] [blame] | 1280 | outputFile = dexOutputFile | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1281 |  | 
|  | 1282 | if ctx.Failed() { | 
|  | 1283 | return | 
|  | 1284 | } | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1285 | } else { | 
|  | 1286 | outputFile = implementationAndResourcesJar | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1287 | } | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1288 |  | 
| Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 1289 | ctx.CheckbuildFile(outputFile) | 
| Colin Cross | 3063b78 | 2018-08-15 11:19:12 -0700 | [diff] [blame] | 1290 |  | 
|  | 1291 | // Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource | 
|  | 1292 | j.outputFile = outputFile.WithoutRel() | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1293 | } | 
|  | 1294 |  | 
| Zoran Jovanovic | 8736ce2 | 2018-08-21 17:10:29 +0200 | [diff] [blame] | 1295 | // Check for invalid kotlinc flags. Only use this for flags explicitly passed by the user, | 
|  | 1296 | // since some of these flags may be used internally. | 
|  | 1297 | func CheckKotlincFlags(ctx android.ModuleContext, flags []string) { | 
|  | 1298 | for _, flag := range flags { | 
|  | 1299 | flag = strings.TrimSpace(flag) | 
|  | 1300 |  | 
|  | 1301 | if !strings.HasPrefix(flag, "-") { | 
|  | 1302 | ctx.PropertyErrorf("kotlincflags", "Flag `%s` must start with `-`", flag) | 
|  | 1303 | } else if strings.HasPrefix(flag, "-Xintellij-plugin-root") { | 
|  | 1304 | ctx.PropertyErrorf("kotlincflags", | 
|  | 1305 | "Bad flag: `%s`, only use internal compiler for consistency.", flag) | 
|  | 1306 | } else if inList(flag, config.KotlincIllegalFlags) { | 
|  | 1307 | ctx.PropertyErrorf("kotlincflags", "Flag `%s` already used by build system", flag) | 
|  | 1308 | } else if flag == "-include-runtime" { | 
|  | 1309 | ctx.PropertyErrorf("kotlincflags", "Bad flag: `%s`, do not include runtime.", flag) | 
|  | 1310 | } else { | 
|  | 1311 | args := strings.Split(flag, " ") | 
|  | 1312 | if args[0] == "-kotlin-home" { | 
|  | 1313 | ctx.PropertyErrorf("kotlincflags", | 
|  | 1314 | "Bad flag: `%s`, kotlin home already set to default (path to kotlinc in the repo).", flag) | 
|  | 1315 | } | 
|  | 1316 | } | 
|  | 1317 | } | 
|  | 1318 | } | 
|  | 1319 |  | 
| Colin Cross | 8eadbf0 | 2017-10-24 17:46:00 -0700 | [diff] [blame] | 1320 | func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars android.Paths, | 
| Colin Cross | 55f63ea | 2018-08-27 12:37:09 -0700 | [diff] [blame] | 1321 | deps deps, flags javaBuilderFlags, jarName string, extraJars android.Paths) android.Path { | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1322 |  | 
|  | 1323 | var jars android.Paths | 
| Colin Cross | 8eadbf0 | 2017-10-24 17:46:00 -0700 | [diff] [blame] | 1324 | if len(srcFiles) > 0 || len(srcJars) > 0 { | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1325 | // Compile java sources into turbine.jar. | 
|  | 1326 | turbineJar := android.PathForModuleOut(ctx, "turbine", jarName) | 
|  | 1327 | TransformJavaToHeaderClasses(ctx, turbineJar, srcFiles, srcJars, flags) | 
|  | 1328 | if ctx.Failed() { | 
|  | 1329 | return nil | 
|  | 1330 | } | 
|  | 1331 | jars = append(jars, turbineJar) | 
|  | 1332 | } | 
|  | 1333 |  | 
| Colin Cross | 55f63ea | 2018-08-27 12:37:09 -0700 | [diff] [blame] | 1334 | jars = append(jars, extraJars...) | 
|  | 1335 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1336 | // Combine any static header libraries into classes-header.jar. If there is only | 
|  | 1337 | // one input jar this step will be skipped. | 
|  | 1338 | var headerJar android.Path | 
|  | 1339 | jars = append(jars, deps.staticHeaderJars...) | 
|  | 1340 |  | 
| Colin Cross | 5c6ecc1 | 2017-10-23 18:12:27 -0700 | [diff] [blame] | 1341 | // we cannot skip the combine step for now if there is only one jar | 
|  | 1342 | // since we have to strip META-INF/TRANSITIVE dir from turbine.jar | 
|  | 1343 | combinedJar := android.PathForModuleOut(ctx, "turbine-combined", jarName) | 
| Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1344 | TransformJarsToJar(ctx, combinedJar, "for turbine", jars, android.OptionalPath{}, | 
|  | 1345 | false, nil, []string{"META-INF"}) | 
| Colin Cross | 5c6ecc1 | 2017-10-23 18:12:27 -0700 | [diff] [blame] | 1346 | headerJar = combinedJar | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1347 |  | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 1348 | if j.expandJarjarRules != nil { | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1349 | // Transform classes.jar into classes-jarjar.jar | 
|  | 1350 | jarjarFile := android.PathForModuleOut(ctx, "turbine-jarjar", jarName) | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 1351 | TransformJarJar(ctx, jarjarFile, headerJar, j.expandJarjarRules) | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1352 | headerJar = jarjarFile | 
|  | 1353 | if ctx.Failed() { | 
|  | 1354 | return nil | 
|  | 1355 | } | 
|  | 1356 | } | 
|  | 1357 |  | 
|  | 1358 | return headerJar | 
|  | 1359 | } | 
|  | 1360 |  | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 1361 | func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags, | 
| Colin Cross | 3063b78 | 2018-08-15 11:19:12 -0700 | [diff] [blame] | 1362 | classesJar android.Path, jarName string) android.ModuleOutPath { | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 1363 |  | 
| Colin Cross | 7a3139e | 2017-12-19 13:57:50 -0800 | [diff] [blame] | 1364 | specs := j.jacocoModuleToZipCommand(ctx) | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 1365 |  | 
| Colin Cross | 84c3882 | 2018-01-03 15:59:46 -0800 | [diff] [blame] | 1366 | jacocoReportClassesFile := android.PathForModuleOut(ctx, "jacoco-report-classes", jarName) | 
| Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 1367 | instrumentedJar := android.PathForModuleOut(ctx, "jacoco", jarName) | 
|  | 1368 |  | 
|  | 1369 | jacocoInstrumentJar(ctx, instrumentedJar, jacocoReportClassesFile, classesJar, specs) | 
|  | 1370 |  | 
|  | 1371 | j.jacocoReportClassesFile = jacocoReportClassesFile | 
|  | 1372 |  | 
|  | 1373 | return instrumentedJar | 
|  | 1374 | } | 
|  | 1375 |  | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1376 | var _ Dependency = (*Module)(nil) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1377 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1378 | func (j *Module) HeaderJars() android.Paths { | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1379 | if j.headerJarFile == nil { | 
|  | 1380 | return nil | 
|  | 1381 | } | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1382 | return android.Paths{j.headerJarFile} | 
|  | 1383 | } | 
|  | 1384 |  | 
|  | 1385 | func (j *Module) ImplementationJars() android.Paths { | 
| shinwang | 9e4c07a | 2018-12-24 15:41:04 +0800 | [diff] [blame] | 1386 | if j.implementationJarFile == nil { | 
|  | 1387 | return nil | 
|  | 1388 | } | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1389 | return android.Paths{j.implementationJarFile} | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1390 | } | 
|  | 1391 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 1392 | func (j *Module) DexJar() android.Path { | 
|  | 1393 | return j.dexJarFile | 
|  | 1394 | } | 
|  | 1395 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1396 | func (j *Module) ResourceJars() android.Paths { | 
|  | 1397 | if j.resourceJar == nil { | 
|  | 1398 | return nil | 
|  | 1399 | } | 
|  | 1400 | return android.Paths{j.resourceJar} | 
|  | 1401 | } | 
|  | 1402 |  | 
|  | 1403 | func (j *Module) ImplementationAndResourcesJars() android.Paths { | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1404 | if j.implementationAndResourcesJar == nil { | 
|  | 1405 | return nil | 
|  | 1406 | } | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1407 | return android.Paths{j.implementationAndResourcesJar} | 
|  | 1408 | } | 
|  | 1409 |  | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1410 | func (j *Module) AidlIncludeDirs() android.Paths { | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1411 | // exportAidlIncludeDirs is type android.Paths already | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 1412 | return j.exportAidlIncludeDirs | 
|  | 1413 | } | 
|  | 1414 |  | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1415 | func (j *Module) ExportedSdkLibs() []string { | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1416 | // exportedSdkLibs is type []string | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1417 | return j.exportedSdkLibs | 
|  | 1418 | } | 
|  | 1419 |  | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1420 | var _ logtagsProducer = (*Module)(nil) | 
| Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 1421 |  | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1422 | func (j *Module) logtags() android.Paths { | 
| Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 1423 | return j.logtagsSrcs | 
|  | 1424 | } | 
|  | 1425 |  | 
| Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 1426 | // Collect information for opening IDE project files in java/jdeps.go. | 
|  | 1427 | func (j *Module) IDEInfo(dpInfo *android.IdeInfo) { | 
|  | 1428 | dpInfo.Deps = append(dpInfo.Deps, j.CompilerDeps()...) | 
|  | 1429 | dpInfo.Srcs = append(dpInfo.Srcs, j.expandIDEInfoCompiledSrcs...) | 
|  | 1430 | dpInfo.Aidl_include_dirs = append(dpInfo.Aidl_include_dirs, j.deviceProperties.Aidl.Include_dirs...) | 
| Steven Moreland | c4efd9c | 2019-01-18 11:51:25 -0800 | [diff] [blame] | 1431 | if j.expandJarjarRules != nil { | 
|  | 1432 | dpInfo.Jarjar_rules = append(dpInfo.Jarjar_rules, j.expandJarjarRules.String()) | 
| Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 1433 | } | 
|  | 1434 | } | 
|  | 1435 |  | 
|  | 1436 | func (j *Module) CompilerDeps() []string { | 
|  | 1437 | jdeps := []string{} | 
|  | 1438 | jdeps = append(jdeps, j.properties.Libs...) | 
|  | 1439 | jdeps = append(jdeps, j.properties.Static_libs...) | 
|  | 1440 | return jdeps | 
|  | 1441 | } | 
|  | 1442 |  | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1443 | // | 
|  | 1444 | // Java libraries (.jar file) | 
|  | 1445 | // | 
|  | 1446 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1447 | type Library struct { | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1448 | Module | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1449 | } | 
|  | 1450 |  | 
| Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1451 | func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bool { | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 1452 | // Store uncompressed (and do not strip) dex files from boot class path jars. | 
|  | 1453 | if inList(ctx.ModuleName(), ctx.Config().BootJars()) { | 
|  | 1454 | return true | 
|  | 1455 | } | 
|  | 1456 |  | 
|  | 1457 | // Store uncompressed dex files that are preopted on /system. | 
| Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1458 | if !dexpreopter.dexpreoptDisabled(ctx) && (ctx.Host() || !odexOnSystemOther(ctx, dexpreopter.installPath)) { | 
| Vladimir Marko | e8b00d6 | 2018-12-21 15:54:16 +0000 | [diff] [blame] | 1459 | return true | 
|  | 1460 | } | 
| Colin Cross | 083a2aa | 2019-02-06 16:37:12 -0800 | [diff] [blame] | 1461 | if ctx.Config().UncompressPrivAppDex() && | 
|  | 1462 | inList(ctx.ModuleName(), ctx.Config().ModulesLoadedByPrivilegedModules()) { | 
|  | 1463 | return true | 
|  | 1464 | } | 
|  | 1465 |  | 
| Colin Cross | 2fc72f6 | 2018-12-21 12:59:54 -0800 | [diff] [blame] | 1466 | return false | 
|  | 1467 | } | 
|  | 1468 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1469 | func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1470 | j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", ctx.ModuleName()+".jar") | 
|  | 1471 | j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 1472 | j.dexpreopter.isInstallable = Bool(j.properties.Installable) | 
| Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1473 | j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter) | 
| Nicolas Geoffray | fa6e9ec | 2019-02-12 13:12:16 +0000 | [diff] [blame] | 1474 | j.deviceProperties.UncompressDex = j.dexpreopter.uncompressedDex | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1475 | j.compile(ctx) | 
| Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 1476 |  | 
| Nicolas Geoffray | 4bdea39 | 2019-01-15 11:48:08 +0000 | [diff] [blame] | 1477 | if (Bool(j.properties.Installable) || ctx.Host()) && !android.DirectlyInAnyApex(ctx, ctx.ModuleName()) { | 
| Colin Cross | 2c429dc | 2017-08-31 16:45:16 -0700 | [diff] [blame] | 1478 | j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), | 
|  | 1479 | ctx.ModuleName()+".jar", j.outputFile) | 
|  | 1480 | } | 
| Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 1481 | } | 
|  | 1482 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1483 | func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1484 | j.deps(ctx) | 
|  | 1485 | } | 
|  | 1486 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1487 | // java_library builds and links sources into a `.jar` file for the device, and possibly for the host as well. | 
|  | 1488 | // | 
|  | 1489 | // By default, a java_library has a single variant that produces a `.jar` file containing `.class` files that were | 
|  | 1490 | // compiled against the device bootclasspath.  This jar is not suitable for installing on a device, but can be used | 
|  | 1491 | // as a `static_libs` dependency of another module. | 
|  | 1492 | // | 
|  | 1493 | // Specifying `installable: true` will product a `.jar` file containing `classes.dex` files, suitable for installing on | 
|  | 1494 | // a device. | 
|  | 1495 | // | 
|  | 1496 | // Specifying `host_supported: true` will produce two variants, one compiled against the device bootclasspath and one | 
|  | 1497 | // compiled against the host bootclasspath. | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1498 | func LibraryFactory() android.Module { | 
|  | 1499 | module := &Library{} | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1500 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1501 | module.AddProperties( | 
|  | 1502 | &module.Module.properties, | 
|  | 1503 | &module.Module.deviceProperties, | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1504 | &module.Module.dexpreoptProperties, | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1505 | &module.Module.protoProperties) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1506 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1507 | InitJavaModule(module, android.HostAndDeviceSupported) | 
|  | 1508 | return module | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1509 | } | 
|  | 1510 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1511 | // java_library_static is an obsolete alias for java_library. | 
|  | 1512 | func LibraryStaticFactory() android.Module { | 
|  | 1513 | return LibraryFactory() | 
|  | 1514 | } | 
|  | 1515 |  | 
|  | 1516 | // java_library_host builds and links sources into a `.jar` file for the host. | 
|  | 1517 | // | 
|  | 1518 | // A java_library_host has a single variant that produces a `.jar` file containing `.class` files that were | 
|  | 1519 | // compiled against the host bootclasspath. | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1520 | func LibraryHostFactory() android.Module { | 
|  | 1521 | module := &Library{} | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1522 |  | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 1523 | module.AddProperties( | 
|  | 1524 | &module.Module.properties, | 
|  | 1525 | &module.Module.protoProperties) | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1526 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1527 | module.Module.properties.Installable = proptools.BoolPtr(true) | 
|  | 1528 |  | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 1529 | InitJavaModule(module, android.HostSupported) | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1530 | return module | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1531 | } | 
|  | 1532 |  | 
|  | 1533 | // | 
| Colin Cross | b628ea5 | 2018-08-14 16:42:33 -0700 | [diff] [blame] | 1534 | // Java Tests | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1535 | // | 
|  | 1536 |  | 
|  | 1537 | type testProperties struct { | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1538 | // list of compatibility suites (for example "cts", "vts") that the module should be | 
|  | 1539 | // installed into. | 
|  | 1540 | Test_suites []string `android:"arch_variant"` | 
| Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 1541 |  | 
|  | 1542 | // the name of the test configuration (for example "AndroidTest.xml") that should be | 
|  | 1543 | // installed with the module. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 1544 | Test_config *string `android:"path,arch_variant"` | 
| Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 1545 |  | 
| Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 1546 | // the name of the test configuration template (for example "AndroidTestTemplate.xml") that | 
|  | 1547 | // should be installed with the module. | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 1548 | Test_config_template *string `android:"path,arch_variant"` | 
| Jack He | 3333889 | 2018-09-19 02:21:28 -0700 | [diff] [blame] | 1549 |  | 
| Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 1550 | // list of files or filegroup modules that provide data that should be installed alongside | 
|  | 1551 | // the test | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 1552 | Data []string `android:"path"` | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1553 | } | 
|  | 1554 |  | 
| Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 1555 | type testHelperLibraryProperties struct { | 
|  | 1556 | // list of compatibility suites (for example "cts", "vts") that the module should be | 
|  | 1557 | // installed into. | 
|  | 1558 | Test_suites []string `android:"arch_variant"` | 
|  | 1559 | } | 
|  | 1560 |  | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1561 | type Test struct { | 
|  | 1562 | Library | 
|  | 1563 |  | 
|  | 1564 | testProperties testProperties | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 1565 |  | 
|  | 1566 | testConfig android.Path | 
| Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 1567 | data       android.Paths | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 1568 | } | 
|  | 1569 |  | 
| Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 1570 | type TestHelperLibrary struct { | 
|  | 1571 | Library | 
|  | 1572 |  | 
|  | 1573 | testHelperLibraryProperties testHelperLibraryProperties | 
|  | 1574 | } | 
|  | 1575 |  | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 1576 | func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
| yangbill | 4f41bc2 | 2019-02-13 21:45:47 +0800 | [diff] [blame] | 1577 | j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, j.testProperties.Test_suites) | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 1578 | j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data) | 
| Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 1579 |  | 
|  | 1580 | j.Library.GenerateAndroidBuildActions(ctx) | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1581 | } | 
|  | 1582 |  | 
| Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 1583 | func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
|  | 1584 | j.Library.GenerateAndroidBuildActions(ctx) | 
|  | 1585 | } | 
|  | 1586 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1587 | // java_test builds a and links sources into a `.jar` file for the device, and possibly for the host as well, and | 
|  | 1588 | // creates an `AndroidTest.xml` file to allow running the test with `atest` or a `TEST_MAPPING` file. | 
|  | 1589 | // | 
|  | 1590 | // By default, a java_test has a single variant that produces a `.jar` file containing `classes.dex` files that were | 
|  | 1591 | // compiled against the device bootclasspath. | 
|  | 1592 | // | 
|  | 1593 | // Specifying `host_supported: true` will produce two variants, one compiled against the device bootclasspath and one | 
|  | 1594 | // compiled against the host bootclasspath. | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1595 | func TestFactory() android.Module { | 
|  | 1596 | module := &Test{} | 
|  | 1597 |  | 
|  | 1598 | module.AddProperties( | 
|  | 1599 | &module.Module.properties, | 
|  | 1600 | &module.Module.deviceProperties, | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1601 | &module.Module.dexpreoptProperties, | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1602 | &module.Module.protoProperties, | 
|  | 1603 | &module.testProperties) | 
|  | 1604 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1605 | module.Module.properties.Installable = proptools.BoolPtr(true) | 
| Colin Cross | e302687 | 2019-01-05 22:30:13 -0800 | [diff] [blame] | 1606 | module.Module.dexpreopter.isTest = true | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1607 |  | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1608 | InitJavaModule(module, android.HostAndDeviceSupported) | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1609 | return module | 
|  | 1610 | } | 
|  | 1611 |  | 
| Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 1612 | // java_test_helper_library creates a java library and makes sure that it is added to the appropriate test suite. | 
|  | 1613 | func TestHelperLibraryFactory() android.Module { | 
|  | 1614 | module := &TestHelperLibrary{} | 
|  | 1615 |  | 
|  | 1616 | module.AddProperties( | 
|  | 1617 | &module.Module.properties, | 
|  | 1618 | &module.Module.deviceProperties, | 
|  | 1619 | &module.Module.dexpreoptProperties, | 
|  | 1620 | &module.Module.protoProperties, | 
|  | 1621 | &module.testHelperLibraryProperties) | 
|  | 1622 |  | 
|  | 1623 | InitJavaModule(module, android.HostAndDeviceSupported) | 
|  | 1624 | return module | 
|  | 1625 | } | 
|  | 1626 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1627 | // java_test_host builds a and links sources into a `.jar` file for the host, and creates an `AndroidTest.xml` file to | 
|  | 1628 | // allow running the test with `atest` or a `TEST_MAPPING` file. | 
|  | 1629 | // | 
|  | 1630 | // A java_test_host has a single variant that produces a `.jar` file containing `.class` files that were | 
|  | 1631 | // compiled against the host bootclasspath. | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1632 | func TestHostFactory() android.Module { | 
|  | 1633 | module := &Test{} | 
|  | 1634 |  | 
|  | 1635 | module.AddProperties( | 
|  | 1636 | &module.Module.properties, | 
|  | 1637 | &module.Module.protoProperties, | 
|  | 1638 | &module.testProperties) | 
|  | 1639 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1640 | module.Module.properties.Installable = proptools.BoolPtr(true) | 
|  | 1641 |  | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1642 | InitJavaModule(module, android.HostSupported) | 
| Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 1643 | return module | 
|  | 1644 | } | 
|  | 1645 |  | 
|  | 1646 | // | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1647 | // Java Binaries (.jar file plus wrapper script) | 
|  | 1648 | // | 
|  | 1649 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1650 | type binaryProperties struct { | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 1651 | // installable script to execute the resulting jar | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 1652 | Wrapper *string `android:"path"` | 
| Colin Cross | 094054a | 2018-10-17 15:10:48 -0700 | [diff] [blame] | 1653 |  | 
|  | 1654 | // Name of the class containing main to be inserted into the manifest as Main-Class. | 
|  | 1655 | Main_class *string | 
| Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 1656 | } | 
|  | 1657 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1658 | type Binary struct { | 
|  | 1659 | Library | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1660 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1661 | binaryProperties binaryProperties | 
| Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 1662 |  | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1663 | isWrapperVariant bool | 
|  | 1664 |  | 
| Colin Cross | c331599 | 2017-12-08 19:12:36 -0800 | [diff] [blame] | 1665 | wrapperFile android.Path | 
| Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 1666 | binaryFile  android.OutputPath | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1667 | } | 
|  | 1668 |  | 
| Alex Light | 2423717 | 2017-10-26 09:46:21 -0700 | [diff] [blame] | 1669 | func (j *Binary) HostToolPath() android.OptionalPath { | 
|  | 1670 | return android.OptionalPathForPath(j.binaryFile) | 
|  | 1671 | } | 
|  | 1672 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1673 | func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1674 | if ctx.Arch().ArchType == android.Common { | 
|  | 1675 | // Compile the jar | 
| Colin Cross | 094054a | 2018-10-17 15:10:48 -0700 | [diff] [blame] | 1676 | if j.binaryProperties.Main_class != nil { | 
|  | 1677 | if j.properties.Manifest != nil { | 
|  | 1678 | ctx.PropertyErrorf("main_class", "main_class cannot be used when manifest is set") | 
|  | 1679 | } | 
|  | 1680 | manifestFile := android.PathForModuleOut(ctx, "manifest.txt") | 
|  | 1681 | GenerateMainClassManifest(ctx, manifestFile, String(j.binaryProperties.Main_class)) | 
|  | 1682 | j.overrideManifest = android.OptionalPathForPath(manifestFile) | 
|  | 1683 | } | 
|  | 1684 |  | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1685 | j.Library.GenerateAndroidBuildActions(ctx) | 
| Nan Zhang | 3c807db | 2017-11-03 14:53:31 -0700 | [diff] [blame] | 1686 | } else { | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1687 | // Handle the binary wrapper | 
|  | 1688 | j.isWrapperVariant = true | 
|  | 1689 |  | 
| Colin Cross | 366938f | 2017-12-11 16:29:02 -0800 | [diff] [blame] | 1690 | if j.binaryProperties.Wrapper != nil { | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 1691 | j.wrapperFile = android.PathForModuleSrc(ctx, *j.binaryProperties.Wrapper) | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1692 | } else { | 
|  | 1693 | j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh") | 
|  | 1694 | } | 
|  | 1695 |  | 
|  | 1696 | // Depend on the installed jar so that the wrapper doesn't get executed by | 
|  | 1697 | // another build rule before the jar has been installed. | 
|  | 1698 | jarFile := ctx.PrimaryModule().(*Binary).installFile | 
|  | 1699 |  | 
|  | 1700 | j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"), | 
|  | 1701 | ctx.ModuleName(), j.wrapperFile, jarFile) | 
| Nan Zhang | 3c807db | 2017-11-03 14:53:31 -0700 | [diff] [blame] | 1702 | } | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1703 | } | 
|  | 1704 |  | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1705 | func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) { | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1706 | if ctx.Arch().ArchType == android.Common { | 
|  | 1707 | j.deps(ctx) | 
|  | 1708 | } | 
| Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 1709 | } | 
|  | 1710 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1711 | // java_binary builds a `.jar` file and a shell script that executes it for the device, and possibly for the host | 
|  | 1712 | // as well. | 
|  | 1713 | // | 
|  | 1714 | // By default, a java_binary has a single variant that produces a `.jar` file containing `classes.dex` files that were | 
|  | 1715 | // compiled against the device bootclasspath. | 
|  | 1716 | // | 
|  | 1717 | // Specifying `host_supported: true` will produce two variants, one compiled against the device bootclasspath and one | 
|  | 1718 | // compiled against the host bootclasspath. | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1719 | func BinaryFactory() android.Module { | 
|  | 1720 | module := &Binary{} | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1721 |  | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1722 | module.AddProperties( | 
| Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 1723 | &module.Module.properties, | 
|  | 1724 | &module.Module.deviceProperties, | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1725 | &module.Module.dexpreoptProperties, | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 1726 | &module.Module.protoProperties, | 
| Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 1727 | &module.binaryProperties) | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1728 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1729 | module.Module.properties.Installable = proptools.BoolPtr(true) | 
|  | 1730 |  | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1731 | android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommonFirst) | 
|  | 1732 | android.InitDefaultableModule(module) | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1733 | return module | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1734 | } | 
|  | 1735 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1736 | // java_binary_host builds a `.jar` file and a shell script that executes it for the host. | 
|  | 1737 | // | 
|  | 1738 | // A java_binary_host has a single variant that produces a `.jar` file containing `.class` files that were | 
|  | 1739 | // compiled against the host bootclasspath. | 
| Colin Cross | f506d87 | 2017-07-19 15:53:04 -0700 | [diff] [blame] | 1740 | func BinaryHostFactory() android.Module { | 
|  | 1741 | module := &Binary{} | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1742 |  | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1743 | module.AddProperties( | 
| Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 1744 | &module.Module.properties, | 
| Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 1745 | &module.Module.protoProperties, | 
| Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 1746 | &module.binaryProperties) | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1747 |  | 
| Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 1748 | module.Module.properties.Installable = proptools.BoolPtr(true) | 
|  | 1749 |  | 
| Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 1750 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommonFirst) | 
|  | 1751 | android.InitDefaultableModule(module) | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1752 | return module | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1753 | } | 
|  | 1754 |  | 
|  | 1755 | // | 
|  | 1756 | // Java prebuilts | 
|  | 1757 | // | 
|  | 1758 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1759 | type ImportProperties struct { | 
| Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 1760 | Jars []string `android:"path"` | 
| Colin Cross | 461bd1a | 2017-10-20 13:59:18 -0700 | [diff] [blame] | 1761 |  | 
| Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 1762 | Sdk_version *string | 
| Colin Cross | 535e2cf | 2017-10-20 17:57:49 -0700 | [diff] [blame] | 1763 |  | 
|  | 1764 | Installable *bool | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1765 |  | 
|  | 1766 | // List of shared java libs that this module has dependencies to | 
|  | 1767 | Libs []string | 
| Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1768 |  | 
|  | 1769 | // List of files to remove from the jar file(s) | 
|  | 1770 | Exclude_files []string | 
|  | 1771 |  | 
|  | 1772 | // List of directories to remove from the jar file(s) | 
|  | 1773 | Exclude_dirs []string | 
| Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 1774 |  | 
|  | 1775 | // if set to true, run Jetifier against .jar file. Defaults to false. | 
| Colin Cross | 1001a79 | 2019-03-21 22:21:39 -0700 | [diff] [blame] | 1776 | Jetifier *bool | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1777 | } | 
|  | 1778 |  | 
|  | 1779 | type Import struct { | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1780 | android.ModuleBase | 
| Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 1781 | android.DefaultableModuleBase | 
| Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 1782 | prebuilt android.Prebuilt | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1783 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1784 | properties ImportProperties | 
|  | 1785 |  | 
| Colin Cross | 0a6e007 | 2017-08-30 14:24:55 -0700 | [diff] [blame] | 1786 | combinedClasspathFile android.Path | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1787 | exportedSdkLibs       []string | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1788 | } | 
|  | 1789 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 1790 | func (j *Import) sdkVersion() string { | 
|  | 1791 | return String(j.properties.Sdk_version) | 
|  | 1792 | } | 
|  | 1793 |  | 
|  | 1794 | func (j *Import) minSdkVersion() string { | 
|  | 1795 | return j.sdkVersion() | 
|  | 1796 | } | 
|  | 1797 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1798 | func (j *Import) Prebuilt() *android.Prebuilt { | 
| Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 1799 | return &j.prebuilt | 
|  | 1800 | } | 
|  | 1801 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1802 | func (j *Import) PrebuiltSrcs() []string { | 
|  | 1803 | return j.properties.Jars | 
|  | 1804 | } | 
|  | 1805 |  | 
|  | 1806 | func (j *Import) Name() string { | 
| Colin Cross | 5ea9bcc | 2017-07-27 15:41:32 -0700 | [diff] [blame] | 1807 | return j.prebuilt.Name(j.ModuleBase.Name()) | 
|  | 1808 | } | 
|  | 1809 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1810 | func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 1811 | ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...) | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 1812 | } | 
|  | 1813 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1814 | func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
| Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 1815 | jars := android.PathsForModuleSrc(ctx, j.properties.Jars) | 
| Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 1816 |  | 
| Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 1817 | jarName := ctx.ModuleName() + ".jar" | 
|  | 1818 | outputFile := android.PathForModuleOut(ctx, "combined", jarName) | 
| Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1819 | TransformJarsToJar(ctx, outputFile, "for prebuilts", jars, android.OptionalPath{}, | 
|  | 1820 | false, j.properties.Exclude_files, j.properties.Exclude_dirs) | 
| Colin Cross | 1001a79 | 2019-03-21 22:21:39 -0700 | [diff] [blame] | 1821 | if Bool(j.properties.Jetifier) { | 
| Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 1822 | inputFile := outputFile | 
|  | 1823 | outputFile = android.PathForModuleOut(ctx, "jetifier", jarName) | 
|  | 1824 | TransformJetifier(ctx, outputFile, inputFile) | 
|  | 1825 | } | 
| Colin Cross | e9a275b | 2017-10-16 17:09:48 -0700 | [diff] [blame] | 1826 | j.combinedClasspathFile = outputFile | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1827 |  | 
|  | 1828 | ctx.VisitDirectDeps(func(module android.Module) { | 
|  | 1829 | otherName := ctx.OtherModuleName(module) | 
|  | 1830 | tag := ctx.OtherModuleDependencyTag(module) | 
|  | 1831 |  | 
|  | 1832 | switch dep := module.(type) { | 
|  | 1833 | case Dependency: | 
|  | 1834 | switch tag { | 
|  | 1835 | case libTag, staticLibTag: | 
|  | 1836 | // sdk lib names from dependencies are re-exported | 
|  | 1837 | j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...) | 
|  | 1838 | } | 
|  | 1839 | case SdkLibraryDependency: | 
|  | 1840 | switch tag { | 
|  | 1841 | case libTag: | 
|  | 1842 | // names of sdk libs that are directly depended are exported | 
|  | 1843 | j.exportedSdkLibs = append(j.exportedSdkLibs, otherName) | 
|  | 1844 | } | 
|  | 1845 | } | 
|  | 1846 | }) | 
|  | 1847 |  | 
|  | 1848 | j.exportedSdkLibs = android.FirstUniqueStrings(j.exportedSdkLibs) | 
| Nan Zhang | 4973ecf | 2018-08-10 13:42:12 -0700 | [diff] [blame] | 1849 | if Bool(j.properties.Installable) { | 
|  | 1850 | ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), | 
|  | 1851 | ctx.ModuleName()+".jar", outputFile) | 
|  | 1852 | } | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1853 | } | 
|  | 1854 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1855 | var _ Dependency = (*Import)(nil) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1856 |  | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1857 | func (j *Import) HeaderJars() android.Paths { | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1858 | if j.combinedClasspathFile == nil { | 
|  | 1859 | return nil | 
|  | 1860 | } | 
| Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1861 | return android.Paths{j.combinedClasspathFile} | 
| Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 1862 | } | 
|  | 1863 |  | 
|  | 1864 | func (j *Import) ImplementationJars() android.Paths { | 
| shinwang | 9e4c07a | 2018-12-24 15:41:04 +0800 | [diff] [blame] | 1865 | if j.combinedClasspathFile == nil { | 
|  | 1866 | return nil | 
|  | 1867 | } | 
| Colin Cross | 37f6d79 | 2018-07-12 12:28:41 -0700 | [diff] [blame] | 1868 | return android.Paths{j.combinedClasspathFile} | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1869 | } | 
|  | 1870 |  | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1871 | func (j *Import) ResourceJars() android.Paths { | 
|  | 1872 | return nil | 
|  | 1873 | } | 
|  | 1874 |  | 
|  | 1875 | func (j *Import) ImplementationAndResourcesJars() android.Paths { | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1876 | if j.combinedClasspathFile == nil { | 
|  | 1877 | return nil | 
|  | 1878 | } | 
| Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 1879 | return android.Paths{j.combinedClasspathFile} | 
|  | 1880 | } | 
|  | 1881 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 1882 | func (j *Import) DexJar() android.Path { | 
|  | 1883 | return nil | 
|  | 1884 | } | 
|  | 1885 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1886 | func (j *Import) AidlIncludeDirs() android.Paths { | 
| Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 1887 | return nil | 
|  | 1888 | } | 
|  | 1889 |  | 
| Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 1890 | func (j *Import) ExportedSdkLibs() []string { | 
|  | 1891 | return j.exportedSdkLibs | 
|  | 1892 | } | 
|  | 1893 |  | 
| albaltai | 36ff7dc | 2018-12-25 14:35:23 +0800 | [diff] [blame] | 1894 | // Add compile time check for interface implementation | 
|  | 1895 | var _ android.IDEInfo = (*Import)(nil) | 
|  | 1896 | var _ android.IDECustomizedModuleName = (*Import)(nil) | 
|  | 1897 |  | 
| Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 1898 | // Collect information for opening IDE project files in java/jdeps.go. | 
|  | 1899 | const ( | 
|  | 1900 | removedPrefix = "prebuilt_" | 
|  | 1901 | ) | 
|  | 1902 |  | 
|  | 1903 | func (j *Import) IDEInfo(dpInfo *android.IdeInfo) { | 
|  | 1904 | dpInfo.Jars = append(dpInfo.Jars, j.PrebuiltSrcs()...) | 
|  | 1905 | } | 
|  | 1906 |  | 
|  | 1907 | func (j *Import) IDECustomizedModuleName() string { | 
|  | 1908 | // TODO(b/113562217): Extract the base module name from the Import name, often the Import name | 
|  | 1909 | // has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better | 
|  | 1910 | // solution to get the Import name. | 
|  | 1911 | name := j.Name() | 
|  | 1912 | if strings.HasPrefix(name, removedPrefix) { | 
| patricktu | bb640e0 | 2018-10-11 18:33:16 +0800 | [diff] [blame] | 1913 | name = strings.TrimPrefix(name, removedPrefix) | 
| Brandon Lee | 5d45c6f | 2018-08-15 15:35:38 -0700 | [diff] [blame] | 1914 | } | 
|  | 1915 | return name | 
|  | 1916 | } | 
|  | 1917 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1918 | var _ android.PrebuiltInterface = (*Import)(nil) | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1919 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1920 | // java_import imports one or more `.jar` files into the build graph as if they were built by a java_library module. | 
|  | 1921 | // | 
|  | 1922 | // By default, a java_import has a single variant that expects a `.jar` file containing `.class` files that were | 
|  | 1923 | // compiled against an Android classpath. | 
|  | 1924 | // | 
|  | 1925 | // Specifying `host_supported: true` will produce two variants, one for use as a dependency of device modules and one | 
|  | 1926 | // for host modules. | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1927 | func ImportFactory() android.Module { | 
|  | 1928 | module := &Import{} | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1929 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1930 | module.AddProperties(&module.properties) | 
|  | 1931 |  | 
|  | 1932 | android.InitPrebuiltModule(module, &module.properties.Jars) | 
| Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 1933 | InitJavaModule(module, android.HostAndDeviceSupported) | 
| Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 1934 | return module | 
| Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1935 | } | 
|  | 1936 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 1937 | // java_import imports one or more `.jar` files into the build graph as if they were built by a java_library_host | 
|  | 1938 | // module. | 
|  | 1939 | // | 
|  | 1940 | // A java_import_host has a single variant that expects a `.jar` file containing `.class` files that were | 
|  | 1941 | // compiled against a host bootclasspath. | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1942 | func ImportFactoryHost() android.Module { | 
|  | 1943 | module := &Import{} | 
|  | 1944 |  | 
|  | 1945 | module.AddProperties(&module.properties) | 
|  | 1946 |  | 
|  | 1947 | android.InitPrebuiltModule(module, &module.properties.Jars) | 
| Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 1948 | InitJavaModule(module, android.HostSupported) | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 1949 | return module | 
|  | 1950 | } | 
|  | 1951 |  | 
| Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 1952 | // dex_import module | 
|  | 1953 |  | 
|  | 1954 | type DexImportProperties struct { | 
|  | 1955 | Jars []string | 
|  | 1956 | } | 
|  | 1957 |  | 
|  | 1958 | type DexImport struct { | 
|  | 1959 | android.ModuleBase | 
|  | 1960 | android.DefaultableModuleBase | 
|  | 1961 | prebuilt android.Prebuilt | 
|  | 1962 |  | 
|  | 1963 | properties DexImportProperties | 
|  | 1964 |  | 
|  | 1965 | dexJarFile              android.Path | 
|  | 1966 | maybeStrippedDexJarFile android.Path | 
|  | 1967 |  | 
|  | 1968 | dexpreopter | 
|  | 1969 | } | 
|  | 1970 |  | 
|  | 1971 | func (j *DexImport) Prebuilt() *android.Prebuilt { | 
|  | 1972 | return &j.prebuilt | 
|  | 1973 | } | 
|  | 1974 |  | 
|  | 1975 | func (j *DexImport) PrebuiltSrcs() []string { | 
|  | 1976 | return j.properties.Jars | 
|  | 1977 | } | 
|  | 1978 |  | 
|  | 1979 | func (j *DexImport) Name() string { | 
|  | 1980 | return j.prebuilt.Name(j.ModuleBase.Name()) | 
|  | 1981 | } | 
|  | 1982 |  | 
|  | 1983 | func (j *DexImport) DepsMutator(ctx android.BottomUpMutatorContext) { | 
|  | 1984 | android.ExtractSourcesDeps(ctx, j.properties.Jars) | 
|  | 1985 | } | 
|  | 1986 |  | 
|  | 1987 | func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
|  | 1988 | if len(j.properties.Jars) != 1 { | 
|  | 1989 | ctx.PropertyErrorf("jars", "exactly one jar must be provided") | 
|  | 1990 | } | 
|  | 1991 |  | 
|  | 1992 | j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", ctx.ModuleName()+".jar") | 
|  | 1993 | j.dexpreopter.isInstallable = true | 
|  | 1994 | j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter) | 
|  | 1995 |  | 
|  | 1996 | inputJar := ctx.ExpandSource(j.properties.Jars[0], "jars") | 
|  | 1997 | dexOutputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".jar") | 
|  | 1998 |  | 
|  | 1999 | if j.dexpreopter.uncompressedDex { | 
|  | 2000 | rule := android.NewRuleBuilder() | 
|  | 2001 |  | 
|  | 2002 | temporary := android.PathForModuleOut(ctx, ctx.ModuleName()+".jar.unaligned") | 
|  | 2003 | rule.Temporary(temporary) | 
|  | 2004 |  | 
|  | 2005 | // use zip2zip to uncompress classes*.dex files | 
|  | 2006 | rule.Command(). | 
|  | 2007 | Tool(ctx.Config().HostToolPath(ctx, "zip2zip")). | 
|  | 2008 | FlagWithInput("-i ", inputJar). | 
|  | 2009 | FlagWithOutput("-o ", temporary). | 
|  | 2010 | FlagWithArg("-0 ", "'classes*.dex'") | 
|  | 2011 |  | 
|  | 2012 | // use zipalign to align uncompressed classes*.dex files | 
|  | 2013 | rule.Command(). | 
|  | 2014 | Tool(ctx.Config().HostToolPath(ctx, "zipalign")). | 
|  | 2015 | Flag("-f"). | 
|  | 2016 | Text("4"). | 
|  | 2017 | Input(temporary). | 
|  | 2018 | Output(dexOutputFile) | 
|  | 2019 |  | 
|  | 2020 | rule.DeleteTemporaryFiles() | 
|  | 2021 |  | 
|  | 2022 | rule.Build(pctx, ctx, "uncompress_dex", "uncompress dex") | 
|  | 2023 | } else { | 
|  | 2024 | ctx.Build(pctx, android.BuildParams{ | 
|  | 2025 | Rule:   android.Cp, | 
|  | 2026 | Input:  inputJar, | 
|  | 2027 | Output: dexOutputFile, | 
|  | 2028 | }) | 
|  | 2029 | } | 
|  | 2030 |  | 
|  | 2031 | j.dexJarFile = dexOutputFile | 
|  | 2032 |  | 
|  | 2033 | dexOutputFile = j.dexpreopt(ctx, dexOutputFile) | 
|  | 2034 |  | 
|  | 2035 | j.maybeStrippedDexJarFile = dexOutputFile | 
|  | 2036 |  | 
|  | 2037 | ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), | 
|  | 2038 | ctx.ModuleName()+".jar", dexOutputFile) | 
|  | 2039 | } | 
|  | 2040 |  | 
|  | 2041 | func (j *DexImport) DexJar() android.Path { | 
|  | 2042 | return j.dexJarFile | 
|  | 2043 | } | 
|  | 2044 |  | 
|  | 2045 | // dex_import imports a `.jar` file containing classes.dex files. | 
|  | 2046 | // | 
|  | 2047 | // A dex_import module cannot be used as a dependency of a java_* or android_* module, it can only be installed | 
|  | 2048 | // to the device. | 
|  | 2049 | func DexImportFactory() android.Module { | 
|  | 2050 | module := &DexImport{} | 
|  | 2051 |  | 
|  | 2052 | module.AddProperties(&module.properties) | 
|  | 2053 |  | 
|  | 2054 | android.InitPrebuiltModule(module, &module.properties.Jars) | 
|  | 2055 | InitJavaModule(module, android.DeviceSupported) | 
|  | 2056 | return module | 
|  | 2057 | } | 
|  | 2058 |  | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 2059 | // | 
|  | 2060 | // Defaults | 
|  | 2061 | // | 
|  | 2062 | type Defaults struct { | 
|  | 2063 | android.ModuleBase | 
|  | 2064 | android.DefaultsModuleBase | 
|  | 2065 | } | 
|  | 2066 |  | 
|  | 2067 | func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
|  | 2068 | } | 
|  | 2069 |  | 
| Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 2070 | // java_defaults provides a set of properties that can be inherited by other java or android modules. | 
|  | 2071 | // | 
|  | 2072 | // A module can use the properties from a java_defaults module using `defaults: ["defaults_module_name"]`.  Each | 
|  | 2073 | // property in the defaults module that exists in the depending module will be prepended to the depending module's | 
|  | 2074 | // value for that property. | 
|  | 2075 | // | 
|  | 2076 | // Example: | 
|  | 2077 | // | 
|  | 2078 | //     java_defaults { | 
|  | 2079 | //         name: "example_defaults", | 
|  | 2080 | //         srcs: ["common/**/*.java"], | 
|  | 2081 | //         javacflags: ["-Xlint:all"], | 
|  | 2082 | //         aaptflags: ["--auto-add-overlay"], | 
|  | 2083 | //     } | 
|  | 2084 | // | 
|  | 2085 | //     java_library { | 
|  | 2086 | //         name: "example", | 
|  | 2087 | //         defaults: ["example_defaults"], | 
|  | 2088 | //         srcs: ["example/**/*.java"], | 
|  | 2089 | //     } | 
|  | 2090 | // | 
|  | 2091 | // is functionally identical to: | 
|  | 2092 | // | 
|  | 2093 | //     java_library { | 
|  | 2094 | //         name: "example", | 
|  | 2095 | //         srcs: [ | 
|  | 2096 | //             "common/**/*.java", | 
|  | 2097 | //             "example/**/*.java", | 
|  | 2098 | //         ], | 
|  | 2099 | //         javacflags: ["-Xlint:all"], | 
|  | 2100 | //     } | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 2101 | func defaultsFactory() android.Module { | 
|  | 2102 | return DefaultsFactory() | 
|  | 2103 | } | 
|  | 2104 |  | 
|  | 2105 | func DefaultsFactory(props ...interface{}) android.Module { | 
|  | 2106 | module := &Defaults{} | 
|  | 2107 |  | 
|  | 2108 | module.AddProperties(props...) | 
|  | 2109 | module.AddProperties( | 
|  | 2110 | &CompilerProperties{}, | 
|  | 2111 | &CompilerDeviceProperties{}, | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 2112 | &DexpreoptProperties{}, | 
| Dan Willemsen | 6424d17 | 2018-03-08 13:27:59 -0800 | [diff] [blame] | 2113 | &android.ProtoProperties{}, | 
| Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 2114 | &aaptProperties{}, | 
|  | 2115 | &androidLibraryProperties{}, | 
|  | 2116 | &appProperties{}, | 
|  | 2117 | &appTestProperties{}, | 
| Jaewoong Jung | 525443a | 2019-02-28 15:35:54 -0800 | [diff] [blame] | 2118 | &overridableAppProperties{}, | 
| Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 2119 | &ImportProperties{}, | 
|  | 2120 | &AARImportProperties{}, | 
|  | 2121 | &sdkLibraryProperties{}, | 
| Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 2122 | &DexImportProperties{}, | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 2123 | ) | 
|  | 2124 |  | 
|  | 2125 | android.InitDefaultsModule(module) | 
|  | 2126 |  | 
|  | 2127 | return module | 
|  | 2128 | } | 
| Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 2129 |  | 
|  | 2130 | var Bool = proptools.Bool | 
| Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 2131 | var BoolDefault = proptools.BoolDefault | 
| Nan Zhang | ea568a4 | 2017-11-08 21:20:04 -0800 | [diff] [blame] | 2132 | var String = proptools.String | 
| Colin Cross | 0d0ba59 | 2018-02-20 13:33:42 -0800 | [diff] [blame] | 2133 | var inList = android.InList |