Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1 | // Copyright (C) 2018 The Android Open Source Project |
| 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 apex |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 19 | "path" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 20 | "path/filepath" |
Jiyong Park | ab3ceb3 | 2018-10-10 14:05:29 +0900 | [diff] [blame] | 21 | "sort" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 22 | "strings" |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 23 | "sync" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 24 | |
| 25 | "android/soong/android" |
| 26 | "android/soong/cc" |
| 27 | "android/soong/java" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 28 | "android/soong/python" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 29 | |
| 30 | "github.com/google/blueprint" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 31 | "github.com/google/blueprint/bootstrap" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 32 | "github.com/google/blueprint/proptools" |
| 33 | ) |
| 34 | |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 35 | const ( |
| 36 | imageApexSuffix = ".apex" |
| 37 | zipApexSuffix = ".zipapex" |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 38 | flattenedSuffix = ".flattened" |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 39 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 40 | imageApexType = "image" |
| 41 | zipApexType = "zip" |
| 42 | flattenedApexType = "flattened" |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 43 | ) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 44 | |
| 45 | type dependencyTag struct { |
| 46 | blueprint.BaseDependencyTag |
| 47 | name string |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 48 | |
| 49 | // determines if the dependent will be part of the APEX payload |
| 50 | payload bool |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | var ( |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 54 | sharedLibTag = dependencyTag{name: "sharedLib", payload: true} |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 55 | jniLibTag = dependencyTag{name: "jniLib", payload: true} |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 56 | executableTag = dependencyTag{name: "executable", payload: true} |
| 57 | javaLibTag = dependencyTag{name: "javaLib", payload: true} |
| 58 | prebuiltTag = dependencyTag{name: "prebuilt", payload: true} |
| 59 | testTag = dependencyTag{name: "test", payload: true} |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 60 | keyTag = dependencyTag{name: "key"} |
| 61 | certificateTag = dependencyTag{name: "certificate"} |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 62 | usesTag = dependencyTag{name: "uses"} |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 63 | androidAppTag = dependencyTag{name: "androidApp", payload: true} |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 64 | rroTag = dependencyTag{name: "rro", payload: true} |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 65 | apexAvailWl = makeApexAvailableWhitelist() |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 66 | |
| 67 | inverseApexAvailWl = invertApexWhiteList(apexAvailWl) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 68 | ) |
| 69 | |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 70 | // Transform the map of apex -> modules to module -> apexes. |
| 71 | func invertApexWhiteList(m map[string][]string) map[string][]string { |
| 72 | r := make(map[string][]string) |
| 73 | for apex, modules := range m { |
| 74 | for _, module := range modules { |
| 75 | r[module] = append(r[module], apex) |
| 76 | } |
| 77 | } |
| 78 | return r |
| 79 | } |
| 80 | |
| 81 | // Retrieve the while list of apexes to which the supplied module belongs. |
| 82 | func WhitelistedApexAvailable(moduleName string) []string { |
| 83 | return inverseApexAvailWl[normalizeModuleName(moduleName)] |
| 84 | } |
| 85 | |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 86 | // This is a map from apex to modules, which overrides the |
| 87 | // apex_available setting for that particular module to make |
| 88 | // it available for the apex regardless of its setting. |
| 89 | // TODO(b/147364041): remove this |
| 90 | func makeApexAvailableWhitelist() map[string][]string { |
| 91 | // The "Module separator"s below are employed to minimize merge conflicts. |
| 92 | m := make(map[string][]string) |
| 93 | // |
| 94 | // Module separator |
| 95 | // |
Paul Duffin | 50cbefd | 2020-03-10 13:44:19 +0000 | [diff] [blame] | 96 | artApexContents := []string{ |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 97 | "art_cmdlineparser_headers", |
| 98 | "art_disassembler_headers", |
| 99 | "art_libartbase_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 100 | "bionic_libc_platform_headers", |
| 101 | "core-repackaged-icu4j", |
| 102 | "cpp-define-generator-asm-support", |
| 103 | "cpp-define-generator-definitions", |
| 104 | "crtbegin_dynamic", |
| 105 | "crtbegin_dynamic1", |
| 106 | "crtbegin_so1", |
| 107 | "crtbrand", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 108 | "dex2oat_headers", |
| 109 | "dt_fd_forward_export", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 110 | "icu4c_extra_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 111 | "javavm_headers", |
| 112 | "jni_platform_headers", |
| 113 | "libPlatformProperties", |
| 114 | "libadbconnection_client", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 115 | "libadbconnection_server", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 116 | "libandroidicuinit", |
| 117 | "libart_runtime_headers_ndk", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 118 | "libartd-disassembler", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 119 | "libdexfile_all_headers", |
| 120 | "libdexfile_external_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 121 | "libdexfile_support", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 122 | "libdmabufinfo", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 123 | "libexpat", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 124 | "libfdlibm", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 125 | "libicui18n_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 126 | "libicuuc", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 127 | "libicuuc_headers", |
| 128 | "libicuuc_stubdata", |
| 129 | "libjdwp_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 130 | "liblz4", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 131 | "liblzma", |
| 132 | "libmeminfo", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 133 | "libnativebridge-headers", |
| 134 | "libnativehelper_header_only", |
| 135 | "libnativeloader-headers", |
| 136 | "libnpt_headers", |
| 137 | "libopenjdkjvmti_headers", |
| 138 | "libperfetto_client_experimental", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 139 | "libprocinfo", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 140 | "libunwind_llvm", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 141 | "libunwindstack", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 142 | "libv8", |
| 143 | "libv8base", |
| 144 | "libv8gen", |
| 145 | "libv8platform", |
| 146 | "libv8sampler", |
| 147 | "libv8src", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 148 | "libvixl", |
| 149 | "libvixld", |
| 150 | "libz", |
| 151 | "libziparchive", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 152 | "perfetto_trace_protos", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 153 | } |
Paul Duffin | 50cbefd | 2020-03-10 13:44:19 +0000 | [diff] [blame] | 154 | m["com.android.art.debug"] = artApexContents |
| 155 | m["com.android.art.release"] = artApexContents |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 156 | // |
| 157 | // Module separator |
| 158 | // |
| 159 | m["com.android.bluetooth.updatable"] = []string{ |
| 160 | "android.hardware.audio.common@5.0", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 161 | "android.hardware.bluetooth.a2dp@1.0", |
| 162 | "android.hardware.bluetooth.audio@2.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 163 | "android.hardware.bluetooth@1.0", |
| 164 | "android.hardware.bluetooth@1.1", |
| 165 | "android.hardware.graphics.bufferqueue@1.0", |
| 166 | "android.hardware.graphics.bufferqueue@2.0", |
| 167 | "android.hardware.graphics.common@1.0", |
| 168 | "android.hardware.graphics.common@1.1", |
| 169 | "android.hardware.graphics.common@1.2", |
| 170 | "android.hardware.media@1.0", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 171 | "android.hidl.safe_union@1.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 172 | "android.hidl.token@1.0", |
| 173 | "android.hidl.token@1.0-utils", |
| 174 | "avrcp-target-service", |
| 175 | "avrcp_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 176 | "bluetooth-protos-lite", |
| 177 | "bluetooth.mapsapi", |
| 178 | "com.android.vcard", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 179 | "dnsresolver_aidl_interface-V2-java", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 180 | "ipmemorystore-aidl-interfaces-V5-java", |
| 181 | "ipmemorystore-aidl-interfaces-java", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 182 | "internal_include_headers", |
| 183 | "lib-bt-packets", |
| 184 | "lib-bt-packets-avrcp", |
| 185 | "lib-bt-packets-base", |
| 186 | "libFraunhoferAAC", |
| 187 | "libaudio-a2dp-hw-utils", |
| 188 | "libaudio-hearing-aid-hw-utils", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 189 | "libbinder_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 190 | "libbluetooth", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 191 | "libbluetooth-types", |
| 192 | "libbluetooth-types-header", |
| 193 | "libbluetooth_gd", |
| 194 | "libbluetooth_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 195 | "libbluetooth_jni", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 196 | "libbt-audio-hal-interface", |
| 197 | "libbt-bta", |
| 198 | "libbt-common", |
| 199 | "libbt-hci", |
| 200 | "libbt-platform-protos-lite", |
| 201 | "libbt-protos-lite", |
| 202 | "libbt-sbc-decoder", |
| 203 | "libbt-sbc-encoder", |
| 204 | "libbt-stack", |
| 205 | "libbt-utils", |
| 206 | "libbtcore", |
| 207 | "libbtdevice", |
| 208 | "libbte", |
| 209 | "libbtif", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 210 | "libchrome", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 211 | "libevent", |
| 212 | "libfmq", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 213 | "libg722codec", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 214 | "libgui_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 215 | "libmedia_headers", |
| 216 | "libmodpb64", |
| 217 | "libosi", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 218 | "libstagefright_foundation_headers", |
| 219 | "libstagefright_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 220 | "libstatslog", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 221 | "libstatssocket", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 222 | "libtinyxml2", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 223 | "libudrv-uipc", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 224 | "libz", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 225 | "media_plugin_headers", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 226 | "net-utils-services-common", |
| 227 | "netd_aidl_interface-unstable-java", |
| 228 | "netd_event_listener_interface-java", |
| 229 | "netlink-client", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 230 | "networkstack-client", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 231 | "sap-api-java-static", |
| 232 | "services.net", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 233 | } |
| 234 | // |
| 235 | // Module separator |
| 236 | // |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 237 | m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"} |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 238 | // |
| 239 | // Module separator |
| 240 | // |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 241 | m["com.android.conscrypt"] = []string{ |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 242 | "libnativehelper_header_only", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 243 | } |
| 244 | // |
| 245 | // Module separator |
| 246 | // |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 247 | m["com.android.neuralnetworks"] = []string{ |
| 248 | "android.hardware.neuralnetworks@1.0", |
| 249 | "android.hardware.neuralnetworks@1.1", |
| 250 | "android.hardware.neuralnetworks@1.2", |
| 251 | "android.hardware.neuralnetworks@1.3", |
| 252 | "android.hidl.allocator@1.0", |
| 253 | "android.hidl.memory.token@1.0", |
| 254 | "android.hidl.memory@1.0", |
| 255 | "android.hidl.safe_union@1.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 256 | "libarect", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 257 | "libbuildversion", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 258 | "libmath", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 259 | "libprocpartition", |
| 260 | "libsync", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 261 | } |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 262 | // |
| 263 | // Module separator |
| 264 | // |
| 265 | m["com.android.media"] = []string{ |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 266 | "android.frameworks.bufferhub@1.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 267 | "android.hardware.cas.native@1.0", |
| 268 | "android.hardware.cas@1.0", |
| 269 | "android.hardware.configstore-utils", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 270 | "android.hardware.configstore@1.0", |
| 271 | "android.hardware.configstore@1.1", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 272 | "android.hardware.graphics.allocator@2.0", |
| 273 | "android.hardware.graphics.allocator@3.0", |
| 274 | "android.hardware.graphics.bufferqueue@1.0", |
| 275 | "android.hardware.graphics.bufferqueue@2.0", |
| 276 | "android.hardware.graphics.common@1.0", |
| 277 | "android.hardware.graphics.common@1.1", |
| 278 | "android.hardware.graphics.common@1.2", |
| 279 | "android.hardware.graphics.mapper@2.0", |
| 280 | "android.hardware.graphics.mapper@2.1", |
| 281 | "android.hardware.graphics.mapper@3.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 282 | "android.hardware.media.omx@1.0", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 283 | "android.hardware.media@1.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 284 | "android.hidl.allocator@1.0", |
| 285 | "android.hidl.memory.token@1.0", |
| 286 | "android.hidl.memory@1.0", |
| 287 | "android.hidl.token@1.0", |
| 288 | "android.hidl.token@1.0-utils", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 289 | "bionic_libc_platform_headers", |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 290 | "exoplayer2-extractor", |
| 291 | "exoplayer2-extractor-annotation-stubs", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 292 | "gl_headers", |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 293 | "jsr305", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 294 | "libEGL", |
| 295 | "libEGL_blobCache", |
| 296 | "libEGL_getProcAddress", |
| 297 | "libFLAC", |
| 298 | "libFLAC-config", |
| 299 | "libFLAC-headers", |
| 300 | "libGLESv2", |
| 301 | "libaacextractor", |
| 302 | "libamrextractor", |
| 303 | "libarect", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 304 | "libaudio_system_headers", |
| 305 | "libaudioclient", |
| 306 | "libaudioclient_headers", |
| 307 | "libaudiofoundation", |
| 308 | "libaudiofoundation_headers", |
| 309 | "libaudiomanager", |
| 310 | "libaudiopolicy", |
| 311 | "libaudioutils", |
| 312 | "libaudioutils_fixedfft", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 313 | "libbinder_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 314 | "libbluetooth-types-header", |
| 315 | "libbufferhub", |
| 316 | "libbufferhub_headers", |
| 317 | "libbufferhubqueue", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 318 | "libc_malloc_debug_backtrace", |
| 319 | "libcamera_client", |
| 320 | "libcamera_metadata", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 321 | "libdexfile_external_headers", |
| 322 | "libdexfile_support", |
| 323 | "libdvr_headers", |
| 324 | "libexpat", |
| 325 | "libfifo", |
| 326 | "libflacextractor", |
| 327 | "libgrallocusage", |
| 328 | "libgraphicsenv", |
| 329 | "libgui", |
| 330 | "libgui_headers", |
| 331 | "libhardware_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 332 | "libinput", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 333 | "liblzma", |
| 334 | "libmath", |
| 335 | "libmedia", |
| 336 | "libmedia_codeclist", |
| 337 | "libmedia_headers", |
| 338 | "libmedia_helper", |
| 339 | "libmedia_helper_headers", |
| 340 | "libmedia_midiiowrapper", |
| 341 | "libmedia_omx", |
| 342 | "libmediautils", |
| 343 | "libmidiextractor", |
| 344 | "libmkvextractor", |
| 345 | "libmp3extractor", |
| 346 | "libmp4extractor", |
| 347 | "libmpeg2extractor", |
| 348 | "libnativebase_headers", |
| 349 | "libnativebridge-headers", |
| 350 | "libnativebridge_lazy", |
| 351 | "libnativeloader-headers", |
| 352 | "libnativeloader_lazy", |
| 353 | "libnativewindow_headers", |
| 354 | "libnblog", |
| 355 | "liboggextractor", |
| 356 | "libpackagelistparser", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 357 | "libpdx", |
| 358 | "libpdx_default_transport", |
| 359 | "libpdx_headers", |
| 360 | "libpdx_uds", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 361 | "libprocinfo", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 362 | "libsonivox", |
| 363 | "libspeexresampler", |
| 364 | "libspeexresampler", |
| 365 | "libstagefright_esds", |
| 366 | "libstagefright_flacdec", |
| 367 | "libstagefright_flacdec", |
| 368 | "libstagefright_foundation", |
| 369 | "libstagefright_foundation_headers", |
| 370 | "libstagefright_foundation_without_imemory", |
| 371 | "libstagefright_headers", |
| 372 | "libstagefright_id3", |
| 373 | "libstagefright_metadatautils", |
| 374 | "libstagefright_mpeg2extractor", |
| 375 | "libstagefright_mpeg2support", |
| 376 | "libsync", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 377 | "libui", |
| 378 | "libui_headers", |
| 379 | "libunwindstack", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 380 | "libvibrator", |
| 381 | "libvorbisidec", |
| 382 | "libwavextractor", |
| 383 | "libwebm", |
| 384 | "media_ndk_headers", |
| 385 | "media_plugin_headers", |
| 386 | "updatable-media", |
| 387 | } |
| 388 | // |
| 389 | // Module separator |
| 390 | // |
| 391 | m["com.android.media.swcodec"] = []string{ |
| 392 | "android.frameworks.bufferhub@1.0", |
| 393 | "android.hardware.common-ndk_platform", |
| 394 | "android.hardware.configstore-utils", |
| 395 | "android.hardware.configstore@1.0", |
| 396 | "android.hardware.configstore@1.1", |
| 397 | "android.hardware.graphics.allocator@2.0", |
| 398 | "android.hardware.graphics.allocator@3.0", |
| 399 | "android.hardware.graphics.bufferqueue@1.0", |
| 400 | "android.hardware.graphics.bufferqueue@2.0", |
| 401 | "android.hardware.graphics.common-ndk_platform", |
| 402 | "android.hardware.graphics.common@1.0", |
| 403 | "android.hardware.graphics.common@1.1", |
| 404 | "android.hardware.graphics.common@1.2", |
| 405 | "android.hardware.graphics.mapper@2.0", |
| 406 | "android.hardware.graphics.mapper@2.1", |
| 407 | "android.hardware.graphics.mapper@3.0", |
| 408 | "android.hardware.graphics.mapper@4.0", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 409 | "android.hardware.media.bufferpool@2.0", |
| 410 | "android.hardware.media.c2@1.0", |
| 411 | "android.hardware.media.omx@1.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 412 | "android.hardware.media@1.0", |
| 413 | "android.hardware.media@1.0", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 414 | "android.hidl.memory.token@1.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 415 | "android.hidl.memory@1.0", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 416 | "android.hidl.safe_union@1.0", |
| 417 | "android.hidl.token@1.0", |
| 418 | "android.hidl.token@1.0-utils", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 419 | "libEGL", |
| 420 | "libFLAC", |
| 421 | "libFLAC-config", |
| 422 | "libFLAC-headers", |
| 423 | "libFraunhoferAAC", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 424 | "libLibGuiProperties", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 425 | "libarect", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 426 | "libaudio_system_headers", |
| 427 | "libaudioutils", |
| 428 | "libaudioutils", |
| 429 | "libaudioutils_fixedfft", |
| 430 | "libavcdec", |
| 431 | "libavcenc", |
| 432 | "libavservices_minijail", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 433 | "libavservices_minijail", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 434 | "libbinder_headers", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 435 | "libbinderthreadstateutils", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 436 | "libbluetooth-types-header", |
| 437 | "libbufferhub_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 438 | "libc_scudo", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 439 | "libcodec2", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 440 | "libcodec2_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 441 | "libcodec2_hidl@1.0", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 442 | "libcodec2_hidl@1.1", |
| 443 | "libcodec2_internal", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 444 | "libcodec2_soft_aacdec", |
| 445 | "libcodec2_soft_aacenc", |
| 446 | "libcodec2_soft_amrnbdec", |
| 447 | "libcodec2_soft_amrnbenc", |
| 448 | "libcodec2_soft_amrwbdec", |
| 449 | "libcodec2_soft_amrwbenc", |
| 450 | "libcodec2_soft_av1dec_gav1", |
| 451 | "libcodec2_soft_avcdec", |
| 452 | "libcodec2_soft_avcenc", |
| 453 | "libcodec2_soft_common", |
| 454 | "libcodec2_soft_flacdec", |
| 455 | "libcodec2_soft_flacenc", |
| 456 | "libcodec2_soft_g711alawdec", |
| 457 | "libcodec2_soft_g711mlawdec", |
| 458 | "libcodec2_soft_gsmdec", |
| 459 | "libcodec2_soft_h263dec", |
| 460 | "libcodec2_soft_h263enc", |
| 461 | "libcodec2_soft_hevcdec", |
| 462 | "libcodec2_soft_hevcenc", |
| 463 | "libcodec2_soft_mp3dec", |
| 464 | "libcodec2_soft_mpeg2dec", |
| 465 | "libcodec2_soft_mpeg4dec", |
| 466 | "libcodec2_soft_mpeg4enc", |
| 467 | "libcodec2_soft_opusdec", |
| 468 | "libcodec2_soft_opusenc", |
| 469 | "libcodec2_soft_rawdec", |
| 470 | "libcodec2_soft_vorbisdec", |
| 471 | "libcodec2_soft_vp8dec", |
| 472 | "libcodec2_soft_vp8enc", |
| 473 | "libcodec2_soft_vp9dec", |
| 474 | "libcodec2_soft_vp9enc", |
| 475 | "libcodec2_vndk", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 476 | "libdexfile_support", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 477 | "libdvr_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 478 | "libfmq", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 479 | "libfmq", |
| 480 | "libgav1", |
| 481 | "libgralloctypes", |
| 482 | "libgrallocusage", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 483 | "libgraphicsenv", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 484 | "libgsm", |
| 485 | "libgui_bufferqueue_static", |
| 486 | "libgui_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 487 | "libhardware", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 488 | "libhardware_headers", |
| 489 | "libhevcdec", |
| 490 | "libhevcenc", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 491 | "libion", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 492 | "libjpeg", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 493 | "liblzma", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 494 | "libmath", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 495 | "libmedia_codecserviceregistrant", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 496 | "libmedia_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 497 | "libmpeg2dec", |
| 498 | "libnativebase_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 499 | "libnativebridge_lazy", |
| 500 | "libnativeloader_lazy", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 501 | "libnativewindow_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 502 | "libpdx_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 503 | "libscudo_wrapper", |
| 504 | "libsfplugin_ccodec_utils", |
| 505 | "libstagefright_amrnb_common", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 506 | "libstagefright_amrnbdec", |
| 507 | "libstagefright_amrnbenc", |
| 508 | "libstagefright_amrwbdec", |
| 509 | "libstagefright_amrwbenc", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 510 | "libstagefright_bufferpool@2.0.1", |
| 511 | "libstagefright_bufferqueue_helper", |
| 512 | "libstagefright_enc_common", |
| 513 | "libstagefright_flacdec", |
| 514 | "libstagefright_foundation", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 515 | "libstagefright_foundation_headers", |
| 516 | "libstagefright_headers", |
| 517 | "libstagefright_m4vh263dec", |
| 518 | "libstagefright_m4vh263enc", |
| 519 | "libstagefright_mp3dec", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 520 | "libsync", |
| 521 | "libui", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 522 | "libui_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 523 | "libunwindstack", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 524 | "libvorbisidec", |
| 525 | "libvpx", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 526 | "libyuv", |
| 527 | "libyuv_static", |
| 528 | "media_ndk_headers", |
| 529 | "media_plugin_headers", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 530 | "mediaswcodec", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 531 | } |
| 532 | // |
| 533 | // Module separator |
| 534 | // |
| 535 | m["com.android.mediaprovider"] = []string{ |
| 536 | "MediaProvider", |
| 537 | "MediaProviderGoogle", |
| 538 | "fmtlib_ndk", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 539 | "libbase_ndk", |
| 540 | "libfuse", |
| 541 | "libfuse_jni", |
| 542 | "libnativehelper_header_only", |
| 543 | } |
| 544 | // |
| 545 | // Module separator |
| 546 | // |
| 547 | m["com.android.permission"] = []string{ |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 548 | "kotlin-annotations", |
| 549 | "kotlin-stdlib", |
| 550 | "kotlin-stdlib-jdk7", |
| 551 | "kotlin-stdlib-jdk8", |
| 552 | "kotlinx-coroutines-android", |
| 553 | "kotlinx-coroutines-android-nodeps", |
| 554 | "kotlinx-coroutines-core", |
| 555 | "kotlinx-coroutines-core-nodeps", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 556 | "permissioncontroller-statsd", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 557 | } |
| 558 | // |
| 559 | // Module separator |
| 560 | // |
| 561 | m["com.android.runtime"] = []string{ |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 562 | "bionic_libc_platform_headers", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 563 | "libarm-optimized-routines-math", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 564 | "libc_aeabi", |
| 565 | "libc_bionic", |
| 566 | "libc_bionic_ndk", |
| 567 | "libc_bootstrap", |
| 568 | "libc_common", |
| 569 | "libc_common_shared", |
| 570 | "libc_common_static", |
| 571 | "libc_dns", |
| 572 | "libc_dynamic_dispatch", |
| 573 | "libc_fortify", |
| 574 | "libc_freebsd", |
| 575 | "libc_freebsd_large_stack", |
| 576 | "libc_gdtoa", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 577 | "libc_init_dynamic", |
| 578 | "libc_init_static", |
| 579 | "libc_jemalloc_wrapper", |
| 580 | "libc_netbsd", |
| 581 | "libc_nomalloc", |
| 582 | "libc_nopthread", |
| 583 | "libc_openbsd", |
| 584 | "libc_openbsd_large_stack", |
| 585 | "libc_openbsd_ndk", |
| 586 | "libc_pthread", |
| 587 | "libc_static_dispatch", |
| 588 | "libc_syscalls", |
| 589 | "libc_tzcode", |
| 590 | "libc_unwind_static", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 591 | "libdebuggerd", |
| 592 | "libdebuggerd_common_headers", |
| 593 | "libdebuggerd_handler_core", |
| 594 | "libdebuggerd_handler_fallback", |
| 595 | "libdexfile_external_headers", |
| 596 | "libdexfile_support", |
| 597 | "libdexfile_support_static", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 598 | "libdl_static", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 599 | "libjemalloc5", |
| 600 | "liblinker_main", |
| 601 | "liblinker_malloc", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 602 | "liblz4", |
| 603 | "liblzma", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 604 | "libprocinfo", |
| 605 | "libpropertyinfoparser", |
| 606 | "libscudo", |
| 607 | "libstdc++", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 608 | "libsystemproperties", |
| 609 | "libtombstoned_client_static", |
| 610 | "libunwindstack", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 611 | "libz", |
| 612 | "libziparchive", |
| 613 | } |
| 614 | // |
| 615 | // Module separator |
| 616 | // |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 617 | m["com.android.tethering"] = []string{ |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 618 | "android.hardware.tetheroffload.config-V1.0-java", |
| 619 | "android.hardware.tetheroffload.control-V1.0-java", |
| 620 | "android.hidl.base-V1.0-java", |
| 621 | "ipmemorystore-aidl-interfaces-java", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 622 | "libcgrouprc", |
| 623 | "libcgrouprc_format", |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 624 | "libnativehelper_compat_libc++", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 625 | "libtetherutilsjni", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 626 | "libvndksupport", |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 627 | "net-utils-framework-common", |
| 628 | "netd_aidl_interface-V3-java", |
| 629 | "netlink-client", |
| 630 | "networkstack-aidl-interfaces-java", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 631 | "tethering-aidl-interfaces-java", |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 632 | "TetheringApiCurrentLib", |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 633 | } |
| 634 | // |
| 635 | // Module separator |
| 636 | // |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 637 | m["com.android.wifi"] = []string{ |
| 638 | "PlatformProperties", |
| 639 | "android.hardware.wifi-V1.0-java", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 640 | "android.hardware.wifi-V1.0-java-constants", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 641 | "android.hardware.wifi-V1.1-java", |
| 642 | "android.hardware.wifi-V1.2-java", |
| 643 | "android.hardware.wifi-V1.3-java", |
| 644 | "android.hardware.wifi-V1.4-java", |
| 645 | "android.hardware.wifi.hostapd-V1.0-java", |
| 646 | "android.hardware.wifi.hostapd-V1.1-java", |
| 647 | "android.hardware.wifi.hostapd-V1.2-java", |
| 648 | "android.hardware.wifi.supplicant-V1.0-java", |
| 649 | "android.hardware.wifi.supplicant-V1.1-java", |
| 650 | "android.hardware.wifi.supplicant-V1.2-java", |
| 651 | "android.hardware.wifi.supplicant-V1.3-java", |
| 652 | "android.hidl.base-V1.0-java", |
| 653 | "android.hidl.manager-V1.0-java", |
| 654 | "android.hidl.manager-V1.1-java", |
| 655 | "android.hidl.manager-V1.2-java", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 656 | "bouncycastle-unbundled", |
| 657 | "dnsresolver_aidl_interface-V2-java", |
| 658 | "error_prone_annotations", |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 659 | "framework-wifi-pre-jarjar", |
| 660 | "framework-wifi-util-lib", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 661 | "ipmemorystore-aidl-interfaces-V3-java", |
| 662 | "ipmemorystore-aidl-interfaces-java", |
| 663 | "ksoap2", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 664 | "libnanohttpd", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 665 | "libwifi-jni", |
| 666 | "net-utils-services-common", |
| 667 | "netd_aidl_interface-V2-java", |
| 668 | "netd_aidl_interface-unstable-java", |
| 669 | "netd_event_listener_interface-java", |
| 670 | "netlink-client", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 671 | "networkstack-client", |
| 672 | "services.net", |
| 673 | "wifi-lite-protos", |
| 674 | "wifi-nano-protos", |
| 675 | "wifi-service-pre-jarjar", |
| 676 | "wifi-service-resources", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 677 | } |
| 678 | // |
| 679 | // Module separator |
| 680 | // |
| 681 | m["com.android.sdkext"] = []string{ |
| 682 | "fmtlib_ndk", |
| 683 | "libbase_ndk", |
| 684 | "libprotobuf-cpp-lite-ndk", |
| 685 | } |
| 686 | // |
| 687 | // Module separator |
| 688 | // |
| 689 | m["com.android.os.statsd"] = []string{ |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 690 | "libstatssocket", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 691 | } |
| 692 | // |
| 693 | // Module separator |
| 694 | // |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 695 | m[android.AvailableToAnyApex] = []string{ |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 696 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries |
| 697 | "androidx", |
| 698 | "androidx-constraintlayout_constraintlayout", |
| 699 | "androidx-constraintlayout_constraintlayout-nodeps", |
| 700 | "androidx-constraintlayout_constraintlayout-solver", |
| 701 | "androidx-constraintlayout_constraintlayout-solver-nodeps", |
| 702 | "com.google.android.material_material", |
| 703 | "com.google.android.material_material-nodeps", |
| 704 | |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 705 | "libatomic", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 706 | "libclang_rt", |
| 707 | "libgcc_stripped", |
| 708 | "libprofile-clang-extras", |
| 709 | "libprofile-clang-extras_ndk", |
| 710 | "libprofile-extras", |
| 711 | "libprofile-extras_ndk", |
| 712 | "libunwind_llvm", |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 713 | } |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 714 | return m |
| 715 | } |
| 716 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 717 | func init() { |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 718 | android.RegisterModuleType("apex", BundleFactory) |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 719 | android.RegisterModuleType("apex_test", testApexBundleFactory) |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 720 | android.RegisterModuleType("apex_vndk", vndkApexBundleFactory) |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 721 | android.RegisterModuleType("apex_defaults", defaultsFactory) |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 722 | android.RegisterModuleType("prebuilt_apex", PrebuiltFactory) |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 723 | android.RegisterModuleType("override_apex", overrideApexFactory) |
Jaewoong Jung | fa00c06 | 2020-05-14 14:15:24 -0700 | [diff] [blame] | 724 | android.RegisterModuleType("apex_set", apexSetFactory) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 725 | |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 726 | android.PreDepsMutators(RegisterPreDepsMutators) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 727 | android.PostDepsMutators(RegisterPostDepsMutators) |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 728 | |
| 729 | android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) { |
| 730 | apexFileContextsInfos := apexFileContextsInfos(ctx.Config()) |
| 731 | sort.Strings(*apexFileContextsInfos) |
| 732 | ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " ")) |
| 733 | }) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 734 | } |
| 735 | |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 736 | func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { |
| 737 | ctx.TopDown("apex_vndk", apexVndkMutator).Parallel() |
| 738 | ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel() |
| 739 | } |
| 740 | |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 741 | func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 742 | ctx.TopDown("apex_deps", apexDepsMutator) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 743 | ctx.BottomUp("apex", apexMutator).Parallel() |
| 744 | ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel() |
| 745 | ctx.BottomUp("apex_uses", apexUsesMutator).Parallel() |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 746 | ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel() |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 747 | } |
| 748 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 749 | // Mark the direct and transitive dependencies of apex bundles so that they |
| 750 | // can be built for the apex bundles. |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 751 | func apexDepsMutator(mctx android.TopDownMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 752 | if !mctx.Module().Enabled() { |
| 753 | return |
| 754 | } |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 755 | var apexBundles []android.ApexInfo |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 756 | var directDep bool |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 757 | if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 758 | apexBundles = []android.ApexInfo{{ |
Jooyung Han | 5417f77 | 2020-03-12 18:37:20 +0900 | [diff] [blame] | 759 | ApexName: mctx.ModuleName(), |
| 760 | MinSdkVersion: a.minSdkVersion(mctx), |
Ulya Trafimovich | 7c140d8 | 2020-04-22 18:05:58 +0100 | [diff] [blame] | 761 | Updatable: proptools.Bool(a.properties.Updatable), |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 762 | }} |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 763 | directDep = true |
| 764 | } else if am, ok := mctx.Module().(android.ApexModule); ok { |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 765 | apexBundles = am.ApexVariations() |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 766 | directDep = false |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 767 | } |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 768 | |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 769 | if len(apexBundles) == 0 { |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 770 | return |
| 771 | } |
| 772 | |
Paul Duffin | 923e8a5 | 2020-03-30 15:33:32 +0100 | [diff] [blame] | 773 | cur := mctx.Module().(android.DepIsInSameApex) |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 774 | |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 775 | mctx.VisitDirectDeps(func(child android.Module) { |
| 776 | depName := mctx.OtherModuleName(child) |
| 777 | if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() && |
Paul Duffin | 6534770 | 2020-03-31 15:23:40 +0100 | [diff] [blame] | 778 | (cur.DepIsInSameApex(mctx, child) || inAnySdk(child)) { |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 779 | android.UpdateApexDependency(apexBundles, depName, directDep) |
| 780 | am.BuildForApexes(apexBundles) |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 781 | } |
| 782 | }) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 783 | } |
| 784 | |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 785 | // mark if a module cannot be available to platform. A module cannot be available |
| 786 | // to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform" |
| 787 | // is absent) or 2) it depends on another module that isn't (or can't be) available to platform |
| 788 | func markPlatformAvailability(mctx android.BottomUpMutatorContext) { |
| 789 | // Host and recovery are not considered as platform |
| 790 | if mctx.Host() || mctx.Module().InstallInRecovery() { |
| 791 | return |
| 792 | } |
| 793 | |
| 794 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 795 | availableToPlatform := am.AvailableFor(android.AvailableToPlatform) |
| 796 | |
| 797 | // In a rare case when a lib is marked as available only to an apex |
| 798 | // but the apex doesn't exist. This can happen in a partial manifest branch |
| 799 | // like master-art. Currently, libstatssocket in the stats APEX is causing |
| 800 | // this problem. |
| 801 | // Include the lib in platform because the module SDK that ought to provide |
| 802 | // it doesn't exist, so it would otherwise be left out completely. |
| 803 | // TODO(b/154888298) remove this by adding those libraries in module SDKS and skipping |
| 804 | // this check for libraries provided by SDKs. |
| 805 | if !availableToPlatform && !android.InAnyApex(am.Name()) { |
| 806 | availableToPlatform = true |
| 807 | } |
| 808 | |
| 809 | // If any of the dep is not available to platform, this module is also considered |
| 810 | // as being not available to platform even if it has "//apex_available:platform" |
| 811 | mctx.VisitDirectDeps(func(child android.Module) { |
| 812 | if !am.DepIsInSameApex(mctx, child) { |
| 813 | // if the dependency crosses apex boundary, don't consider it |
| 814 | return |
| 815 | } |
| 816 | if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() { |
| 817 | availableToPlatform = false |
| 818 | // TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform" |
| 819 | } |
| 820 | }) |
| 821 | |
| 822 | // Exception 1: stub libraries and native bridge libraries are always available to platform |
| 823 | if cc, ok := mctx.Module().(*cc.Module); ok && |
| 824 | (cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) { |
| 825 | availableToPlatform = true |
| 826 | } |
| 827 | |
| 828 | // Exception 2: bootstrap bionic libraries are also always available to platform |
| 829 | if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) { |
| 830 | availableToPlatform = true |
| 831 | } |
| 832 | |
| 833 | if !availableToPlatform { |
| 834 | am.SetNotAvailableForPlatform() |
| 835 | } |
| 836 | } |
| 837 | } |
| 838 | |
Paul Duffin | 6534770 | 2020-03-31 15:23:40 +0100 | [diff] [blame] | 839 | // If a module in an APEX depends on a module from an SDK then it needs an APEX |
| 840 | // specific variant created for it. Refer to sdk.sdkDepsReplaceMutator. |
| 841 | func inAnySdk(module android.Module) bool { |
| 842 | if sa, ok := module.(android.SdkAware); ok { |
| 843 | return sa.IsInAnySdk() |
| 844 | } |
| 845 | |
| 846 | return false |
| 847 | } |
| 848 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 849 | // Create apex variations if a module is included in APEX(s). |
| 850 | func apexMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 851 | if !mctx.Module().Enabled() { |
| 852 | return |
| 853 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 854 | if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 855 | am.CreateApexVariations(mctx) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 856 | } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 857 | // apex bundle itself is mutated so that it and its modules have same |
| 858 | // apex variant. |
| 859 | apexBundleName := mctx.ModuleName() |
| 860 | mctx.CreateVariations(apexBundleName) |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 861 | } else if o, ok := mctx.Module().(*OverrideApex); ok { |
| 862 | apexBundleName := o.GetOverriddenModuleName() |
| 863 | if apexBundleName == "" { |
| 864 | mctx.ModuleErrorf("base property is not set") |
| 865 | return |
| 866 | } |
| 867 | mctx.CreateVariations(apexBundleName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 868 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 869 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 870 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 871 | |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 872 | var ( |
| 873 | apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey") |
| 874 | apexFileContextsInfosMutex sync.Mutex |
| 875 | ) |
| 876 | |
| 877 | func apexFileContextsInfos(config android.Config) *[]string { |
| 878 | return config.Once(apexFileContextsInfosKey, func() interface{} { |
| 879 | return &[]string{} |
| 880 | }).(*[]string) |
| 881 | } |
| 882 | |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 883 | func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) { |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 884 | apexFileContextsInfosMutex.Lock() |
| 885 | defer apexFileContextsInfosMutex.Unlock() |
| 886 | apexFileContextsInfos := apexFileContextsInfos(ctx.Config()) |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 887 | *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo) |
Jooyung Han | 7a78a92 | 2019-10-08 21:59:58 +0900 | [diff] [blame] | 888 | } |
| 889 | |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 890 | func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 891 | if !mctx.Module().Enabled() { |
| 892 | return |
| 893 | } |
Sundong Ahn | e8fb724 | 2019-09-17 13:50:45 +0900 | [diff] [blame] | 894 | if ab, ok := mctx.Module().(*apexBundle); ok { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 895 | var variants []string |
| 896 | switch proptools.StringDefault(ab.properties.Payload_type, "image") { |
| 897 | case "image": |
| 898 | variants = append(variants, imageApexType, flattenedApexType) |
| 899 | case "zip": |
| 900 | variants = append(variants, zipApexType) |
| 901 | case "both": |
| 902 | variants = append(variants, imageApexType, zipApexType, flattenedApexType) |
| 903 | default: |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 904 | mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type) |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 905 | return |
| 906 | } |
| 907 | |
| 908 | modules := mctx.CreateLocalVariations(variants...) |
| 909 | |
| 910 | for i, v := range variants { |
| 911 | switch v { |
| 912 | case imageApexType: |
| 913 | modules[i].(*apexBundle).properties.ApexType = imageApex |
| 914 | case zipApexType: |
| 915 | modules[i].(*apexBundle).properties.ApexType = zipApex |
| 916 | case flattenedApexType: |
| 917 | modules[i].(*apexBundle).properties.ApexType = flattenedApex |
Jooyung Han | 91df208 | 2019-11-20 01:49:42 +0900 | [diff] [blame] | 918 | if !mctx.Config().FlattenApex() && ab.Platform() { |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 919 | modules[i].(*apexBundle).MakeAsSystemExt() |
| 920 | } |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 921 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 922 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 923 | } else if _, ok := mctx.Module().(*OverrideApex); ok { |
| 924 | mctx.CreateVariations(imageApexType, flattenedApexType) |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 925 | } |
| 926 | } |
| 927 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 928 | func apexUsesMutator(mctx android.BottomUpMutatorContext) { |
| 929 | if ab, ok := mctx.Module().(*apexBundle); ok { |
| 930 | mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...) |
| 931 | } |
| 932 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 933 | |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 934 | var ( |
| 935 | useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist") |
| 936 | ) |
| 937 | |
| 938 | // useVendorWhitelist returns the list of APEXes which are allowed to use_vendor. |
| 939 | // When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__, |
| 940 | // which may cause compatibility issues. (e.g. libbinder) |
| 941 | // Even though libbinder restricts its availability via 'apex_available' property and relies on |
| 942 | // yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules |
| 943 | // to avoid similar problems. |
| 944 | func useVendorWhitelist(config android.Config) []string { |
| 945 | return config.Once(useVendorWhitelistKey, func() interface{} { |
| 946 | return []string{ |
| 947 | // swcodec uses "vendor" variants for smaller size |
| 948 | "com.android.media.swcodec", |
| 949 | "test_com.android.media.swcodec", |
| 950 | } |
| 951 | }).([]string) |
| 952 | } |
| 953 | |
| 954 | // setUseVendorWhitelistForTest overrides useVendorWhitelist and must be |
| 955 | // called before the first call to useVendorWhitelist() |
| 956 | func setUseVendorWhitelistForTest(config android.Config, whitelist []string) { |
| 957 | config.Once(useVendorWhitelistKey, func() interface{} { |
| 958 | return whitelist |
| 959 | }) |
| 960 | } |
| 961 | |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 962 | type ApexNativeDependencies struct { |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 963 | // List of native libraries |
| 964 | Native_shared_libs []string |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 965 | |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 966 | // List of JNI libraries |
| 967 | Jni_libs []string |
| 968 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 969 | // List of native executables |
| 970 | Binaries []string |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 971 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 972 | // List of native tests |
| 973 | Tests []string |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 974 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 975 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 976 | type apexMultilibProperties struct { |
| 977 | // Native dependencies whose compile_multilib is "first" |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 978 | First ApexNativeDependencies |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 979 | |
| 980 | // Native dependencies whose compile_multilib is "both" |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 981 | Both ApexNativeDependencies |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 982 | |
| 983 | // Native dependencies whose compile_multilib is "prefer32" |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 984 | Prefer32 ApexNativeDependencies |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 985 | |
| 986 | // Native dependencies whose compile_multilib is "32" |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 987 | Lib32 ApexNativeDependencies |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 988 | |
| 989 | // Native dependencies whose compile_multilib is "64" |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 990 | Lib64 ApexNativeDependencies |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 991 | } |
| 992 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 993 | type apexBundleProperties struct { |
| 994 | // Json manifest file describing meta info of this APEX bundle. Default: |
Dario Freni | 4abb1dc | 2018-11-20 18:04:58 +0000 | [diff] [blame] | 995 | // "apex_manifest.json" |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 996 | Manifest *string `android:"path"` |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 997 | |
Jiyong Park | 40e26a2 | 2019-02-08 02:53:06 +0900 | [diff] [blame] | 998 | // AndroidManifest.xml file used for the zip container of this APEX bundle. |
| 999 | // If unspecified, a default one is automatically generated. |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 1000 | AndroidManifest *string `android:"path"` |
Jiyong Park | 40e26a2 | 2019-02-08 02:53:06 +0900 | [diff] [blame] | 1001 | |
Roland Levillain | 411c584 | 2019-09-19 16:37:20 +0100 | [diff] [blame] | 1002 | // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on |
| 1003 | // device (/apex/<apex_name>). |
| 1004 | // If unspecified, defaults to the value of name. |
Jiyong Park | 05e70dd | 2019-03-18 14:26:32 +0900 | [diff] [blame] | 1005 | Apex_name *string |
| 1006 | |
Jiyong Park | d0a65ba | 2018-11-10 06:37:15 +0900 | [diff] [blame] | 1007 | // Determines the file contexts file for setting security context to each file in this APEX bundle. |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 1008 | // For platform APEXes, this should points to a file under /system/sepolicy |
| 1009 | // Default: /system/sepolicy/apex/<module_name>_file_contexts. |
| 1010 | File_contexts *string `android:"path"` |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1011 | |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1012 | ApexNativeDependencies |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1013 | |
| 1014 | // List of java libraries that are embedded inside this APEX bundle |
| 1015 | Java_libs []string |
| 1016 | |
| 1017 | // List of prebuilt files that are embedded inside this APEX bundle |
| 1018 | Prebuilts []string |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1019 | |
| 1020 | // Name of the apex_key module that provides the private key to sign APEX |
| 1021 | Key *string |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1022 | |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1023 | // The type of APEX to build. Controls what the APEX payload is. Either |
| 1024 | // 'image', 'zip' or 'both'. Default: 'image'. |
| 1025 | Payload_type *string |
| 1026 | |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1027 | // The name of a certificate in the default certificate directory, blank to use the default product certificate, |
| 1028 | // or an android_app_certificate module name in the form ":module". |
| 1029 | Certificate *string |
| 1030 | |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1031 | // Whether this APEX is installable to one of the partitions. Default: true. |
| 1032 | Installable *bool |
| 1033 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1034 | // For native libraries and binaries, use the vendor variant instead of the core (platform) variant. |
| 1035 | // Default is false. |
| 1036 | Use_vendor *bool |
| 1037 | |
Alex Light | fc0bd7c | 2019-01-29 18:31:59 -0800 | [diff] [blame] | 1038 | // For telling the apex to ignore special handling for system libraries such as bionic. Default is false. |
| 1039 | Ignore_system_library_special_case *bool |
| 1040 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1041 | Multilib apexMultilibProperties |
Jiyong Park | 235e67c | 2019-02-09 11:50:56 +0900 | [diff] [blame] | 1042 | |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1043 | // List of sanitizer names that this APEX is enabled for |
| 1044 | SanitizerNames []string `blueprint:"mutated"` |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1045 | |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1046 | PreventInstall bool `blueprint:"mutated"` |
| 1047 | |
| 1048 | HideFromMake bool `blueprint:"mutated"` |
| 1049 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1050 | // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false. |
| 1051 | Provide_cpp_shared_libs *bool |
| 1052 | |
| 1053 | // List of providing APEXes' names so that this APEX can depend on provided shared libraries. |
| 1054 | Uses []string |
Nikita Ioffe | 5d5ae76 | 2019-08-31 14:38:05 +0100 | [diff] [blame] | 1055 | |
| 1056 | // A txt file containing list of files that are whitelisted to be included in this APEX. |
| 1057 | Whitelisted_files *string |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 1058 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1059 | // package format of this apex variant; could be non-flattened, flattened, or zip. |
| 1060 | // imageApex, zipApex or flattened |
| 1061 | ApexType apexPackaging `blueprint:"mutated"` |
Sundong Ahn | e8fb724 | 2019-09-17 13:50:45 +0900 | [diff] [blame] | 1062 | |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1063 | // List of SDKs that are used to build this APEX. A reference to an SDK should be either |
| 1064 | // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current` |
| 1065 | // is implied. This value affects all modules included in this APEX. In other words, they are |
| 1066 | // also built with the SDKs specified here. |
| 1067 | Uses_sdks []string |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1068 | |
Nikita Ioffe | c72b5dd | 2019-12-07 17:30:22 +0000 | [diff] [blame] | 1069 | // Whenever apex_payload.img of the APEX should include dm-verity hashtree. |
| 1070 | // Should be only used in tests#. |
| 1071 | Test_only_no_hashtree *bool |
Jooyung Han | 214bf37 | 2019-11-12 13:03:50 +0900 | [diff] [blame] | 1072 | |
Dario Freni | ca91339 | 2020-04-27 18:21:11 +0100 | [diff] [blame] | 1073 | // Whenever apex_payload.img of the APEX should not be dm-verity signed. |
| 1074 | // Should be only used in tests#. |
| 1075 | Test_only_unsigned_payload *bool |
| 1076 | |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1077 | IsCoverageVariant bool `blueprint:"mutated"` |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 1078 | |
| 1079 | // Whether this APEX is considered updatable or not. When set to true, this will enforce additional |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1080 | // rules for making sure that the APEX is truly updatable. |
| 1081 | // - To be updatable, min_sdk_version should be set as well |
| 1082 | // This will also disable the size optimizations like symlinking to the system libs. |
| 1083 | // Default is false. |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 1084 | Updatable *bool |
Colin Cross | 5031787 | 2020-02-19 20:41:10 -0800 | [diff] [blame] | 1085 | |
| 1086 | // The minimum SDK version that this apex must be compatibile with. |
| 1087 | Min_sdk_version *string |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | type apexTargetBundleProperties struct { |
| 1091 | Target struct { |
| 1092 | // Multilib properties only for android. |
| 1093 | Android struct { |
| 1094 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1095 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1096 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1097 | // Multilib properties only for host. |
| 1098 | Host struct { |
| 1099 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1100 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1101 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1102 | // Multilib properties only for host linux_bionic. |
| 1103 | Linux_bionic struct { |
| 1104 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1105 | } |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1106 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1107 | // Multilib properties only for host linux_glibc. |
| 1108 | Linux_glibc struct { |
| 1109 | Multilib apexMultilibProperties |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1110 | } |
| 1111 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1112 | } |
| 1113 | |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1114 | type overridableProperties struct { |
| 1115 | // List of APKs to package inside APEX |
| 1116 | Apps []string |
Jaewoong Jung | 7abcf8e | 2019-12-19 17:32:06 -0800 | [diff] [blame] | 1117 | |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1118 | // List of runtime resource overlays (RROs) inside APEX |
| 1119 | Rros []string |
| 1120 | |
Jaewoong Jung | 7abcf8e | 2019-12-19 17:32:06 -0800 | [diff] [blame] | 1121 | // Names of modules to be overridden. Listed modules can only be other binaries |
| 1122 | // (in Make or Soong). |
| 1123 | // This does not completely prevent installation of the overridden binaries, but if both |
| 1124 | // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed |
| 1125 | // from PRODUCT_PACKAGES. |
| 1126 | Overrides []string |
Baligh Uddin | 004d717 | 2020-02-19 21:29:28 -0800 | [diff] [blame] | 1127 | |
| 1128 | // Logging Parent value |
| 1129 | Logging_parent string |
Baligh Uddin | 5b57dba | 2020-03-15 13:01:05 -0700 | [diff] [blame] | 1130 | |
| 1131 | // Apex Container Package Name. |
| 1132 | // Override value for attribute package:name in AndroidManifest.xml |
| 1133 | Package_name string |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1134 | } |
| 1135 | |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1136 | type apexPackaging int |
| 1137 | |
| 1138 | const ( |
| 1139 | imageApex apexPackaging = iota |
| 1140 | zipApex |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1141 | flattenedApex |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1142 | ) |
| 1143 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1144 | // The suffix for the output "file", not the module |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1145 | func (a apexPackaging) suffix() string { |
| 1146 | switch a { |
| 1147 | case imageApex: |
| 1148 | return imageApexSuffix |
| 1149 | case zipApex: |
| 1150 | return zipApexSuffix |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1151 | default: |
Roland Levillain | 4644b22 | 2019-07-31 14:09:17 +0100 | [diff] [blame] | 1152 | panic(fmt.Errorf("unknown APEX type %d", a)) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | func (a apexPackaging) name() string { |
| 1157 | switch a { |
| 1158 | case imageApex: |
| 1159 | return imageApexType |
| 1160 | case zipApex: |
| 1161 | return zipApexType |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1162 | default: |
Roland Levillain | 4644b22 | 2019-07-31 14:09:17 +0100 | [diff] [blame] | 1163 | panic(fmt.Errorf("unknown APEX type %d", a)) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1164 | } |
| 1165 | } |
| 1166 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1167 | type apexFileClass int |
| 1168 | |
| 1169 | const ( |
| 1170 | etc apexFileClass = iota |
| 1171 | nativeSharedLib |
| 1172 | nativeExecutable |
| 1173 | shBinary |
| 1174 | pyBinary |
| 1175 | goBinary |
| 1176 | javaSharedLib |
| 1177 | nativeTest |
| 1178 | app |
| 1179 | ) |
| 1180 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1181 | func (class apexFileClass) NameInMake() string { |
| 1182 | switch class { |
| 1183 | case etc: |
| 1184 | return "ETC" |
| 1185 | case nativeSharedLib: |
| 1186 | return "SHARED_LIBRARIES" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1187 | case nativeExecutable, shBinary, pyBinary, goBinary: |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1188 | return "EXECUTABLES" |
| 1189 | case javaSharedLib: |
| 1190 | return "JAVA_LIBRARIES" |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1191 | case nativeTest: |
| 1192 | return "NATIVE_TESTS" |
Sundong Ahn | e1f05aa | 2019-08-27 13:55:42 +0900 | [diff] [blame] | 1193 | case app: |
Jiyong Park | f383f7c | 2019-10-11 20:46:25 +0900 | [diff] [blame] | 1194 | // b/142537672 Why isn't this APP? We want to have full control over |
| 1195 | // the paths and file names of the apk file under the flattend APEX. |
| 1196 | // If this is set to APP, then the paths and file names are modified |
| 1197 | // by the Make build system. For example, it is installed to |
| 1198 | // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of |
| 1199 | // /system/apex/<apexname>/app/<Appname> because the build system automatically |
| 1200 | // appends module name (which is <apexname>.<Appname> to the path. |
| 1201 | return "ETC" |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1202 | default: |
Roland Levillain | 4644b22 | 2019-07-31 14:09:17 +0100 | [diff] [blame] | 1203 | panic(fmt.Errorf("unknown class %d", class)) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1204 | } |
| 1205 | } |
| 1206 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1207 | // apexFile represents a file in an APEX bundle |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1208 | type apexFile struct { |
| 1209 | builtFile android.Path |
| 1210 | moduleName string |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1211 | installDir string |
| 1212 | class apexFileClass |
Jiyong Park | a889484 | 2018-12-19 17:36:39 +0900 | [diff] [blame] | 1213 | module android.Module |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1214 | // list of symlinks that will be created in installDir that point to this apexFile |
| 1215 | symlinks []string |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1216 | dataPaths android.Paths |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1217 | transitiveDep bool |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1218 | moduleDir string |
Jiyong Park | 7afd107 | 2019-12-30 16:56:33 +0900 | [diff] [blame] | 1219 | |
| 1220 | requiredModuleNames []string |
| 1221 | targetRequiredModuleNames []string |
| 1222 | hostRequiredModuleNames []string |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1223 | |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1224 | jacocoReportClassesFile android.Path // only for javalibs and apps |
| 1225 | certificate java.Certificate // only for apps |
Jiyong Park | cfaa164 | 2020-02-28 16:51:07 +0900 | [diff] [blame] | 1226 | overriddenPackageName string // only for apps |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1227 | |
| 1228 | isJniLib bool |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1229 | } |
| 1230 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1231 | func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile { |
| 1232 | ret := apexFile{ |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1233 | builtFile: builtFile, |
| 1234 | moduleName: moduleName, |
| 1235 | installDir: installDir, |
| 1236 | class: class, |
| 1237 | module: module, |
| 1238 | } |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1239 | if module != nil { |
| 1240 | ret.moduleDir = ctx.OtherModuleDir(module) |
Jiyong Park | 7afd107 | 2019-12-30 16:56:33 +0900 | [diff] [blame] | 1241 | ret.requiredModuleNames = module.RequiredModuleNames() |
| 1242 | ret.targetRequiredModuleNames = module.TargetRequiredModuleNames() |
| 1243 | ret.hostRequiredModuleNames = module.HostRequiredModuleNames() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1244 | } |
| 1245 | return ret |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1246 | } |
| 1247 | |
| 1248 | func (af *apexFile) Ok() bool { |
Jiyong Park | 479321d | 2019-12-16 11:47:12 +0900 | [diff] [blame] | 1249 | return af.builtFile != nil && af.builtFile.String() != "" |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1250 | } |
| 1251 | |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1252 | func (af *apexFile) apexRelativePath(path string) string { |
| 1253 | return filepath.Join(af.installDir, path) |
| 1254 | } |
| 1255 | |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1256 | // Path() returns path of this apex file relative to the APEX root |
| 1257 | func (af *apexFile) Path() string { |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1258 | return af.apexRelativePath(af.builtFile.Base()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | // SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root |
| 1262 | func (af *apexFile) SymlinkPaths() []string { |
| 1263 | var ret []string |
| 1264 | for _, symlink := range af.symlinks { |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1265 | ret = append(ret, af.apexRelativePath(symlink)) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1266 | } |
| 1267 | return ret |
| 1268 | } |
| 1269 | |
| 1270 | func (af *apexFile) AvailableToPlatform() bool { |
| 1271 | if af.module == nil { |
| 1272 | return false |
| 1273 | } |
| 1274 | if am, ok := af.module.(android.ApexModule); ok { |
| 1275 | return am.AvailableFor(android.AvailableToPlatform) |
| 1276 | } |
| 1277 | return false |
| 1278 | } |
| 1279 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1280 | type apexBundle struct { |
| 1281 | android.ModuleBase |
| 1282 | android.DefaultableModuleBase |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1283 | android.OverridableModuleBase |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1284 | android.SdkBase |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1285 | |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1286 | properties apexBundleProperties |
| 1287 | targetProperties apexTargetBundleProperties |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1288 | overridableProperties overridableProperties |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1289 | |
Jooyung Han | f21c797 | 2019-12-16 22:32:06 +0900 | [diff] [blame] | 1290 | // specific to apex_vndk modules |
| 1291 | vndkProperties apexVndkProperties |
| 1292 | |
Colin Cross | a492590 | 2018-11-16 11:36:28 -0800 | [diff] [blame] | 1293 | bundleModuleFile android.WritablePath |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1294 | outputFile android.WritablePath |
Colin Cross | 70dda7e | 2019-10-01 22:05:35 -0700 | [diff] [blame] | 1295 | installDir android.InstallPath |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1296 | |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 1297 | prebuiltFileToDelete string |
| 1298 | |
Jiyong Park | 42cca6c | 2019-04-01 11:15:50 +0900 | [diff] [blame] | 1299 | public_key_file android.Path |
| 1300 | private_key_file android.Path |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1301 | |
| 1302 | container_certificate_file android.Path |
| 1303 | container_private_key_file android.Path |
| 1304 | |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 1305 | fileContexts android.Path |
| 1306 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1307 | // list of files to be included in this apex |
| 1308 | filesInfo []apexFile |
| 1309 | |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1310 | // list of module names that should be installed along with this APEX |
| 1311 | requiredDeps []string |
| 1312 | |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1313 | // list of module names that this APEX is including (to be shown via *-deps-info target) |
Artur Satayev | 872a144 | 2020-04-27 17:08:37 +0100 | [diff] [blame] | 1314 | android.ApexBundleDepsInfo |
Jiyong Park | ac2bacd | 2019-02-20 21:49:26 +0900 | [diff] [blame] | 1315 | |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1316 | testApex bool |
| 1317 | vndkApex bool |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1318 | artApex bool |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1319 | primaryApexType bool |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1320 | |
Jooyung Han | 214bf37 | 2019-11-12 13:03:50 +0900 | [diff] [blame] | 1321 | manifestJsonOut android.WritablePath |
| 1322 | manifestPbOut android.WritablePath |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 1323 | |
Jooyung Han | 002ab68 | 2020-01-08 01:57:58 +0900 | [diff] [blame] | 1324 | // list of commands to create symlinks for backward compatibility. |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 1325 | // these commands will be attached as LOCAL_POST_INSTALL_CMD to |
Jooyung Han | 002ab68 | 2020-01-08 01:57:58 +0900 | [diff] [blame] | 1326 | // apex package itself(for unflattened build) or apex_manifest(for flattened build) |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 1327 | // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting. |
| 1328 | compatSymlinks []string |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1329 | |
| 1330 | // Suffix of module name in Android.mk |
| 1331 | // ".flattened", ".apex", ".zipapex", or "" |
| 1332 | suffix string |
Jiyong Park | 3a1602e | 2020-01-14 14:39:19 +0900 | [diff] [blame] | 1333 | |
| 1334 | installedFilesFile android.WritablePath |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1335 | |
| 1336 | // Whether to create symlink to the system file instead of having a file |
| 1337 | // inside the apex or not |
| 1338 | linkToSystemLib bool |
Jiyong Park | 19972c7 | 2020-01-28 20:05:29 +0900 | [diff] [blame] | 1339 | |
| 1340 | // Struct holding the merged notice file paths in different formats |
| 1341 | mergedNotices android.NoticeOutputs |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1342 | } |
| 1343 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1344 | func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1345 | nativeModules ApexNativeDependencies, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1346 | target android.Target, imageVariation string) { |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1347 | // Use *FarVariation* to be able to depend on modules having |
| 1348 | // conflicting variations with this module. This is required since |
| 1349 | // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64' |
| 1350 | // for native shared libs. |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1351 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1352 | {Mutator: "image", Variation: imageVariation}, |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1353 | {Mutator: "link", Variation: "shared"}, |
Jiyong Park | 28d395a | 2018-12-07 22:42:47 +0900 | [diff] [blame] | 1354 | {Mutator: "version", Variation: ""}, // "" is the non-stub variant |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1355 | }...), sharedLibTag, nativeModules.Native_shared_libs...) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1356 | |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1357 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
| 1358 | {Mutator: "image", Variation: imageVariation}, |
| 1359 | {Mutator: "link", Variation: "shared"}, |
| 1360 | {Mutator: "version", Variation: ""}, // "" is the non-stub variant |
| 1361 | }...), jniLibTag, nativeModules.Jni_libs...) |
| 1362 | |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1363 | ctx.AddFarVariationDependencies(append(target.Variations(), |
| 1364 | blueprint.Variation{Mutator: "image", Variation: imageVariation}), |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1365 | executableTag, nativeModules.Binaries...) |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1366 | |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1367 | ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1368 | {Mutator: "image", Variation: imageVariation}, |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1369 | {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1370 | }...), testTag, nativeModules.Tests...) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1371 | } |
| 1372 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1373 | func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { |
| 1374 | if ctx.Os().Class == android.Device { |
| 1375 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil) |
| 1376 | } else { |
| 1377 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil) |
| 1378 | if ctx.Os().Bionic() { |
| 1379 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil) |
| 1380 | } else { |
| 1381 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil) |
| 1382 | } |
| 1383 | } |
| 1384 | } |
| 1385 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1386 | func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 1387 | if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) { |
| 1388 | ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true") |
| 1389 | } |
| 1390 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1391 | targets := ctx.MultiTargets() |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1392 | config := ctx.DeviceConfig() |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1393 | |
| 1394 | a.combineProperties(ctx) |
| 1395 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1396 | has32BitTarget := false |
| 1397 | for _, target := range targets { |
| 1398 | if target.Arch.ArchType.Multilib == "lib32" { |
| 1399 | has32BitTarget = true |
| 1400 | } |
| 1401 | } |
| 1402 | for i, target := range targets { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1403 | // When multilib.* is omitted for native_shared_libs/jni_libs/tests, it implies |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1404 | // multilib.both |
| 1405 | addDependenciesForNativeModules(ctx, |
| 1406 | ApexNativeDependencies{ |
| 1407 | Native_shared_libs: a.properties.Native_shared_libs, |
| 1408 | Tests: a.properties.Tests, |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1409 | Jni_libs: a.properties.Jni_libs, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1410 | Binaries: nil, |
| 1411 | }, |
| 1412 | target, a.getImageVariation(config)) |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1413 | |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1414 | // Add native modules targetting both ABIs |
| 1415 | addDependenciesForNativeModules(ctx, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1416 | a.properties.Multilib.Both, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1417 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1418 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1419 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 1420 | isPrimaryAbi := i == 0 |
| 1421 | if isPrimaryAbi { |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1422 | // When multilib.* is omitted for binaries, it implies |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1423 | // multilib.first |
| 1424 | addDependenciesForNativeModules(ctx, |
| 1425 | ApexNativeDependencies{ |
| 1426 | Native_shared_libs: nil, |
| 1427 | Tests: nil, |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1428 | Jni_libs: nil, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1429 | Binaries: a.properties.Binaries, |
| 1430 | }, |
| 1431 | target, a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1432 | |
| 1433 | // Add native modules targetting the first ABI |
| 1434 | addDependenciesForNativeModules(ctx, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1435 | a.properties.Multilib.First, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1436 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1437 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1438 | } |
| 1439 | |
| 1440 | switch target.Arch.ArchType.Multilib { |
| 1441 | case "lib32": |
| 1442 | // Add native modules targetting 32-bit ABI |
| 1443 | addDependenciesForNativeModules(ctx, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1444 | a.properties.Multilib.Lib32, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1445 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1446 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1447 | |
| 1448 | addDependenciesForNativeModules(ctx, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1449 | a.properties.Multilib.Prefer32, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1450 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1451 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1452 | case "lib64": |
| 1453 | // Add native modules targetting 64-bit ABI |
| 1454 | addDependenciesForNativeModules(ctx, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1455 | a.properties.Multilib.Lib64, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1456 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1457 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1458 | |
| 1459 | if !has32BitTarget { |
| 1460 | addDependenciesForNativeModules(ctx, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1461 | a.properties.Multilib.Prefer32, |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1462 | target, |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1463 | a.getImageVariation(config)) |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1464 | } |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 1465 | |
| 1466 | if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device { |
| 1467 | for _, sanitizer := range ctx.Config().SanitizeDevice() { |
| 1468 | if sanitizer == "hwaddress" { |
| 1469 | addDependenciesForNativeModules(ctx, |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1470 | ApexNativeDependencies{[]string{"libclang_rt.hwasan-aarch64-android"}, nil, nil, nil}, |
Jooyung Han | 01a868d | 2020-02-27 13:40:44 +0900 | [diff] [blame] | 1471 | target, a.getImageVariation(config)) |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 1472 | break |
| 1473 | } |
| 1474 | } |
| 1475 | } |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 1476 | } |
| 1477 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1478 | } |
| 1479 | |
Jiyong Park | ce6aadc | 2019-11-20 13:58:28 +0900 | [diff] [blame] | 1480 | // For prebuilt_etc, use the first variant (64 on 64/32bit device, |
| 1481 | // 32 on 32bit device) regardless of the TARGET_PREFER_* setting. |
| 1482 | // b/144532908 |
| 1483 | archForPrebuiltEtc := config.Arches()[0] |
| 1484 | for _, arch := range config.Arches() { |
| 1485 | // Prefer 64-bit arch if there is any |
| 1486 | if arch.ArchType.Multilib == "lib64" { |
| 1487 | archForPrebuiltEtc = arch |
| 1488 | break |
| 1489 | } |
| 1490 | } |
| 1491 | ctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 1492 | {Mutator: "os", Variation: ctx.Os().String()}, |
| 1493 | {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, |
| 1494 | }, prebuiltTag, a.properties.Prebuilts...) |
| 1495 | |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1496 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 1497 | javaLibTag, a.properties.Java_libs...) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1498 | |
Ulya Trafimovich | 4456188 | 2020-01-03 13:25:54 +0000 | [diff] [blame] | 1499 | // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library. |
| 1500 | if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { |
| 1501 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 1502 | javaLibTag, "jacocoagent") |
| 1503 | } |
| 1504 | |
Jiyong Park | 23c52b0 | 2019-02-02 13:13:47 +0900 | [diff] [blame] | 1505 | if String(a.properties.Key) == "" { |
| 1506 | ctx.ModuleErrorf("key is missing") |
| 1507 | return |
| 1508 | } |
| 1509 | ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key)) |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1510 | |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1511 | cert := android.SrcIsModule(a.getCertString(ctx)) |
Jiyong Park | 23c52b0 | 2019-02-02 13:13:47 +0900 | [diff] [blame] | 1512 | if cert != "" { |
| 1513 | ctx.AddDependency(ctx.Module(), certificateTag, cert) |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1514 | } |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 1515 | |
| 1516 | // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks |
| 1517 | if len(a.properties.Uses_sdks) > 0 { |
| 1518 | sdkRefs := []android.SdkRef{} |
| 1519 | for _, str := range a.properties.Uses_sdks { |
| 1520 | parsed := android.ParseSdkRef(ctx, str, "uses_sdks") |
| 1521 | sdkRefs = append(sdkRefs, parsed) |
| 1522 | } |
| 1523 | a.BuildWithSdks(sdkRefs) |
| 1524 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1525 | } |
| 1526 | |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1527 | func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) { |
| 1528 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 1529 | androidAppTag, a.overridableProperties.Apps...) |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1530 | ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), |
| 1531 | rroTag, a.overridableProperties.Rros...) |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1532 | } |
| 1533 | |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 1534 | func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
| 1535 | // direct deps of an APEX bundle are all part of the APEX bundle |
| 1536 | return true |
| 1537 | } |
| 1538 | |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 1539 | func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string { |
Jooyung Han | 27151d9 | 2019-12-16 17:45:32 +0900 | [diff] [blame] | 1540 | moduleName := ctx.ModuleName() |
| 1541 | // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list, |
| 1542 | // we check with the pseudo module name to see if its certificate is overridden. |
| 1543 | if a.vndkApex { |
| 1544 | moduleName = vndkApexName |
| 1545 | } |
| 1546 | certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName) |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1547 | if overridden { |
Jaewoong Jung | acb6db3 | 2019-02-28 16:22:30 +0000 | [diff] [blame] | 1548 | return ":" + certificate |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1549 | } |
| 1550 | return String(a.properties.Certificate) |
| 1551 | } |
| 1552 | |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 1553 | func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) { |
| 1554 | switch tag { |
| 1555 | case "": |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1556 | return android.Paths{a.outputFile}, nil |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 1557 | default: |
| 1558 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
Jiyong Park | 5a83202 | 2018-12-20 09:54:35 +0900 | [diff] [blame] | 1559 | } |
Jiyong Park | 74e240b | 2018-11-27 21:27:08 +0900 | [diff] [blame] | 1560 | } |
| 1561 | |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1562 | func (a *apexBundle) installable() bool { |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1563 | return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable)) |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1564 | } |
| 1565 | |
Nikita Ioffe | c72b5dd | 2019-12-07 17:30:22 +0000 | [diff] [blame] | 1566 | func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool { |
| 1567 | return proptools.Bool(a.properties.Test_only_no_hashtree) |
| 1568 | } |
| 1569 | |
Dario Freni | ca91339 | 2020-04-27 18:21:11 +0100 | [diff] [blame] | 1570 | func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool { |
| 1571 | return proptools.Bool(a.properties.Test_only_unsigned_payload) |
| 1572 | } |
| 1573 | |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1574 | func (a *apexBundle) getImageVariation(config android.DeviceConfig) string { |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 1575 | if a.vndkApex { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 1576 | return cc.VendorVariationPrefix + a.vndkVersion(config) |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 1577 | } |
Jiyong Park | 7c1dc61 | 2019-01-05 11:15:24 +0900 | [diff] [blame] | 1578 | if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 1579 | return cc.VendorVariationPrefix + config.PlatformVndkVersion() |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1580 | } else { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 1581 | return android.CoreVariation |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1582 | } |
| 1583 | } |
| 1584 | |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1585 | func (a *apexBundle) EnableSanitizer(sanitizerName string) { |
| 1586 | if !android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1587 | a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName) |
| 1588 | } |
| 1589 | } |
| 1590 | |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1591 | func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool { |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1592 | if android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1593 | return true |
Jiyong Park | 235e67c | 2019-02-09 11:50:56 +0900 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | // Then follow the global setting |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1597 | globalSanitizerNames := []string{} |
| 1598 | if a.Host() { |
| 1599 | globalSanitizerNames = ctx.Config().SanitizeHost() |
| 1600 | } else { |
| 1601 | arches := ctx.Config().SanitizeDeviceArch() |
| 1602 | if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) { |
| 1603 | globalSanitizerNames = ctx.Config().SanitizeDevice() |
| 1604 | } |
| 1605 | } |
| 1606 | return android.InList(sanitizerName, globalSanitizerNames) |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 1607 | } |
| 1608 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 1609 | var _ cc.Coverage = (*apexBundle)(nil) |
| 1610 | |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1611 | func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { |
Oliver Nguyen | 1382ab6 | 2019-12-06 15:22:41 -0800 | [diff] [blame] | 1612 | return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled()) |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1613 | } |
| 1614 | |
| 1615 | func (a *apexBundle) PreventInstall() { |
| 1616 | a.properties.PreventInstall = true |
| 1617 | } |
| 1618 | |
| 1619 | func (a *apexBundle) HideFromMake() { |
| 1620 | a.properties.HideFromMake = true |
| 1621 | } |
| 1622 | |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1623 | func (a *apexBundle) MarkAsCoverageVariant(coverage bool) { |
| 1624 | a.properties.IsCoverageVariant = coverage |
| 1625 | } |
| 1626 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 1627 | func (a *apexBundle) EnableCoverageIfNeeded() {} |
| 1628 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1629 | // TODO(jiyong) move apexFileFor* close to the apexFile type definition |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1630 | func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1631 | // Decide the APEX-local directory by the multilib of the library |
| 1632 | // In the future, we may query this to the module. |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1633 | var dirInApex string |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1634 | switch ccMod.Arch().ArchType.Multilib { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1635 | case "lib32": |
| 1636 | dirInApex = "lib" |
| 1637 | case "lib64": |
| 1638 | dirInApex = "lib64" |
| 1639 | } |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1640 | if ccMod.Target().NativeBridge == android.NativeBridgeEnabled { |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1641 | dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1642 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1643 | dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath()) |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1644 | if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) { |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1645 | // Special case for Bionic libs and other libs installed with them. This is |
| 1646 | // to prevent those libs from being included in the search path |
| 1647 | // /apex/com.android.runtime/${LIB}. This exclusion is required because |
| 1648 | // those libs in the Runtime APEX are available via the legacy paths in |
| 1649 | // /system/lib/. By the init process, the libs in the APEX are bind-mounted |
| 1650 | // to the legacy paths and thus will be loaded into the default linker |
| 1651 | // namespace (aka "platform" namespace). If the libs are directly in |
| 1652 | // /apex/com.android.runtime/${LIB} then the same libs will be loaded again |
| 1653 | // into the runtime linker namespace, which will result in double loading of |
| 1654 | // them, which isn't supported. |
| 1655 | dirInApex = filepath.Join(dirInApex, "bionic") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1656 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1657 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1658 | fileToCopy := ccMod.OutputFile().Path() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1659 | return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1660 | } |
| 1661 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1662 | func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile { |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1663 | dirInApex := "bin" |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1664 | if cc.Target().NativeBridge == android.NativeBridgeEnabled { |
dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 1665 | dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath) |
Jiyong Park | acbf6c7 | 2019-07-09 16:19:16 +0900 | [diff] [blame] | 1666 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1667 | dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1668 | fileToCopy := cc.OutputFile().Path() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1669 | af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1670 | af.symlinks = cc.Symlinks() |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1671 | af.dataPaths = cc.DataPaths() |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1672 | return af |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1673 | } |
| 1674 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1675 | func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1676 | dirInApex := "bin" |
| 1677 | fileToCopy := py.HostToolPath().Path() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1678 | return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1679 | } |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1680 | func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1681 | dirInApex := "bin" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1682 | s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath()) |
| 1683 | if err != nil { |
| 1684 | ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1685 | return apexFile{} |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1686 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1687 | fileToCopy := android.PathForOutput(ctx, s) |
| 1688 | // NB: Since go binaries are static we don't need the module for anything here, which is |
| 1689 | // good since the go tool is a blueprint.Module not an android.Module like we would |
| 1690 | // normally use. |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1691 | return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1692 | } |
| 1693 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1694 | func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1695 | dirInApex := filepath.Join("bin", sh.SubDir()) |
| 1696 | fileToCopy := sh.OutputFile() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1697 | af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1698 | af.symlinks = sh.Symlinks() |
| 1699 | return af |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1700 | } |
| 1701 | |
Paul Duffin | 581bbbe | 2020-05-14 20:49:32 +0100 | [diff] [blame] | 1702 | func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib java.Dependency, module android.Module) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1703 | dirInApex := "javalib" |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 1704 | fileToCopy := lib.DexJar() |
Paul Duffin | 581bbbe | 2020-05-14 20:49:32 +0100 | [diff] [blame] | 1705 | af := newApexFile(ctx, fileToCopy, module.Name(), dirInApex, javaSharedLib, module) |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1706 | af.jacocoReportClassesFile = lib.JacocoReportClassesFile() |
| 1707 | return af |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1708 | } |
| 1709 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1710 | func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1711 | dirInApex := filepath.Join("etc", prebuilt.SubDir()) |
| 1712 | fileToCopy := prebuilt.OutputFile() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1713 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1714 | } |
| 1715 | |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1716 | func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile { |
| 1717 | dirInApex := filepath.Join("etc", config.SubDir()) |
| 1718 | fileToCopy := config.CompatConfig() |
| 1719 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config) |
| 1720 | } |
| 1721 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1722 | func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1723 | android.Module |
| 1724 | Privileged() bool |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1725 | InstallApkName() string |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1726 | OutputFile() android.Path |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1727 | JacocoReportClassesFile() android.Path |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1728 | Certificate() java.Certificate |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1729 | }) apexFile { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1730 | appDir := "app" |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1731 | if aapp.Privileged() { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1732 | appDir = "priv-app" |
| 1733 | } |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1734 | dirInApex := filepath.Join(appDir, aapp.InstallApkName()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1735 | fileToCopy := aapp.OutputFile() |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1736 | af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp) |
| 1737 | af.jacocoReportClassesFile = aapp.JacocoReportClassesFile() |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1738 | af.certificate = aapp.Certificate() |
Jiyong Park | cfaa164 | 2020-02-28 16:51:07 +0900 | [diff] [blame] | 1739 | |
| 1740 | if app, ok := aapp.(interface { |
| 1741 | OverriddenManifestPackageName() string |
| 1742 | }); ok { |
| 1743 | af.overriddenPackageName = app.OverriddenManifestPackageName() |
| 1744 | } |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1745 | return af |
Dario Freni | cde2a03 | 2019-10-27 00:29:22 +0100 | [diff] [blame] | 1746 | } |
| 1747 | |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1748 | func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile { |
| 1749 | rroDir := "overlay" |
| 1750 | dirInApex := filepath.Join(rroDir, rro.Theme()) |
| 1751 | fileToCopy := rro.OutputFile() |
| 1752 | af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro) |
| 1753 | af.certificate = rro.Certificate() |
| 1754 | |
| 1755 | if a, ok := rro.(interface { |
| 1756 | OverriddenManifestPackageName() string |
| 1757 | }); ok { |
| 1758 | af.overriddenPackageName = a.OverriddenManifestPackageName() |
| 1759 | } |
| 1760 | return af |
| 1761 | } |
| 1762 | |
Roland Levillain | 935639d | 2019-08-13 14:55:28 +0100 | [diff] [blame] | 1763 | // Context "decorator", overriding the InstallBypassMake method to always reply `true`. |
| 1764 | type flattenedApexContext struct { |
| 1765 | android.ModuleContext |
| 1766 | } |
| 1767 | |
| 1768 | func (c *flattenedApexContext) InstallBypassMake() bool { |
| 1769 | return true |
| 1770 | } |
| 1771 | |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1772 | // Function called while walking an APEX's payload dependencies. |
| 1773 | // |
| 1774 | // Return true if the `to` module should be visited, false otherwise. |
| 1775 | type payloadDepsCallback func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool |
| 1776 | |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1777 | // Visit dependencies that contributes to the payload of this APEX |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1778 | func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, do payloadDepsCallback) { |
Paul Duffin | df915ff | 2020-03-30 17:58:21 +0100 | [diff] [blame] | 1779 | ctx.WalkDeps(func(child, parent android.Module) bool { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1780 | am, ok := child.(android.ApexModule) |
| 1781 | if !ok || !am.CanHaveApexVariants() { |
| 1782 | return false |
| 1783 | } |
| 1784 | |
| 1785 | // Check for the direct dependencies that contribute to the payload |
| 1786 | if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok { |
| 1787 | if dt.payload { |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1788 | return do(ctx, parent, am, false /* externalDep */) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1789 | } |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1790 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1791 | return false |
| 1792 | } |
| 1793 | |
| 1794 | // Check for the indirect dependencies if it is considered as part of the APEX |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 1795 | if am.ApexName() != "" { |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1796 | return do(ctx, parent, am, false /* externalDep */) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1797 | } |
| 1798 | |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1799 | return do(ctx, parent, am, true /* externalDep */) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1800 | }) |
| 1801 | } |
| 1802 | |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1803 | func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int { |
| 1804 | ver := proptools.StringDefault(a.properties.Min_sdk_version, "current") |
Jooyung Han | aed150d | 2020-04-02 01:41:41 +0900 | [diff] [blame] | 1805 | intVer, err := android.ApiStrToNum(ctx, ver) |
| 1806 | if err != nil { |
| 1807 | ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1808 | } |
Jooyung Han | aed150d | 2020-04-02 01:41:41 +0900 | [diff] [blame] | 1809 | return intVer |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1810 | } |
| 1811 | |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1812 | // Ensures that the dependencies are marked as available for this APEX |
| 1813 | func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { |
| 1814 | // Let's be practical. Availability for test, host, and the VNDK apex isn't important |
| 1815 | if ctx.Host() || a.testApex || a.vndkApex { |
| 1816 | return |
| 1817 | } |
| 1818 | |
Jiyong Park | 58d1090 | 2020-03-28 14:43:19 +0900 | [diff] [blame] | 1819 | // Coverage build adds additional dependencies for the coverage-only runtime libraries. |
| 1820 | // Requiring them and their transitive depencies with apex_available is not right |
| 1821 | // because they just add noise. |
| 1822 | if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) { |
| 1823 | return |
| 1824 | } |
| 1825 | |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1826 | a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
| 1827 | if externalDep { |
| 1828 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 1829 | return false |
| 1830 | } |
| 1831 | |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1832 | apexName := ctx.ModuleName() |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 1833 | fromName := ctx.OtherModuleName(from) |
| 1834 | toName := ctx.OtherModuleName(to) |
Paul Duffin | 6534770 | 2020-03-31 15:23:40 +0100 | [diff] [blame] | 1835 | |
| 1836 | // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither |
| 1837 | // do any of its dependencies. |
| 1838 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 1839 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 1840 | return false |
| 1841 | } |
| 1842 | |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1843 | if to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) { |
| 1844 | return true |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1845 | } |
Jiyong Park | 1c7e962 | 2020-05-07 16:12:13 +0900 | [diff] [blame] | 1846 | ctx.ModuleErrorf("%q requires %q that is not available for the APEX. Dependency path:%s", fromName, toName, ctx.GetPathString(true)) |
Paul Duffin | be5a5be | 2020-03-30 15:54:08 +0100 | [diff] [blame] | 1847 | // Visit this module's dependencies to check and report any issues with their availability. |
| 1848 | return true |
Jiyong Park | 201cedd | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1849 | }) |
| 1850 | } |
| 1851 | |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1852 | func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { |
| 1853 | if proptools.Bool(a.properties.Updatable) { |
| 1854 | if String(a.properties.Min_sdk_version) == "" { |
| 1855 | ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well") |
| 1856 | } |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 1857 | |
| 1858 | a.checkJavaStableSdkVersion(ctx) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1859 | } |
| 1860 | } |
| 1861 | |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1862 | // Ensures that a lib providing stub isn't statically linked |
| 1863 | func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) { |
| 1864 | // Practically, we only care about regular APEXes on the device. |
| 1865 | if ctx.Host() || a.testApex || a.vndkApex { |
| 1866 | return |
| 1867 | } |
| 1868 | |
| 1869 | a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
| 1870 | if ccm, ok := to.(*cc.Module); ok { |
| 1871 | apexName := ctx.ModuleName() |
| 1872 | fromName := ctx.OtherModuleName(from) |
| 1873 | toName := ctx.OtherModuleName(to) |
| 1874 | |
| 1875 | // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither |
| 1876 | // do any of its dependencies. |
| 1877 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 1878 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 1879 | return false |
| 1880 | } |
| 1881 | |
| 1882 | // TODO(jiyong) remove this check when R is published to AOSP. Currently, libstatssocket |
| 1883 | // is capable of providing a stub variant, but is being statically linked from the bluetooth |
| 1884 | // APEX. |
| 1885 | if toName == "libstatssocket" { |
| 1886 | return false |
| 1887 | } |
| 1888 | |
| 1889 | // The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule. |
| 1890 | // It can't make the static dependencies dynamic because it can't |
| 1891 | // do the dynamic linking for itself. |
| 1892 | if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump") { |
| 1893 | return false |
| 1894 | } |
| 1895 | |
| 1896 | isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !android.DirectlyInApex(apexName, toName) |
| 1897 | if isStubLibraryFromOtherApex && !externalDep { |
| 1898 | ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+ |
| 1899 | "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false)) |
| 1900 | } |
| 1901 | |
| 1902 | } |
| 1903 | return true |
| 1904 | }) |
| 1905 | } |
| 1906 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1907 | func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1908 | buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() |
| 1909 | switch a.properties.ApexType { |
| 1910 | case imageApex: |
| 1911 | if buildFlattenedAsDefault { |
| 1912 | a.suffix = imageApexSuffix |
| 1913 | } else { |
| 1914 | a.suffix = "" |
| 1915 | a.primaryApexType = true |
Jooyung Han | 3ab2c3e | 2019-12-05 16:27:44 +0900 | [diff] [blame] | 1916 | |
| 1917 | if ctx.Config().InstallExtraFlattenedApexes() { |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1918 | a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix) |
Jooyung Han | 3ab2c3e | 2019-12-05 16:27:44 +0900 | [diff] [blame] | 1919 | } |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1920 | } |
| 1921 | case zipApex: |
| 1922 | if proptools.String(a.properties.Payload_type) == "zip" { |
| 1923 | a.suffix = "" |
| 1924 | a.primaryApexType = true |
| 1925 | } else { |
| 1926 | a.suffix = zipApexSuffix |
| 1927 | } |
| 1928 | case flattenedApex: |
| 1929 | if buildFlattenedAsDefault { |
| 1930 | a.suffix = "" |
| 1931 | a.primaryApexType = true |
| 1932 | } else { |
| 1933 | a.suffix = flattenedSuffix |
| 1934 | } |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1935 | } |
| 1936 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1937 | if len(a.properties.Tests) > 0 && !a.testApex { |
| 1938 | ctx.PropertyErrorf("tests", "property not allowed in apex module type") |
| 1939 | return |
| 1940 | } |
| 1941 | |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1942 | a.checkApexAvailability(ctx) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1943 | a.checkUpdatable(ctx) |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1944 | a.checkStaticLinkingToStubLibraries(ctx) |
Jiyong Park | 678c881 | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1945 | |
Alex Light | fc0bd7c | 2019-01-29 18:31:59 -0800 | [diff] [blame] | 1946 | handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case) |
| 1947 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1948 | // native lib dependencies |
| 1949 | var provideNativeLibs []string |
| 1950 | var requireNativeLibs []string |
| 1951 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1952 | // Check if "uses" requirements are met with dependent apexBundles |
| 1953 | var providedNativeSharedLibs []string |
| 1954 | useVendor := proptools.Bool(a.properties.Use_vendor) |
| 1955 | ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) { |
| 1956 | if ctx.OtherModuleDependencyTag(m) != usesTag { |
| 1957 | return |
| 1958 | } |
| 1959 | otherName := ctx.OtherModuleName(m) |
| 1960 | other, ok := m.(*apexBundle) |
| 1961 | if !ok { |
| 1962 | ctx.PropertyErrorf("uses", "%q is not a provider", otherName) |
| 1963 | return |
| 1964 | } |
| 1965 | if proptools.Bool(other.properties.Use_vendor) != useVendor { |
| 1966 | ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName) |
| 1967 | return |
| 1968 | } |
| 1969 | if !proptools.Bool(other.properties.Provide_cpp_shared_libs) { |
| 1970 | ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName) |
| 1971 | return |
| 1972 | } |
| 1973 | providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...) |
| 1974 | }) |
| 1975 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1976 | var filesInfo []apexFile |
Jiyong Park | 678c881 | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1977 | // TODO(jiyong) do this using walkPayloadDeps |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1978 | ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1979 | depTag := ctx.OtherModuleDependencyTag(child) |
Paul Duffin | dddd546 | 2020-04-07 15:25:44 +0100 | [diff] [blame] | 1980 | if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { |
| 1981 | return false |
| 1982 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1983 | depName := ctx.OtherModuleName(child) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1984 | if _, isDirectDep := parent.(*apexBundle); isDirectDep { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1985 | switch depTag { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1986 | case sharedLibTag, jniLibTag: |
| 1987 | isJniLib := depTag == jniLibTag |
Jooyung Han | faa2d5f | 2020-02-06 17:42:40 +0900 | [diff] [blame] | 1988 | if c, ok := child.(*cc.Module); ok { |
| 1989 | // bootstrap bionic libs are treated as provided by system |
| 1990 | if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) { |
| 1991 | provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base()) |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1992 | } |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1993 | fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs) |
| 1994 | fi.isJniLib = isJniLib |
| 1995 | filesInfo = append(filesInfo, fi) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1996 | return true // track transitive dependencies |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1997 | } else { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1998 | propertyName := "native_shared_libs" |
| 1999 | if isJniLib { |
| 2000 | propertyName = "jni_libs" |
| 2001 | } |
| 2002 | ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2003 | } |
| 2004 | case executableTag: |
| 2005 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2006 | filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2007 | return true // track transitive dependencies |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 2008 | } else if sh, ok := child.(*android.ShBinary); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2009 | filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh)) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 2010 | } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2011 | filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py)) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 2012 | } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2013 | filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb)) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 2014 | } else { |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 2015 | ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2016 | } |
| 2017 | case javaLibTag: |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 2018 | if javaLib, ok := child.(*java.Library); ok { |
Paul Duffin | 581bbbe | 2020-05-14 20:49:32 +0100 | [diff] [blame] | 2019 | af := apexFileForJavaLibrary(ctx, javaLib, javaLib) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2020 | if !af.Ok() { |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2021 | ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName) |
| 2022 | } else { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2023 | filesInfo = append(filesInfo, af) |
| 2024 | return true // track transitive dependencies |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 2025 | } |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 2026 | } else if sdkLib, ok := child.(*java.SdkLibrary); ok { |
Paul Duffin | 581bbbe | 2020-05-14 20:49:32 +0100 | [diff] [blame] | 2027 | af := apexFileForJavaLibrary(ctx, sdkLib, sdkLib) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 2028 | if !af.Ok() { |
| 2029 | ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName) |
| 2030 | return false |
| 2031 | } |
| 2032 | filesInfo = append(filesInfo, af) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 2033 | return true // track transitive dependencies |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 2034 | } else { |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 2035 | ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child)) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2036 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2037 | case androidAppTag: |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2038 | if ap, ok := child.(*java.AndroidApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 2039 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2040 | return true // track transitive dependencies |
| 2041 | } else if ap, ok := child.(*java.AndroidAppImport); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 2042 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Dario Freni | 6f3937c | 2019-12-20 22:58:03 +0000 | [diff] [blame] | 2043 | } else if ap, ok := child.(*java.AndroidTestHelperApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 2044 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2045 | } else { |
| 2046 | ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) |
| 2047 | } |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 2048 | case rroTag: |
| 2049 | if rro, ok := child.(java.RuntimeResourceOverlayModule); ok { |
| 2050 | filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro)) |
| 2051 | } else { |
| 2052 | ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName) |
| 2053 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2054 | case prebuiltTag: |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 2055 | if prebuilt, ok := child.(android.PrebuiltEtcModule); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2056 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 2057 | } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok { |
| 2058 | filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName)) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 2059 | } else { |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 2060 | ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 2061 | } |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 2062 | case testTag: |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2063 | if ccTest, ok := child.(*cc.Module); ok { |
| 2064 | if ccTest.IsTestPerSrcAllTestsVariation() { |
| 2065 | // Multiple-output test module (where `test_per_src: true`). |
| 2066 | // |
| 2067 | // `ccTest` is the "" ("all tests") variation of a `test_per_src` module. |
| 2068 | // We do not add this variation to `filesInfo`, as it has no output; |
| 2069 | // however, we do add the other variations of this module as indirect |
| 2070 | // dependencies (see below). |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 2071 | } else { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2072 | // Single-output test module (where `test_per_src: false`). |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2073 | af := apexFileForExecutable(ctx, ccTest) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2074 | af.class = nativeTest |
| 2075 | filesInfo = append(filesInfo, af) |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 2076 | } |
Jiyong Park | af9539f | 2020-05-04 10:31:32 +0900 | [diff] [blame] | 2077 | return true // track transitive dependencies |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 2078 | } else { |
| 2079 | ctx.PropertyErrorf("tests", "%q is not a cc module", depName) |
| 2080 | } |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 2081 | case keyTag: |
| 2082 | if key, ok := child.(*apexKey); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 2083 | a.private_key_file = key.private_key_file |
| 2084 | a.public_key_file = key.public_key_file |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 2085 | } else { |
| 2086 | ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2087 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2088 | return false |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 2089 | case certificateTag: |
| 2090 | if dep, ok := child.(*java.AndroidAppCertificate); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 2091 | a.container_certificate_file = dep.Certificate.Pem |
| 2092 | a.container_private_key_file = dep.Certificate.Key |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 2093 | } else { |
| 2094 | ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName) |
| 2095 | } |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 2096 | case android.PrebuiltDepTag: |
| 2097 | // If the prebuilt is force disabled, remember to delete the prebuilt file |
| 2098 | // that might have been installed in the previous builds |
| 2099 | if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() { |
| 2100 | a.prebuiltFileToDelete = prebuilt.InstallFilename() |
| 2101 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2102 | } |
Jooyung Han | 8aee204 | 2019-10-29 05:08:31 +0900 | [diff] [blame] | 2103 | } else if !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2104 | // indirect dependencies |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 2105 | if am, ok := child.(android.ApexModule); ok { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2106 | // We cannot use a switch statement on `depTag` here as the checked |
| 2107 | // tags used below are private (e.g. `cc.sharedDepTag`). |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 2108 | if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2109 | if cc, ok := child.(*cc.Module); ok { |
| 2110 | if android.InList(cc.Name(), providedNativeSharedLibs) { |
| 2111 | // If we're using a shared library which is provided from other APEX, |
| 2112 | // don't include it in this APEX |
| 2113 | return false |
Jiyong Park | ac2bacd | 2019-02-20 21:49:26 +0900 | [diff] [blame] | 2114 | } |
Jooyung Han | 671f1ce | 2019-12-17 12:47:13 +0900 | [diff] [blame] | 2115 | if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2116 | // If the dependency is a stubs lib, don't include it in this APEX, |
| 2117 | // but make sure that the lib is installed on the device. |
| 2118 | // In case no APEX is having the lib, the lib is installed to the system |
| 2119 | // partition. |
| 2120 | // |
| 2121 | // Always include if we are a host-apex however since those won't have any |
| 2122 | // system libraries. |
Yo Chiang | 29555d5 | 2020-05-06 15:59:59 +0800 | [diff] [blame] | 2123 | if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.BaseModuleName(), a.requiredDeps) { |
| 2124 | a.requiredDeps = append(a.requiredDeps, cc.BaseModuleName()) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2125 | } |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 2126 | requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base()) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2127 | // Don't track further |
| 2128 | return false |
| 2129 | } |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2130 | af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2131 | af.transitiveDep = true |
| 2132 | filesInfo = append(filesInfo, af) |
| 2133 | return true // track transitive dependencies |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2134 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2135 | } else if cc.IsTestPerSrcDepTag(depTag) { |
| 2136 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2137 | af := apexFileForExecutable(ctx, cc) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2138 | // Handle modules created as `test_per_src` variations of a single test module: |
| 2139 | // use the name of the generated test binary (`fileToCopy`) instead of the name |
| 2140 | // of the original test module (`depName`, shared by all `test_per_src` |
| 2141 | // variations of that module). |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2142 | af.moduleName = filepath.Base(af.builtFile.String()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2143 | // these are not considered transitive dep |
| 2144 | af.transitiveDep = false |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2145 | filesInfo = append(filesInfo, af) |
| 2146 | return true // track transitive dependencies |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2147 | } |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 2148 | } else if java.IsJniDepTag(depTag) { |
Jooyung Han | b7bebe2 | 2020-02-25 16:59:29 +0900 | [diff] [blame] | 2149 | // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps |
| 2150 | return false |
Jiyong Park | e383388 | 2020-02-17 17:28:10 +0900 | [diff] [blame] | 2151 | } else if java.IsXmlPermissionsFileDepTag(depTag) { |
| 2152 | if prebuilt, ok := child.(android.PrebuiltEtcModule); ok { |
| 2153 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
| 2154 | } |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 2155 | } else if am.CanHaveApexVariants() && am.IsInstallableToApex() { |
Jiyong Park | 1c7e962 | 2020-05-07 16:12:13 +0900 | [diff] [blame] | 2156 | ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2157 | } |
| 2158 | } |
| 2159 | } |
| 2160 | return false |
| 2161 | }) |
| 2162 | |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 2163 | // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries. |
| 2164 | // Build rules are generated by the dexpreopt singleton, and here we access build artifacts |
| 2165 | // via the global boot image config. |
| 2166 | if a.artApex { |
Tim Joines | c1ef1bb | 2020-03-18 18:00:41 +0000 | [diff] [blame] | 2167 | for arch, files := range java.DexpreoptedArtApexJars(ctx) { |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 2168 | dirInApex := filepath.Join("javalib", arch.String()) |
| 2169 | for _, f := range files { |
| 2170 | localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String()) |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2171 | af := newApexFile(ctx, f, localModule, dirInApex, etc, nil) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2172 | filesInfo = append(filesInfo, af) |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 2173 | } |
| 2174 | } |
| 2175 | } |
| 2176 | |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 2177 | if a.private_key_file == nil { |
Jiyong Park | fa0a373 | 2018-11-09 05:52:26 +0900 | [diff] [blame] | 2178 | ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key)) |
| 2179 | return |
| 2180 | } |
| 2181 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2182 | // remove duplicates in filesInfo |
| 2183 | removeDup := func(filesInfo []apexFile) []apexFile { |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2184 | encountered := make(map[string]apexFile) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2185 | for _, f := range filesInfo { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 2186 | dest := filepath.Join(f.installDir, f.builtFile.Base()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2187 | if e, ok := encountered[dest]; !ok { |
| 2188 | encountered[dest] = f |
| 2189 | } else { |
| 2190 | // If a module is directly included and also transitively depended on |
| 2191 | // consider it as directly included. |
| 2192 | e.transitiveDep = e.transitiveDep && f.transitiveDep |
| 2193 | encountered[dest] = e |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2194 | } |
| 2195 | } |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2196 | var result []apexFile |
| 2197 | for _, v := range encountered { |
| 2198 | result = append(result, v) |
| 2199 | } |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2200 | return result |
| 2201 | } |
| 2202 | filesInfo = removeDup(filesInfo) |
| 2203 | |
| 2204 | // to have consistent build rules |
| 2205 | sort.Slice(filesInfo, func(i, j int) bool { |
| 2206 | return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String() |
| 2207 | }) |
| 2208 | |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2209 | a.installDir = android.PathForModuleInstall(ctx, "apex") |
| 2210 | a.filesInfo = filesInfo |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 2211 | |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 2212 | if a.properties.ApexType != zipApex { |
| 2213 | if a.properties.File_contexts == nil { |
| 2214 | a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts") |
| 2215 | } else { |
| 2216 | a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts) |
| 2217 | if a.Platform() { |
| 2218 | if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched { |
| 2219 | ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts) |
| 2220 | } |
| 2221 | } |
| 2222 | } |
| 2223 | if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() { |
| 2224 | ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts) |
| 2225 | return |
| 2226 | } |
| 2227 | } |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2228 | // Optimization. If we are building bundled APEX, for the files that are gathered due to the |
| 2229 | // transitive dependencies, don't place them inside the APEX, but place a symlink pointing |
| 2230 | // the same library in the system partition, thus effectively sharing the same libraries |
| 2231 | // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed |
| 2232 | // in the APEX. |
| 2233 | a.linkToSystemLib = !ctx.Config().UnbundledBuild() && |
| 2234 | a.installable() && |
| 2235 | !proptools.Bool(a.properties.Use_vendor) |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 2236 | |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 2237 | // We don't need the optimization for updatable APEXes, as it might give false signal |
| 2238 | // to the system health when the APEXes are still bundled (b/149805758) |
| 2239 | if proptools.Bool(a.properties.Updatable) && a.properties.ApexType == imageApex { |
| 2240 | a.linkToSystemLib = false |
| 2241 | } |
| 2242 | |
Jiyong Park | 638d30e | 2020-02-26 18:27:19 +0900 | [diff] [blame] | 2243 | // We also don't want the optimization for host APEXes, because it doesn't make sense. |
| 2244 | if ctx.Host() { |
| 2245 | a.linkToSystemLib = false |
| 2246 | } |
| 2247 | |
Jooyung Han | d15aa1f | 2019-09-27 00:38:03 +0900 | [diff] [blame] | 2248 | // prepare apex_manifest.json |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 2249 | a.buildManifest(ctx, provideNativeLibs, requireNativeLibs) |
| 2250 | |
| 2251 | a.setCertificateAndPrivateKey(ctx) |
| 2252 | if a.properties.ApexType == flattenedApex { |
| 2253 | a.buildFlattenedApex(ctx) |
| 2254 | } else { |
| 2255 | a.buildUnflattenedApex(ctx) |
| 2256 | } |
| 2257 | |
Jooyung Han | 002ab68 | 2020-01-08 01:57:58 +0900 | [diff] [blame] | 2258 | a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx) |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 2259 | |
| 2260 | a.buildApexDependencyInfo(ctx) |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 2261 | } |
| 2262 | |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 2263 | // Enforce that Java deps of the apex are using stable SDKs to compile |
| 2264 | func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) { |
| 2265 | // Visit direct deps only. As long as we guarantee top-level deps are using |
| 2266 | // stable SDKs, java's checkLinkType guarantees correct usage for transitive deps |
| 2267 | ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) { |
| 2268 | tag := ctx.OtherModuleDependencyTag(module) |
| 2269 | switch tag { |
| 2270 | case javaLibTag, androidAppTag: |
| 2271 | if m, ok := module.(interface{ CheckStableSdkVersion() error }); ok { |
| 2272 | if err := m.CheckStableSdkVersion(); err != nil { |
| 2273 | ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err) |
| 2274 | } |
| 2275 | } |
| 2276 | } |
| 2277 | }) |
| 2278 | } |
| 2279 | |
Jooyung Han | 5e9013b | 2020-03-10 06:23:13 +0900 | [diff] [blame] | 2280 | func whitelistedApexAvailable(apex, moduleName string) bool { |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2281 | key := apex |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2282 | moduleName = normalizeModuleName(moduleName) |
| 2283 | |
| 2284 | if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) { |
| 2285 | return true |
| 2286 | } |
| 2287 | |
| 2288 | key = android.AvailableToAnyApex |
| 2289 | if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) { |
| 2290 | return true |
| 2291 | } |
| 2292 | |
| 2293 | return false |
| 2294 | } |
| 2295 | |
| 2296 | func normalizeModuleName(moduleName string) string { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 2297 | // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build |
| 2298 | // system. Trim the prefix for the check since they are confusing |
| 2299 | moduleName = strings.TrimPrefix(moduleName, "prebuilt_") |
| 2300 | if strings.HasPrefix(moduleName, "libclang_rt.") { |
| 2301 | // This module has many arch variants that depend on the product being built. |
| 2302 | // We don't want to list them all |
| 2303 | moduleName = "libclang_rt" |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2304 | } |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame^] | 2305 | if strings.HasPrefix(moduleName, "androidx.") { |
| 2306 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries |
| 2307 | moduleName = "androidx" |
| 2308 | } |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2309 | return moduleName |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2310 | } |
| 2311 | |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 2312 | func newApexBundle() *apexBundle { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 2313 | module := &apexBundle{} |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2314 | module.AddProperties(&module.properties) |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 2315 | module.AddProperties(&module.targetProperties) |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 2316 | module.AddProperties(&module.overridableProperties) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 2317 | module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool { |
Jiyong Park | 397e55e | 2018-10-24 21:09:55 +0900 | [diff] [blame] | 2318 | return class == android.Device && ctx.Config().DevicePrefer32BitExecutables() |
| 2319 | }) |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 2320 | android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2321 | android.InitDefaultableModule(module) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 2322 | android.InitSdkAwareModule(module) |
Jaewoong Jung | 7abcf8e | 2019-12-19 17:32:06 -0800 | [diff] [blame] | 2323 | android.InitOverridableModule(module, &module.overridableProperties.Overrides) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2324 | return module |
| 2325 | } |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 2326 | |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 2327 | func ApexBundleFactory(testApex bool, artApex bool) android.Module { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 2328 | bundle := newApexBundle() |
| 2329 | bundle.testApex = testApex |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 2330 | bundle.artApex = artApex |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 2331 | return bundle |
| 2332 | } |
| 2333 | |
Jiyong Park | fce0b42 | 2020-02-11 03:56:06 +0900 | [diff] [blame] | 2334 | // apex_test is an APEX for testing. The difference from the ordinary apex module type is that |
| 2335 | // certain compatibility checks such as apex_available are not done for apex_test. |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 2336 | func testApexBundleFactory() android.Module { |
| 2337 | bundle := newApexBundle() |
| 2338 | bundle.testApex = true |
| 2339 | return bundle |
| 2340 | } |
| 2341 | |
Jiyong Park | fce0b42 | 2020-02-11 03:56:06 +0900 | [diff] [blame] | 2342 | // apex packages other modules into an APEX file which is a packaging format for system-level |
| 2343 | // components like binaries, shared libraries, etc. |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 2344 | func BundleFactory() android.Module { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 2345 | return newApexBundle() |
| 2346 | } |
| 2347 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 2348 | // |
| 2349 | // Defaults |
| 2350 | // |
| 2351 | type Defaults struct { |
| 2352 | android.ModuleBase |
| 2353 | android.DefaultsModuleBase |
| 2354 | } |
| 2355 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 2356 | func defaultsFactory() android.Module { |
| 2357 | return DefaultsFactory() |
| 2358 | } |
| 2359 | |
| 2360 | func DefaultsFactory(props ...interface{}) android.Module { |
| 2361 | module := &Defaults{} |
| 2362 | |
| 2363 | module.AddProperties(props...) |
| 2364 | module.AddProperties( |
| 2365 | &apexBundleProperties{}, |
| 2366 | &apexTargetBundleProperties{}, |
Jooyung Han | f21c797 | 2019-12-16 22:32:06 +0900 | [diff] [blame] | 2367 | &overridableProperties{}, |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 2368 | ) |
| 2369 | |
| 2370 | android.InitDefaultsModule(module) |
| 2371 | return module |
| 2372 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 2373 | |
| 2374 | // |
| 2375 | // OverrideApex |
| 2376 | // |
| 2377 | type OverrideApex struct { |
| 2378 | android.ModuleBase |
| 2379 | android.OverrideModuleBase |
| 2380 | } |
| 2381 | |
| 2382 | func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 2383 | // All the overrides happen in the base module. |
| 2384 | } |
| 2385 | |
| 2386 | // override_apex is used to create an apex module based on another apex module |
| 2387 | // by overriding some of its properties. |
| 2388 | func overrideApexFactory() android.Module { |
| 2389 | m := &OverrideApex{} |
| 2390 | m.AddProperties(&overridableProperties{}) |
| 2391 | |
| 2392 | android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 2393 | android.InitOverrideModule(m) |
| 2394 | return m |
| 2395 | } |