blob: 840dd49834816c2f7eb4ad56d824a550a0b937e6 [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",
Jiyong Park0f80c182020-01-31 02:49:53 +0900372 "libc_scudo",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000373 "libcodec2",
Jiyong Park0f80c182020-01-31 02:49:53 +0900374 "libcodec2_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000375 "libcodec2_hidl@1.0",
Jiyong Park0f80c182020-01-31 02:49:53 +0900376 "libcodec2_hidl@1.1",
377 "libcodec2_internal",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000378 "libcodec2_soft_aacdec",
379 "libcodec2_soft_aacenc",
380 "libcodec2_soft_amrnbdec",
381 "libcodec2_soft_amrnbenc",
382 "libcodec2_soft_amrwbdec",
383 "libcodec2_soft_amrwbenc",
384 "libcodec2_soft_av1dec_gav1",
385 "libcodec2_soft_avcdec",
386 "libcodec2_soft_avcenc",
387 "libcodec2_soft_common",
388 "libcodec2_soft_flacdec",
389 "libcodec2_soft_flacenc",
390 "libcodec2_soft_g711alawdec",
391 "libcodec2_soft_g711mlawdec",
392 "libcodec2_soft_gsmdec",
393 "libcodec2_soft_h263dec",
394 "libcodec2_soft_h263enc",
395 "libcodec2_soft_hevcdec",
396 "libcodec2_soft_hevcenc",
397 "libcodec2_soft_mp3dec",
398 "libcodec2_soft_mpeg2dec",
399 "libcodec2_soft_mpeg4dec",
400 "libcodec2_soft_mpeg4enc",
401 "libcodec2_soft_opusdec",
402 "libcodec2_soft_opusenc",
403 "libcodec2_soft_rawdec",
404 "libcodec2_soft_vorbisdec",
405 "libcodec2_soft_vp8dec",
406 "libcodec2_soft_vp8enc",
407 "libcodec2_soft_vp9dec",
408 "libcodec2_soft_vp9enc",
409 "libcodec2_vndk",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000410 "libdexfile_support",
Jiyong Park0f80c182020-01-31 02:49:53 +0900411 "libdvr_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000412 "libfmq",
Jiyong Park0f80c182020-01-31 02:49:53 +0900413 "libfmq",
414 "libgav1",
415 "libgralloctypes",
416 "libgrallocusage",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000417 "libgraphicsenv",
Jiyong Park0f80c182020-01-31 02:49:53 +0900418 "libgsm",
419 "libgui_bufferqueue_static",
420 "libgui_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000421 "libhardware",
Jiyong Park0f80c182020-01-31 02:49:53 +0900422 "libhardware_headers",
423 "libhevcdec",
424 "libhevcenc",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000425 "libion",
Jiyong Park0f80c182020-01-31 02:49:53 +0900426 "libjpeg",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000427 "liblzma",
Jiyong Park0f80c182020-01-31 02:49:53 +0900428 "libmath",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000429 "libmedia_codecserviceregistrant",
Jiyong Park0f80c182020-01-31 02:49:53 +0900430 "libmedia_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900431 "libmpeg2dec",
432 "libnativebase_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000433 "libnativebridge_lazy",
434 "libnativeloader_lazy",
Jiyong Park0f80c182020-01-31 02:49:53 +0900435 "libnativewindow_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900436 "libpdx_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000437 "libscudo_wrapper",
438 "libsfplugin_ccodec_utils",
439 "libstagefright_amrnb_common",
Jiyong Park0f80c182020-01-31 02:49:53 +0900440 "libstagefright_amrnbdec",
441 "libstagefright_amrnbenc",
442 "libstagefright_amrwbdec",
443 "libstagefright_amrwbenc",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000444 "libstagefright_bufferpool@2.0.1",
445 "libstagefright_bufferqueue_helper",
446 "libstagefright_enc_common",
447 "libstagefright_flacdec",
448 "libstagefright_foundation",
Jiyong Park0f80c182020-01-31 02:49:53 +0900449 "libstagefright_foundation_headers",
450 "libstagefright_headers",
451 "libstagefright_m4vh263dec",
452 "libstagefright_m4vh263enc",
453 "libstagefright_mp3dec",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000454 "libsync",
455 "libui",
Jiyong Park0f80c182020-01-31 02:49:53 +0900456 "libui_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000457 "libunwindstack",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000458 "libvorbisidec",
459 "libvpx",
Jiyong Park0f80c182020-01-31 02:49:53 +0900460 "libyuv",
461 "libyuv_static",
462 "media_ndk_headers",
463 "media_plugin_headers",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000464 "mediaswcodec",
Jiyong Park0f80c182020-01-31 02:49:53 +0900465 }
466 //
467 // Module separator
468 //
469 m["com.android.mediaprovider"] = []string{
470 "MediaProvider",
471 "MediaProviderGoogle",
472 "fmtlib_ndk",
Jiyong Park0f80c182020-01-31 02:49:53 +0900473 "libbase_ndk",
474 "libfuse",
475 "libfuse_jni",
Jiyong Park0f80c182020-01-31 02:49:53 +0900476 }
477 //
478 // Module separator
479 //
480 m["com.android.permission"] = []string{
Jiyong Park0f80c182020-01-31 02:49:53 +0900481 "kotlin-annotations",
482 "kotlin-stdlib",
483 "kotlin-stdlib-jdk7",
484 "kotlin-stdlib-jdk8",
485 "kotlinx-coroutines-android",
486 "kotlinx-coroutines-android-nodeps",
487 "kotlinx-coroutines-core",
488 "kotlinx-coroutines-core-nodeps",
Jiyong Park0f80c182020-01-31 02:49:53 +0900489 "permissioncontroller-statsd",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000490 }
491 //
492 // Module separator
493 //
494 m["com.android.runtime"] = []string{
Jiyong Park0f80c182020-01-31 02:49:53 +0900495 "bionic_libc_platform_headers",
Jiyong Park0f80c182020-01-31 02:49:53 +0900496 "libarm-optimized-routines-math",
Jiyong Park0f80c182020-01-31 02:49:53 +0900497 "libc_aeabi",
498 "libc_bionic",
499 "libc_bionic_ndk",
500 "libc_bootstrap",
501 "libc_common",
502 "libc_common_shared",
503 "libc_common_static",
504 "libc_dns",
505 "libc_dynamic_dispatch",
506 "libc_fortify",
507 "libc_freebsd",
508 "libc_freebsd_large_stack",
509 "libc_gdtoa",
Jiyong Park0f80c182020-01-31 02:49:53 +0900510 "libc_init_dynamic",
511 "libc_init_static",
512 "libc_jemalloc_wrapper",
513 "libc_netbsd",
514 "libc_nomalloc",
515 "libc_nopthread",
516 "libc_openbsd",
517 "libc_openbsd_large_stack",
518 "libc_openbsd_ndk",
519 "libc_pthread",
520 "libc_static_dispatch",
521 "libc_syscalls",
522 "libc_tzcode",
523 "libc_unwind_static",
Jiyong Park0f80c182020-01-31 02:49:53 +0900524 "libdebuggerd",
525 "libdebuggerd_common_headers",
526 "libdebuggerd_handler_core",
527 "libdebuggerd_handler_fallback",
528 "libdexfile_external_headers",
529 "libdexfile_support",
530 "libdexfile_support_static",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900531 "libdl_static",
Jiyong Park0f80c182020-01-31 02:49:53 +0900532 "libjemalloc5",
533 "liblinker_main",
534 "liblinker_malloc",
Jiyong Park0f80c182020-01-31 02:49:53 +0900535 "liblz4",
536 "liblzma",
Jiyong Park0f80c182020-01-31 02:49:53 +0900537 "libprocinfo",
538 "libpropertyinfoparser",
539 "libscudo",
540 "libstdc++",
Jiyong Park0f80c182020-01-31 02:49:53 +0900541 "libsystemproperties",
542 "libtombstoned_client_static",
543 "libunwindstack",
Jiyong Park0f80c182020-01-31 02:49:53 +0900544 "libz",
545 "libziparchive",
546 }
547 //
548 // Module separator
549 //
Jiyong Park0f80c182020-01-31 02:49:53 +0900550 m["com.android.tethering"] = []string{
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900551 "android.hardware.tetheroffload.config-V1.0-java",
552 "android.hardware.tetheroffload.control-V1.0-java",
553 "android.hidl.base-V1.0-java",
554 "ipmemorystore-aidl-interfaces-java",
Jiyong Park0f80c182020-01-31 02:49:53 +0900555 "libcgrouprc",
556 "libcgrouprc_format",
Jiyong Park0f80c182020-01-31 02:49:53 +0900557 "libtetherutilsjni",
Jiyong Park0f80c182020-01-31 02:49:53 +0900558 "libvndksupport",
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900559 "net-utils-framework-common",
560 "netd_aidl_interface-V3-java",
561 "netlink-client",
562 "networkstack-aidl-interfaces-java",
Jiyong Park0f80c182020-01-31 02:49:53 +0900563 "tethering-aidl-interfaces-java",
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900564 "TetheringApiCurrentLib",
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000565 }
566 //
567 // Module separator
568 //
Jiyong Park0f80c182020-01-31 02:49:53 +0900569 m["com.android.wifi"] = []string{
570 "PlatformProperties",
571 "android.hardware.wifi-V1.0-java",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900572 "android.hardware.wifi-V1.0-java-constants",
Jiyong Park0f80c182020-01-31 02:49:53 +0900573 "android.hardware.wifi-V1.1-java",
574 "android.hardware.wifi-V1.2-java",
575 "android.hardware.wifi-V1.3-java",
576 "android.hardware.wifi-V1.4-java",
577 "android.hardware.wifi.hostapd-V1.0-java",
578 "android.hardware.wifi.hostapd-V1.1-java",
579 "android.hardware.wifi.hostapd-V1.2-java",
580 "android.hardware.wifi.supplicant-V1.0-java",
581 "android.hardware.wifi.supplicant-V1.1-java",
582 "android.hardware.wifi.supplicant-V1.2-java",
583 "android.hardware.wifi.supplicant-V1.3-java",
584 "android.hidl.base-V1.0-java",
585 "android.hidl.manager-V1.0-java",
586 "android.hidl.manager-V1.1-java",
587 "android.hidl.manager-V1.2-java",
Jiyong Park0f80c182020-01-31 02:49:53 +0900588 "bouncycastle-unbundled",
589 "dnsresolver_aidl_interface-V2-java",
590 "error_prone_annotations",
Jooyung Han5e9013b2020-03-10 06:23:13 +0900591 "framework-wifi-pre-jarjar",
592 "framework-wifi-util-lib",
Jiyong Park0f80c182020-01-31 02:49:53 +0900593 "ipmemorystore-aidl-interfaces-V3-java",
594 "ipmemorystore-aidl-interfaces-java",
595 "ksoap2",
Jiyong Park0f80c182020-01-31 02:49:53 +0900596 "libnanohttpd",
Jiyong Park0f80c182020-01-31 02:49:53 +0900597 "libwifi-jni",
598 "net-utils-services-common",
599 "netd_aidl_interface-V2-java",
600 "netd_aidl_interface-unstable-java",
601 "netd_event_listener_interface-java",
602 "netlink-client",
Jiyong Park0f80c182020-01-31 02:49:53 +0900603 "networkstack-client",
604 "services.net",
605 "wifi-lite-protos",
606 "wifi-nano-protos",
607 "wifi-service-pre-jarjar",
608 "wifi-service-resources",
Jiyong Park0f80c182020-01-31 02:49:53 +0900609 }
610 //
611 // Module separator
612 //
613 m["com.android.sdkext"] = []string{
614 "fmtlib_ndk",
615 "libbase_ndk",
616 "libprotobuf-cpp-lite-ndk",
617 }
618 //
619 // Module separator
620 //
621 m["com.android.os.statsd"] = []string{
Jiyong Park0f80c182020-01-31 02:49:53 +0900622 "libstatssocket",
Jiyong Park0f80c182020-01-31 02:49:53 +0900623 }
624 //
625 // Module separator
626 //
Paul Duffin7d74e7b2020-03-06 12:30:13 +0000627 m[android.AvailableToAnyApex] = []string{
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900628 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries
629 "androidx",
630 "androidx-constraintlayout_constraintlayout",
631 "androidx-constraintlayout_constraintlayout-nodeps",
632 "androidx-constraintlayout_constraintlayout-solver",
633 "androidx-constraintlayout_constraintlayout-solver-nodeps",
634 "com.google.android.material_material",
635 "com.google.android.material_material-nodeps",
636
Jiyong Park0f80c182020-01-31 02:49:53 +0900637 "libatomic",
Jiyong Park0f80c182020-01-31 02:49:53 +0900638 "libclang_rt",
639 "libgcc_stripped",
640 "libprofile-clang-extras",
641 "libprofile-clang-extras_ndk",
642 "libprofile-extras",
643 "libprofile-extras_ndk",
644 "libunwind_llvm",
Jiyong Park0f80c182020-01-31 02:49:53 +0900645 }
Anton Hanssoneec79eb2020-01-10 15:12:39 +0000646 return m
647}
648
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900649func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +0900650 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -0800651 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +0900652 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +0900653 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -0700654 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +0900655 android.RegisterModuleType("override_apex", overrideApexFactory)
Jaewoong Jungfa00c062020-05-14 14:15:24 -0700656 android.RegisterModuleType("apex_set", apexSetFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900657
Jooyung Han31c470b2019-10-18 16:26:59 +0900658 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900659 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +0900660
661 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
662 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
663 sort.Strings(*apexFileContextsInfos)
664 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
665 })
Jiyong Parkd1063c12019-07-17 20:08:41 +0900666}
667
Jooyung Han31c470b2019-10-18 16:26:59 +0900668func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
669 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
670 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
671}
672
Jiyong Parkd1063c12019-07-17 20:08:41 +0900673func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parkf760cae2020-02-12 07:53:12 +0900674 ctx.TopDown("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900675 ctx.BottomUp("apex", apexMutator).Parallel()
676 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
677 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park89e850a2020-04-07 16:37:39 +0900678 ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900679}
680
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900681// Mark the direct and transitive dependencies of apex bundles so that they
682// can be built for the apex bundles.
Jiyong Parkf760cae2020-02-12 07:53:12 +0900683func apexDepsMutator(mctx android.TopDownMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +0900684 if !mctx.Module().Enabled() {
685 return
686 }
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800687 var apexBundles []android.ApexInfo
Jiyong Parkf760cae2020-02-12 07:53:12 +0900688 var directDep bool
Jooyung Hana57af4a2020-01-23 05:36:59 +0000689 if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jooyung Han49f67012020-04-17 13:43:10 +0900690 apexBundles = []android.ApexInfo{{
Jooyung Han5417f772020-03-12 18:37:20 +0900691 ApexName: mctx.ModuleName(),
692 MinSdkVersion: a.minSdkVersion(mctx),
Artur Satayev849f8442020-04-28 14:57:42 +0100693 Updatable: a.Updatable(),
Jooyung Han5e9013b2020-03-10 06:23:13 +0900694 }}
Jiyong Parkf760cae2020-02-12 07:53:12 +0900695 directDep = true
696 } else if am, ok := mctx.Module().(android.ApexModule); ok {
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800697 apexBundles = am.ApexVariations()
Jiyong Parkf760cae2020-02-12 07:53:12 +0900698 directDep = false
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900699 }
Jiyong Parkf760cae2020-02-12 07:53:12 +0900700
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800701 if len(apexBundles) == 0 {
Jiyong Parkf760cae2020-02-12 07:53:12 +0900702 return
703 }
704
Paul Duffin923e8a52020-03-30 15:33:32 +0100705 cur := mctx.Module().(android.DepIsInSameApex)
Jooyung Han5e9013b2020-03-10 06:23:13 +0900706
Jiyong Parkf760cae2020-02-12 07:53:12 +0900707 mctx.VisitDirectDeps(func(child android.Module) {
708 depName := mctx.OtherModuleName(child)
709 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
Paul Duffin65347702020-03-31 15:23:40 +0100710 (cur.DepIsInSameApex(mctx, child) || inAnySdk(child)) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800711 android.UpdateApexDependency(apexBundles, depName, directDep)
712 am.BuildForApexes(apexBundles)
Jiyong Parkf760cae2020-02-12 07:53:12 +0900713 }
714 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900715}
716
Jiyong Park89e850a2020-04-07 16:37:39 +0900717// mark if a module cannot be available to platform. A module cannot be available
718// to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform"
719// is absent) or 2) it depends on another module that isn't (or can't be) available to platform
720func markPlatformAvailability(mctx android.BottomUpMutatorContext) {
721 // Host and recovery are not considered as platform
722 if mctx.Host() || mctx.Module().InstallInRecovery() {
723 return
724 }
725
726 if am, ok := mctx.Module().(android.ApexModule); ok {
727 availableToPlatform := am.AvailableFor(android.AvailableToPlatform)
728
729 // In a rare case when a lib is marked as available only to an apex
730 // but the apex doesn't exist. This can happen in a partial manifest branch
731 // like master-art. Currently, libstatssocket in the stats APEX is causing
732 // this problem.
733 // Include the lib in platform because the module SDK that ought to provide
734 // it doesn't exist, so it would otherwise be left out completely.
735 // TODO(b/154888298) remove this by adding those libraries in module SDKS and skipping
736 // this check for libraries provided by SDKs.
737 if !availableToPlatform && !android.InAnyApex(am.Name()) {
738 availableToPlatform = true
739 }
740
741 // If any of the dep is not available to platform, this module is also considered
742 // as being not available to platform even if it has "//apex_available:platform"
743 mctx.VisitDirectDeps(func(child android.Module) {
744 if !am.DepIsInSameApex(mctx, child) {
745 // if the dependency crosses apex boundary, don't consider it
746 return
747 }
748 if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() {
749 availableToPlatform = false
750 // TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform"
751 }
752 })
753
754 // Exception 1: stub libraries and native bridge libraries are always available to platform
755 if cc, ok := mctx.Module().(*cc.Module); ok &&
756 (cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) {
757 availableToPlatform = true
758 }
759
760 // Exception 2: bootstrap bionic libraries are also always available to platform
761 if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) {
762 availableToPlatform = true
763 }
764
765 if !availableToPlatform {
766 am.SetNotAvailableForPlatform()
767 }
768 }
769}
770
Paul Duffin65347702020-03-31 15:23:40 +0100771// If a module in an APEX depends on a module from an SDK then it needs an APEX
772// specific variant created for it. Refer to sdk.sdkDepsReplaceMutator.
773func inAnySdk(module android.Module) bool {
774 if sa, ok := module.(android.SdkAware); ok {
775 return sa.IsInAnySdk()
776 }
777
778 return false
779}
780
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900781// Create apex variations if a module is included in APEX(s).
782func apexMutator(mctx android.BottomUpMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +0900783 if !mctx.Module().Enabled() {
784 return
785 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900786 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900787 am.CreateApexVariations(mctx)
Jooyung Hana57af4a2020-01-23 05:36:59 +0000788 } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900789 // apex bundle itself is mutated so that it and its modules have same
790 // apex variant.
791 apexBundleName := mctx.ModuleName()
792 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +0900793 } else if o, ok := mctx.Module().(*OverrideApex); ok {
794 apexBundleName := o.GetOverriddenModuleName()
795 if apexBundleName == "" {
796 mctx.ModuleErrorf("base property is not set")
797 return
798 }
799 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900800 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900801
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900802}
Sundong Ahne9b55722019-09-06 17:37:42 +0900803
Jooyung Han7a78a922019-10-08 21:59:58 +0900804var (
805 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
806 apexFileContextsInfosMutex sync.Mutex
807)
808
809func apexFileContextsInfos(config android.Config) *[]string {
810 return config.Once(apexFileContextsInfosKey, func() interface{} {
811 return &[]string{}
812 }).(*[]string)
813}
814
Jooyung Han54aca7b2019-11-20 02:26:02 +0900815func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +0900816 apexFileContextsInfosMutex.Lock()
817 defer apexFileContextsInfosMutex.Unlock()
818 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +0900819 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +0900820}
821
Sundong Ahne9b55722019-09-06 17:37:42 +0900822func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +0900823 if !mctx.Module().Enabled() {
824 return
825 }
Sundong Ahne8fb7242019-09-17 13:50:45 +0900826 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +0900827 var variants []string
828 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
829 case "image":
830 variants = append(variants, imageApexType, flattenedApexType)
831 case "zip":
832 variants = append(variants, zipApexType)
833 case "both":
834 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
835 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900836 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +0900837 return
838 }
839
840 modules := mctx.CreateLocalVariations(variants...)
841
842 for i, v := range variants {
843 switch v {
844 case imageApexType:
845 modules[i].(*apexBundle).properties.ApexType = imageApex
846 case zipApexType:
847 modules[i].(*apexBundle).properties.ApexType = zipApex
848 case flattenedApexType:
849 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +0900850 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +0900851 modules[i].(*apexBundle).MakeAsSystemExt()
852 }
Sundong Ahnabb64432019-10-22 13:58:29 +0900853 }
Sundong Ahne9b55722019-09-06 17:37:42 +0900854 }
Jiyong Park5d790c32019-11-15 18:40:32 +0900855 } else if _, ok := mctx.Module().(*OverrideApex); ok {
856 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +0900857 }
858}
859
Jooyung Han5c998b92019-06-27 11:30:33 +0900860func apexUsesMutator(mctx android.BottomUpMutatorContext) {
861 if ab, ok := mctx.Module().(*apexBundle); ok {
862 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
863 }
864}
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900865
Jooyung Handc782442019-11-01 03:14:38 +0900866var (
Colin Cross440e0d02020-06-11 11:32:11 -0700867 useVendorAllowListKey = android.NewOnceKey("useVendorAllowList")
Jooyung Handc782442019-11-01 03:14:38 +0900868)
869
Colin Cross440e0d02020-06-11 11:32:11 -0700870// useVendorAllowList returns the list of APEXes which are allowed to use_vendor.
Jooyung Handc782442019-11-01 03:14:38 +0900871// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
872// which may cause compatibility issues. (e.g. libbinder)
873// Even though libbinder restricts its availability via 'apex_available' property and relies on
874// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
875// to avoid similar problems.
Colin Cross440e0d02020-06-11 11:32:11 -0700876func useVendorAllowList(config android.Config) []string {
877 return config.Once(useVendorAllowListKey, func() interface{} {
Jooyung Handc782442019-11-01 03:14:38 +0900878 return []string{
879 // swcodec uses "vendor" variants for smaller size
880 "com.android.media.swcodec",
881 "test_com.android.media.swcodec",
882 }
883 }).([]string)
884}
885
Colin Cross440e0d02020-06-11 11:32:11 -0700886// setUseVendorAllowListForTest overrides useVendorAllowList and must be
887// called before the first call to useVendorAllowList()
888func setUseVendorAllowListForTest(config android.Config, allowList []string) {
889 config.Once(useVendorAllowListKey, func() interface{} {
890 return allowList
Jooyung Handc782442019-11-01 03:14:38 +0900891 })
892}
893
Jooyung Han01a868d2020-02-27 13:40:44 +0900894type ApexNativeDependencies struct {
Alex Light9670d332019-01-29 18:07:33 -0800895 // List of native libraries
896 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +0900897
Jooyung Han643adc42020-02-27 13:50:06 +0900898 // List of JNI libraries
899 Jni_libs []string
900
Alex Light9670d332019-01-29 18:07:33 -0800901 // List of native executables
902 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +0900903
Roland Levillain630846d2019-06-26 12:48:34 +0100904 // List of native tests
905 Tests []string
Alex Light9670d332019-01-29 18:07:33 -0800906}
Jooyung Han344d5432019-08-23 11:17:39 +0900907
Alex Light9670d332019-01-29 18:07:33 -0800908type apexMultilibProperties struct {
909 // Native dependencies whose compile_multilib is "first"
Jooyung Han01a868d2020-02-27 13:40:44 +0900910 First ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800911
912 // Native dependencies whose compile_multilib is "both"
Jooyung Han01a868d2020-02-27 13:40:44 +0900913 Both ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800914
915 // Native dependencies whose compile_multilib is "prefer32"
Jooyung Han01a868d2020-02-27 13:40:44 +0900916 Prefer32 ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800917
918 // Native dependencies whose compile_multilib is "32"
Jooyung Han01a868d2020-02-27 13:40:44 +0900919 Lib32 ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800920
921 // Native dependencies whose compile_multilib is "64"
Jooyung Han01a868d2020-02-27 13:40:44 +0900922 Lib64 ApexNativeDependencies
Alex Light9670d332019-01-29 18:07:33 -0800923}
924
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900925type apexBundleProperties struct {
926 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +0000927 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -0800928 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900929
Jiyong Park40e26a22019-02-08 02:53:06 +0900930 // AndroidManifest.xml file used for the zip container of this APEX bundle.
931 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -0800932 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +0900933
Roland Levillain411c5842019-09-19 16:37:20 +0100934 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
935 // device (/apex/<apex_name>).
936 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +0900937 Apex_name *string
938
Jiyong Parkd0a65ba2018-11-10 06:37:15 +0900939 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +0900940 // For platform APEXes, this should points to a file under /system/sepolicy
941 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
942 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900943
Jooyung Han01a868d2020-02-27 13:40:44 +0900944 ApexNativeDependencies
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900945
946 // List of java libraries that are embedded inside this APEX bundle
947 Java_libs []string
948
949 // List of prebuilt files that are embedded inside this APEX bundle
950 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +0900951
952 // Name of the apex_key module that provides the private key to sign APEX
953 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +0900954
Alex Light5098a612018-11-29 17:12:15 -0800955 // The type of APEX to build. Controls what the APEX payload is. Either
956 // 'image', 'zip' or 'both'. Default: 'image'.
957 Payload_type *string
958
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900959 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
960 // or an android_app_certificate module name in the form ":module".
961 Certificate *string
962
Jiyong Park92c0f9c2018-12-13 23:14:57 +0900963 // Whether this APEX is installable to one of the partitions. Default: true.
964 Installable *bool
965
Jiyong Parkda6eb592018-12-19 17:12:36 +0900966 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
967 // Default is false.
968 Use_vendor *bool
969
Alex Lightfc0bd7c2019-01-29 18:31:59 -0800970 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
971 Ignore_system_library_special_case *bool
972
Alex Light9670d332019-01-29 18:07:33 -0800973 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +0900974
Jiyong Parkf97782b2019-02-13 20:28:58 +0900975 // List of sanitizer names that this APEX is enabled for
976 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +0900977
Jiyong Parkee9a98d2019-08-09 14:44:36 +0900978 PreventInstall bool `blueprint:"mutated"`
979
980 HideFromMake bool `blueprint:"mutated"`
981
Jooyung Han5c998b92019-06-27 11:30:33 +0900982 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
983 Provide_cpp_shared_libs *bool
984
985 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
986 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +0100987
Colin Cross440e0d02020-06-11 11:32:11 -0700988 // A txt file containing list of files that are allowed to be included in this APEX.
Colin Crosscbd62d02020-06-11 15:33:41 -0700989 Allowed_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +0900990
Sundong Ahnabb64432019-10-22 13:58:29 +0900991 // package format of this apex variant; could be non-flattened, flattened, or zip.
992 // imageApex, zipApex or flattened
993 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +0900994
Jiyong Parkd1063c12019-07-17 20:08:41 +0900995 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
996 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
997 // is implied. This value affects all modules included in this APEX. In other words, they are
998 // also built with the SDKs specified here.
999 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +09001000
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001001 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
1002 // Should be only used in tests#.
1003 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +09001004
Dario Frenica913392020-04-27 18:21:11 +01001005 // Whenever apex_payload.img of the APEX should not be dm-verity signed.
1006 // Should be only used in tests#.
1007 Test_only_unsigned_payload *bool
1008
Jiyong Park956305c2020-01-09 12:32:06 +09001009 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park9d677202020-02-19 16:29:35 +09001010
1011 // Whether this APEX is considered updatable or not. When set to true, this will enforce additional
Jooyung Han548640b2020-04-27 12:10:30 +09001012 // rules for making sure that the APEX is truly updatable.
1013 // - To be updatable, min_sdk_version should be set as well
1014 // This will also disable the size optimizations like symlinking to the system libs.
1015 // Default is false.
Jiyong Park9d677202020-02-19 16:29:35 +09001016 Updatable *bool
Colin Cross50317872020-02-19 20:41:10 -08001017
1018 // The minimum SDK version that this apex must be compatibile with.
1019 Min_sdk_version *string
Alex Light9670d332019-01-29 18:07:33 -08001020}
1021
1022type apexTargetBundleProperties struct {
1023 Target struct {
1024 // Multilib properties only for android.
1025 Android struct {
1026 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001027 }
Jooyung Han344d5432019-08-23 11:17:39 +09001028
Alex Light9670d332019-01-29 18:07:33 -08001029 // Multilib properties only for host.
1030 Host struct {
1031 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001032 }
Jooyung Han344d5432019-08-23 11:17:39 +09001033
Alex Light9670d332019-01-29 18:07:33 -08001034 // Multilib properties only for host linux_bionic.
1035 Linux_bionic struct {
1036 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001037 }
Jooyung Han344d5432019-08-23 11:17:39 +09001038
Alex Light9670d332019-01-29 18:07:33 -08001039 // Multilib properties only for host linux_glibc.
1040 Linux_glibc struct {
1041 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001042 }
1043 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001044}
1045
Jiyong Park5d790c32019-11-15 18:40:32 +09001046type overridableProperties struct {
1047 // List of APKs to package inside APEX
1048 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001049
Jiyong Park69aeba92020-04-24 21:16:36 +09001050 // List of runtime resource overlays (RROs) inside APEX
1051 Rros []string
1052
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001053 // Names of modules to be overridden. Listed modules can only be other binaries
1054 // (in Make or Soong).
1055 // This does not completely prevent installation of the overridden binaries, but if both
1056 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
1057 // from PRODUCT_PACKAGES.
1058 Overrides []string
Baligh Uddin004d7172020-02-19 21:29:28 -08001059
1060 // Logging Parent value
1061 Logging_parent string
Baligh Uddin5b57dba2020-03-15 13:01:05 -07001062
1063 // Apex Container Package Name.
1064 // Override value for attribute package:name in AndroidManifest.xml
1065 Package_name string
Jiyong Park5d790c32019-11-15 18:40:32 +09001066}
1067
Alex Light5098a612018-11-29 17:12:15 -08001068type apexPackaging int
1069
1070const (
1071 imageApex apexPackaging = iota
1072 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +09001073 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -08001074)
1075
Sundong Ahnabb64432019-10-22 13:58:29 +09001076// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -08001077func (a apexPackaging) suffix() string {
1078 switch a {
1079 case imageApex:
1080 return imageApexSuffix
1081 case zipApex:
1082 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -08001083 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001084 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001085 }
1086}
1087
1088func (a apexPackaging) name() string {
1089 switch a {
1090 case imageApex:
1091 return imageApexType
1092 case zipApex:
1093 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -08001094 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001095 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001096 }
1097}
1098
Jiyong Parkf653b052019-11-18 15:39:01 +09001099type apexFileClass int
1100
1101const (
1102 etc apexFileClass = iota
1103 nativeSharedLib
1104 nativeExecutable
1105 shBinary
1106 pyBinary
1107 goBinary
1108 javaSharedLib
1109 nativeTest
1110 app
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001111 appSet
Jiyong Parkf653b052019-11-18 15:39:01 +09001112)
1113
Jiyong Park8fd61922018-11-08 02:50:25 +09001114func (class apexFileClass) NameInMake() string {
1115 switch class {
1116 case etc:
1117 return "ETC"
1118 case nativeSharedLib:
1119 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -08001120 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +09001121 return "EXECUTABLES"
1122 case javaSharedLib:
1123 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +01001124 case nativeTest:
1125 return "NATIVE_TESTS"
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001126 case app, appSet:
Jiyong Parkf383f7c2019-10-11 20:46:25 +09001127 // b/142537672 Why isn't this APP? We want to have full control over
1128 // the paths and file names of the apk file under the flattend APEX.
1129 // If this is set to APP, then the paths and file names are modified
1130 // by the Make build system. For example, it is installed to
1131 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
1132 // /system/apex/<apexname>/app/<Appname> because the build system automatically
1133 // appends module name (which is <apexname>.<Appname> to the path.
1134 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +09001135 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001136 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +09001137 }
1138}
1139
Jiyong Parkf653b052019-11-18 15:39:01 +09001140// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +09001141type apexFile struct {
1142 builtFile android.Path
Jiyong Parka62aa232020-05-28 23:46:55 +09001143 stem string
Jiyong Park8fd61922018-11-08 02:50:25 +09001144 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +09001145 installDir string
1146 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +09001147 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +09001148 // list of symlinks that will be created in installDir that point to this apexFile
1149 symlinks []string
Liz Kammer1c14a212020-05-12 15:26:55 -07001150 dataPaths android.Paths
Jiyong Parkf653b052019-11-18 15:39:01 +09001151 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +09001152 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +09001153
1154 requiredModuleNames []string
1155 targetRequiredModuleNames []string
1156 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +09001157
Colin Cross503c1d02020-01-28 14:00:53 -08001158 jacocoReportClassesFile android.Path // only for javalibs and apps
1159 certificate java.Certificate // only for apps
Jiyong Parkcfaa1642020-02-28 16:51:07 +09001160 overriddenPackageName string // only for apps
Jooyung Han643adc42020-02-27 13:50:06 +09001161
1162 isJniLib bool
Jiyong Parkf653b052019-11-18 15:39:01 +09001163}
1164
Jiyong Park1833cef2019-12-13 13:28:36 +09001165func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
1166 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +09001167 builtFile: builtFile,
1168 moduleName: moduleName,
1169 installDir: installDir,
1170 class: class,
1171 module: module,
1172 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001173 if module != nil {
1174 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +09001175 ret.requiredModuleNames = module.RequiredModuleNames()
1176 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
1177 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +09001178 }
1179 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +09001180}
1181
1182func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +09001183 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +09001184}
1185
Liz Kammer1c14a212020-05-12 15:26:55 -07001186func (af *apexFile) apexRelativePath(path string) string {
1187 return filepath.Join(af.installDir, path)
1188}
1189
Jiyong Park7cd10e32020-01-14 09:22:18 +09001190// Path() returns path of this apex file relative to the APEX root
1191func (af *apexFile) Path() string {
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001192 return af.apexRelativePath(af.Stem())
1193}
1194
1195func (af *apexFile) Stem() string {
Jiyong Parka62aa232020-05-28 23:46:55 +09001196 if af.stem != "" {
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001197 return af.stem
Jiyong Parka62aa232020-05-28 23:46:55 +09001198 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001199 return af.builtFile.Base()
Jiyong Park7cd10e32020-01-14 09:22:18 +09001200}
1201
1202// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
1203func (af *apexFile) SymlinkPaths() []string {
1204 var ret []string
1205 for _, symlink := range af.symlinks {
Liz Kammer1c14a212020-05-12 15:26:55 -07001206 ret = append(ret, af.apexRelativePath(symlink))
Jiyong Park7cd10e32020-01-14 09:22:18 +09001207 }
1208 return ret
1209}
1210
1211func (af *apexFile) AvailableToPlatform() bool {
1212 if af.module == nil {
1213 return false
1214 }
1215 if am, ok := af.module.(android.ApexModule); ok {
1216 return am.AvailableFor(android.AvailableToPlatform)
1217 }
1218 return false
1219}
1220
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001221type apexBundle struct {
1222 android.ModuleBase
1223 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +09001224 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +09001225 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001226
Jiyong Park5d790c32019-11-15 18:40:32 +09001227 properties apexBundleProperties
1228 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +09001229 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001230
Jooyung Hanf21c7972019-12-16 22:32:06 +09001231 // specific to apex_vndk modules
1232 vndkProperties apexVndkProperties
1233
Colin Crossa4925902018-11-16 11:36:28 -08001234 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +09001235 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -07001236 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +09001237
Jiyong Park03b68dd2019-07-26 23:20:40 +09001238 prebuiltFileToDelete string
1239
Jiyong Park42cca6c2019-04-01 11:15:50 +09001240 public_key_file android.Path
1241 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001242
1243 container_certificate_file android.Path
1244 container_private_key_file android.Path
1245
Jooyung Han54aca7b2019-11-20 02:26:02 +09001246 fileContexts android.Path
1247
Jiyong Park8fd61922018-11-08 02:50:25 +09001248 // list of files to be included in this apex
1249 filesInfo []apexFile
1250
Jiyong Park956305c2020-01-09 12:32:06 +09001251 // list of module names that should be installed along with this APEX
1252 requiredDeps []string
1253
Jiyong Park956305c2020-01-09 12:32:06 +09001254 // list of module names that this APEX is including (to be shown via *-deps-info target)
Artur Satayev872a1442020-04-27 17:08:37 +01001255 android.ApexBundleDepsInfo
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001256
Sundong Ahnabb64432019-10-22 13:58:29 +09001257 testApex bool
1258 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001259 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +09001260 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +09001261
Jooyung Han214bf372019-11-12 13:03:50 +09001262 manifestJsonOut android.WritablePath
1263 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +09001264
Jooyung Han002ab682020-01-08 01:57:58 +09001265 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +09001266 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +09001267 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +09001268 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
1269 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +09001270
1271 // Suffix of module name in Android.mk
1272 // ".flattened", ".apex", ".zipapex", or ""
1273 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +09001274
1275 installedFilesFile android.WritablePath
Jiyong Park7cd10e32020-01-14 09:22:18 +09001276
1277 // Whether to create symlink to the system file instead of having a file
1278 // inside the apex or not
1279 linkToSystemLib bool
Jiyong Park19972c72020-01-28 20:05:29 +09001280
1281 // Struct holding the merged notice file paths in different formats
1282 mergedNotices android.NoticeOutputs
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001283}
1284
Jiyong Park397e55e2018-10-24 21:09:55 +09001285func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Jooyung Han01a868d2020-02-27 13:40:44 +09001286 nativeModules ApexNativeDependencies,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001287 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +09001288 // Use *FarVariation* to be able to depend on modules having
1289 // conflicting variations with this module. This is required since
1290 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
1291 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001292 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +09001293 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +09001294 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +09001295 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Jooyung Han01a868d2020-02-27 13:40:44 +09001296 }...), sharedLibTag, nativeModules.Native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001297
Jooyung Han643adc42020-02-27 13:50:06 +09001298 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
1299 {Mutator: "image", Variation: imageVariation},
1300 {Mutator: "link", Variation: "shared"},
1301 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
1302 }...), jniLibTag, nativeModules.Jni_libs...)
1303
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001304 ctx.AddFarVariationDependencies(append(target.Variations(),
1305 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
Jooyung Han01a868d2020-02-27 13:40:44 +09001306 executableTag, nativeModules.Binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +01001307
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001308 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001309 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001310 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Jooyung Han01a868d2020-02-27 13:40:44 +09001311 }...), testTag, nativeModules.Tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001312}
1313
Alex Light9670d332019-01-29 18:07:33 -08001314func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
1315 if ctx.Os().Class == android.Device {
1316 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
1317 } else {
1318 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
1319 if ctx.Os().Bionic() {
1320 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
1321 } else {
1322 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
1323 }
1324 }
1325}
1326
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001327func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Cross440e0d02020-06-11 11:32:11 -07001328 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) {
Jooyung Handc782442019-11-01 03:14:38 +09001329 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1330 }
1331
Jiyong Park397e55e2018-10-24 21:09:55 +09001332 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +09001333 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -08001334
1335 a.combineProperties(ctx)
1336
Jiyong Park397e55e2018-10-24 21:09:55 +09001337 has32BitTarget := false
1338 for _, target := range targets {
1339 if target.Arch.ArchType.Multilib == "lib32" {
1340 has32BitTarget = true
1341 }
1342 }
1343 for i, target := range targets {
Jooyung Han643adc42020-02-27 13:50:06 +09001344 // When multilib.* is omitted for native_shared_libs/jni_libs/tests, it implies
Jooyung Han01a868d2020-02-27 13:40:44 +09001345 // multilib.both
1346 addDependenciesForNativeModules(ctx,
1347 ApexNativeDependencies{
1348 Native_shared_libs: a.properties.Native_shared_libs,
1349 Tests: a.properties.Tests,
Jooyung Han643adc42020-02-27 13:50:06 +09001350 Jni_libs: a.properties.Jni_libs,
Jooyung Han01a868d2020-02-27 13:40:44 +09001351 Binaries: nil,
1352 },
1353 target, a.getImageVariation(config))
Roland Levillain630846d2019-06-26 12:48:34 +01001354
Jiyong Park397e55e2018-10-24 21:09:55 +09001355 // Add native modules targetting both ABIs
1356 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001357 a.properties.Multilib.Both,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001358 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001359 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001360
Alex Light3d673592019-01-18 14:37:31 -08001361 isPrimaryAbi := i == 0
1362 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +09001363 // When multilib.* is omitted for binaries, it implies
Jooyung Han01a868d2020-02-27 13:40:44 +09001364 // multilib.first
1365 addDependenciesForNativeModules(ctx,
1366 ApexNativeDependencies{
1367 Native_shared_libs: nil,
1368 Tests: nil,
Jooyung Han643adc42020-02-27 13:50:06 +09001369 Jni_libs: nil,
Jooyung Han01a868d2020-02-27 13:40:44 +09001370 Binaries: a.properties.Binaries,
1371 },
1372 target, a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001373
1374 // Add native modules targetting the first ABI
1375 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001376 a.properties.Multilib.First,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001377 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001378 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001379 }
1380
1381 switch target.Arch.ArchType.Multilib {
1382 case "lib32":
1383 // Add native modules targetting 32-bit ABI
1384 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001385 a.properties.Multilib.Lib32,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001386 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001387 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001388
1389 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001390 a.properties.Multilib.Prefer32,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001391 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001392 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001393 case "lib64":
1394 // Add native modules targetting 64-bit ABI
1395 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001396 a.properties.Multilib.Lib64,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001397 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001398 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001399
1400 if !has32BitTarget {
1401 addDependenciesForNativeModules(ctx,
Jooyung Han01a868d2020-02-27 13:40:44 +09001402 a.properties.Multilib.Prefer32,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001403 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001404 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001405 }
1406 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001407 }
1408
Jiyong Parkce6aadc2019-11-20 13:58:28 +09001409 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
1410 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
1411 // b/144532908
1412 archForPrebuiltEtc := config.Arches()[0]
1413 for _, arch := range config.Arches() {
1414 // Prefer 64-bit arch if there is any
1415 if arch.ArchType.Multilib == "lib64" {
1416 archForPrebuiltEtc = arch
1417 break
1418 }
1419 }
1420 ctx.AddFarVariationDependencies([]blueprint.Variation{
1421 {Mutator: "os", Variation: ctx.Os().String()},
1422 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
1423 }, prebuiltTag, a.properties.Prebuilts...)
1424
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001425 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1426 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001427
Ulya Trafimovich44561882020-01-03 13:25:54 +00001428 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
1429 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
1430 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1431 javaLibTag, "jacocoagent")
1432 }
1433
Jiyong Park23c52b02019-02-02 13:13:47 +09001434 if String(a.properties.Key) == "" {
1435 ctx.ModuleErrorf("key is missing")
1436 return
1437 }
1438 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001439
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001440 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +09001441 if cert != "" {
1442 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001443 }
Jiyong Parkd1063c12019-07-17 20:08:41 +09001444
1445 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
1446 if len(a.properties.Uses_sdks) > 0 {
1447 sdkRefs := []android.SdkRef{}
1448 for _, str := range a.properties.Uses_sdks {
1449 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
1450 sdkRefs = append(sdkRefs, parsed)
1451 }
1452 a.BuildWithSdks(sdkRefs)
1453 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001454}
1455
Jiyong Park5d790c32019-11-15 18:40:32 +09001456func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
1457 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1458 androidAppTag, a.overridableProperties.Apps...)
Jiyong Park69aeba92020-04-24 21:16:36 +09001459 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1460 rroTag, a.overridableProperties.Rros...)
Jiyong Park5d790c32019-11-15 18:40:32 +09001461}
1462
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001463func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1464 // direct deps of an APEX bundle are all part of the APEX bundle
1465 return true
1466}
1467
Colin Cross0ea8ba82019-06-06 14:33:29 -07001468func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001469 moduleName := ctx.ModuleName()
1470 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1471 // we check with the pseudo module name to see if its certificate is overridden.
1472 if a.vndkApex {
1473 moduleName = vndkApexName
1474 }
1475 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001476 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001477 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001478 }
1479 return String(a.properties.Certificate)
1480}
1481
Colin Cross41955e82019-05-29 14:40:35 -07001482func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1483 switch tag {
1484 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001485 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001486 default:
1487 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001488 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001489}
1490
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001491func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001492 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001493}
1494
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001495func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1496 return proptools.Bool(a.properties.Test_only_no_hashtree)
1497}
1498
Dario Frenica913392020-04-27 18:21:11 +01001499func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool {
1500 return proptools.Bool(a.properties.Test_only_unsigned_payload)
1501}
1502
Jiyong Park7c1dc612019-01-05 11:15:24 +09001503func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001504 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001505 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001506 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001507 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001508 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001509 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001510 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001511 }
1512}
1513
Jiyong Parkf97782b2019-02-13 20:28:58 +09001514func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1515 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1516 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1517 }
1518}
1519
Jiyong Park388ef3f2019-01-28 19:47:32 +09001520func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001521 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1522 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001523 }
1524
1525 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001526 globalSanitizerNames := []string{}
1527 if a.Host() {
1528 globalSanitizerNames = ctx.Config().SanitizeHost()
1529 } else {
1530 arches := ctx.Config().SanitizeDeviceArch()
1531 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1532 globalSanitizerNames = ctx.Config().SanitizeDevice()
1533 }
1534 }
1535 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001536}
1537
Jooyung Han8ce8db92020-05-15 19:05:05 +09001538func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) {
1539 if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") {
1540 for _, target := range ctx.MultiTargets() {
1541 if target.Arch.ArchType.Multilib == "lib64" {
1542 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
1543 {Mutator: "image", Variation: a.getImageVariation(ctx.DeviceConfig())},
1544 {Mutator: "link", Variation: "shared"},
1545 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
1546 }...), sharedLibTag, "libclang_rt.hwasan-aarch64-android")
1547 break
1548 }
1549 }
1550 }
1551}
1552
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001553var _ cc.Coverage = (*apexBundle)(nil)
1554
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001555func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
Colin Cross1a6acd42020-06-16 17:51:46 -07001556 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001557}
1558
1559func (a *apexBundle) PreventInstall() {
1560 a.properties.PreventInstall = true
1561}
1562
1563func (a *apexBundle) HideFromMake() {
1564 a.properties.HideFromMake = true
1565}
1566
Jiyong Park956305c2020-01-09 12:32:06 +09001567func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1568 a.properties.IsCoverageVariant = coverage
1569}
1570
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001571func (a *apexBundle) EnableCoverageIfNeeded() {}
1572
Jiyong Parkf653b052019-11-18 15:39:01 +09001573// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001574func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001575 // Decide the APEX-local directory by the multilib of the library
1576 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001577 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001578 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001579 case "lib32":
1580 dirInApex = "lib"
1581 case "lib64":
1582 dirInApex = "lib64"
1583 }
Colin Cross3b19f5d2019-09-17 14:45:31 -07001584 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001585 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001586 }
Jooyung Han35155c42020-02-06 17:33:20 +09001587 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Jiyong Park1833cef2019-12-13 13:28:36 +09001588 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001589 // Special case for Bionic libs and other libs installed with them. This is
1590 // to prevent those libs from being included in the search path
1591 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1592 // those libs in the Runtime APEX are available via the legacy paths in
1593 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1594 // to the legacy paths and thus will be loaded into the default linker
1595 // namespace (aka "platform" namespace). If the libs are directly in
1596 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1597 // into the runtime linker namespace, which will result in double loading of
1598 // them, which isn't supported.
1599 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001600 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001601
Jiyong Parkf653b052019-11-18 15:39:01 +09001602 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001603 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001604}
1605
Jiyong Park1833cef2019-12-13 13:28:36 +09001606func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jooyung Han35155c42020-02-06 17:33:20 +09001607 dirInApex := "bin"
Colin Cross3b19f5d2019-09-17 14:45:31 -07001608 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001609 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001610 }
Jooyung Han35155c42020-02-06 17:33:20 +09001611 dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001612 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001613 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001614 af.symlinks = cc.Symlinks()
Liz Kammer1c14a212020-05-12 15:26:55 -07001615 af.dataPaths = cc.DataPaths()
Jiyong Parkf653b052019-11-18 15:39:01 +09001616 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001617}
1618
Jiyong Park1833cef2019-12-13 13:28:36 +09001619func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001620 dirInApex := "bin"
1621 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001622 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001623}
Jiyong Park1833cef2019-12-13 13:28:36 +09001624func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001625 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001626 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1627 if err != nil {
1628 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001629 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001630 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001631 fileToCopy := android.PathForOutput(ctx, s)
1632 // NB: Since go binaries are static we don't need the module for anything here, which is
1633 // good since the go tool is a blueprint.Module not an android.Module like we would
1634 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001635 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001636}
1637
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001638func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001639 dirInApex := filepath.Join("bin", sh.SubDir())
1640 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001641 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001642 af.symlinks = sh.Symlinks()
1643 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001644}
1645
Jiyong Parka62aa232020-05-28 23:46:55 +09001646type javaDependency interface {
Ulyana Trafimovich5539e7b2020-06-04 14:08:17 +00001647 DexJarBuildPath() android.Path
Jiyong Park77acec62020-06-01 21:39:15 +09001648 JacocoReportClassesFile() android.Path
Jiyong Parka62aa232020-05-28 23:46:55 +09001649 Stem() string
1650}
1651
1652func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, module android.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001653 dirInApex := "javalib"
Ulyana Trafimovich5539e7b2020-06-04 14:08:17 +00001654 fileToCopy := lib.DexJarBuildPath()
Paul Duffin44b481b2020-06-17 16:59:43 +01001655 // Remove prebuilt_ if necessary so the source and prebuilt modules have the same name.
1656 name := strings.TrimPrefix(module.Name(), "prebuilt_")
1657 af := newApexFile(ctx, fileToCopy, name, dirInApex, javaSharedLib, module)
Jiyong Park618922e2020-01-08 13:35:43 +09001658 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
Jiyong Parka62aa232020-05-28 23:46:55 +09001659 af.stem = lib.Stem() + ".jar"
Jiyong Park618922e2020-01-08 13:35:43 +09001660 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001661}
1662
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001663func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001664 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1665 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001666 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001667}
1668
atrost6e126252020-01-27 17:01:16 +00001669func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1670 dirInApex := filepath.Join("etc", config.SubDir())
1671 fileToCopy := config.CompatConfig()
1672 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1673}
1674
Jiyong Park1833cef2019-12-13 13:28:36 +09001675func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001676 android.Module
1677 Privileged() bool
Jooyung Han39ee1192020-03-23 20:21:11 +09001678 InstallApkName() string
Jiyong Parkf653b052019-11-18 15:39:01 +09001679 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001680 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001681 Certificate() java.Certificate
Jooyung Han39ee1192020-03-23 20:21:11 +09001682}) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001683 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001684 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001685 appDir = "priv-app"
1686 }
Jooyung Han39ee1192020-03-23 20:21:11 +09001687 dirInApex := filepath.Join(appDir, aapp.InstallApkName())
Jiyong Parkf653b052019-11-18 15:39:01 +09001688 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001689 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1690 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross503c1d02020-01-28 14:00:53 -08001691 af.certificate = aapp.Certificate()
Jiyong Parkcfaa1642020-02-28 16:51:07 +09001692
1693 if app, ok := aapp.(interface {
1694 OverriddenManifestPackageName() string
1695 }); ok {
1696 af.overriddenPackageName = app.OverriddenManifestPackageName()
1697 }
Jiyong Park618922e2020-01-08 13:35:43 +09001698 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001699}
1700
Jiyong Park69aeba92020-04-24 21:16:36 +09001701func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile {
1702 rroDir := "overlay"
1703 dirInApex := filepath.Join(rroDir, rro.Theme())
1704 fileToCopy := rro.OutputFile()
1705 af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro)
1706 af.certificate = rro.Certificate()
1707
1708 if a, ok := rro.(interface {
1709 OverriddenManifestPackageName() string
1710 }); ok {
1711 af.overriddenPackageName = a.OverriddenManifestPackageName()
1712 }
1713 return af
1714}
1715
Roland Levillain935639d2019-08-13 14:55:28 +01001716// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1717type flattenedApexContext struct {
1718 android.ModuleContext
1719}
1720
1721func (c *flattenedApexContext) InstallBypassMake() bool {
1722 return true
1723}
1724
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001725// Function called while walking an APEX's payload dependencies.
1726//
1727// Return true if the `to` module should be visited, false otherwise.
1728type payloadDepsCallback func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool
1729
Jiyong Park201cedd2020-02-07 17:25:49 +09001730// Visit dependencies that contributes to the payload of this APEX
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001731func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, do payloadDepsCallback) {
Paul Duffindf915ff2020-03-30 17:58:21 +01001732 ctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0f80c182020-01-31 02:49:53 +09001733 am, ok := child.(android.ApexModule)
1734 if !ok || !am.CanHaveApexVariants() {
1735 return false
1736 }
1737
1738 // Check for the direct dependencies that contribute to the payload
1739 if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
1740 if dt.payload {
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001741 return do(ctx, parent, am, false /* externalDep */)
Jiyong Park0f80c182020-01-31 02:49:53 +09001742 }
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001743 // As soon as the dependency graph crosses the APEX boundary, don't go further.
Jiyong Park0f80c182020-01-31 02:49:53 +09001744 return false
1745 }
1746
1747 // Check for the indirect dependencies if it is considered as part of the APEX
Jooyung Han5e9013b2020-03-10 06:23:13 +09001748 if am.ApexName() != "" {
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001749 return do(ctx, parent, am, false /* externalDep */)
Jiyong Park0f80c182020-01-31 02:49:53 +09001750 }
1751
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001752 return do(ctx, parent, am, true /* externalDep */)
Jiyong Park0f80c182020-01-31 02:49:53 +09001753 })
1754}
1755
Jooyung Han03b51852020-02-26 22:45:42 +09001756func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
1757 ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
Jooyung Hanaed150d2020-04-02 01:41:41 +09001758 intVer, err := android.ApiStrToNum(ctx, ver)
1759 if err != nil {
1760 ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
Jooyung Han03b51852020-02-26 22:45:42 +09001761 }
Jooyung Hanaed150d2020-04-02 01:41:41 +09001762 return intVer
Jooyung Han03b51852020-02-26 22:45:42 +09001763}
1764
Artur Satayev849f8442020-04-28 14:57:42 +01001765func (a *apexBundle) Updatable() bool {
1766 return proptools.Bool(a.properties.Updatable)
1767}
1768
1769var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil)
1770
Jiyong Park201cedd2020-02-07 17:25:49 +09001771// Ensures that the dependencies are marked as available for this APEX
1772func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
1773 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
1774 if ctx.Host() || a.testApex || a.vndkApex {
1775 return
1776 }
1777
Jiyong Park58d10902020-03-28 14:43:19 +09001778 // Coverage build adds additional dependencies for the coverage-only runtime libraries.
1779 // Requiring them and their transitive depencies with apex_available is not right
1780 // because they just add noise.
1781 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) {
1782 return
1783 }
1784
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001785 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
1786 if externalDep {
1787 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1788 return false
1789 }
1790
Jiyong Park201cedd2020-02-07 17:25:49 +09001791 apexName := ctx.ModuleName()
Jooyung Han5e9013b2020-03-10 06:23:13 +09001792 fromName := ctx.OtherModuleName(from)
1793 toName := ctx.OtherModuleName(to)
Paul Duffin65347702020-03-31 15:23:40 +01001794
1795 // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither
1796 // do any of its dependencies.
1797 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
1798 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1799 return false
1800 }
1801
Colin Cross440e0d02020-06-11 11:32:11 -07001802 if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
Paul Duffinbe5a5be2020-03-30 15:54:08 +01001803 return true
Jiyong Park201cedd2020-02-07 17:25:49 +09001804 }
Jiyong Park1c7e9622020-05-07 16:12:13 +09001805 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 +01001806 // Visit this module's dependencies to check and report any issues with their availability.
1807 return true
Jiyong Park201cedd2020-02-07 17:25:49 +09001808 })
1809}
1810
Jooyung Han548640b2020-04-27 12:10:30 +09001811func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
Artur Satayev849f8442020-04-28 14:57:42 +01001812 if a.Updatable() {
Jooyung Han548640b2020-04-27 12:10:30 +09001813 if String(a.properties.Min_sdk_version) == "" {
1814 ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
1815 }
Artur Satayev8cf899a2020-04-15 17:29:42 +01001816
1817 a.checkJavaStableSdkVersion(ctx)
Jooyung Han548640b2020-04-27 12:10:30 +09001818 }
1819}
1820
Jiyong Park7d95a512020-05-10 15:16:24 +09001821// Ensures that a lib providing stub isn't statically linked
1822func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) {
1823 // Practically, we only care about regular APEXes on the device.
1824 if ctx.Host() || a.testApex || a.vndkApex {
1825 return
1826 }
1827
1828 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
1829 if ccm, ok := to.(*cc.Module); ok {
1830 apexName := ctx.ModuleName()
1831 fromName := ctx.OtherModuleName(from)
1832 toName := ctx.OtherModuleName(to)
1833
1834 // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither
1835 // do any of its dependencies.
1836 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
1837 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1838 return false
1839 }
1840
1841 // TODO(jiyong) remove this check when R is published to AOSP. Currently, libstatssocket
1842 // is capable of providing a stub variant, but is being statically linked from the bluetooth
1843 // APEX.
1844 if toName == "libstatssocket" {
1845 return false
1846 }
1847
1848 // The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule.
1849 // It can't make the static dependencies dynamic because it can't
1850 // do the dynamic linking for itself.
1851 if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump") {
1852 return false
1853 }
1854
1855 isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !android.DirectlyInApex(apexName, toName)
1856 if isStubLibraryFromOtherApex && !externalDep {
1857 ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
1858 "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))
1859 }
1860
1861 }
1862 return true
1863 })
1864}
1865
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001866func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09001867 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
1868 switch a.properties.ApexType {
1869 case imageApex:
1870 if buildFlattenedAsDefault {
1871 a.suffix = imageApexSuffix
1872 } else {
1873 a.suffix = ""
1874 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001875
1876 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09001877 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09001878 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001879 }
1880 case zipApex:
1881 if proptools.String(a.properties.Payload_type) == "zip" {
1882 a.suffix = ""
1883 a.primaryApexType = true
1884 } else {
1885 a.suffix = zipApexSuffix
1886 }
1887 case flattenedApex:
1888 if buildFlattenedAsDefault {
1889 a.suffix = ""
1890 a.primaryApexType = true
1891 } else {
1892 a.suffix = flattenedSuffix
1893 }
Alex Light5098a612018-11-29 17:12:15 -08001894 }
1895
Roland Levillain630846d2019-06-26 12:48:34 +01001896 if len(a.properties.Tests) > 0 && !a.testApex {
1897 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
1898 return
1899 }
1900
Jiyong Park0f80c182020-01-31 02:49:53 +09001901 a.checkApexAvailability(ctx)
Jooyung Han548640b2020-04-27 12:10:30 +09001902 a.checkUpdatable(ctx)
Jiyong Park7d95a512020-05-10 15:16:24 +09001903 a.checkStaticLinkingToStubLibraries(ctx)
Jiyong Park678c8812020-02-07 17:25:49 +09001904
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001905 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1906
Jooyung Hane1633032019-08-01 17:41:43 +09001907 // native lib dependencies
1908 var provideNativeLibs []string
1909 var requireNativeLibs []string
1910
Jooyung Han5c998b92019-06-27 11:30:33 +09001911 // Check if "uses" requirements are met with dependent apexBundles
1912 var providedNativeSharedLibs []string
1913 useVendor := proptools.Bool(a.properties.Use_vendor)
1914 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
1915 if ctx.OtherModuleDependencyTag(m) != usesTag {
1916 return
1917 }
1918 otherName := ctx.OtherModuleName(m)
1919 other, ok := m.(*apexBundle)
1920 if !ok {
1921 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
1922 return
1923 }
1924 if proptools.Bool(other.properties.Use_vendor) != useVendor {
1925 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
1926 return
1927 }
1928 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
1929 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
1930 return
1931 }
1932 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
1933 })
1934
Jiyong Parkf653b052019-11-18 15:39:01 +09001935 var filesInfo []apexFile
Jiyong Park678c8812020-02-07 17:25:49 +09001936 // TODO(jiyong) do this using walkPayloadDeps
Alex Light778127a2019-02-27 14:19:50 -08001937 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001938 depTag := ctx.OtherModuleDependencyTag(child)
Paul Duffindddd5462020-04-07 15:25:44 +01001939 if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
1940 return false
1941 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001942 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001943 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001944 switch depTag {
Jooyung Han643adc42020-02-27 13:50:06 +09001945 case sharedLibTag, jniLibTag:
1946 isJniLib := depTag == jniLibTag
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09001947 if c, ok := child.(*cc.Module); ok {
Jooyung Han643adc42020-02-27 13:50:06 +09001948 fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
1949 fi.isJniLib = isJniLib
1950 filesInfo = append(filesInfo, fi)
Jooyung Han45a96772020-06-15 14:59:42 +09001951 // Collect the list of stub-providing libs except:
1952 // - VNDK libs are only for vendors
1953 // - bootstrap bionic libs are treated as provided by system
1954 if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001955 provideNativeLibs = append(provideNativeLibs, fi.Stem())
1956 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001957 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001958 } else {
Jooyung Han643adc42020-02-27 13:50:06 +09001959 propertyName := "native_shared_libs"
1960 if isJniLib {
1961 propertyName = "jni_libs"
1962 }
1963 ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001964 }
1965 case executableTag:
1966 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001967 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001968 return true // track transitive dependencies
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001969 } else if sh, ok := child.(*sh.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001970 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001971 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001972 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001973 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001974 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001975 } else {
Alex Light778127a2019-02-27 14:19:50 -08001976 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 +09001977 }
1978 case javaLibTag:
Jiyong Park77acec62020-06-01 21:39:15 +09001979 switch child.(type) {
Paul Duffineedc5d52020-06-12 17:46:39 +01001980 case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport:
Jiyong Park77acec62020-06-01 21:39:15 +09001981 af := apexFileForJavaLibrary(ctx, child.(javaDependency), child.(android.Module))
Jooyung Han58f26ab2019-12-18 15:34:32 +09001982 if !af.Ok() {
1983 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1984 return false
1985 }
1986 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09001987 return true // track transitive dependencies
Jiyong Park77acec62020-06-01 21:39:15 +09001988 default:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001989 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001990 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001991 case androidAppTag:
Jiyong Parkf653b052019-11-18 15:39:01 +09001992 if ap, ok := child.(*java.AndroidApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001993 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Jiyong Parkf653b052019-11-18 15:39:01 +09001994 return true // track transitive dependencies
1995 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001996 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Dario Freni6f3937c2019-12-20 22:58:03 +00001997 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001998 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001999 } else if ap, ok := child.(*java.AndroidAppSet); ok {
2000 appDir := "app"
2001 if ap.Privileged() {
2002 appDir = "priv-app"
2003 }
2004 af := newApexFile(ctx, ap.OutputFile(), ap.Name(),
2005 filepath.Join(appDir, ap.BaseModuleName()), appSet, ap)
2006 af.certificate = java.PresignedCertificate
2007 filesInfo = append(filesInfo, af)
Jiyong Parkf653b052019-11-18 15:39:01 +09002008 } else {
2009 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
2010 }
Jiyong Park69aeba92020-04-24 21:16:36 +09002011 case rroTag:
2012 if rro, ok := child.(java.RuntimeResourceOverlayModule); ok {
2013 filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro))
2014 } else {
2015 ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
2016 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002017 case prebuiltTag:
Jaewoong Jung4b79e982020-06-01 10:45:49 -07002018 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002019 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
atrost6e126252020-01-27 17:01:16 +00002020 } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
2021 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002022 } else {
atrost6e126252020-01-27 17:01:16 +00002023 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09002024 }
Roland Levillain630846d2019-06-26 12:48:34 +01002025 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01002026 if ccTest, ok := child.(*cc.Module); ok {
2027 if ccTest.IsTestPerSrcAllTestsVariation() {
2028 // Multiple-output test module (where `test_per_src: true`).
2029 //
2030 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
2031 // We do not add this variation to `filesInfo`, as it has no output;
2032 // however, we do add the other variations of this module as indirect
2033 // dependencies (see below).
Roland Levillain9b5fde92019-06-28 15:41:19 +01002034 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01002035 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09002036 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09002037 af.class = nativeTest
2038 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01002039 }
Jiyong Parkaf9539f2020-05-04 10:31:32 +09002040 return true // track transitive dependencies
Roland Levillain630846d2019-06-26 12:48:34 +01002041 } else {
2042 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
2043 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09002044 case keyTag:
2045 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002046 a.private_key_file = key.private_key_file
2047 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09002048 } else {
2049 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002050 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002051 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002052 case certificateTag:
2053 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002054 a.container_certificate_file = dep.Certificate.Pem
2055 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002056 } else {
2057 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
2058 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09002059 case android.PrebuiltDepTag:
2060 // If the prebuilt is force disabled, remember to delete the prebuilt file
2061 // that might have been installed in the previous builds
2062 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
2063 a.prebuiltFileToDelete = prebuilt.InstallFilename()
2064 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002065 }
Jooyung Han8aee2042019-10-29 05:08:31 +09002066 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002067 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09002068 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01002069 // We cannot use a switch statement on `depTag` here as the checked
2070 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09002071 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002072 if cc, ok := child.(*cc.Module); ok {
2073 if android.InList(cc.Name(), providedNativeSharedLibs) {
2074 // If we're using a shared library which is provided from other APEX,
2075 // don't include it in this APEX
2076 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09002077 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09002078 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
2079 af.transitiveDep = true
Jooyung Han671f1ce2019-12-17 12:47:13 +09002080 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002081 // If the dependency is a stubs lib, don't include it in this APEX,
2082 // but make sure that the lib is installed on the device.
2083 // In case no APEX is having the lib, the lib is installed to the system
2084 // partition.
2085 //
2086 // Always include if we are a host-apex however since those won't have any
2087 // system libraries.
Yo Chiang29555d52020-05-06 15:59:59 +08002088 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.BaseModuleName(), a.requiredDeps) {
2089 a.requiredDeps = append(a.requiredDeps, cc.BaseModuleName())
Roland Levillainf89cd092019-07-29 16:22:59 +01002090 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09002091 requireNativeLibs = append(requireNativeLibs, af.Stem())
Roland Levillainf89cd092019-07-29 16:22:59 +01002092 // Don't track further
2093 return false
2094 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002095 filesInfo = append(filesInfo, af)
2096 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09002097 }
Roland Levillainf89cd092019-07-29 16:22:59 +01002098 } else if cc.IsTestPerSrcDepTag(depTag) {
2099 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002100 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01002101 // Handle modules created as `test_per_src` variations of a single test module:
2102 // use the name of the generated test binary (`fileToCopy`) instead of the name
2103 // of the original test module (`depName`, shared by all `test_per_src`
2104 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09002105 af.moduleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002106 // these are not considered transitive dep
2107 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09002108 filesInfo = append(filesInfo, af)
2109 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01002110 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09002111 } else if java.IsJniDepTag(depTag) {
Jooyung Hanb7bebe22020-02-25 16:59:29 +09002112 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
2113 return false
Jiyong Parke3833882020-02-17 17:28:10 +09002114 } else if java.IsXmlPermissionsFileDepTag(depTag) {
Jaewoong Jung4b79e982020-06-01 10:45:49 -07002115 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Parke3833882020-02-17 17:28:10 +09002116 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
2117 }
Jooyung Han9c80bae2019-08-20 17:30:57 +09002118 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Jiyong Park1c7e9622020-05-07 16:12:13 +09002119 ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002120 }
2121 }
2122 }
2123 return false
2124 })
2125
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002126 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
2127 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
2128 // via the global boot image config.
2129 if a.artApex {
Tim Joinesc1ef1bb2020-03-18 18:00:41 +00002130 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002131 dirInApex := filepath.Join("javalib", arch.String())
2132 for _, f := range files {
2133 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09002134 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09002135 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002136 }
2137 }
2138 }
2139
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002140 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09002141 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
2142 return
2143 }
2144
Jiyong Park8fd61922018-11-08 02:50:25 +09002145 // remove duplicates in filesInfo
2146 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002147 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002148 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002149 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002150 if e, ok := encountered[dest]; !ok {
2151 encountered[dest] = f
2152 } else {
2153 // If a module is directly included and also transitively depended on
2154 // consider it as directly included.
2155 e.transitiveDep = e.transitiveDep && f.transitiveDep
2156 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002157 }
2158 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002159 var result []apexFile
2160 for _, v := range encountered {
2161 result = append(result, v)
2162 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002163 return result
2164 }
2165 filesInfo = removeDup(filesInfo)
2166
2167 // to have consistent build rules
2168 sort.Slice(filesInfo, func(i, j int) bool {
2169 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
2170 })
2171
Jiyong Park8fd61922018-11-08 02:50:25 +09002172 a.installDir = android.PathForModuleInstall(ctx, "apex")
2173 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002174
Jooyung Han54aca7b2019-11-20 02:26:02 +09002175 if a.properties.ApexType != zipApex {
2176 if a.properties.File_contexts == nil {
2177 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
2178 } else {
2179 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
2180 if a.Platform() {
2181 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
2182 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
2183 }
2184 }
2185 }
2186 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
2187 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
2188 return
2189 }
2190 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002191 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2192 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2193 // the same library in the system partition, thus effectively sharing the same libraries
2194 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2195 // in the APEX.
2196 a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
2197 a.installable() &&
2198 !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002199
Jiyong Park9d677202020-02-19 16:29:35 +09002200 // We don't need the optimization for updatable APEXes, as it might give false signal
2201 // to the system health when the APEXes are still bundled (b/149805758)
Artur Satayev849f8442020-04-28 14:57:42 +01002202 if a.Updatable() && a.properties.ApexType == imageApex {
Jiyong Park9d677202020-02-19 16:29:35 +09002203 a.linkToSystemLib = false
2204 }
2205
Jiyong Park638d30e2020-02-26 18:27:19 +09002206 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2207 if ctx.Host() {
2208 a.linkToSystemLib = false
2209 }
2210
Jooyung Hand15aa1f2019-09-27 00:38:03 +09002211 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09002212 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
2213
2214 a.setCertificateAndPrivateKey(ctx)
2215 if a.properties.ApexType == flattenedApex {
2216 a.buildFlattenedApex(ctx)
2217 } else {
2218 a.buildUnflattenedApex(ctx)
2219 }
2220
Jooyung Han002ab682020-01-08 01:57:58 +09002221 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09002222
2223 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002224}
2225
Artur Satayev8cf899a2020-04-15 17:29:42 +01002226// Enforce that Java deps of the apex are using stable SDKs to compile
2227func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
2228 // Visit direct deps only. As long as we guarantee top-level deps are using
2229 // stable SDKs, java's checkLinkType guarantees correct usage for transitive deps
2230 ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
2231 tag := ctx.OtherModuleDependencyTag(module)
2232 switch tag {
2233 case javaLibTag, androidAppTag:
2234 if m, ok := module.(interface{ CheckStableSdkVersion() error }); ok {
2235 if err := m.CheckStableSdkVersion(); err != nil {
2236 ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err)
2237 }
2238 }
2239 }
2240 })
2241}
2242
Colin Cross440e0d02020-06-11 11:32:11 -07002243func baselineApexAvailable(apex, moduleName string) bool {
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002244 key := apex
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002245 moduleName = normalizeModuleName(moduleName)
2246
Colin Cross440e0d02020-06-11 11:32:11 -07002247 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002248 return true
2249 }
2250
2251 key = android.AvailableToAnyApex
Colin Cross440e0d02020-06-11 11:32:11 -07002252 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002253 return true
2254 }
2255
2256 return false
2257}
2258
2259func normalizeModuleName(moduleName string) string {
Jiyong Park0f80c182020-01-31 02:49:53 +09002260 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2261 // system. Trim the prefix for the check since they are confusing
2262 moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
2263 if strings.HasPrefix(moduleName, "libclang_rt.") {
2264 // This module has many arch variants that depend on the product being built.
2265 // We don't want to list them all
2266 moduleName = "libclang_rt"
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002267 }
Jooyung Hanacc7bbe2020-05-20 09:06:00 +09002268 if strings.HasPrefix(moduleName, "androidx.") {
2269 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries
2270 moduleName = "androidx"
2271 }
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002272 return moduleName
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002273}
2274
Jooyung Han344d5432019-08-23 11:17:39 +09002275func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09002276 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002277 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08002278 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09002279 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08002280 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002281 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09002282 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08002283 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002284 return module
2285}
Jiyong Park30ca9372019-02-07 16:27:23 +09002286
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002287func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002288 bundle := newApexBundle()
2289 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002290 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09002291 return bundle
2292}
2293
Jiyong Parkfce0b422020-02-11 03:56:06 +09002294// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2295// certain compatibility checks such as apex_available are not done for apex_test.
Jooyung Han344d5432019-08-23 11:17:39 +09002296func testApexBundleFactory() android.Module {
2297 bundle := newApexBundle()
2298 bundle.testApex = true
2299 return bundle
2300}
2301
Jiyong Parkfce0b422020-02-11 03:56:06 +09002302// apex packages other modules into an APEX file which is a packaging format for system-level
2303// components like binaries, shared libraries, etc.
Jiyong Parkd1063c12019-07-17 20:08:41 +09002304func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002305 return newApexBundle()
2306}
2307
Jiyong Park30ca9372019-02-07 16:27:23 +09002308//
2309// Defaults
2310//
2311type Defaults struct {
2312 android.ModuleBase
2313 android.DefaultsModuleBase
2314}
2315
Jiyong Park30ca9372019-02-07 16:27:23 +09002316func defaultsFactory() android.Module {
2317 return DefaultsFactory()
2318}
2319
2320func DefaultsFactory(props ...interface{}) android.Module {
2321 module := &Defaults{}
2322
2323 module.AddProperties(props...)
2324 module.AddProperties(
2325 &apexBundleProperties{},
2326 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09002327 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09002328 )
2329
2330 android.InitDefaultsModule(module)
2331 return module
2332}
Jiyong Park5d790c32019-11-15 18:40:32 +09002333
2334//
2335// OverrideApex
2336//
2337type OverrideApex struct {
2338 android.ModuleBase
2339 android.OverrideModuleBase
2340}
2341
2342func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2343 // All the overrides happen in the base module.
2344}
2345
2346// override_apex is used to create an apex module based on another apex module
2347// by overriding some of its properties.
2348func overrideApexFactory() android.Module {
2349 m := &OverrideApex{}
2350 m.AddProperties(&overridableProperties{})
2351
2352 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2353 android.InitOverrideModule(m)
2354 return m
2355}