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