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