blob: e21cc5bcdb988b8b0134ffd6918e69c5d72d5e3d [file] [log] [blame]
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001// 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
15package apex
16
17import (
18 "fmt"
Jooyung Han54aca7b2019-11-20 02:26:02 +090019 "path"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090020 "path/filepath"
Jiyong Parkab3ceb32018-10-10 14:05:29 +090021 "sort"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090022 "strings"
Jooyung Han344d5432019-08-23 11:17:39 +090023 "sync"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090024
Jiyong Park48ca7dc2018-10-10 14:01:00 +090025 "github.com/google/blueprint"
Alex Light778127a2019-02-27 14:19:50 -080026 "github.com/google/blueprint/bootstrap"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090027 "github.com/google/blueprint/proptools"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070028
29 "android/soong/android"
30 "android/soong/cc"
31 prebuilt_etc "android/soong/etc"
32 "android/soong/java"
33 "android/soong/python"
34 "android/soong/sh"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090035)
36
Jooyung Han72bd2f82019-10-23 16:46:38 +090037const (
38 imageApexSuffix = ".apex"
39 zipApexSuffix = ".zipapex"
Sundong Ahnabb64432019-10-22 13:58:29 +090040 flattenedSuffix = ".flattened"
Alex Light5098a612018-11-29 17:12:15 -080041
Sundong Ahnabb64432019-10-22 13:58:29 +090042 imageApexType = "image"
43 zipApexType = "zip"
44 flattenedApexType = "flattened"
Jooyung Han72bd2f82019-10-23 16:46:38 +090045)
Jiyong Park48ca7dc2018-10-10 14:01:00 +090046
47type dependencyTag struct {
48 blueprint.BaseDependencyTag
49 name string
Jiyong Park0f80c182020-01-31 02:49:53 +090050
51 // determines if the dependent will be part of the APEX payload
52 payload bool
Jiyong Park48ca7dc2018-10-10 14:01:00 +090053}
54
55var (
Jiyong Park0f80c182020-01-31 02:49:53 +090056 sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
Jooyung Han643adc42020-02-27 13:50:06 +090057 jniLibTag = dependencyTag{name: "jniLib", payload: true}
Jiyong Park0f80c182020-01-31 02:49:53 +090058 executableTag = dependencyTag{name: "executable", payload: true}
59 javaLibTag = dependencyTag{name: "javaLib", payload: true}
60 prebuiltTag = dependencyTag{name: "prebuilt", payload: true}
61 testTag = dependencyTag{name: "test", payload: true}
Jiyong Parkc00cbd92018-10-30 21:20:05 +090062 keyTag = dependencyTag{name: "key"}
63 certificateTag = dependencyTag{name: "certificate"}
Jooyung Han5c998b92019-06-27 11:30:33 +090064 usesTag = dependencyTag{name: "uses"}
Jiyong Park0f80c182020-01-31 02:49:53 +090065 androidAppTag = dependencyTag{name: "androidApp", payload: true}
Jiyong Park69aeba92020-04-24 21:16:36 +090066 rroTag = dependencyTag{name: "rro", payload: true}
Paul Duffin7d74e7b2020-03-06 12:30:13 +000067
Colin Cross440e0d02020-06-11 11:32:11 -070068 apexAvailBaseline = makeApexAvailableBaseline()
69
70 inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline)
Jiyong Park48ca7dc2018-10-10 14:01:00 +090071)
72
Paul Duffin7d74e7b2020-03-06 12:30:13 +000073// Transform the map of apex -> modules to module -> apexes.
Colin Cross440e0d02020-06-11 11:32:11 -070074func invertApexBaseline(m map[string][]string) map[string][]string {
Paul Duffin7d74e7b2020-03-06 12:30:13 +000075 r := make(map[string][]string)
76 for apex, modules := range m {
77 for _, module := range modules {
78 r[module] = append(r[module], apex)
79 }
80 }
81 return r
82}
83
Colin Cross440e0d02020-06-11 11:32:11 -070084// Retrieve the baseline of apexes to which the supplied module belongs.
85func BaselineApexAvailable(moduleName string) []string {
86 return inverseApexAvailBaseline[normalizeModuleName(moduleName)]
Paul Duffin7d74e7b2020-03-06 12:30:13 +000087}
88
Anton Hanssoneec79eb2020-01-10 15:12:39 +000089// This is a map from apex to modules, which overrides the
90// apex_available setting for that particular module to make
91// it available for the apex regardless of its setting.
92// TODO(b/147364041): remove this
Colin Cross440e0d02020-06-11 11:32:11 -070093func makeApexAvailableBaseline() map[string][]string {
Anton Hanssoneec79eb2020-01-10 15:12:39 +000094 // The "Module separator"s below are employed to minimize merge conflicts.
95 m := make(map[string][]string)
96 //
97 // Module separator
98 //
Anton Hanssoneec79eb2020-01-10 15:12:39 +000099 m["com.android.bluetooth.updatable"] = []string{
100 "android.hardware.audio.common@5.0",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000101 "android.hardware.bluetooth.a2dp@1.0",
102 "android.hardware.bluetooth.audio@2.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900103 "android.hardware.bluetooth@1.0",
104 "android.hardware.bluetooth@1.1",
105 "android.hardware.graphics.bufferqueue@1.0",
106 "android.hardware.graphics.bufferqueue@2.0",
107 "android.hardware.graphics.common@1.0",
108 "android.hardware.graphics.common@1.1",
109 "android.hardware.graphics.common@1.2",
110 "android.hardware.media@1.0",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000111 "android.hidl.safe_union@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900112 "android.hidl.token@1.0",
113 "android.hidl.token@1.0-utils",
114 "avrcp-target-service",
115 "avrcp_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900116 "bluetooth-protos-lite",
117 "bluetooth.mapsapi",
118 "com.android.vcard",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900119 "dnsresolver_aidl_interface-V2-java",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900120 "ipmemorystore-aidl-interfaces-V5-java",
121 "ipmemorystore-aidl-interfaces-java",
Jiyong Park0f80c182020-01-31 02:49:53 +0900122 "internal_include_headers",
123 "lib-bt-packets",
124 "lib-bt-packets-avrcp",
125 "lib-bt-packets-base",
126 "libFraunhoferAAC",
127 "libaudio-a2dp-hw-utils",
128 "libaudio-hearing-aid-hw-utils",
Jiyong Park0f80c182020-01-31 02:49:53 +0900129 "libbinder_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000130 "libbluetooth",
Jiyong Park0f80c182020-01-31 02:49:53 +0900131 "libbluetooth-types",
132 "libbluetooth-types-header",
133 "libbluetooth_gd",
134 "libbluetooth_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000135 "libbluetooth_jni",
Jiyong Park0f80c182020-01-31 02:49:53 +0900136 "libbt-audio-hal-interface",
137 "libbt-bta",
138 "libbt-common",
139 "libbt-hci",
140 "libbt-platform-protos-lite",
141 "libbt-protos-lite",
142 "libbt-sbc-decoder",
143 "libbt-sbc-encoder",
144 "libbt-stack",
145 "libbt-utils",
146 "libbtcore",
147 "libbtdevice",
148 "libbte",
149 "libbtif",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000150 "libchrome",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000151 "libevent",
152 "libfmq",
Jiyong Park0f80c182020-01-31 02:49:53 +0900153 "libg722codec",
Jiyong Park0f80c182020-01-31 02:49:53 +0900154 "libgui_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900155 "libmedia_headers",
156 "libmodpb64",
157 "libosi",
Jiyong Park0f80c182020-01-31 02:49:53 +0900158 "libstagefright_foundation_headers",
159 "libstagefright_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000160 "libstatslog",
Jiyong Park0f80c182020-01-31 02:49:53 +0900161 "libstatssocket",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000162 "libtinyxml2",
Jiyong Park0f80c182020-01-31 02:49:53 +0900163 "libudrv-uipc",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000164 "libz",
Jiyong Park0f80c182020-01-31 02:49:53 +0900165 "media_plugin_headers",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900166 "net-utils-services-common",
167 "netd_aidl_interface-unstable-java",
168 "netd_event_listener_interface-java",
169 "netlink-client",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900170 "networkstack-client",
Jiyong Park0f80c182020-01-31 02:49:53 +0900171 "sap-api-java-static",
172 "services.net",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000173 }
174 //
175 // Module separator
176 //
Jiyong Park0f80c182020-01-31 02:49:53 +0900177 m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000178 //
179 // Module separator
180 //
Jiyong Park0f80c182020-01-31 02:49:53 +0900181 m["com.android.neuralnetworks"] = []string{
182 "android.hardware.neuralnetworks@1.0",
183 "android.hardware.neuralnetworks@1.1",
184 "android.hardware.neuralnetworks@1.2",
185 "android.hardware.neuralnetworks@1.3",
186 "android.hidl.allocator@1.0",
187 "android.hidl.memory.token@1.0",
188 "android.hidl.memory@1.0",
189 "android.hidl.safe_union@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900190 "libarect",
Jiyong Park0f80c182020-01-31 02:49:53 +0900191 "libbuildversion",
Jiyong Park0f80c182020-01-31 02:49:53 +0900192 "libmath",
Jiyong Park0f80c182020-01-31 02:49:53 +0900193 "libprocpartition",
194 "libsync",
Jiyong Park0f80c182020-01-31 02:49:53 +0900195 }
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000196 //
197 // Module separator
198 //
199 m["com.android.media"] = []string{
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000200 "android.frameworks.bufferhub@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900201 "android.hardware.cas.native@1.0",
202 "android.hardware.cas@1.0",
203 "android.hardware.configstore-utils",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000204 "android.hardware.configstore@1.0",
205 "android.hardware.configstore@1.1",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000206 "android.hardware.graphics.allocator@2.0",
207 "android.hardware.graphics.allocator@3.0",
208 "android.hardware.graphics.bufferqueue@1.0",
209 "android.hardware.graphics.bufferqueue@2.0",
210 "android.hardware.graphics.common@1.0",
211 "android.hardware.graphics.common@1.1",
212 "android.hardware.graphics.common@1.2",
213 "android.hardware.graphics.mapper@2.0",
214 "android.hardware.graphics.mapper@2.1",
215 "android.hardware.graphics.mapper@3.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900216 "android.hardware.media.omx@1.0",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000217 "android.hardware.media@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900218 "android.hidl.allocator@1.0",
219 "android.hidl.memory.token@1.0",
220 "android.hidl.memory@1.0",
221 "android.hidl.token@1.0",
222 "android.hidl.token@1.0-utils",
Jiyong Park0f80c182020-01-31 02:49:53 +0900223 "bionic_libc_platform_headers",
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900224 "exoplayer2-extractor",
225 "exoplayer2-extractor-annotation-stubs",
Jiyong Park0f80c182020-01-31 02:49:53 +0900226 "gl_headers",
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900227 "jsr305",
Jiyong Park0f80c182020-01-31 02:49:53 +0900228 "libEGL",
229 "libEGL_blobCache",
230 "libEGL_getProcAddress",
231 "libFLAC",
232 "libFLAC-config",
233 "libFLAC-headers",
234 "libGLESv2",
235 "libaacextractor",
236 "libamrextractor",
237 "libarect",
Jiyong Park0f80c182020-01-31 02:49:53 +0900238 "libaudio_system_headers",
239 "libaudioclient",
240 "libaudioclient_headers",
241 "libaudiofoundation",
242 "libaudiofoundation_headers",
243 "libaudiomanager",
244 "libaudiopolicy",
245 "libaudioutils",
246 "libaudioutils_fixedfft",
Jiyong Park0f80c182020-01-31 02:49:53 +0900247 "libbinder_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900248 "libbluetooth-types-header",
249 "libbufferhub",
250 "libbufferhub_headers",
251 "libbufferhubqueue",
Jiyong Park0f80c182020-01-31 02:49:53 +0900252 "libc_malloc_debug_backtrace",
253 "libcamera_client",
254 "libcamera_metadata",
Jiyong Park0f80c182020-01-31 02:49:53 +0900255 "libdexfile_external_headers",
256 "libdexfile_support",
257 "libdvr_headers",
258 "libexpat",
259 "libfifo",
260 "libflacextractor",
261 "libgrallocusage",
262 "libgraphicsenv",
263 "libgui",
264 "libgui_headers",
265 "libhardware_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900266 "libinput",
Jiyong Park0f80c182020-01-31 02:49:53 +0900267 "liblzma",
268 "libmath",
269 "libmedia",
270 "libmedia_codeclist",
271 "libmedia_headers",
272 "libmedia_helper",
273 "libmedia_helper_headers",
274 "libmedia_midiiowrapper",
275 "libmedia_omx",
276 "libmediautils",
277 "libmidiextractor",
278 "libmkvextractor",
279 "libmp3extractor",
280 "libmp4extractor",
281 "libmpeg2extractor",
282 "libnativebase_headers",
283 "libnativebridge-headers",
284 "libnativebridge_lazy",
285 "libnativeloader-headers",
286 "libnativeloader_lazy",
287 "libnativewindow_headers",
288 "libnblog",
289 "liboggextractor",
290 "libpackagelistparser",
Jiyong Park0f80c182020-01-31 02:49:53 +0900291 "libpdx",
292 "libpdx_default_transport",
293 "libpdx_headers",
294 "libpdx_uds",
Jiyong Park0f80c182020-01-31 02:49:53 +0900295 "libprocinfo",
Jiyong Park0f80c182020-01-31 02:49:53 +0900296 "libsonivox",
297 "libspeexresampler",
298 "libspeexresampler",
299 "libstagefright_esds",
300 "libstagefright_flacdec",
301 "libstagefright_flacdec",
302 "libstagefright_foundation",
303 "libstagefright_foundation_headers",
304 "libstagefright_foundation_without_imemory",
305 "libstagefright_headers",
306 "libstagefright_id3",
307 "libstagefright_metadatautils",
308 "libstagefright_mpeg2extractor",
309 "libstagefright_mpeg2support",
310 "libsync",
Jiyong Park0f80c182020-01-31 02:49:53 +0900311 "libui",
312 "libui_headers",
313 "libunwindstack",
Jiyong Park0f80c182020-01-31 02:49:53 +0900314 "libvibrator",
315 "libvorbisidec",
316 "libwavextractor",
317 "libwebm",
318 "media_ndk_headers",
319 "media_plugin_headers",
320 "updatable-media",
321 }
322 //
323 // Module separator
324 //
325 m["com.android.media.swcodec"] = []string{
326 "android.frameworks.bufferhub@1.0",
327 "android.hardware.common-ndk_platform",
328 "android.hardware.configstore-utils",
329 "android.hardware.configstore@1.0",
330 "android.hardware.configstore@1.1",
331 "android.hardware.graphics.allocator@2.0",
332 "android.hardware.graphics.allocator@3.0",
333 "android.hardware.graphics.bufferqueue@1.0",
334 "android.hardware.graphics.bufferqueue@2.0",
335 "android.hardware.graphics.common-ndk_platform",
336 "android.hardware.graphics.common@1.0",
337 "android.hardware.graphics.common@1.1",
338 "android.hardware.graphics.common@1.2",
339 "android.hardware.graphics.mapper@2.0",
340 "android.hardware.graphics.mapper@2.1",
341 "android.hardware.graphics.mapper@3.0",
342 "android.hardware.graphics.mapper@4.0",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000343 "android.hardware.media.bufferpool@2.0",
344 "android.hardware.media.c2@1.0",
345 "android.hardware.media.omx@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900346 "android.hardware.media@1.0",
347 "android.hardware.media@1.0",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000348 "android.hidl.memory.token@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900349 "android.hidl.memory@1.0",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000350 "android.hidl.safe_union@1.0",
351 "android.hidl.token@1.0",
352 "android.hidl.token@1.0-utils",
Jiyong Park0f80c182020-01-31 02:49:53 +0900353 "libEGL",
354 "libFLAC",
355 "libFLAC-config",
356 "libFLAC-headers",
357 "libFraunhoferAAC",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900358 "libLibGuiProperties",
Jiyong Park0f80c182020-01-31 02:49:53 +0900359 "libarect",
Jiyong Park0f80c182020-01-31 02:49:53 +0900360 "libaudio_system_headers",
361 "libaudioutils",
362 "libaudioutils",
363 "libaudioutils_fixedfft",
364 "libavcdec",
365 "libavcenc",
366 "libavservices_minijail",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000367 "libavservices_minijail",
Jiyong Park0f80c182020-01-31 02:49:53 +0900368 "libbinder_headers",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900369 "libbinderthreadstateutils",
Jiyong Park0f80c182020-01-31 02:49:53 +0900370 "libbluetooth-types-header",
371 "libbufferhub_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000372 "libcodec2",
Jiyong Park0f80c182020-01-31 02:49:53 +0900373 "libcodec2_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000374 "libcodec2_hidl@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900375 "libcodec2_hidl@1.1",
376 "libcodec2_internal",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000377 "libcodec2_soft_aacdec",
378 "libcodec2_soft_aacenc",
379 "libcodec2_soft_amrnbdec",
380 "libcodec2_soft_amrnbenc",
381 "libcodec2_soft_amrwbdec",
382 "libcodec2_soft_amrwbenc",
383 "libcodec2_soft_av1dec_gav1",
384 "libcodec2_soft_avcdec",
385 "libcodec2_soft_avcenc",
386 "libcodec2_soft_common",
387 "libcodec2_soft_flacdec",
388 "libcodec2_soft_flacenc",
389 "libcodec2_soft_g711alawdec",
390 "libcodec2_soft_g711mlawdec",
391 "libcodec2_soft_gsmdec",
392 "libcodec2_soft_h263dec",
393 "libcodec2_soft_h263enc",
394 "libcodec2_soft_hevcdec",
395 "libcodec2_soft_hevcenc",
396 "libcodec2_soft_mp3dec",
397 "libcodec2_soft_mpeg2dec",
398 "libcodec2_soft_mpeg4dec",
399 "libcodec2_soft_mpeg4enc",
400 "libcodec2_soft_opusdec",
401 "libcodec2_soft_opusenc",
402 "libcodec2_soft_rawdec",
403 "libcodec2_soft_vorbisdec",
404 "libcodec2_soft_vp8dec",
405 "libcodec2_soft_vp8enc",
406 "libcodec2_soft_vp9dec",
407 "libcodec2_soft_vp9enc",
408 "libcodec2_vndk",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000409 "libdexfile_support",
Jiyong Park0f80c182020-01-31 02:49:53 +0900410 "libdvr_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000411 "libfmq",
Jiyong Park0f80c182020-01-31 02:49:53 +0900412 "libfmq",
413 "libgav1",
414 "libgralloctypes",
415 "libgrallocusage",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000416 "libgraphicsenv",
Jiyong Park0f80c182020-01-31 02:49:53 +0900417 "libgsm",
418 "libgui_bufferqueue_static",
419 "libgui_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000420 "libhardware",
Jiyong Park0f80c182020-01-31 02:49:53 +0900421 "libhardware_headers",
422 "libhevcdec",
423 "libhevcenc",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000424 "libion",
Jiyong Park0f80c182020-01-31 02:49:53 +0900425 "libjpeg",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000426 "liblzma",
Jiyong Park0f80c182020-01-31 02:49:53 +0900427 "libmath",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000428 "libmedia_codecserviceregistrant",
Jiyong Park0f80c182020-01-31 02:49:53 +0900429 "libmedia_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900430 "libmpeg2dec",
431 "libnativebase_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000432 "libnativebridge_lazy",
433 "libnativeloader_lazy",
Jiyong Park0f80c182020-01-31 02:49:53 +0900434 "libnativewindow_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900435 "libpdx_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000436 "libscudo_wrapper",
437 "libsfplugin_ccodec_utils",
438 "libstagefright_amrnb_common",
Jiyong Park0f80c182020-01-31 02:49:53 +0900439 "libstagefright_amrnbdec",
440 "libstagefright_amrnbenc",
441 "libstagefright_amrwbdec",
442 "libstagefright_amrwbenc",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000443 "libstagefright_bufferpool@2.0.1",
444 "libstagefright_bufferqueue_helper",
445 "libstagefright_enc_common",
446 "libstagefright_flacdec",
447 "libstagefright_foundation",
Jiyong Park0f80c182020-01-31 02:49:53 +0900448 "libstagefright_foundation_headers",
449 "libstagefright_headers",
450 "libstagefright_m4vh263dec",
451 "libstagefright_m4vh263enc",
452 "libstagefright_mp3dec",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000453 "libsync",
454 "libui",
Jiyong Park0f80c182020-01-31 02:49:53 +0900455 "libui_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000456 "libunwindstack",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000457 "libvorbisidec",
458 "libvpx",
Jiyong Park0f80c182020-01-31 02:49:53 +0900459 "libyuv",
460 "libyuv_static",
461 "media_ndk_headers",
462 "media_plugin_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000463 "mediaswcodec",
Jiyong Park0f80c182020-01-31 02:49:53 +0900464 }
465 //
466 // Module separator
467 //
468 m["com.android.mediaprovider"] = []string{
469 "MediaProvider",
470 "MediaProviderGoogle",
471 "fmtlib_ndk",
Jiyong Park0f80c182020-01-31 02:49:53 +0900472 "libbase_ndk",
473 "libfuse",
474 "libfuse_jni",
Jiyong Park0f80c182020-01-31 02:49:53 +0900475 }
476 //
477 // Module separator
478 //
479 m["com.android.permission"] = []string{
Jiyong Park0f80c182020-01-31 02:49:53 +0900480 "kotlin-annotations",
481 "kotlin-stdlib",
482 "kotlin-stdlib-jdk7",
483 "kotlin-stdlib-jdk8",
484 "kotlinx-coroutines-android",
485 "kotlinx-coroutines-android-nodeps",
486 "kotlinx-coroutines-core",
487 "kotlinx-coroutines-core-nodeps",
Jiyong Park0f80c182020-01-31 02:49:53 +0900488 "permissioncontroller-statsd",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000489 }
490 //
491 // Module separator
492 //
493 m["com.android.runtime"] = []string{
Jiyong Park0f80c182020-01-31 02:49:53 +0900494 "bionic_libc_platform_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900495 "libarm-optimized-routines-math",
Jiyong Park0f80c182020-01-31 02:49:53 +0900496 "libc_aeabi",
497 "libc_bionic",
498 "libc_bionic_ndk",
499 "libc_bootstrap",
500 "libc_common",
501 "libc_common_shared",
502 "libc_common_static",
503 "libc_dns",
504 "libc_dynamic_dispatch",
505 "libc_fortify",
506 "libc_freebsd",
507 "libc_freebsd_large_stack",
508 "libc_gdtoa",
Jiyong Park0f80c182020-01-31 02:49:53 +0900509 "libc_init_dynamic",
510 "libc_init_static",
511 "libc_jemalloc_wrapper",
512 "libc_netbsd",
513 "libc_nomalloc",
514 "libc_nopthread",
515 "libc_openbsd",
516 "libc_openbsd_large_stack",
517 "libc_openbsd_ndk",
518 "libc_pthread",
519 "libc_static_dispatch",
520 "libc_syscalls",
521 "libc_tzcode",
522 "libc_unwind_static",
Jiyong Park0f80c182020-01-31 02:49:53 +0900523 "libdebuggerd",
524 "libdebuggerd_common_headers",
525 "libdebuggerd_handler_core",
526 "libdebuggerd_handler_fallback",
527 "libdexfile_external_headers",
528 "libdexfile_support",
529 "libdexfile_support_static",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900530 "libdl_static",
Jiyong Park0f80c182020-01-31 02:49:53 +0900531 "libjemalloc5",
532 "liblinker_main",
533 "liblinker_malloc",
Jiyong Park0f80c182020-01-31 02:49:53 +0900534 "liblz4",
535 "liblzma",
Jiyong Park0f80c182020-01-31 02:49:53 +0900536 "libprocinfo",
537 "libpropertyinfoparser",
538 "libscudo",
539 "libstdc++",
Jiyong Park0f80c182020-01-31 02:49:53 +0900540 "libsystemproperties",
541 "libtombstoned_client_static",
542 "libunwindstack",
Jiyong Park0f80c182020-01-31 02:49:53 +0900543 "libz",
544 "libziparchive",
545 }
546 //
547 // Module separator
548 //
Jiyong Park0f80c182020-01-31 02:49:53 +0900549 m["com.android.tethering"] = []string{
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900550 "android.hardware.tetheroffload.config-V1.0-java",
551 "android.hardware.tetheroffload.control-V1.0-java",
552 "android.hidl.base-V1.0-java",
553 "ipmemorystore-aidl-interfaces-java",
Jiyong Park0f80c182020-01-31 02:49:53 +0900554 "libcgrouprc",
555 "libcgrouprc_format",
Jiyong Park0f80c182020-01-31 02:49:53 +0900556 "libtetherutilsjni",
Jiyong Park0f80c182020-01-31 02:49:53 +0900557 "libvndksupport",
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900558 "net-utils-framework-common",
559 "netd_aidl_interface-V3-java",
560 "netlink-client",
561 "networkstack-aidl-interfaces-java",
Jiyong Park0f80c182020-01-31 02:49:53 +0900562 "tethering-aidl-interfaces-java",
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900563 "TetheringApiCurrentLib",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000564 }
565 //
566 // Module separator
567 //
Jiyong Park0f80c182020-01-31 02:49:53 +0900568 m["com.android.wifi"] = []string{
569 "PlatformProperties",
570 "android.hardware.wifi-V1.0-java",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900571 "android.hardware.wifi-V1.0-java-constants",
Jiyong Park0f80c182020-01-31 02:49:53 +0900572 "android.hardware.wifi-V1.1-java",
573 "android.hardware.wifi-V1.2-java",
574 "android.hardware.wifi-V1.3-java",
575 "android.hardware.wifi-V1.4-java",
576 "android.hardware.wifi.hostapd-V1.0-java",
577 "android.hardware.wifi.hostapd-V1.1-java",
578 "android.hardware.wifi.hostapd-V1.2-java",
579 "android.hardware.wifi.supplicant-V1.0-java",
580 "android.hardware.wifi.supplicant-V1.1-java",
581 "android.hardware.wifi.supplicant-V1.2-java",
582 "android.hardware.wifi.supplicant-V1.3-java",
583 "android.hidl.base-V1.0-java",
584 "android.hidl.manager-V1.0-java",
585 "android.hidl.manager-V1.1-java",
586 "android.hidl.manager-V1.2-java",
Jiyong Park0f80c182020-01-31 02:49:53 +0900587 "bouncycastle-unbundled",
588 "dnsresolver_aidl_interface-V2-java",
589 "error_prone_annotations",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900590 "framework-wifi-pre-jarjar",
591 "framework-wifi-util-lib",
Jiyong Park0f80c182020-01-31 02:49:53 +0900592 "ipmemorystore-aidl-interfaces-V3-java",
593 "ipmemorystore-aidl-interfaces-java",
594 "ksoap2",
Jiyong Park0f80c182020-01-31 02:49:53 +0900595 "libnanohttpd",
Jiyong Park0f80c182020-01-31 02:49:53 +0900596 "libwifi-jni",
597 "net-utils-services-common",
598 "netd_aidl_interface-V2-java",
599 "netd_aidl_interface-unstable-java",
600 "netd_event_listener_interface-java",
601 "netlink-client",
Jiyong Park0f80c182020-01-31 02:49:53 +0900602 "networkstack-client",
603 "services.net",
604 "wifi-lite-protos",
605 "wifi-nano-protos",
606 "wifi-service-pre-jarjar",
607 "wifi-service-resources",
Jiyong Park0f80c182020-01-31 02:49:53 +0900608 }
609 //
610 // Module separator
611 //
612 m["com.android.sdkext"] = []string{
613 "fmtlib_ndk",
614 "libbase_ndk",
615 "libprotobuf-cpp-lite-ndk",
616 }
617 //
618 // Module separator
619 //
620 m["com.android.os.statsd"] = []string{
Jiyong Park0f80c182020-01-31 02:49:53 +0900621 "libstatssocket",
Jiyong Park0f80c182020-01-31 02:49:53 +0900622 }
623 //
624 // Module separator
625 //
Paul Duffin7d74e7b2020-03-06 12:30:13 +0000626 m[android.AvailableToAnyApex] = []string{
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900627 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries
628 "androidx",
629 "androidx-constraintlayout_constraintlayout",
630 "androidx-constraintlayout_constraintlayout-nodeps",
631 "androidx-constraintlayout_constraintlayout-solver",
632 "androidx-constraintlayout_constraintlayout-solver-nodeps",
633 "com.google.android.material_material",
634 "com.google.android.material_material-nodeps",
635
Jiyong Park0f80c182020-01-31 02:49:53 +0900636 "libatomic",
Jiyong Park0f80c182020-01-31 02:49:53 +0900637 "libclang_rt",
638 "libgcc_stripped",
639 "libprofile-clang-extras",
640 "libprofile-clang-extras_ndk",
641 "libprofile-extras",
642 "libprofile-extras_ndk",
643 "libunwind_llvm",
Jiyong Park0f80c182020-01-31 02:49:53 +0900644 }
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000645 return m
646}
647
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900648func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +0900649 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -0800650 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +0900651 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +0900652 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -0700653 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +0900654 android.RegisterModuleType("override_apex", overrideApexFactory)
Jaewoong Jungfa00c062020-05-14 14:15:24 -0700655 android.RegisterModuleType("apex_set", apexSetFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900656
Jooyung Han31c470b2019-10-18 16:26:59 +0900657 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900658 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +0900659
660 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
661 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
662 sort.Strings(*apexFileContextsInfos)
663 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
664 })
Jiyong Parkd1063c12019-07-17 20:08:41 +0900665}
666
Jooyung Han31c470b2019-10-18 16:26:59 +0900667func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
668 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
669 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
670}
671
Jiyong Parkd1063c12019-07-17 20:08:41 +0900672func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parkf760cae2020-02-12 07:53:12 +0900673 ctx.TopDown("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900674 ctx.BottomUp("apex", apexMutator).Parallel()
675 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
676 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park89e850a2020-04-07 16:37:39 +0900677 ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900678}
679
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900680// Mark the direct and transitive dependencies of apex bundles so that they
681// can be built for the apex bundles.
Jiyong Parkf760cae2020-02-12 07:53:12 +0900682func apexDepsMutator(mctx android.TopDownMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +0900683 if !mctx.Module().Enabled() {
684 return
685 }
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800686 var apexBundles []android.ApexInfo
Jiyong Parkf760cae2020-02-12 07:53:12 +0900687 var directDep bool
Jooyung Hana57af4a2020-01-23 05:36:59 +0000688 if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jooyung Han49f67012020-04-17 13:43:10 +0900689 apexBundles = []android.ApexInfo{{
Jooyung Han5417f772020-03-12 18:37:20 +0900690 ApexName: mctx.ModuleName(),
691 MinSdkVersion: a.minSdkVersion(mctx),
Artur Satayev849f8442020-04-28 14:57:42 +0100692 Updatable: a.Updatable(),
Jooyung Han5e9013b2020-03-10 06:23:13 +0900693 }}
Jiyong Parkf760cae2020-02-12 07:53:12 +0900694 directDep = true
695 } else if am, ok := mctx.Module().(android.ApexModule); ok {
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800696 apexBundles = am.ApexVariations()
Jiyong Parkf760cae2020-02-12 07:53:12 +0900697 directDep = false
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900698 }
Jiyong Parkf760cae2020-02-12 07:53:12 +0900699
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800700 if len(apexBundles) == 0 {
Jiyong Parkf760cae2020-02-12 07:53:12 +0900701 return
702 }
703
Paul Duffin923e8a52020-03-30 15:33:32 +0100704 cur := mctx.Module().(android.DepIsInSameApex)
Jooyung Han5e9013b2020-03-10 06:23:13 +0900705
Jiyong Parkf760cae2020-02-12 07:53:12 +0900706 mctx.VisitDirectDeps(func(child android.Module) {
707 depName := mctx.OtherModuleName(child)
708 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
Paul Duffin65347702020-03-31 15:23:40 +0100709 (cur.DepIsInSameApex(mctx, child) || inAnySdk(child)) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800710 android.UpdateApexDependency(apexBundles, depName, directDep)
711 am.BuildForApexes(apexBundles)
Jiyong Parkf760cae2020-02-12 07:53:12 +0900712 }
713 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900714}
715
Jiyong Park89e850a2020-04-07 16:37:39 +0900716// mark if a module cannot be available to platform. A module cannot be available
717// to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform"
718// is absent) or 2) it depends on another module that isn't (or can't be) available to platform
719func markPlatformAvailability(mctx android.BottomUpMutatorContext) {
720 // Host and recovery are not considered as platform
721 if mctx.Host() || mctx.Module().InstallInRecovery() {
722 return
723 }
724
725 if am, ok := mctx.Module().(android.ApexModule); ok {
726 availableToPlatform := am.AvailableFor(android.AvailableToPlatform)
727
728 // In a rare case when a lib is marked as available only to an apex
729 // but the apex doesn't exist. This can happen in a partial manifest branch
730 // like master-art. Currently, libstatssocket in the stats APEX is causing
731 // this problem.
732 // Include the lib in platform because the module SDK that ought to provide
733 // it doesn't exist, so it would otherwise be left out completely.
734 // TODO(b/154888298) remove this by adding those libraries in module SDKS and skipping
735 // this check for libraries provided by SDKs.
736 if !availableToPlatform && !android.InAnyApex(am.Name()) {
737 availableToPlatform = true
738 }
739
740 // If any of the dep is not available to platform, this module is also considered
741 // as being not available to platform even if it has "//apex_available:platform"
742 mctx.VisitDirectDeps(func(child android.Module) {
743 if !am.DepIsInSameApex(mctx, child) {
744 // if the dependency crosses apex boundary, don't consider it
745 return
746 }
747 if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() {
748 availableToPlatform = false
749 // TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform"
750 }
751 })
752
753 // Exception 1: stub libraries and native bridge libraries are always available to platform
754 if cc, ok := mctx.Module().(*cc.Module); ok &&
755 (cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) {
756 availableToPlatform = true
757 }
758
759 // Exception 2: bootstrap bionic libraries are also always available to platform
760 if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) {
761 availableToPlatform = true
762 }
763
764 if !availableToPlatform {
765 am.SetNotAvailableForPlatform()
766 }
767 }
768}
769
Paul Duffin65347702020-03-31 15:23:40 +0100770// If a module in an APEX depends on a module from an SDK then it needs an APEX
771// specific variant created for it. Refer to sdk.sdkDepsReplaceMutator.
772func inAnySdk(module android.Module) bool {
773 if sa, ok := module.(android.SdkAware); ok {
774 return sa.IsInAnySdk()
775 }
776
777 return false
778}
779
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900780// Create apex variations if a module is included in APEX(s).
781func apexMutator(mctx android.BottomUpMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +0900782 if !mctx.Module().Enabled() {
783 return
784 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900785 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900786 am.CreateApexVariations(mctx)
Jooyung Hana57af4a2020-01-23 05:36:59 +0000787 } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900788 // apex bundle itself is mutated so that it and its modules have same
789 // apex variant.
790 apexBundleName := mctx.ModuleName()
791 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +0900792 } else if o, ok := mctx.Module().(*OverrideApex); ok {
793 apexBundleName := o.GetOverriddenModuleName()
794 if apexBundleName == "" {
795 mctx.ModuleErrorf("base property is not set")
796 return
797 }
798 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900799 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900800
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900801}
Sundong Ahne9b55722019-09-06 17:37:42 +0900802
Jooyung Han7a78a922019-10-08 21:59:58 +0900803var (
804 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
805 apexFileContextsInfosMutex sync.Mutex
806)
807
808func apexFileContextsInfos(config android.Config) *[]string {
809 return config.Once(apexFileContextsInfosKey, func() interface{} {
810 return &[]string{}
811 }).(*[]string)
812}
813
Jooyung Han54aca7b2019-11-20 02:26:02 +0900814func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +0900815 apexFileContextsInfosMutex.Lock()
816 defer apexFileContextsInfosMutex.Unlock()
817 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +0900818 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +0900819}
820
Sundong Ahne9b55722019-09-06 17:37:42 +0900821func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +0900822 if !mctx.Module().Enabled() {
823 return
824 }
Sundong Ahne8fb7242019-09-17 13:50:45 +0900825 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +0900826 var variants []string
827 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
828 case "image":
829 variants = append(variants, imageApexType, flattenedApexType)
830 case "zip":
831 variants = append(variants, zipApexType)
832 case "both":
833 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
834 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900835 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +0900836 return
837 }
838
839 modules := mctx.CreateLocalVariations(variants...)
840
841 for i, v := range variants {
842 switch v {
843 case imageApexType:
844 modules[i].(*apexBundle).properties.ApexType = imageApex
845 case zipApexType:
846 modules[i].(*apexBundle).properties.ApexType = zipApex
847 case flattenedApexType:
848 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +0900849 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900850 modules[i].(*apexBundle).MakeAsSystemExt()
851 }
Sundong Ahnabb64432019-10-22 13:58:29 +0900852 }
Sundong Ahne9b55722019-09-06 17:37:42 +0900853 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900854 } else if _, ok := mctx.Module().(*OverrideApex); ok {
855 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +0900856 }
857}
858
Jooyung Han5c998b92019-06-27 11:30:33 +0900859func apexUsesMutator(mctx android.BottomUpMutatorContext) {
860 if ab, ok := mctx.Module().(*apexBundle); ok {
861 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
862 }
863}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900864
Jooyung Handc782442019-11-01 03:14:38 +0900865var (
Colin Cross440e0d02020-06-11 11:32:11 -0700866 useVendorAllowListKey = android.NewOnceKey("useVendorAllowList")
Jooyung Handc782442019-11-01 03:14:38 +0900867)
868
Colin Cross440e0d02020-06-11 11:32:11 -0700869// useVendorAllowList returns the list of APEXes which are allowed to use_vendor.
Jooyung Handc782442019-11-01 03:14:38 +0900870// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
871// which may cause compatibility issues. (e.g. libbinder)
872// Even though libbinder restricts its availability via 'apex_available' property and relies on
873// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
874// to avoid similar problems.
Colin Cross440e0d02020-06-11 11:32:11 -0700875func useVendorAllowList(config android.Config) []string {
876 return config.Once(useVendorAllowListKey, func() interface{} {
Jooyung Handc782442019-11-01 03:14:38 +0900877 return []string{
878 // swcodec uses "vendor" variants for smaller size
879 "com.android.media.swcodec",
880 "test_com.android.media.swcodec",
881 }
882 }).([]string)
883}
884
Colin Cross440e0d02020-06-11 11:32:11 -0700885// setUseVendorAllowListForTest overrides useVendorAllowList and must be
886// called before the first call to useVendorAllowList()
887func setUseVendorAllowListForTest(config android.Config, allowList []string) {
888 config.Once(useVendorAllowListKey, func() interface{} {
889 return allowList
Jooyung Handc782442019-11-01 03:14:38 +0900890 })
891}
892
Jooyung Han01a868d2020-02-27 13:40:44 +0900893type ApexNativeDependencies struct {
Alex Light9670d332019-01-29 18:07:33 -0800894 // List of native libraries
895 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +0900896
Jooyung Han643adc42020-02-27 13:50:06 +0900897 // List of JNI libraries
898 Jni_libs []string
899
Alex Light9670d332019-01-29 18:07:33 -0800900 // List of native executables
901 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +0900902
Roland Levillain630846d2019-06-26 12:48:34 +0100903 // List of native tests
904 Tests []string
Alex Light9670d332019-01-29 18:07:33 -0800905}
Jooyung Han344d5432019-08-23 11:17:39 +0900906
Alex Light9670d332019-01-29 18:07:33 -0800907type apexMultilibProperties struct {
908 // Native dependencies whose compile_multilib is "first"
Jooyung Han01a868d2020-02-27 13:40:44 +0900909 First ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800910
911 // Native dependencies whose compile_multilib is "both"
Jooyung Han01a868d2020-02-27 13:40:44 +0900912 Both ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800913
914 // Native dependencies whose compile_multilib is "prefer32"
Jooyung Han01a868d2020-02-27 13:40:44 +0900915 Prefer32 ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800916
917 // Native dependencies whose compile_multilib is "32"
Jooyung Han01a868d2020-02-27 13:40:44 +0900918 Lib32 ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800919
920 // Native dependencies whose compile_multilib is "64"
Jooyung Han01a868d2020-02-27 13:40:44 +0900921 Lib64 ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800922}
923
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900924type apexBundleProperties struct {
925 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +0000926 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -0800927 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900928
Jiyong Park40e26a22019-02-08 02:53:06 +0900929 // AndroidManifest.xml file used for the zip container of this APEX bundle.
930 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -0800931 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +0900932
Roland Levillain411c5842019-09-19 16:37:20 +0100933 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
934 // device (/apex/<apex_name>).
935 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +0900936 Apex_name *string
937
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900938 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +0900939 // For platform APEXes, this should points to a file under /system/sepolicy
940 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
941 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900942
Jooyung Han01a868d2020-02-27 13:40:44 +0900943 ApexNativeDependencies
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900944
945 // List of java libraries that are embedded inside this APEX bundle
946 Java_libs []string
947
948 // List of prebuilt files that are embedded inside this APEX bundle
949 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +0900950
951 // Name of the apex_key module that provides the private key to sign APEX
952 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +0900953
Alex Light5098a612018-11-29 17:12:15 -0800954 // The type of APEX to build. Controls what the APEX payload is. Either
955 // 'image', 'zip' or 'both'. Default: 'image'.
956 Payload_type *string
957
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900958 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
959 // or an android_app_certificate module name in the form ":module".
960 Certificate *string
961
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900962 // Whether this APEX is installable to one of the partitions. Default: true.
963 Installable *bool
964
Jiyong Parkda6eb592018-12-19 17:12:36 +0900965 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
966 // Default is false.
967 Use_vendor *bool
968
Alex Lightfc0bd7c2019-01-29 18:31:59 -0800969 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
970 Ignore_system_library_special_case *bool
971
Alex Light9670d332019-01-29 18:07:33 -0800972 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +0900973
Jiyong Parkf97782b2019-02-13 20:28:58 +0900974 // List of sanitizer names that this APEX is enabled for
975 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +0900976
Jiyong Parkee9a98d2019-08-09 14:44:36 +0900977 PreventInstall bool `blueprint:"mutated"`
978
979 HideFromMake bool `blueprint:"mutated"`
980
Jooyung Han5c998b92019-06-27 11:30:33 +0900981 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
982 Provide_cpp_shared_libs *bool
983
984 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
985 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +0100986
Sundong Ahnabb64432019-10-22 13:58:29 +0900987 // package format of this apex variant; could be non-flattened, flattened, or zip.
988 // imageApex, zipApex or flattened
989 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +0900990
Jiyong Parkd1063c12019-07-17 20:08:41 +0900991 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
992 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
993 // is implied. This value affects all modules included in this APEX. In other words, they are
994 // also built with the SDKs specified here.
995 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +0900996
Nikita Ioffec72b5dd2019-12-07 17:30:22 +0000997 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
998 // Should be only used in tests#.
999 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +09001000
Dario Frenica913392020-04-27 18:21:11 +01001001 // Whenever apex_payload.img of the APEX should not be dm-verity signed.
1002 // Should be only used in tests#.
1003 Test_only_unsigned_payload *bool
1004
Jiyong Park956305c2020-01-09 12:32:06 +09001005 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park9d677202020-02-19 16:29:35 +09001006
1007 // Whether this APEX is considered updatable or not. When set to true, this will enforce additional
Jooyung Han548640b2020-04-27 12:10:30 +09001008 // rules for making sure that the APEX is truly updatable.
1009 // - To be updatable, min_sdk_version should be set as well
1010 // This will also disable the size optimizations like symlinking to the system libs.
1011 // Default is false.
Jiyong Park9d677202020-02-19 16:29:35 +09001012 Updatable *bool
Colin Cross50317872020-02-19 20:41:10 -08001013
1014 // The minimum SDK version that this apex must be compatibile with.
1015 Min_sdk_version *string
Alex Light9670d332019-01-29 18:07:33 -08001016}
1017
1018type apexTargetBundleProperties struct {
1019 Target struct {
1020 // Multilib properties only for android.
1021 Android struct {
1022 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001023 }
Jooyung Han344d5432019-08-23 11:17:39 +09001024
Alex Light9670d332019-01-29 18:07:33 -08001025 // Multilib properties only for host.
1026 Host struct {
1027 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001028 }
Jooyung Han344d5432019-08-23 11:17:39 +09001029
Alex Light9670d332019-01-29 18:07:33 -08001030 // Multilib properties only for host linux_bionic.
1031 Linux_bionic struct {
1032 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001033 }
Jooyung Han344d5432019-08-23 11:17:39 +09001034
Alex Light9670d332019-01-29 18:07:33 -08001035 // Multilib properties only for host linux_glibc.
1036 Linux_glibc struct {
1037 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001038 }
1039 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001040}
1041
Jiyong Park5d790c32019-11-15 18:40:32 +09001042type overridableProperties struct {
1043 // List of APKs to package inside APEX
1044 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001045
Jiyong Park69aeba92020-04-24 21:16:36 +09001046 // List of runtime resource overlays (RROs) inside APEX
1047 Rros []string
1048
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001049 // Names of modules to be overridden. Listed modules can only be other binaries
1050 // (in Make or Soong).
1051 // This does not completely prevent installation of the overridden binaries, but if both
1052 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
1053 // from PRODUCT_PACKAGES.
1054 Overrides []string
Baligh Uddin004d7172020-02-19 21:29:28 -08001055
1056 // Logging Parent value
1057 Logging_parent string
Baligh Uddin5b57dba2020-03-15 13:01:05 -07001058
1059 // Apex Container Package Name.
1060 // Override value for attribute package:name in AndroidManifest.xml
1061 Package_name string
Jooyung Han938b5932020-06-20 12:47:47 +09001062
1063 // A txt file containing list of files that are allowed to be included in this APEX.
1064 Allowed_files *string `android:"path"`
Jiyong Park5d790c32019-11-15 18:40:32 +09001065}
1066
Alex Light5098a612018-11-29 17:12:15 -08001067type apexPackaging int
1068
1069const (
1070 imageApex apexPackaging = iota
1071 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +09001072 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -08001073)
1074
Sundong Ahnabb64432019-10-22 13:58:29 +09001075// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -08001076func (a apexPackaging) suffix() string {
1077 switch a {
1078 case imageApex:
1079 return imageApexSuffix
1080 case zipApex:
1081 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -08001082 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001083 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001084 }
1085}
1086
1087func (a apexPackaging) name() string {
1088 switch a {
1089 case imageApex:
1090 return imageApexType
1091 case zipApex:
1092 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -08001093 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001094 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001095 }
1096}
1097
Jiyong Parkf653b052019-11-18 15:39:01 +09001098type apexFileClass int
1099
1100const (
1101 etc apexFileClass = iota
1102 nativeSharedLib
1103 nativeExecutable
1104 shBinary
1105 pyBinary
1106 goBinary
1107 javaSharedLib
1108 nativeTest
1109 app
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001110 appSet
Jiyong Parkf653b052019-11-18 15:39:01 +09001111)
1112
Jiyong Park8fd61922018-11-08 02:50:25 +09001113func (class apexFileClass) NameInMake() string {
1114 switch class {
1115 case etc:
1116 return "ETC"
1117 case nativeSharedLib:
1118 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -08001119 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +09001120 return "EXECUTABLES"
1121 case javaSharedLib:
1122 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +01001123 case nativeTest:
1124 return "NATIVE_TESTS"
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001125 case app, appSet:
Jiyong Parkf383f7c2019-10-11 20:46:25 +09001126 // b/142537672 Why isn't this APP? We want to have full control over
1127 // the paths and file names of the apk file under the flattend APEX.
1128 // If this is set to APP, then the paths and file names are modified
1129 // by the Make build system. For example, it is installed to
1130 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
1131 // /system/apex/<apexname>/app/<Appname> because the build system automatically
1132 // appends module name (which is <apexname>.<Appname> to the path.
1133 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +09001134 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001135 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +09001136 }
1137}
1138
Jiyong Parkf653b052019-11-18 15:39:01 +09001139// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +09001140type apexFile struct {
1141 builtFile android.Path
Jiyong Parka62aa232020-05-28 23:46:55 +09001142 stem string
Jiyong Park8fd61922018-11-08 02:50:25 +09001143 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +09001144 installDir string
1145 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +09001146 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +09001147 // list of symlinks that will be created in installDir that point to this apexFile
1148 symlinks []string
Liz Kammer1c14a212020-05-12 15:26:55 -07001149 dataPaths android.Paths
Jiyong Parkf653b052019-11-18 15:39:01 +09001150 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +09001151 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +09001152
1153 requiredModuleNames []string
1154 targetRequiredModuleNames []string
1155 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +09001156
Colin Cross503c1d02020-01-28 14:00:53 -08001157 jacocoReportClassesFile android.Path // only for javalibs and apps
1158 certificate java.Certificate // only for apps
Jiyong Parkcfaa1642020-02-28 16:51:07 +09001159 overriddenPackageName string // only for apps
Jooyung Han643adc42020-02-27 13:50:06 +09001160
1161 isJniLib bool
Jiyong Parkf653b052019-11-18 15:39:01 +09001162}
1163
Jiyong Park1833cef2019-12-13 13:28:36 +09001164func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
1165 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +09001166 builtFile: builtFile,
1167 moduleName: moduleName,
1168 installDir: installDir,
1169 class: class,
1170 module: module,
1171 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001172 if module != nil {
1173 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +09001174 ret.requiredModuleNames = module.RequiredModuleNames()
1175 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
1176 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +09001177 }
1178 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +09001179}
1180
1181func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +09001182 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +09001183}
1184
Liz Kammer1c14a212020-05-12 15:26:55 -07001185func (af *apexFile) apexRelativePath(path string) string {
1186 return filepath.Join(af.installDir, path)
1187}
1188
Jiyong Park7cd10e32020-01-14 09:22:18 +09001189// Path() returns path of this apex file relative to the APEX root
1190func (af *apexFile) Path() string {
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001191 return af.apexRelativePath(af.Stem())
1192}
1193
1194func (af *apexFile) Stem() string {
Jiyong Parka62aa232020-05-28 23:46:55 +09001195 if af.stem != "" {
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001196 return af.stem
Jiyong Parka62aa232020-05-28 23:46:55 +09001197 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001198 return af.builtFile.Base()
Jiyong Park7cd10e32020-01-14 09:22:18 +09001199}
1200
1201// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
1202func (af *apexFile) SymlinkPaths() []string {
1203 var ret []string
1204 for _, symlink := range af.symlinks {
Liz Kammer1c14a212020-05-12 15:26:55 -07001205 ret = append(ret, af.apexRelativePath(symlink))
Jiyong Park7cd10e32020-01-14 09:22:18 +09001206 }
1207 return ret
1208}
1209
1210func (af *apexFile) AvailableToPlatform() bool {
1211 if af.module == nil {
1212 return false
1213 }
1214 if am, ok := af.module.(android.ApexModule); ok {
1215 return am.AvailableFor(android.AvailableToPlatform)
1216 }
1217 return false
1218}
1219
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001220type apexBundle struct {
1221 android.ModuleBase
1222 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +09001223 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +09001224 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001225
Jiyong Park5d790c32019-11-15 18:40:32 +09001226 properties apexBundleProperties
1227 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +09001228 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001229
Jooyung Hanf21c7972019-12-16 22:32:06 +09001230 // specific to apex_vndk modules
1231 vndkProperties apexVndkProperties
1232
Colin Crossa4925902018-11-16 11:36:28 -08001233 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +09001234 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -07001235 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +09001236
Jiyong Park03b68dd2019-07-26 23:20:40 +09001237 prebuiltFileToDelete string
1238
Jiyong Park42cca6c2019-04-01 11:15:50 +09001239 public_key_file android.Path
1240 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001241
1242 container_certificate_file android.Path
1243 container_private_key_file android.Path
1244
Jooyung Han54aca7b2019-11-20 02:26:02 +09001245 fileContexts android.Path
1246
Jiyong Park8fd61922018-11-08 02:50:25 +09001247 // list of files to be included in this apex
1248 filesInfo []apexFile
1249
Jiyong Park956305c2020-01-09 12:32:06 +09001250 // list of module names that should be installed along with this APEX
1251 requiredDeps []string
1252
Jiyong Park956305c2020-01-09 12:32:06 +09001253 // list of module names that this APEX is including (to be shown via *-deps-info target)
Artur Satayev872a1442020-04-27 17:08:37 +01001254 android.ApexBundleDepsInfo
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001255
Sundong Ahnabb64432019-10-22 13:58:29 +09001256 testApex bool
1257 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001258 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +09001259 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +09001260
Jooyung Han214bf372019-11-12 13:03:50 +09001261 manifestJsonOut android.WritablePath
1262 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +09001263
Jooyung Han002ab682020-01-08 01:57:58 +09001264 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +09001265 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +09001266 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +09001267 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
1268 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +09001269
1270 // Suffix of module name in Android.mk
1271 // ".flattened", ".apex", ".zipapex", or ""
1272 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +09001273
1274 installedFilesFile android.WritablePath
Jiyong Park7cd10e32020-01-14 09:22:18 +09001275
1276 // Whether to create symlink to the system file instead of having a file
1277 // inside the apex or not
1278 linkToSystemLib bool
Jiyong Park19972c72020-01-28 20:05:29 +09001279
1280 // Struct holding the merged notice file paths in different formats
1281 mergedNotices android.NoticeOutputs
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001282}
1283
Jiyong Park397e55e2018-10-24 21:09:55 +09001284func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Jooyung Han01a868d2020-02-27 13:40:44 +09001285 nativeModules ApexNativeDependencies,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001286 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +09001287 // Use *FarVariation* to be able to depend on modules having
1288 // conflicting variations with this module. This is required since
1289 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
1290 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001291 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +09001292 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +09001293 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +09001294 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Jooyung Han01a868d2020-02-27 13:40:44 +09001295 }...), sharedLibTag, nativeModules.Native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001296
Jooyung Han643adc42020-02-27 13:50:06 +09001297 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
1298 {Mutator: "image", Variation: imageVariation},
1299 {Mutator: "link", Variation: "shared"},
1300 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
1301 }...), jniLibTag, nativeModules.Jni_libs...)
1302
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001303 ctx.AddFarVariationDependencies(append(target.Variations(),
1304 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
Jooyung Han01a868d2020-02-27 13:40:44 +09001305 executableTag, nativeModules.Binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +01001306
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001307 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001308 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001309 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Jooyung Han01a868d2020-02-27 13:40:44 +09001310 }...), testTag, nativeModules.Tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001311}
1312
Alex Light9670d332019-01-29 18:07:33 -08001313func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
1314 if ctx.Os().Class == android.Device {
1315 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
1316 } else {
1317 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
1318 if ctx.Os().Bionic() {
1319 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
1320 } else {
1321 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
1322 }
1323 }
1324}
1325
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001326func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Cross440e0d02020-06-11 11:32:11 -07001327 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) {
Jooyung Handc782442019-11-01 03:14:38 +09001328 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1329 }
1330
Jiyong Park397e55e2018-10-24 21:09:55 +09001331 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +09001332 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -08001333
1334 a.combineProperties(ctx)
1335
Jiyong Park397e55e2018-10-24 21:09:55 +09001336 has32BitTarget := false
1337 for _, target := range targets {
1338 if target.Arch.ArchType.Multilib == "lib32" {
1339 has32BitTarget = true
1340 }
1341 }
1342 for i, target := range targets {
Jooyung Han643adc42020-02-27 13:50:06 +09001343 // When multilib.* is omitted for native_shared_libs/jni_libs/tests, it implies
Jooyung Han01a868d2020-02-27 13:40:44 +09001344 // multilib.both
1345 addDependenciesForNativeModules(ctx,
1346 ApexNativeDependencies{
1347 Native_shared_libs: a.properties.Native_shared_libs,
1348 Tests: a.properties.Tests,
Jooyung Han643adc42020-02-27 13:50:06 +09001349 Jni_libs: a.properties.Jni_libs,
Jooyung Han01a868d2020-02-27 13:40:44 +09001350 Binaries: nil,
1351 },
1352 target, a.getImageVariation(config))
Roland Levillain630846d2019-06-26 12:48:34 +01001353
Jiyong Park397e55e2018-10-24 21:09:55 +09001354 // Add native modules targetting both ABIs
1355 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001356 a.properties.Multilib.Both,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001357 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001358 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001359
Alex Light3d673592019-01-18 14:37:31 -08001360 isPrimaryAbi := i == 0
1361 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +09001362 // When multilib.* is omitted for binaries, it implies
Jooyung Han01a868d2020-02-27 13:40:44 +09001363 // multilib.first
1364 addDependenciesForNativeModules(ctx,
1365 ApexNativeDependencies{
1366 Native_shared_libs: nil,
1367 Tests: nil,
Jooyung Han643adc42020-02-27 13:50:06 +09001368 Jni_libs: nil,
Jooyung Han01a868d2020-02-27 13:40:44 +09001369 Binaries: a.properties.Binaries,
1370 },
1371 target, a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001372
1373 // Add native modules targetting the first ABI
1374 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001375 a.properties.Multilib.First,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001376 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001377 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001378 }
1379
1380 switch target.Arch.ArchType.Multilib {
1381 case "lib32":
1382 // Add native modules targetting 32-bit ABI
1383 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001384 a.properties.Multilib.Lib32,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001385 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001386 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001387
1388 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001389 a.properties.Multilib.Prefer32,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001390 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001391 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001392 case "lib64":
1393 // Add native modules targetting 64-bit ABI
1394 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001395 a.properties.Multilib.Lib64,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001396 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001397 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001398
1399 if !has32BitTarget {
1400 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001401 a.properties.Multilib.Prefer32,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001402 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001403 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001404 }
1405 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001406 }
1407
Jiyong Parkce6aadc2019-11-20 13:58:28 +09001408 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
1409 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
1410 // b/144532908
1411 archForPrebuiltEtc := config.Arches()[0]
1412 for _, arch := range config.Arches() {
1413 // Prefer 64-bit arch if there is any
1414 if arch.ArchType.Multilib == "lib64" {
1415 archForPrebuiltEtc = arch
1416 break
1417 }
1418 }
1419 ctx.AddFarVariationDependencies([]blueprint.Variation{
1420 {Mutator: "os", Variation: ctx.Os().String()},
1421 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
1422 }, prebuiltTag, a.properties.Prebuilts...)
1423
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001424 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1425 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001426
Ulya Trafimovich44561882020-01-03 13:25:54 +00001427 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
1428 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
1429 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1430 javaLibTag, "jacocoagent")
1431 }
1432
Jiyong Park23c52b02019-02-02 13:13:47 +09001433 if String(a.properties.Key) == "" {
1434 ctx.ModuleErrorf("key is missing")
1435 return
1436 }
1437 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001438
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001439 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +09001440 if cert != "" {
1441 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001442 }
Jiyong Parkd1063c12019-07-17 20:08:41 +09001443
1444 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
1445 if len(a.properties.Uses_sdks) > 0 {
1446 sdkRefs := []android.SdkRef{}
1447 for _, str := range a.properties.Uses_sdks {
1448 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
1449 sdkRefs = append(sdkRefs, parsed)
1450 }
1451 a.BuildWithSdks(sdkRefs)
1452 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001453}
1454
Jiyong Park5d790c32019-11-15 18:40:32 +09001455func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Han938b5932020-06-20 12:47:47 +09001456 if a.overridableProperties.Allowed_files != nil {
1457 android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files)
1458 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001459 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1460 androidAppTag, a.overridableProperties.Apps...)
Jiyong Park69aeba92020-04-24 21:16:36 +09001461 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1462 rroTag, a.overridableProperties.Rros...)
Jiyong Park5d790c32019-11-15 18:40:32 +09001463}
1464
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001465func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1466 // direct deps of an APEX bundle are all part of the APEX bundle
1467 return true
1468}
1469
Colin Cross0ea8ba82019-06-06 14:33:29 -07001470func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001471 moduleName := ctx.ModuleName()
1472 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1473 // we check with the pseudo module name to see if its certificate is overridden.
1474 if a.vndkApex {
1475 moduleName = vndkApexName
1476 }
1477 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001478 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001479 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001480 }
1481 return String(a.properties.Certificate)
1482}
1483
Colin Cross41955e82019-05-29 14:40:35 -07001484func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1485 switch tag {
1486 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001487 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001488 default:
1489 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001490 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001491}
1492
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001493func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001494 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001495}
1496
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001497func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1498 return proptools.Bool(a.properties.Test_only_no_hashtree)
1499}
1500
Dario Frenica913392020-04-27 18:21:11 +01001501func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool {
1502 return proptools.Bool(a.properties.Test_only_unsigned_payload)
1503}
1504
Jiyong Park7c1dc612019-01-05 11:15:24 +09001505func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001506 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001507 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001508 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001509 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001510 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001511 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001512 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001513 }
1514}
1515
Jiyong Parkf97782b2019-02-13 20:28:58 +09001516func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1517 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1518 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1519 }
1520}
1521
Jiyong Park388ef3f2019-01-28 19:47:32 +09001522func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001523 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1524 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001525 }
1526
1527 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001528 globalSanitizerNames := []string{}
1529 if a.Host() {
1530 globalSanitizerNames = ctx.Config().SanitizeHost()
1531 } else {
1532 arches := ctx.Config().SanitizeDeviceArch()
1533 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1534 globalSanitizerNames = ctx.Config().SanitizeDevice()
1535 }
1536 }
1537 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001538}
1539
Jooyung Han8ce8db92020-05-15 19:05:05 +09001540func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) {
1541 if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") {
1542 for _, target := range ctx.MultiTargets() {
1543 if target.Arch.ArchType.Multilib == "lib64" {
1544 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
1545 {Mutator: "image", Variation: a.getImageVariation(ctx.DeviceConfig())},
1546 {Mutator: "link", Variation: "shared"},
1547 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
1548 }...), sharedLibTag, "libclang_rt.hwasan-aarch64-android")
1549 break
1550 }
1551 }
1552 }
1553}
1554
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001555var _ cc.Coverage = (*apexBundle)(nil)
1556
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001557func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
Colin Cross1a6acd42020-06-16 17:51:46 -07001558 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001559}
1560
1561func (a *apexBundle) PreventInstall() {
1562 a.properties.PreventInstall = true
1563}
1564
1565func (a *apexBundle) HideFromMake() {
1566 a.properties.HideFromMake = true
1567}
1568
Jiyong Park956305c2020-01-09 12:32:06 +09001569func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1570 a.properties.IsCoverageVariant = coverage
1571}
1572
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001573func (a *apexBundle) EnableCoverageIfNeeded() {}
1574
Jiyong Parkf653b052019-11-18 15:39:01 +09001575// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001576func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001577 // Decide the APEX-local directory by the multilib of the library
1578 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001579 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001580 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001581 case "lib32":
1582 dirInApex = "lib"
1583 case "lib64":
1584 dirInApex = "lib64"
1585 }
Colin Cross3b19f5d2019-09-17 14:45:31 -07001586 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001587 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001588 }
Jooyung Han35155c42020-02-06 17:33:20 +09001589 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Jiyong Park1833cef2019-12-13 13:28:36 +09001590 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001591 // Special case for Bionic libs and other libs installed with them. This is
1592 // to prevent those libs from being included in the search path
1593 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1594 // those libs in the Runtime APEX are available via the legacy paths in
1595 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1596 // to the legacy paths and thus will be loaded into the default linker
1597 // namespace (aka "platform" namespace). If the libs are directly in
1598 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1599 // into the runtime linker namespace, which will result in double loading of
1600 // them, which isn't supported.
1601 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001602 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001603
Jiyong Parkf653b052019-11-18 15:39:01 +09001604 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001605 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001606}
1607
Jiyong Park1833cef2019-12-13 13:28:36 +09001608func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jooyung Han35155c42020-02-06 17:33:20 +09001609 dirInApex := "bin"
Colin Cross3b19f5d2019-09-17 14:45:31 -07001610 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001611 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001612 }
Jooyung Han35155c42020-02-06 17:33:20 +09001613 dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001614 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001615 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001616 af.symlinks = cc.Symlinks()
Liz Kammer1c14a212020-05-12 15:26:55 -07001617 af.dataPaths = cc.DataPaths()
Jiyong Parkf653b052019-11-18 15:39:01 +09001618 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001619}
1620
Jiyong Park1833cef2019-12-13 13:28:36 +09001621func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001622 dirInApex := "bin"
1623 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001624 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001625}
Jiyong Park1833cef2019-12-13 13:28:36 +09001626func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001627 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001628 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1629 if err != nil {
1630 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001631 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001632 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001633 fileToCopy := android.PathForOutput(ctx, s)
1634 // NB: Since go binaries are static we don't need the module for anything here, which is
1635 // good since the go tool is a blueprint.Module not an android.Module like we would
1636 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001637 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001638}
1639
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001640func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001641 dirInApex := filepath.Join("bin", sh.SubDir())
1642 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001643 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001644 af.symlinks = sh.Symlinks()
1645 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001646}
1647
Jiyong Parka62aa232020-05-28 23:46:55 +09001648type javaDependency interface {
Ulyana Trafimovich5539e7b2020-06-04 14:08:17 +00001649 DexJarBuildPath() android.Path
Jiyong Park77acec62020-06-01 21:39:15 +09001650 JacocoReportClassesFile() android.Path
Jiyong Parka62aa232020-05-28 23:46:55 +09001651 Stem() string
1652}
1653
1654func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, module android.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001655 dirInApex := "javalib"
Ulyana Trafimovich5539e7b2020-06-04 14:08:17 +00001656 fileToCopy := lib.DexJarBuildPath()
Paul Duffin44b481b2020-06-17 16:59:43 +01001657 // Remove prebuilt_ if necessary so the source and prebuilt modules have the same name.
1658 name := strings.TrimPrefix(module.Name(), "prebuilt_")
1659 af := newApexFile(ctx, fileToCopy, name, dirInApex, javaSharedLib, module)
Jiyong Park618922e2020-01-08 13:35:43 +09001660 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
Jiyong Parka62aa232020-05-28 23:46:55 +09001661 af.stem = lib.Stem() + ".jar"
Jiyong Park618922e2020-01-08 13:35:43 +09001662 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001663}
1664
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001665func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001666 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1667 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001668 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001669}
1670
atrost6e126252020-01-27 17:01:16 +00001671func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1672 dirInApex := filepath.Join("etc", config.SubDir())
1673 fileToCopy := config.CompatConfig()
1674 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1675}
1676
Jiyong Park1833cef2019-12-13 13:28:36 +09001677func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001678 android.Module
1679 Privileged() bool
Jooyung Han39ee1192020-03-23 20:21:11 +09001680 InstallApkName() string
Jiyong Parkf653b052019-11-18 15:39:01 +09001681 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001682 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001683 Certificate() java.Certificate
Jooyung Han39ee1192020-03-23 20:21:11 +09001684}) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001685 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001686 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001687 appDir = "priv-app"
1688 }
Jooyung Han39ee1192020-03-23 20:21:11 +09001689 dirInApex := filepath.Join(appDir, aapp.InstallApkName())
Jiyong Parkf653b052019-11-18 15:39:01 +09001690 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001691 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1692 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross503c1d02020-01-28 14:00:53 -08001693 af.certificate = aapp.Certificate()
Jiyong Parkcfaa1642020-02-28 16:51:07 +09001694
1695 if app, ok := aapp.(interface {
1696 OverriddenManifestPackageName() string
1697 }); ok {
1698 af.overriddenPackageName = app.OverriddenManifestPackageName()
1699 }
Jiyong Park618922e2020-01-08 13:35:43 +09001700 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001701}
1702
Jiyong Park69aeba92020-04-24 21:16:36 +09001703func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile {
1704 rroDir := "overlay"
1705 dirInApex := filepath.Join(rroDir, rro.Theme())
1706 fileToCopy := rro.OutputFile()
1707 af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro)
1708 af.certificate = rro.Certificate()
1709
1710 if a, ok := rro.(interface {
1711 OverriddenManifestPackageName() string
1712 }); ok {
1713 af.overriddenPackageName = a.OverriddenManifestPackageName()
1714 }
1715 return af
1716}
1717
Roland Levillain935639d2019-08-13 14:55:28 +01001718// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1719type flattenedApexContext struct {
1720 android.ModuleContext
1721}
1722
1723func (c *flattenedApexContext) InstallBypassMake() bool {
1724 return true
1725}
1726
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001727// Function called while walking an APEX's payload dependencies.
1728//
1729// Return true if the `to` module should be visited, false otherwise.
1730type payloadDepsCallback func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool
1731
Jiyong Park201cedd2020-02-07 17:25:49 +09001732// Visit dependencies that contributes to the payload of this APEX
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001733func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, do payloadDepsCallback) {
Paul Duffindf915ff2020-03-30 17:58:21 +01001734 ctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0f80c182020-01-31 02:49:53 +09001735 am, ok := child.(android.ApexModule)
1736 if !ok || !am.CanHaveApexVariants() {
1737 return false
1738 }
1739
1740 // Check for the direct dependencies that contribute to the payload
1741 if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
1742 if dt.payload {
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001743 return do(ctx, parent, am, false /* externalDep */)
Jiyong Park0f80c182020-01-31 02:49:53 +09001744 }
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001745 // As soon as the dependency graph crosses the APEX boundary, don't go further.
Jiyong Park0f80c182020-01-31 02:49:53 +09001746 return false
1747 }
1748
1749 // Check for the indirect dependencies if it is considered as part of the APEX
Jooyung Han5e9013b2020-03-10 06:23:13 +09001750 if am.ApexName() != "" {
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001751 return do(ctx, parent, am, false /* externalDep */)
Jiyong Park0f80c182020-01-31 02:49:53 +09001752 }
1753
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001754 return do(ctx, parent, am, true /* externalDep */)
Jiyong Park0f80c182020-01-31 02:49:53 +09001755 })
1756}
1757
Jooyung Han03b51852020-02-26 22:45:42 +09001758func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
1759 ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
Jooyung Hanaed150d2020-04-02 01:41:41 +09001760 intVer, err := android.ApiStrToNum(ctx, ver)
1761 if err != nil {
1762 ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
Jooyung Han03b51852020-02-26 22:45:42 +09001763 }
Jooyung Hanaed150d2020-04-02 01:41:41 +09001764 return intVer
Jooyung Han03b51852020-02-26 22:45:42 +09001765}
1766
Artur Satayev849f8442020-04-28 14:57:42 +01001767func (a *apexBundle) Updatable() bool {
1768 return proptools.Bool(a.properties.Updatable)
1769}
1770
1771var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil)
1772
Jiyong Park201cedd2020-02-07 17:25:49 +09001773// Ensures that the dependencies are marked as available for this APEX
1774func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
1775 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
1776 if ctx.Host() || a.testApex || a.vndkApex {
1777 return
1778 }
1779
Jiyong Park58d10902020-03-28 14:43:19 +09001780 // Coverage build adds additional dependencies for the coverage-only runtime libraries.
1781 // Requiring them and their transitive depencies with apex_available is not right
1782 // because they just add noise.
1783 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) {
1784 return
1785 }
1786
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001787 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
1788 if externalDep {
1789 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1790 return false
1791 }
1792
Jiyong Park201cedd2020-02-07 17:25:49 +09001793 apexName := ctx.ModuleName()
Jooyung Han5e9013b2020-03-10 06:23:13 +09001794 fromName := ctx.OtherModuleName(from)
1795 toName := ctx.OtherModuleName(to)
Paul Duffin65347702020-03-31 15:23:40 +01001796
1797 // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither
1798 // do any of its dependencies.
1799 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
1800 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1801 return false
1802 }
1803
Colin Cross440e0d02020-06-11 11:32:11 -07001804 if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001805 return true
Jiyong Park201cedd2020-02-07 17:25:49 +09001806 }
Jiyong Park1c7e9622020-05-07 16:12:13 +09001807 ctx.ModuleErrorf("%q requires %q that is not available for the APEX. Dependency path:%s", fromName, toName, ctx.GetPathString(true))
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001808 // Visit this module's dependencies to check and report any issues with their availability.
1809 return true
Jiyong Park201cedd2020-02-07 17:25:49 +09001810 })
1811}
1812
Jooyung Han548640b2020-04-27 12:10:30 +09001813func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
Artur Satayev849f8442020-04-28 14:57:42 +01001814 if a.Updatable() {
Jooyung Han548640b2020-04-27 12:10:30 +09001815 if String(a.properties.Min_sdk_version) == "" {
1816 ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
1817 }
Artur Satayev8cf899a2020-04-15 17:29:42 +01001818
1819 a.checkJavaStableSdkVersion(ctx)
Jooyung Han548640b2020-04-27 12:10:30 +09001820 }
1821}
1822
Jiyong Park7d95a512020-05-10 15:16:24 +09001823// Ensures that a lib providing stub isn't statically linked
1824func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) {
1825 // Practically, we only care about regular APEXes on the device.
1826 if ctx.Host() || a.testApex || a.vndkApex {
1827 return
1828 }
1829
1830 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
1831 if ccm, ok := to.(*cc.Module); ok {
1832 apexName := ctx.ModuleName()
1833 fromName := ctx.OtherModuleName(from)
1834 toName := ctx.OtherModuleName(to)
1835
1836 // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither
1837 // do any of its dependencies.
1838 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
1839 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1840 return false
1841 }
1842
1843 // TODO(jiyong) remove this check when R is published to AOSP. Currently, libstatssocket
1844 // is capable of providing a stub variant, but is being statically linked from the bluetooth
1845 // APEX.
1846 if toName == "libstatssocket" {
1847 return false
1848 }
1849
1850 // The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule.
1851 // It can't make the static dependencies dynamic because it can't
1852 // do the dynamic linking for itself.
1853 if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump") {
1854 return false
1855 }
1856
1857 isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !android.DirectlyInApex(apexName, toName)
1858 if isStubLibraryFromOtherApex && !externalDep {
1859 ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
1860 "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))
1861 }
1862
1863 }
1864 return true
1865 })
1866}
1867
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001868func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Martin Stjernholm56507b42020-06-24 22:31:36 +01001869 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuildApps()
Sundong Ahnabb64432019-10-22 13:58:29 +09001870 switch a.properties.ApexType {
1871 case imageApex:
1872 if buildFlattenedAsDefault {
1873 a.suffix = imageApexSuffix
1874 } else {
1875 a.suffix = ""
1876 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001877
1878 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09001879 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001880 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001881 }
1882 case zipApex:
1883 if proptools.String(a.properties.Payload_type) == "zip" {
1884 a.suffix = ""
1885 a.primaryApexType = true
1886 } else {
1887 a.suffix = zipApexSuffix
1888 }
1889 case flattenedApex:
1890 if buildFlattenedAsDefault {
1891 a.suffix = ""
1892 a.primaryApexType = true
1893 } else {
1894 a.suffix = flattenedSuffix
1895 }
Alex Light5098a612018-11-29 17:12:15 -08001896 }
1897
Roland Levillain630846d2019-06-26 12:48:34 +01001898 if len(a.properties.Tests) > 0 && !a.testApex {
1899 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
1900 return
1901 }
1902
Jiyong Park0f80c182020-01-31 02:49:53 +09001903 a.checkApexAvailability(ctx)
Jooyung Han548640b2020-04-27 12:10:30 +09001904 a.checkUpdatable(ctx)
Jiyong Park7d95a512020-05-10 15:16:24 +09001905 a.checkStaticLinkingToStubLibraries(ctx)
Jiyong Park678c8812020-02-07 17:25:49 +09001906
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001907 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1908
Jooyung Hane1633032019-08-01 17:41:43 +09001909 // native lib dependencies
1910 var provideNativeLibs []string
1911 var requireNativeLibs []string
1912
Jooyung Han5c998b92019-06-27 11:30:33 +09001913 // Check if "uses" requirements are met with dependent apexBundles
1914 var providedNativeSharedLibs []string
1915 useVendor := proptools.Bool(a.properties.Use_vendor)
1916 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
1917 if ctx.OtherModuleDependencyTag(m) != usesTag {
1918 return
1919 }
1920 otherName := ctx.OtherModuleName(m)
1921 other, ok := m.(*apexBundle)
1922 if !ok {
1923 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
1924 return
1925 }
1926 if proptools.Bool(other.properties.Use_vendor) != useVendor {
1927 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
1928 return
1929 }
1930 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
1931 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
1932 return
1933 }
1934 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
1935 })
1936
Jiyong Parkf653b052019-11-18 15:39:01 +09001937 var filesInfo []apexFile
Jiyong Park678c8812020-02-07 17:25:49 +09001938 // TODO(jiyong) do this using walkPayloadDeps
Alex Light778127a2019-02-27 14:19:50 -08001939 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001940 depTag := ctx.OtherModuleDependencyTag(child)
Paul Duffindddd5462020-04-07 15:25:44 +01001941 if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
1942 return false
1943 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001944 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001945 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001946 switch depTag {
Jooyung Han643adc42020-02-27 13:50:06 +09001947 case sharedLibTag, jniLibTag:
1948 isJniLib := depTag == jniLibTag
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09001949 if c, ok := child.(*cc.Module); ok {
Jooyung Han643adc42020-02-27 13:50:06 +09001950 fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
1951 fi.isJniLib = isJniLib
1952 filesInfo = append(filesInfo, fi)
Jooyung Han45a96772020-06-15 14:59:42 +09001953 // Collect the list of stub-providing libs except:
1954 // - VNDK libs are only for vendors
1955 // - bootstrap bionic libs are treated as provided by system
1956 if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001957 provideNativeLibs = append(provideNativeLibs, fi.Stem())
1958 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001959 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001960 } else {
Jooyung Han643adc42020-02-27 13:50:06 +09001961 propertyName := "native_shared_libs"
1962 if isJniLib {
1963 propertyName = "jni_libs"
1964 }
1965 ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001966 }
1967 case executableTag:
1968 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001969 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001970 return true // track transitive dependencies
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001971 } else if sh, ok := child.(*sh.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001972 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001973 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001974 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001975 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001976 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001977 } else {
Alex Light778127a2019-02-27 14:19:50 -08001978 ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001979 }
1980 case javaLibTag:
Jiyong Park77acec62020-06-01 21:39:15 +09001981 switch child.(type) {
Paul Duffineedc5d52020-06-12 17:46:39 +01001982 case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport:
Jiyong Park77acec62020-06-01 21:39:15 +09001983 af := apexFileForJavaLibrary(ctx, child.(javaDependency), child.(android.Module))
Jooyung Han58f26ab2019-12-18 15:34:32 +09001984 if !af.Ok() {
1985 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1986 return false
1987 }
1988 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09001989 return true // track transitive dependencies
Jiyong Park77acec62020-06-01 21:39:15 +09001990 default:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001991 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001992 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001993 case androidAppTag:
Jiyong Parkf653b052019-11-18 15:39:01 +09001994 if ap, ok := child.(*java.AndroidApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001995 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Jiyong Parkf653b052019-11-18 15:39:01 +09001996 return true // track transitive dependencies
1997 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001998 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Dario Freni6f3937c2019-12-20 22:58:03 +00001999 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09002000 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Sasha Smundak18d98bc2020-05-27 16:36:07 -07002001 } else if ap, ok := child.(*java.AndroidAppSet); ok {
2002 appDir := "app"
2003 if ap.Privileged() {
2004 appDir = "priv-app"
2005 }
2006 af := newApexFile(ctx, ap.OutputFile(), ap.Name(),
2007 filepath.Join(appDir, ap.BaseModuleName()), appSet, ap)
2008 af.certificate = java.PresignedCertificate
2009 filesInfo = append(filesInfo, af)
Jiyong Parkf653b052019-11-18 15:39:01 +09002010 } else {
2011 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
2012 }
Jiyong Park69aeba92020-04-24 21:16:36 +09002013 case rroTag:
2014 if rro, ok := child.(java.RuntimeResourceOverlayModule); ok {
2015 filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro))
2016 } else {
2017 ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
2018 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002019 case prebuiltTag:
Jaewoong Jung4b79e982020-06-01 10:45:49 -07002020 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002021 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
atrost6e126252020-01-27 17:01:16 +00002022 } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
2023 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002024 } else {
atrost6e126252020-01-27 17:01:16 +00002025 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09002026 }
Roland Levillain630846d2019-06-26 12:48:34 +01002027 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01002028 if ccTest, ok := child.(*cc.Module); ok {
2029 if ccTest.IsTestPerSrcAllTestsVariation() {
2030 // Multiple-output test module (where `test_per_src: true`).
2031 //
2032 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
2033 // We do not add this variation to `filesInfo`, as it has no output;
2034 // however, we do add the other variations of this module as indirect
2035 // dependencies (see below).
Roland Levillain9b5fde92019-06-28 15:41:19 +01002036 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01002037 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09002038 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09002039 af.class = nativeTest
2040 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01002041 }
Jiyong Parkaf9539f2020-05-04 10:31:32 +09002042 return true // track transitive dependencies
Roland Levillain630846d2019-06-26 12:48:34 +01002043 } else {
2044 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
2045 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09002046 case keyTag:
2047 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002048 a.private_key_file = key.private_key_file
2049 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09002050 } else {
2051 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002052 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002053 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002054 case certificateTag:
2055 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002056 a.container_certificate_file = dep.Certificate.Pem
2057 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002058 } else {
2059 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
2060 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09002061 case android.PrebuiltDepTag:
2062 // If the prebuilt is force disabled, remember to delete the prebuilt file
2063 // that might have been installed in the previous builds
2064 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
2065 a.prebuiltFileToDelete = prebuilt.InstallFilename()
2066 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002067 }
Jooyung Han8aee2042019-10-29 05:08:31 +09002068 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002069 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09002070 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01002071 // We cannot use a switch statement on `depTag` here as the checked
2072 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09002073 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002074 if cc, ok := child.(*cc.Module); ok {
2075 if android.InList(cc.Name(), providedNativeSharedLibs) {
2076 // If we're using a shared library which is provided from other APEX,
2077 // don't include it in this APEX
2078 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09002079 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09002080 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
2081 af.transitiveDep = true
Jooyung Han671f1ce2019-12-17 12:47:13 +09002082 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002083 // If the dependency is a stubs lib, don't include it in this APEX,
2084 // but make sure that the lib is installed on the device.
2085 // In case no APEX is having the lib, the lib is installed to the system
2086 // partition.
2087 //
2088 // Always include if we are a host-apex however since those won't have any
2089 // system libraries.
Yo Chiang29555d52020-05-06 15:59:59 +08002090 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.BaseModuleName(), a.requiredDeps) {
2091 a.requiredDeps = append(a.requiredDeps, cc.BaseModuleName())
Roland Levillainf89cd092019-07-29 16:22:59 +01002092 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09002093 requireNativeLibs = append(requireNativeLibs, af.Stem())
Roland Levillainf89cd092019-07-29 16:22:59 +01002094 // Don't track further
2095 return false
2096 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002097 filesInfo = append(filesInfo, af)
2098 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09002099 }
Roland Levillainf89cd092019-07-29 16:22:59 +01002100 } else if cc.IsTestPerSrcDepTag(depTag) {
2101 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002102 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01002103 // Handle modules created as `test_per_src` variations of a single test module:
2104 // use the name of the generated test binary (`fileToCopy`) instead of the name
2105 // of the original test module (`depName`, shared by all `test_per_src`
2106 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09002107 af.moduleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002108 // these are not considered transitive dep
2109 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09002110 filesInfo = append(filesInfo, af)
2111 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01002112 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09002113 } else if java.IsJniDepTag(depTag) {
Jooyung Hanb7bebe22020-02-25 16:59:29 +09002114 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
2115 return false
Jiyong Parke3833882020-02-17 17:28:10 +09002116 } else if java.IsXmlPermissionsFileDepTag(depTag) {
Jaewoong Jung4b79e982020-06-01 10:45:49 -07002117 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Parke3833882020-02-17 17:28:10 +09002118 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
2119 }
Jooyung Han9c80bae2019-08-20 17:30:57 +09002120 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Jiyong Park1c7e9622020-05-07 16:12:13 +09002121 ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002122 }
2123 }
2124 }
2125 return false
2126 })
2127
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002128 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
2129 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
2130 // via the global boot image config.
2131 if a.artApex {
Tim Joinesc1ef1bb2020-03-18 18:00:41 +00002132 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002133 dirInApex := filepath.Join("javalib", arch.String())
2134 for _, f := range files {
2135 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09002136 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09002137 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002138 }
2139 }
2140 }
2141
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002142 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09002143 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
2144 return
2145 }
2146
Jiyong Park8fd61922018-11-08 02:50:25 +09002147 // remove duplicates in filesInfo
2148 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002149 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002150 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002151 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002152 if e, ok := encountered[dest]; !ok {
2153 encountered[dest] = f
2154 } else {
2155 // If a module is directly included and also transitively depended on
2156 // consider it as directly included.
2157 e.transitiveDep = e.transitiveDep && f.transitiveDep
2158 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002159 }
2160 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002161 var result []apexFile
2162 for _, v := range encountered {
2163 result = append(result, v)
2164 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002165 return result
2166 }
2167 filesInfo = removeDup(filesInfo)
2168
2169 // to have consistent build rules
2170 sort.Slice(filesInfo, func(i, j int) bool {
2171 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
2172 })
2173
Jiyong Park8fd61922018-11-08 02:50:25 +09002174 a.installDir = android.PathForModuleInstall(ctx, "apex")
2175 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002176
Jooyung Han54aca7b2019-11-20 02:26:02 +09002177 if a.properties.ApexType != zipApex {
2178 if a.properties.File_contexts == nil {
2179 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
2180 } else {
2181 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
2182 if a.Platform() {
2183 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
2184 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
2185 }
2186 }
2187 }
2188 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
2189 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
2190 return
2191 }
2192 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002193 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2194 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2195 // the same library in the system partition, thus effectively sharing the same libraries
2196 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2197 // in the APEX.
2198 a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
2199 a.installable() &&
2200 !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002201
Jiyong Park9d677202020-02-19 16:29:35 +09002202 // We don't need the optimization for updatable APEXes, as it might give false signal
2203 // to the system health when the APEXes are still bundled (b/149805758)
Artur Satayev849f8442020-04-28 14:57:42 +01002204 if a.Updatable() && a.properties.ApexType == imageApex {
Jiyong Park9d677202020-02-19 16:29:35 +09002205 a.linkToSystemLib = false
2206 }
2207
Jiyong Park638d30e2020-02-26 18:27:19 +09002208 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2209 if ctx.Host() {
2210 a.linkToSystemLib = false
2211 }
2212
Jooyung Hand15aa1f2019-09-27 00:38:03 +09002213 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09002214 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
2215
2216 a.setCertificateAndPrivateKey(ctx)
2217 if a.properties.ApexType == flattenedApex {
2218 a.buildFlattenedApex(ctx)
2219 } else {
2220 a.buildUnflattenedApex(ctx)
2221 }
2222
Jooyung Han002ab682020-01-08 01:57:58 +09002223 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09002224
2225 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002226}
2227
Artur Satayev8cf899a2020-04-15 17:29:42 +01002228// Enforce that Java deps of the apex are using stable SDKs to compile
2229func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
2230 // Visit direct deps only. As long as we guarantee top-level deps are using
2231 // stable SDKs, java's checkLinkType guarantees correct usage for transitive deps
2232 ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
2233 tag := ctx.OtherModuleDependencyTag(module)
2234 switch tag {
2235 case javaLibTag, androidAppTag:
2236 if m, ok := module.(interface{ CheckStableSdkVersion() error }); ok {
2237 if err := m.CheckStableSdkVersion(); err != nil {
2238 ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err)
2239 }
2240 }
2241 }
2242 })
2243}
2244
Colin Cross440e0d02020-06-11 11:32:11 -07002245func baselineApexAvailable(apex, moduleName string) bool {
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002246 key := apex
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002247 moduleName = normalizeModuleName(moduleName)
2248
Colin Cross440e0d02020-06-11 11:32:11 -07002249 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002250 return true
2251 }
2252
2253 key = android.AvailableToAnyApex
Colin Cross440e0d02020-06-11 11:32:11 -07002254 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002255 return true
2256 }
2257
2258 return false
2259}
2260
2261func normalizeModuleName(moduleName string) string {
Jiyong Park0f80c182020-01-31 02:49:53 +09002262 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2263 // system. Trim the prefix for the check since they are confusing
2264 moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
2265 if strings.HasPrefix(moduleName, "libclang_rt.") {
2266 // This module has many arch variants that depend on the product being built.
2267 // We don't want to list them all
2268 moduleName = "libclang_rt"
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002269 }
Jooyung Hanacc7bbe2020-05-20 09:06:00 +09002270 if strings.HasPrefix(moduleName, "androidx.") {
2271 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries
2272 moduleName = "androidx"
2273 }
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002274 return moduleName
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002275}
2276
Jooyung Han344d5432019-08-23 11:17:39 +09002277func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09002278 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002279 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08002280 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09002281 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08002282 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002283 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09002284 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08002285 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002286 return module
2287}
Jiyong Park30ca9372019-02-07 16:27:23 +09002288
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002289func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002290 bundle := newApexBundle()
2291 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002292 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09002293 return bundle
2294}
2295
Jiyong Parkfce0b422020-02-11 03:56:06 +09002296// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2297// certain compatibility checks such as apex_available are not done for apex_test.
Jooyung Han344d5432019-08-23 11:17:39 +09002298func testApexBundleFactory() android.Module {
2299 bundle := newApexBundle()
2300 bundle.testApex = true
2301 return bundle
2302}
2303
Jiyong Parkfce0b422020-02-11 03:56:06 +09002304// apex packages other modules into an APEX file which is a packaging format for system-level
2305// components like binaries, shared libraries, etc.
Jiyong Parkd1063c12019-07-17 20:08:41 +09002306func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002307 return newApexBundle()
2308}
2309
Jiyong Park30ca9372019-02-07 16:27:23 +09002310//
2311// Defaults
2312//
2313type Defaults struct {
2314 android.ModuleBase
2315 android.DefaultsModuleBase
2316}
2317
Jiyong Park30ca9372019-02-07 16:27:23 +09002318func defaultsFactory() android.Module {
2319 return DefaultsFactory()
2320}
2321
2322func DefaultsFactory(props ...interface{}) android.Module {
2323 module := &Defaults{}
2324
2325 module.AddProperties(props...)
2326 module.AddProperties(
2327 &apexBundleProperties{},
2328 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09002329 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09002330 )
2331
2332 android.InitDefaultsModule(module)
2333 return module
2334}
Jiyong Park5d790c32019-11-15 18:40:32 +09002335
2336//
2337// OverrideApex
2338//
2339type OverrideApex struct {
2340 android.ModuleBase
2341 android.OverrideModuleBase
2342}
2343
2344func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2345 // All the overrides happen in the base module.
2346}
2347
2348// override_apex is used to create an apex module based on another apex module
2349// by overriding some of its properties.
2350func overrideApexFactory() android.Module {
2351 m := &OverrideApex{}
2352 m.AddProperties(&overridableProperties{})
2353
2354 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2355 android.InitOverrideModule(m)
2356 return m
2357}