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