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