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