blob: 987a118dd7e983355872937519c01be356200729 [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"
Jooyung Han0c4e0162020-02-26 22:45:42 +090022 "strconv"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090023 "strings"
Jooyung Han344d5432019-08-23 11:17:39 +090024 "sync"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090025
26 "android/soong/android"
27 "android/soong/cc"
28 "android/soong/java"
Alex Light778127a2019-02-27 14:19:50 -080029 "android/soong/python"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090030
31 "github.com/google/blueprint"
Alex Light778127a2019-02-27 14:19:50 -080032 "github.com/google/blueprint/bootstrap"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090033 "github.com/google/blueprint/proptools"
34)
35
Jooyung Han72bd2f82019-10-23 16:46:38 +090036const (
37 imageApexSuffix = ".apex"
38 zipApexSuffix = ".zipapex"
Sundong Ahnabb64432019-10-22 13:58:29 +090039 flattenedSuffix = ".flattened"
Alex Light5098a612018-11-29 17:12:15 -080040
Sundong Ahnabb64432019-10-22 13:58:29 +090041 imageApexType = "image"
42 zipApexType = "zip"
43 flattenedApexType = "flattened"
Jooyung Han72bd2f82019-10-23 16:46:38 +090044)
Jiyong Park48ca7dc2018-10-10 14:01:00 +090045
46type dependencyTag struct {
47 blueprint.BaseDependencyTag
48 name string
Jiyong Parkfa899442020-01-31 02:49:53 +090049
50 // determines if the dependent will be part of the APEX payload
51 payload bool
Jiyong Park48ca7dc2018-10-10 14:01:00 +090052}
53
54var (
Jiyong Parkfa899442020-01-31 02:49:53 +090055 sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
56 executableTag = dependencyTag{name: "executable", payload: true}
57 javaLibTag = dependencyTag{name: "javaLib", payload: true}
58 prebuiltTag = dependencyTag{name: "prebuilt", payload: true}
59 testTag = dependencyTag{name: "test", payload: true}
Jiyong Parkc00cbd92018-10-30 21:20:05 +090060 keyTag = dependencyTag{name: "key"}
61 certificateTag = dependencyTag{name: "certificate"}
Jooyung Han5c998b92019-06-27 11:30:33 +090062 usesTag = dependencyTag{name: "uses"}
Jiyong Parkfa899442020-01-31 02:49:53 +090063 androidAppTag = dependencyTag{name: "androidApp", payload: true}
Anton Hansson5053c292020-01-10 15:12:39 +000064 apexAvailWl = makeApexAvailableWhitelist()
Jiyong Park48ca7dc2018-10-10 14:01:00 +090065)
66
Anton Hansson5053c292020-01-10 15:12:39 +000067// This is a map from apex to modules, which overrides the
68// apex_available setting for that particular module to make
69// it available for the apex regardless of its setting.
70// TODO(b/147364041): remove this
71func makeApexAvailableWhitelist() map[string][]string {
72 // The "Module separator"s below are employed to minimize merge conflicts.
73 m := make(map[string][]string)
74 //
75 // Module separator
76 //
Jiyong Parkfa899442020-01-31 02:49:53 +090077 m["com.android.adbd"] = []string{
78 "adbd",
79 "bcm_object",
80 "fmtlib",
81 "libadbconnection_server",
82 "libadbd",
83 "libadbd_auth",
84 "libadbd_core",
85 "libadbd_services",
86 "libasyncio",
87 "libbacktrace_headers",
88 "libbase",
89 "libbase_headers",
90 "libbuildversion",
91 "libc++",
92 "libcap",
93 "libcrypto",
94 "libcrypto_utils",
95 "libcutils",
96 "libcutils_headers",
97 "libdiagnose_usb",
Jiyong Parkfa899442020-01-31 02:49:53 +090098 "liblog_headers",
99 "libmdnssd",
100 "libminijail",
101 "libminijail_gen_constants",
102 "libminijail_gen_constants_obj",
103 "libminijail_gen_syscall",
104 "libminijail_gen_syscall_obj",
105 "libminijail_generated",
106 "libpackagelistparser",
107 "libpcre2",
108 "libprocessgroup_headers",
109 "libqemu_pipe",
110 "libselinux",
111 "libsystem_headers",
112 "libutils_headers",
113 }
114 //
115 // Module separator
116 //
Anton Hansson5053c292020-01-10 15:12:39 +0000117 m["com.android.art"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900118 "art_cmdlineparser_headers",
119 "art_disassembler_headers",
120 "art_libartbase_headers",
121 "bcm_object",
122 "bionic_libc_platform_headers",
123 "core-repackaged-icu4j",
124 "cpp-define-generator-asm-support",
125 "cpp-define-generator-definitions",
126 "crtbegin_dynamic",
127 "crtbegin_dynamic1",
128 "crtbegin_so1",
129 "crtbrand",
130 "conscrypt.module.intra.core.api.stubs",
131 "dex2oat_headers",
132 "dt_fd_forward_export",
133 "fmtlib",
134 "icu4c_extra_headers",
Anton Hanssonf17f2482020-01-16 09:11:57 +0000135 "jacocoagent",
Jiyong Parkfa899442020-01-31 02:49:53 +0900136 "javavm_headers",
137 "jni_platform_headers",
138 "libPlatformProperties",
139 "libadbconnection_client",
Anton Hansson5053c292020-01-10 15:12:39 +0000140 "libadbconnection_server",
Jiyong Parkfa899442020-01-31 02:49:53 +0900141 "libandroidicuinit",
142 "libart_runtime_headers_ndk",
Anton Hansson5053c292020-01-10 15:12:39 +0000143 "libartd-disassembler",
Jiyong Parkfa899442020-01-31 02:49:53 +0900144 "libasync_safe",
Anton Hansson5053c292020-01-10 15:12:39 +0000145 "libbacktrace",
146 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900147 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000148 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900149 "libc++_static",
150 "libc++abi",
151 "libc++demangle",
152 "libc_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000153 "libcrypto",
Jiyong Parkfa899442020-01-31 02:49:53 +0900154 "libdexfile_all_headers",
155 "libdexfile_external_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000156 "libdexfile_support",
Jiyong Parkfa899442020-01-31 02:49:53 +0900157 "libdmabufinfo",
Anton Hansson5053c292020-01-10 15:12:39 +0000158 "libexpat",
Jiyong Parkfa899442020-01-31 02:49:53 +0900159 "libfdlibm",
160 "libgtest_prod",
161 "libicui18n_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000162 "libicuuc",
Jiyong Parkfa899442020-01-31 02:49:53 +0900163 "libicuuc_headers",
164 "libicuuc_stubdata",
165 "libjdwp_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900166 "liblog_headers",
167 "liblz4",
Anton Hansson5053c292020-01-10 15:12:39 +0000168 "liblzma",
169 "libmeminfo",
Jiyong Parkfa899442020-01-31 02:49:53 +0900170 "libnativebridge-headers",
171 "libnativehelper_header_only",
172 "libnativeloader-headers",
173 "libnpt_headers",
174 "libopenjdkjvmti_headers",
175 "libperfetto_client_experimental",
Anton Hansson5053c292020-01-10 15:12:39 +0000176 "libprocinfo",
Jiyong Parkfa899442020-01-31 02:49:53 +0900177 "libprotobuf-cpp-lite",
178 "libunwind_llvm",
Anton Hansson5053c292020-01-10 15:12:39 +0000179 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900180 "libv8",
181 "libv8base",
182 "libv8gen",
183 "libv8platform",
184 "libv8sampler",
185 "libv8src",
Anton Hansson5053c292020-01-10 15:12:39 +0000186 "libvixl",
187 "libvixld",
188 "libz",
189 "libziparchive",
Jiyong Parkfa899442020-01-31 02:49:53 +0900190 "perfetto_trace_protos",
Anton Hansson5053c292020-01-10 15:12:39 +0000191 }
192 //
193 // Module separator
194 //
195 m["com.android.bluetooth.updatable"] = []string{
196 "android.hardware.audio.common@5.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000197 "android.hardware.bluetooth.a2dp@1.0",
198 "android.hardware.bluetooth.audio@2.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900199 "android.hardware.bluetooth@1.0",
200 "android.hardware.bluetooth@1.1",
201 "android.hardware.graphics.bufferqueue@1.0",
202 "android.hardware.graphics.bufferqueue@2.0",
203 "android.hardware.graphics.common@1.0",
204 "android.hardware.graphics.common@1.1",
205 "android.hardware.graphics.common@1.2",
206 "android.hardware.media@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000207 "android.hidl.safe_union@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900208 "android.hidl.token@1.0",
209 "android.hidl.token@1.0-utils",
210 "avrcp-target-service",
211 "avrcp_headers",
212 "bcm_object",
213 "bluetooth-protos-lite",
214 "bluetooth.mapsapi",
215 "com.android.vcard",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900216 "dnsresolver_aidl_interface-V2-java",
Jiyong Parkfa899442020-01-31 02:49:53 +0900217 "fmtlib",
218 "guava",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900219 "ipmemorystore-aidl-interfaces-V5-java",
220 "ipmemorystore-aidl-interfaces-java",
Jiyong Parkfa899442020-01-31 02:49:53 +0900221 "internal_include_headers",
222 "lib-bt-packets",
223 "lib-bt-packets-avrcp",
224 "lib-bt-packets-base",
225 "libFraunhoferAAC",
226 "libaudio-a2dp-hw-utils",
227 "libaudio-hearing-aid-hw-utils",
228 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000229 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900230 "libbase_headers",
231 "libbinder_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000232 "libbluetooth",
Jiyong Parkfa899442020-01-31 02:49:53 +0900233 "libbluetooth-types",
234 "libbluetooth-types-header",
235 "libbluetooth_gd",
236 "libbluetooth_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000237 "libbluetooth_jni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900238 "libbt-audio-hal-interface",
239 "libbt-bta",
240 "libbt-common",
241 "libbt-hci",
242 "libbt-platform-protos-lite",
243 "libbt-protos-lite",
244 "libbt-sbc-decoder",
245 "libbt-sbc-encoder",
246 "libbt-stack",
247 "libbt-utils",
248 "libbtcore",
249 "libbtdevice",
250 "libbte",
251 "libbtif",
Anton Hansson5053c292020-01-10 15:12:39 +0000252 "libc++",
253 "libchrome",
254 "libcrypto",
255 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900256 "libcutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000257 "libevent",
258 "libfmq",
Jiyong Parkfa899442020-01-31 02:49:53 +0900259 "libg722codec",
260 "libgtest_prod",
261 "libgui_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000262 "libhidlbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900263 "libhidlbase-impl-internal",
264 "libhidltransport-impl-internal",
265 "libhwbinder-impl-internal",
266 "libjsoncpp",
267 "liblog_headers",
268 "libmedia_headers",
269 "libmodpb64",
270 "libosi",
Anton Hansson5053c292020-01-10 15:12:39 +0000271 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900272 "libprocessgroup_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000273 "libprotobuf-cpp-lite",
Jiyong Parkfa899442020-01-31 02:49:53 +0900274 "libprotobuf-java-lite",
275 "libprotobuf-java-micro",
276 "libstagefright_foundation_headers",
277 "libstagefright_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000278 "libstatslog",
Jiyong Parkfa899442020-01-31 02:49:53 +0900279 "libstatssocket",
280 "libsystem_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000281 "libtinyxml2",
Jiyong Parkfa899442020-01-31 02:49:53 +0900282 "libudrv-uipc",
Jiyong Parkfa899442020-01-31 02:49:53 +0900283 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000284 "libz",
Jiyong Parkfa899442020-01-31 02:49:53 +0900285 "media_plugin_headers",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900286 "net-utils-services-common",
287 "netd_aidl_interface-unstable-java",
288 "netd_event_listener_interface-java",
289 "netlink-client",
290 "networkstack-aidl-interfaces-unstable-java",
291 "networkstack-client",
Jiyong Parkfa899442020-01-31 02:49:53 +0900292 "sap-api-java-static",
293 "services.net",
Anton Hansson5053c292020-01-10 15:12:39 +0000294 }
295 //
296 // Module separator
297 //
298 m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
299 //
300 // Module separator
301 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900302 m["com.android.conscrypt"] = []string{
303 "bcm_object",
304 "boringssl_self_test",
305 "libc++",
306 "libcrypto",
307 "libnativehelper_header_only",
308 "libssl",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900309 "unsupportedappusage",
Jiyong Parkfa899442020-01-31 02:49:53 +0900310 }
Anton Hansson5053c292020-01-10 15:12:39 +0000311 //
312 // Module separator
313 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900314 m["com.android.extservices"] = []string{
315 "flatbuffer_headers",
316 "liblua",
317 "libtextclassifier",
318 "libtextclassifier_hash_static",
319 "libtflite_static",
320 "libutf",
321 "libz_current",
322 "tensorflow_headers",
323 }
324 //
325 // Module separator
326 //
327 m["com.android.cronet"] = []string{
328 "cronet_impl_common_java",
329 "cronet_impl_native_java",
330 "cronet_impl_platform_java",
331 "libcronet.80.0.3986.0",
332 "org.chromium.net.cronet",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900333 "org.chromium.net.cronet.xml",
Jiyong Parkfa899442020-01-31 02:49:53 +0900334 "prebuilt_libcronet.80.0.3986.0",
335 }
336 //
337 // Module separator
338 //
339 m["com.android.neuralnetworks"] = []string{
340 "android.hardware.neuralnetworks@1.0",
341 "android.hardware.neuralnetworks@1.1",
342 "android.hardware.neuralnetworks@1.2",
343 "android.hardware.neuralnetworks@1.3",
344 "android.hidl.allocator@1.0",
345 "android.hidl.memory.token@1.0",
346 "android.hidl.memory@1.0",
347 "android.hidl.safe_union@1.0",
348 "bcm_object",
349 "fmtlib",
350 "gemmlowp_headers",
351 "libarect",
352 "libbacktrace_headers",
353 "libbase",
354 "libbase_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900355 "libbuildversion",
356 "libc++",
357 "libcrypto",
358 "libcrypto_static",
359 "libcutils",
360 "libcutils_headers",
361 "libeigen",
362 "libfmq",
363 "libhidlbase",
364 "libhidlbase-impl-internal",
365 "libhidlmemory",
366 "libhidltransport-impl-internal",
367 "libhwbinder-impl-internal",
368 "libjsoncpp",
369 "liblog_headers",
370 "libmath",
371 "libneuralnetworks_common",
372 "libneuralnetworks_headers",
373 "libprocessgroup",
374 "libprocessgroup_headers",
375 "libprocpartition",
376 "libsync",
377 "libsystem_headers",
378 "libtextclassifier_hash",
379 "libtextclassifier_hash_headers",
380 "libtextclassifier_hash_static",
381 "libtflite_kernel_utils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900382 "libutils_headers",
383 "philox_random",
384 "philox_random_headers",
385 "tensorflow_headers",
386 }
Anton Hansson5053c292020-01-10 15:12:39 +0000387 //
388 // Module separator
389 //
Anton Hansson5053c292020-01-10 15:12:39 +0000390 m["com.android.media"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900391 "android.frameworks.bufferhub@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000392 "android.hardware.cas.native@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900393 "android.hardware.cas@1.0",
394 "android.hardware.configstore-utils",
395 "android.hardware.configstore@1.0",
396 "android.hardware.configstore@1.1",
397 "android.hardware.graphics.allocator@2.0",
398 "android.hardware.graphics.allocator@3.0",
399 "android.hardware.graphics.bufferqueue@1.0",
400 "android.hardware.graphics.bufferqueue@2.0",
401 "android.hardware.graphics.common@1.0",
402 "android.hardware.graphics.common@1.1",
403 "android.hardware.graphics.common@1.2",
404 "android.hardware.graphics.mapper@2.0",
405 "android.hardware.graphics.mapper@2.1",
406 "android.hardware.graphics.mapper@3.0",
407 "android.hardware.media.omx@1.0",
408 "android.hardware.media@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000409 "android.hidl.allocator@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000410 "android.hidl.memory.token@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900411 "android.hidl.memory@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000412 "android.hidl.token@1.0",
413 "android.hidl.token@1.0-utils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900414 "bcm_object",
415 "bionic_libc_platform_headers",
416 "fmtlib",
417 "gl_headers",
418 "libEGL",
419 "libEGL_blobCache",
420 "libEGL_getProcAddress",
421 "libFLAC",
422 "libFLAC-config",
423 "libFLAC-headers",
424 "libGLESv2",
Anton Hansson5053c292020-01-10 15:12:39 +0000425 "libaacextractor",
426 "libamrextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900427 "libarect",
428 "libasync_safe",
429 "libaudio_system_headers",
430 "libaudioclient",
431 "libaudioclient_headers",
432 "libaudiofoundation",
433 "libaudiofoundation_headers",
434 "libaudiomanager",
435 "libaudiopolicy",
Anton Hansson5053c292020-01-10 15:12:39 +0000436 "libaudioutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900437 "libaudioutils_fixedfft",
438 "libbacktrace",
439 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000440 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900441 "libbase_headers",
442 "libbinder_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900443 "libbluetooth-types-header",
444 "libbufferhub",
445 "libbufferhub_headers",
446 "libbufferhubqueue",
Anton Hansson5053c292020-01-10 15:12:39 +0000447 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900448 "libc_headers",
449 "libc_malloc_debug_backtrace",
450 "libcamera_client",
451 "libcamera_metadata",
Anton Hansson5053c292020-01-10 15:12:39 +0000452 "libcrypto",
453 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900454 "libcutils_headers",
455 "libdexfile_external_headers",
456 "libdexfile_support",
457 "libdvr_headers",
458 "libexpat",
459 "libfifo",
Anton Hansson5053c292020-01-10 15:12:39 +0000460 "libflacextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900461 "libgrallocusage",
462 "libgraphicsenv",
463 "libgui",
464 "libgui_headers",
465 "libhardware_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000466 "libhidlbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900467 "libhidlbase-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000468 "libhidlmemory",
Jiyong Parkfa899442020-01-31 02:49:53 +0900469 "libhidltransport-impl-internal",
470 "libhwbinder-impl-internal",
471 "libinput",
472 "libjsoncpp",
473 "liblog_headers",
474 "liblzma",
475 "libmath",
476 "libmedia",
477 "libmedia_codeclist",
478 "libmedia_headers",
479 "libmedia_helper",
480 "libmedia_helper_headers",
481 "libmedia_midiiowrapper",
482 "libmedia_omx",
483 "libmediautils",
Anton Hansson5053c292020-01-10 15:12:39 +0000484 "libmidiextractor",
485 "libmkvextractor",
486 "libmp3extractor",
487 "libmp4extractor",
488 "libmpeg2extractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900489 "libnativebase_headers",
490 "libnativebridge-headers",
491 "libnativebridge_lazy",
492 "libnativeloader-headers",
493 "libnativeloader_lazy",
494 "libnativewindow_headers",
495 "libnblog",
Anton Hansson5053c292020-01-10 15:12:39 +0000496 "liboggextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900497 "libpackagelistparser",
498 "libpcre2",
499 "libpdx",
500 "libpdx_default_transport",
501 "libpdx_headers",
502 "libpdx_uds",
Anton Hansson5053c292020-01-10 15:12:39 +0000503 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900504 "libprocessgroup_headers",
505 "libprocinfo",
506 "libselinux",
507 "libsonivox",
Anton Hansson5053c292020-01-10 15:12:39 +0000508 "libspeexresampler",
Jiyong Parkfa899442020-01-31 02:49:53 +0900509 "libspeexresampler",
510 "libstagefright_esds",
Anton Hansson5053c292020-01-10 15:12:39 +0000511 "libstagefright_flacdec",
Jiyong Parkfa899442020-01-31 02:49:53 +0900512 "libstagefright_flacdec",
513 "libstagefright_foundation",
514 "libstagefright_foundation_headers",
515 "libstagefright_foundation_without_imemory",
516 "libstagefright_headers",
517 "libstagefright_id3",
518 "libstagefright_metadatautils",
519 "libstagefright_mpeg2extractor",
520 "libstagefright_mpeg2support",
521 "libsync",
522 "libsystem_headers",
523 "libui",
524 "libui_headers",
525 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900526 "libutils_headers",
527 "libvibrator",
528 "libvorbisidec",
Anton Hansson5053c292020-01-10 15:12:39 +0000529 "libwavextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900530 "libwebm",
531 "media_ndk_headers",
532 "media_plugin_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000533 "updatable-media",
534 }
535 //
536 // Module separator
537 //
538 m["com.android.media.swcodec"] = []string{
539 "android.frameworks.bufferhub@1.0",
540 "android.hardware.common-ndk_platform",
Jiyong Parkfa899442020-01-31 02:49:53 +0900541 "android.hardware.configstore-utils",
542 "android.hardware.configstore@1.0",
543 "android.hardware.configstore@1.1",
Anton Hansson5053c292020-01-10 15:12:39 +0000544 "android.hardware.graphics.allocator@2.0",
545 "android.hardware.graphics.allocator@3.0",
546 "android.hardware.graphics.allocator@4.0",
547 "android.hardware.graphics.bufferqueue@1.0",
548 "android.hardware.graphics.bufferqueue@2.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900549 "android.hardware.graphics.common-ndk_platform",
Anton Hansson5053c292020-01-10 15:12:39 +0000550 "android.hardware.graphics.common@1.0",
551 "android.hardware.graphics.common@1.1",
552 "android.hardware.graphics.common@1.2",
Anton Hansson5053c292020-01-10 15:12:39 +0000553 "android.hardware.graphics.mapper@2.0",
554 "android.hardware.graphics.mapper@2.1",
555 "android.hardware.graphics.mapper@3.0",
556 "android.hardware.graphics.mapper@4.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000557 "android.hardware.media.bufferpool@2.0",
558 "android.hardware.media.c2@1.0",
559 "android.hardware.media.c2@1.1",
560 "android.hardware.media.omx@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900561 "android.hardware.media@1.0",
562 "android.hardware.media@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000563 "android.hidl.memory.token@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900564 "android.hidl.memory@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000565 "android.hidl.safe_union@1.0",
566 "android.hidl.token@1.0",
567 "android.hidl.token@1.0-utils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900568 "fmtlib",
569 "libEGL",
570 "libFLAC",
571 "libFLAC-config",
572 "libFLAC-headers",
573 "libFraunhoferAAC",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900574 "libLibGuiProperties",
Jiyong Parkfa899442020-01-31 02:49:53 +0900575 "libarect",
576 "libasync_safe",
577 "libaudio_system_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000578 "libaudioutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900579 "libaudioutils",
580 "libaudioutils_fixedfft",
581 "libavcdec",
582 "libavcenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000583 "libavservices_minijail",
Jiyong Parkfa899442020-01-31 02:49:53 +0900584 "libavservices_minijail",
585 "libbacktrace",
586 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000587 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900588 "libbase_headers",
589 "libbinder_headers",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900590 "libbinderthreadstateutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900591 "libbluetooth-types-header",
592 "libbufferhub_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000593 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900594 "libc_scudo",
Anton Hansson5053c292020-01-10 15:12:39 +0000595 "libcap",
596 "libcodec2",
Jiyong Parkfa899442020-01-31 02:49:53 +0900597 "libcodec2_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000598 "libcodec2_hidl@1.0",
599 "libcodec2_hidl@1.1",
Jiyong Parkfa899442020-01-31 02:49:53 +0900600 "libcodec2_internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000601 "libcodec2_soft_aacdec",
602 "libcodec2_soft_aacenc",
603 "libcodec2_soft_amrnbdec",
604 "libcodec2_soft_amrnbenc",
605 "libcodec2_soft_amrwbdec",
606 "libcodec2_soft_amrwbenc",
607 "libcodec2_soft_av1dec_gav1",
608 "libcodec2_soft_avcdec",
609 "libcodec2_soft_avcenc",
610 "libcodec2_soft_common",
611 "libcodec2_soft_flacdec",
612 "libcodec2_soft_flacenc",
613 "libcodec2_soft_g711alawdec",
614 "libcodec2_soft_g711mlawdec",
615 "libcodec2_soft_gsmdec",
616 "libcodec2_soft_h263dec",
617 "libcodec2_soft_h263enc",
618 "libcodec2_soft_hevcdec",
619 "libcodec2_soft_hevcenc",
620 "libcodec2_soft_mp3dec",
621 "libcodec2_soft_mpeg2dec",
622 "libcodec2_soft_mpeg4dec",
623 "libcodec2_soft_mpeg4enc",
624 "libcodec2_soft_opusdec",
625 "libcodec2_soft_opusenc",
626 "libcodec2_soft_rawdec",
627 "libcodec2_soft_vorbisdec",
628 "libcodec2_soft_vp8dec",
629 "libcodec2_soft_vp8enc",
630 "libcodec2_soft_vp9dec",
631 "libcodec2_soft_vp9enc",
632 "libcodec2_vndk",
Anton Hansson5053c292020-01-10 15:12:39 +0000633 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900634 "libcutils_headers",
635 "libdexfile_support",
636 "libdvr_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000637 "libfmq",
Jiyong Parkfa899442020-01-31 02:49:53 +0900638 "libfmq",
639 "libgav1",
Anton Hansson5053c292020-01-10 15:12:39 +0000640 "libgralloctypes",
Jiyong Parkfa899442020-01-31 02:49:53 +0900641 "libgrallocusage",
642 "libgraphicsenv",
643 "libgsm",
644 "libgui_bufferqueue_static",
645 "libgui_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000646 "libhardware",
Jiyong Parkfa899442020-01-31 02:49:53 +0900647 "libhardware_headers",
648 "libhevcdec",
649 "libhevcenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000650 "libhidlbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900651 "libhidlbase-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000652 "libhidlmemory",
Jiyong Parkfa899442020-01-31 02:49:53 +0900653 "libhidltransport-impl-internal",
654 "libhwbinder-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000655 "libion",
Jiyong Parkfa899442020-01-31 02:49:53 +0900656 "libjpeg",
657 "libjsoncpp",
658 "liblog_headers",
659 "liblzma",
660 "libmath",
Anton Hansson5053c292020-01-10 15:12:39 +0000661 "libmedia_codecserviceregistrant",
Jiyong Parkfa899442020-01-31 02:49:53 +0900662 "libmedia_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000663 "libminijail",
Jiyong Parkfa899442020-01-31 02:49:53 +0900664 "libminijail_gen_constants",
665 "libminijail_gen_constants_obj",
666 "libminijail_gen_syscall",
667 "libminijail_gen_syscall_obj",
668 "libminijail_generated",
669 "libmpeg2dec",
670 "libnativebase_headers",
671 "libnativebridge_lazy",
672 "libnativeloader_lazy",
673 "libnativewindow_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000674 "libopus",
Jiyong Parkfa899442020-01-31 02:49:53 +0900675 "libpdx_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000676 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900677 "libprocessgroup_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000678 "libscudo_wrapper",
679 "libsfplugin_ccodec_utils",
680 "libspeexresampler",
681 "libstagefright_amrnb_common",
Jiyong Parkfa899442020-01-31 02:49:53 +0900682 "libstagefright_amrnbdec",
683 "libstagefright_amrnbenc",
684 "libstagefright_amrwbdec",
685 "libstagefright_amrwbenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000686 "libstagefright_bufferpool@2.0.1",
687 "libstagefright_bufferqueue_helper",
688 "libstagefright_enc_common",
689 "libstagefright_flacdec",
690 "libstagefright_foundation",
Jiyong Parkfa899442020-01-31 02:49:53 +0900691 "libstagefright_foundation_headers",
692 "libstagefright_headers",
693 "libstagefright_m4vh263dec",
694 "libstagefright_m4vh263enc",
695 "libstagefright_mp3dec",
Anton Hansson5053c292020-01-10 15:12:39 +0000696 "libsync",
Jiyong Parkfa899442020-01-31 02:49:53 +0900697 "libsystem_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000698 "libui",
Jiyong Parkfa899442020-01-31 02:49:53 +0900699 "libui_headers",
700 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900701 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000702 "libvorbisidec",
703 "libvpx",
Jiyong Parkfa899442020-01-31 02:49:53 +0900704 "libyuv",
705 "libyuv_static",
706 "media_ndk_headers",
707 "media_plugin_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000708 "mediaswcodec",
Anton Hansson5053c292020-01-10 15:12:39 +0000709 }
710 //
711 // Module separator
712 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900713 m["com.android.mediaprovider"] = []string{
714 "MediaProvider",
715 "MediaProviderGoogle",
716 "fmtlib_ndk",
717 "guava",
718 "libbase_ndk",
719 "libfuse",
720 "libfuse_jni",
721 "libnativehelper_header_only",
722 }
723 //
724 // Module separator
725 //
726 m["com.android.permission"] = []string{
727 "androidx.annotation_annotation",
728 "androidx.annotation_annotation-nodeps",
729 "androidx.lifecycle_lifecycle-common",
730 "androidx.lifecycle_lifecycle-common-java8",
731 "androidx.lifecycle_lifecycle-common-java8-nodeps",
732 "androidx.lifecycle_lifecycle-common-nodeps",
733 "kotlin-annotations",
734 "kotlin-stdlib",
735 "kotlin-stdlib-jdk7",
736 "kotlin-stdlib-jdk8",
737 "kotlinx-coroutines-android",
738 "kotlinx-coroutines-android-nodeps",
739 "kotlinx-coroutines-core",
740 "kotlinx-coroutines-core-nodeps",
741 "libprotobuf-java-lite",
742 "permissioncontroller-statsd",
Jiyong Park26fb6bd2020-02-06 16:47:54 +0900743 "GooglePermissionController",
744 "PermissionController",
Jiyong Parkfa899442020-01-31 02:49:53 +0900745 }
Anton Hansson5053c292020-01-10 15:12:39 +0000746 //
747 // Module separator
748 //
Anton Hansson5053c292020-01-10 15:12:39 +0000749 m["com.android.runtime"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900750 "bionic_libc_platform_headers",
751 "fmtlib",
752 "libarm-optimized-routines-math",
753 "libasync_safe",
754 "libasync_safe_headers",
755 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000756 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900757 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000758 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900759 "libc_aeabi",
760 "libc_bionic",
761 "libc_bionic_ndk",
762 "libc_bootstrap",
763 "libc_common",
764 "libc_common_shared",
765 "libc_common_static",
766 "libc_dns",
767 "libc_dynamic_dispatch",
768 "libc_fortify",
769 "libc_freebsd",
770 "libc_freebsd_large_stack",
771 "libc_gdtoa",
772 "libc_headers",
773 "libc_init_dynamic",
774 "libc_init_static",
775 "libc_jemalloc_wrapper",
776 "libc_netbsd",
777 "libc_nomalloc",
778 "libc_nopthread",
779 "libc_openbsd",
780 "libc_openbsd_large_stack",
781 "libc_openbsd_ndk",
782 "libc_pthread",
783 "libc_static_dispatch",
784 "libc_syscalls",
785 "libc_tzcode",
786 "libc_unwind_static",
787 "libcutils",
788 "libcutils_headers",
789 "libdebuggerd",
790 "libdebuggerd_common_headers",
791 "libdebuggerd_handler_core",
792 "libdebuggerd_handler_fallback",
793 "libdexfile_external_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000794 "libdexfile_support",
Jiyong Parkfa899442020-01-31 02:49:53 +0900795 "libdexfile_support_static",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900796 "libdl_static",
Jiyong Parkfa899442020-01-31 02:49:53 +0900797 "libgtest_prod",
798 "libjemalloc5",
799 "liblinker_main",
800 "liblinker_malloc",
Jiyong Parkfa899442020-01-31 02:49:53 +0900801 "liblog_headers",
802 "liblz4",
Anton Hansson5053c292020-01-10 15:12:39 +0000803 "liblzma",
Jiyong Parkfa899442020-01-31 02:49:53 +0900804 "libprocessgroup_headers",
805 "libprocinfo",
806 "libpropertyinfoparser",
807 "libscudo",
808 "libstdc++",
809 "libsystem_headers",
810 "libsystemproperties",
811 "libtombstoned_client_static",
Anton Hansson5053c292020-01-10 15:12:39 +0000812 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900813 "libutils_headers",
814 "libz",
815 "libziparchive",
Anton Hansson5053c292020-01-10 15:12:39 +0000816 }
817 //
818 // Module separator
819 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900820 m["com.android.resolv"] = []string{
821 "bcm_object",
822 "dnsresolver_aidl_interface-unstable-ndk_platform",
823 "fmtlib",
824 "libbacktrace_headers",
825 "libbase",
826 "libbase_headers",
827 "libc++",
828 "libcrypto",
829 "libcutils",
830 "libcutils_headers",
831 "libgtest_prod",
832 "libjsoncpp",
Jiyong Parkfa899442020-01-31 02:49:53 +0900833 "liblog_headers",
834 "libnativehelper_header_only",
835 "libnetd_client_headers",
836 "libnetd_resolv",
837 "libnetdutils",
838 "libprocessgroup",
839 "libprocessgroup_headers",
840 "libprotobuf-cpp-lite",
841 "libssl",
842 "libstatslog_resolv",
843 "libstatspush_compat",
844 "libstatssocket",
845 "libstatssocket_headers",
846 "libsystem_headers",
847 "libsysutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900848 "libutils_headers",
849 "netd_event_listener_interface-ndk_platform",
850 "server_configurable_flags",
851 "stats_proto",
852 }
Anton Hansson5053c292020-01-10 15:12:39 +0000853 //
854 // Module separator
855 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900856 m["com.android.tethering"] = []string{
857 "libbase",
858 "libc++",
859 "libnativehelper_compat_libc++",
860 "android.hardware.tetheroffload.config@1.0",
861 "fmtlib",
862 "libbacktrace_headers",
863 "libbase_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900864 "libcgrouprc",
865 "libcgrouprc_format",
866 "libcutils",
867 "libcutils_headers",
868 "libhidlbase",
869 "libhidlbase-impl-internal",
870 "libhidltransport-impl-internal",
871 "libhwbinder-impl-internal",
872 "libjsoncpp",
Jiyong Parkfa899442020-01-31 02:49:53 +0900873 "liblog_headers",
874 "libprocessgroup",
875 "libprocessgroup_headers",
876 "libsystem_headers",
877 "libtetherutilsjni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900878 "libutils_headers",
879 "libvndksupport",
880 "tethering-aidl-interfaces-java",
881 }
Anton Hansson5053c292020-01-10 15:12:39 +0000882 //
883 // Module separator
884 //
885 m["com.android.wifi"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900886 "PlatformProperties",
887 "android.hardware.wifi-V1.0-java",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900888 "android.hardware.wifi-V1.0-java-constants",
Jiyong Parkfa899442020-01-31 02:49:53 +0900889 "android.hardware.wifi-V1.1-java",
890 "android.hardware.wifi-V1.2-java",
891 "android.hardware.wifi-V1.3-java",
892 "android.hardware.wifi-V1.4-java",
893 "android.hardware.wifi.hostapd-V1.0-java",
894 "android.hardware.wifi.hostapd-V1.1-java",
895 "android.hardware.wifi.hostapd-V1.2-java",
896 "android.hardware.wifi.supplicant-V1.0-java",
897 "android.hardware.wifi.supplicant-V1.1-java",
898 "android.hardware.wifi.supplicant-V1.2-java",
899 "android.hardware.wifi.supplicant-V1.3-java",
900 "android.hidl.base-V1.0-java",
901 "android.hidl.manager-V1.0-java",
902 "android.hidl.manager-V1.1-java",
903 "android.hidl.manager-V1.2-java",
904 "androidx.annotation_annotation",
905 "androidx.annotation_annotation-nodeps",
906 "bouncycastle-unbundled",
907 "dnsresolver_aidl_interface-V2-java",
908 "error_prone_annotations",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900909 "framework-wifi-pre-jarjar",
910 "framework-wifi-util-lib",
Jiyong Parkfa899442020-01-31 02:49:53 +0900911 "ipmemorystore-aidl-interfaces-V3-java",
912 "ipmemorystore-aidl-interfaces-java",
913 "ksoap2",
914 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000915 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900916 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000917 "libc++",
918 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900919 "libcutils_headers",
920 "liblog_headers",
921 "libnanohttpd",
Anton Hansson5053c292020-01-10 15:12:39 +0000922 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900923 "libprocessgroup_headers",
924 "libprotobuf-java-lite",
925 "libprotobuf-java-nano",
926 "libsystem_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900927 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000928 "libwifi-jni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900929 "net-utils-services-common",
930 "netd_aidl_interface-V2-java",
931 "netd_aidl_interface-unstable-java",
932 "netd_event_listener_interface-java",
933 "netlink-client",
934 "networkstack-aidl-interfaces-unstable-java",
935 "networkstack-client",
936 "services.net",
937 "wifi-lite-protos",
938 "wifi-nano-protos",
939 "wifi-service-pre-jarjar",
Anton Hansson5053c292020-01-10 15:12:39 +0000940 "wifi-service-resources",
Jiyong Parkfa899442020-01-31 02:49:53 +0900941 "prebuilt_androidx.annotation_annotation-nodeps",
Anton Hansson5053c292020-01-10 15:12:39 +0000942 }
943 //
944 // Module separator
945 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900946 m["com.android.sdkext"] = []string{
947 "fmtlib_ndk",
948 "libbase_ndk",
949 "libprotobuf-cpp-lite-ndk",
950 }
951 //
952 // Module separator
953 //
954 m["com.android.os.statsd"] = []string{
955 "libbacktrace_headers",
956 "libbase_headers",
957 "libc++",
958 "libcutils",
959 "libcutils_headers",
960 "liblog_headers",
961 "libprocessgroup_headers",
962 "libstatssocket",
963 "libsystem_headers",
964 "libutils_headers",
965 }
966 //
967 // Module separator
968 //
969 m["//any"] = []string{
970 "crtbegin_dynamic",
971 "crtbegin_dynamic1",
972 "crtbegin_so",
973 "crtbegin_so1",
974 "crtbegin_static",
975 "crtbrand",
976 "crtend_android",
977 "crtend_so",
978 "libatomic",
979 "libc++_static",
980 "libc++abi",
981 "libc++demangle",
982 "libc_headers",
983 "libclang_rt",
984 "libgcc_stripped",
985 "libprofile-clang-extras",
986 "libprofile-clang-extras_ndk",
987 "libprofile-extras",
988 "libprofile-extras_ndk",
989 "libunwind_llvm",
990 "ndk_crtbegin_dynamic.27",
991 "ndk_crtbegin_so.16",
992 "ndk_crtbegin_so.19",
993 "ndk_crtbegin_so.21",
994 "ndk_crtbegin_so.24",
995 "ndk_crtbegin_so.27",
996 "ndk_crtend_android.27",
997 "ndk_crtend_so.16",
998 "ndk_crtend_so.19",
999 "ndk_crtend_so.21",
1000 "ndk_crtend_so.24",
1001 "ndk_crtend_so.27",
1002 "ndk_libandroid_support",
1003 "ndk_libc++_static",
1004 "ndk_libc++abi",
1005 "ndk_libunwind",
1006 }
Anton Hansson5053c292020-01-10 15:12:39 +00001007 return m
1008}
1009
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001010func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +09001011 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -08001012 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +09001013 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +09001014 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -07001015 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +09001016 android.RegisterModuleType("override_apex", overrideApexFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001017
Jooyung Han31c470b2019-10-18 16:26:59 +09001018 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001019 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +09001020
1021 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
1022 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
1023 sort.Strings(*apexFileContextsInfos)
1024 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
1025 })
Jiyong Parkd1063c12019-07-17 20:08:41 +09001026}
1027
Jooyung Han31c470b2019-10-18 16:26:59 +09001028func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
1029 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
1030 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
1031}
1032
Jiyong Parkd1063c12019-07-17 20:08:41 +09001033func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parkf760cae2020-02-12 07:53:12 +09001034 ctx.TopDown("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001035 ctx.BottomUp("apex", apexMutator).Parallel()
1036 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
1037 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001038}
1039
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001040// Mark the direct and transitive dependencies of apex bundles so that they
1041// can be built for the apex bundles.
Jiyong Parkf760cae2020-02-12 07:53:12 +09001042func apexDepsMutator(mctx android.TopDownMutatorContext) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001043 var apexBundles []android.ApexInfo
Jiyong Parkf760cae2020-02-12 07:53:12 +09001044 var directDep bool
Jooyung Hana57af4a2020-01-23 05:36:59 +00001045 if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jooyung Han0c4e0162020-02-26 22:45:42 +09001046 minSdkVersion := a.minSdkVersion(mctx)
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001047 apexBundles = []android.ApexInfo{android.ApexInfo{
1048 ApexName: mctx.ModuleName(),
1049 LegacyAndroid10Support: proptools.Bool(a.properties.Legacy_android10_support),
Jooyung Han0c4e0162020-02-26 22:45:42 +09001050 MinSdkVersion: minSdkVersion,
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001051 }}
Jiyong Parkf760cae2020-02-12 07:53:12 +09001052 directDep = true
1053 } else if am, ok := mctx.Module().(android.ApexModule); ok {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001054 apexBundles = am.ApexVariations()
Jiyong Parkf760cae2020-02-12 07:53:12 +09001055 directDep = false
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001056 }
Jiyong Parkf760cae2020-02-12 07:53:12 +09001057
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001058 if len(apexBundles) == 0 {
Jiyong Parkf760cae2020-02-12 07:53:12 +09001059 return
1060 }
1061
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001062 cur := mctx.Module().(interface {
1063 DepIsInSameApex(android.BaseModuleContext, android.Module) bool
1064 })
1065
Jiyong Parkf760cae2020-02-12 07:53:12 +09001066 mctx.VisitDirectDeps(func(child android.Module) {
1067 depName := mctx.OtherModuleName(child)
1068 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001069 cur.DepIsInSameApex(mctx, child) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001070 android.UpdateApexDependency(apexBundles, depName, directDep)
1071 am.BuildForApexes(apexBundles)
Jiyong Parkf760cae2020-02-12 07:53:12 +09001072 }
1073 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001074}
1075
1076// Create apex variations if a module is included in APEX(s).
1077func apexMutator(mctx android.BottomUpMutatorContext) {
1078 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +09001079 am.CreateApexVariations(mctx)
Jooyung Hana57af4a2020-01-23 05:36:59 +00001080 } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001081 // apex bundle itself is mutated so that it and its modules have same
1082 // apex variant.
1083 apexBundleName := mctx.ModuleName()
1084 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +09001085 } else if o, ok := mctx.Module().(*OverrideApex); ok {
1086 apexBundleName := o.GetOverriddenModuleName()
1087 if apexBundleName == "" {
1088 mctx.ModuleErrorf("base property is not set")
1089 return
1090 }
1091 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001092 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001093
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001094}
Sundong Ahne9b55722019-09-06 17:37:42 +09001095
Jooyung Han7a78a922019-10-08 21:59:58 +09001096var (
1097 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
1098 apexFileContextsInfosMutex sync.Mutex
1099)
1100
1101func apexFileContextsInfos(config android.Config) *[]string {
1102 return config.Once(apexFileContextsInfosKey, func() interface{} {
1103 return &[]string{}
1104 }).(*[]string)
1105}
1106
Jooyung Han54aca7b2019-11-20 02:26:02 +09001107func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +09001108 apexFileContextsInfosMutex.Lock()
1109 defer apexFileContextsInfosMutex.Unlock()
1110 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +09001111 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +09001112}
1113
Sundong Ahne9b55722019-09-06 17:37:42 +09001114func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Sundong Ahne8fb7242019-09-17 13:50:45 +09001115 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +09001116 var variants []string
1117 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
1118 case "image":
1119 variants = append(variants, imageApexType, flattenedApexType)
1120 case "zip":
1121 variants = append(variants, zipApexType)
1122 case "both":
1123 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
1124 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001125 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +09001126 return
1127 }
1128
1129 modules := mctx.CreateLocalVariations(variants...)
1130
1131 for i, v := range variants {
1132 switch v {
1133 case imageApexType:
1134 modules[i].(*apexBundle).properties.ApexType = imageApex
1135 case zipApexType:
1136 modules[i].(*apexBundle).properties.ApexType = zipApex
1137 case flattenedApexType:
1138 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +09001139 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001140 modules[i].(*apexBundle).MakeAsSystemExt()
1141 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001142 }
Sundong Ahne9b55722019-09-06 17:37:42 +09001143 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001144 } else if _, ok := mctx.Module().(*OverrideApex); ok {
1145 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +09001146 }
1147}
1148
Jooyung Han5c998b92019-06-27 11:30:33 +09001149func apexUsesMutator(mctx android.BottomUpMutatorContext) {
1150 if ab, ok := mctx.Module().(*apexBundle); ok {
1151 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
1152 }
1153}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001154
Jooyung Handc782442019-11-01 03:14:38 +09001155var (
1156 useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
1157)
1158
1159// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
1160// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
1161// which may cause compatibility issues. (e.g. libbinder)
1162// Even though libbinder restricts its availability via 'apex_available' property and relies on
1163// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
1164// to avoid similar problems.
1165func useVendorWhitelist(config android.Config) []string {
1166 return config.Once(useVendorWhitelistKey, func() interface{} {
1167 return []string{
1168 // swcodec uses "vendor" variants for smaller size
1169 "com.android.media.swcodec",
1170 "test_com.android.media.swcodec",
1171 }
1172 }).([]string)
1173}
1174
1175// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
1176// called before the first call to useVendorWhitelist()
1177func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
1178 config.Once(useVendorWhitelistKey, func() interface{} {
1179 return whitelist
1180 })
1181}
1182
Alex Light9670d332019-01-29 18:07:33 -08001183type apexNativeDependencies struct {
1184 // List of native libraries
1185 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +09001186
Alex Light9670d332019-01-29 18:07:33 -08001187 // List of native executables
1188 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +09001189
Roland Levillain630846d2019-06-26 12:48:34 +01001190 // List of native tests
1191 Tests []string
Alex Light9670d332019-01-29 18:07:33 -08001192}
Jooyung Han344d5432019-08-23 11:17:39 +09001193
Alex Light9670d332019-01-29 18:07:33 -08001194type apexMultilibProperties struct {
1195 // Native dependencies whose compile_multilib is "first"
1196 First apexNativeDependencies
1197
1198 // Native dependencies whose compile_multilib is "both"
1199 Both apexNativeDependencies
1200
1201 // Native dependencies whose compile_multilib is "prefer32"
1202 Prefer32 apexNativeDependencies
1203
1204 // Native dependencies whose compile_multilib is "32"
1205 Lib32 apexNativeDependencies
1206
1207 // Native dependencies whose compile_multilib is "64"
1208 Lib64 apexNativeDependencies
1209}
1210
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001211type apexBundleProperties struct {
1212 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +00001213 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -08001214 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001215
Jiyong Park40e26a22019-02-08 02:53:06 +09001216 // AndroidManifest.xml file used for the zip container of this APEX bundle.
1217 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -08001218 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +09001219
Roland Levillain411c5842019-09-19 16:37:20 +01001220 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
1221 // device (/apex/<apex_name>).
1222 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +09001223 Apex_name *string
1224
Jiyong Parkd0a65ba2018-11-10 06:37:15 +09001225 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +09001226 // For platform APEXes, this should points to a file under /system/sepolicy
1227 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
1228 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001229
1230 // List of native shared libs that are embedded inside this APEX bundle
1231 Native_shared_libs []string
1232
Roland Levillain630846d2019-06-26 12:48:34 +01001233 // List of executables that are embedded inside this APEX bundle
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001234 Binaries []string
1235
1236 // List of java libraries that are embedded inside this APEX bundle
1237 Java_libs []string
1238
1239 // List of prebuilt files that are embedded inside this APEX bundle
1240 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +09001241
Roland Levillain630846d2019-06-26 12:48:34 +01001242 // List of tests that are embedded inside this APEX bundle
1243 Tests []string
1244
Jiyong Parkff1458f2018-10-12 21:49:38 +09001245 // Name of the apex_key module that provides the private key to sign APEX
1246 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +09001247
Alex Light5098a612018-11-29 17:12:15 -08001248 // The type of APEX to build. Controls what the APEX payload is. Either
1249 // 'image', 'zip' or 'both'. Default: 'image'.
1250 Payload_type *string
1251
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001252 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
1253 // or an android_app_certificate module name in the form ":module".
1254 Certificate *string
1255
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001256 // Whether this APEX is installable to one of the partitions. Default: true.
1257 Installable *bool
1258
Jiyong Parkda6eb592018-12-19 17:12:36 +09001259 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
1260 // Default is false.
1261 Use_vendor *bool
1262
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001263 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
1264 Ignore_system_library_special_case *bool
1265
Alex Light9670d332019-01-29 18:07:33 -08001266 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +09001267
Jiyong Parkf97782b2019-02-13 20:28:58 +09001268 // List of sanitizer names that this APEX is enabled for
1269 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +09001270
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001271 PreventInstall bool `blueprint:"mutated"`
1272
1273 HideFromMake bool `blueprint:"mutated"`
1274
Jooyung Han5c998b92019-06-27 11:30:33 +09001275 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
1276 Provide_cpp_shared_libs *bool
1277
1278 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
1279 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +01001280
1281 // A txt file containing list of files that are whitelisted to be included in this APEX.
1282 Whitelisted_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001283
Sundong Ahnabb64432019-10-22 13:58:29 +09001284 // package format of this apex variant; could be non-flattened, flattened, or zip.
1285 // imageApex, zipApex or flattened
1286 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +09001287
Jiyong Parkd1063c12019-07-17 20:08:41 +09001288 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
1289 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
1290 // is implied. This value affects all modules included in this APEX. In other words, they are
1291 // also built with the SDKs specified here.
1292 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +09001293
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001294 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
1295 // Should be only used in tests#.
1296 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +09001297
1298 // Whether this APEX should support Android10. Default is false. If this is set true, then apex_manifest.json is bundled as well
1299 // because Android10 requires legacy apex_manifest.json instead of apex_manifest.pb
1300 Legacy_android10_support *bool
Jiyong Park956305c2020-01-09 12:32:06 +09001301
1302 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park9d677202020-02-19 16:29:35 +09001303
1304 // Whether this APEX is considered updatable or not. When set to true, this will enforce additional
1305 // rules for making sure that the APEX is truely updatable. This will also disable the size optimizations
1306 // like symlinking to the system libs. Default is false.
1307 Updatable *bool
Colin Cross7365eaa2020-02-19 20:41:10 -08001308
1309 // The minimum SDK version that this apex must be compatible with.
1310 Min_sdk_version *string
Alex Light9670d332019-01-29 18:07:33 -08001311}
1312
1313type apexTargetBundleProperties struct {
1314 Target struct {
1315 // Multilib properties only for android.
1316 Android struct {
1317 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001318 }
Jooyung Han344d5432019-08-23 11:17:39 +09001319
Alex Light9670d332019-01-29 18:07:33 -08001320 // Multilib properties only for host.
1321 Host struct {
1322 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001323 }
Jooyung Han344d5432019-08-23 11:17:39 +09001324
Alex Light9670d332019-01-29 18:07:33 -08001325 // Multilib properties only for host linux_bionic.
1326 Linux_bionic struct {
1327 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001328 }
Jooyung Han344d5432019-08-23 11:17:39 +09001329
Alex Light9670d332019-01-29 18:07:33 -08001330 // Multilib properties only for host linux_glibc.
1331 Linux_glibc struct {
1332 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001333 }
1334 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001335}
1336
Jiyong Park5d790c32019-11-15 18:40:32 +09001337type overridableProperties struct {
1338 // List of APKs to package inside APEX
1339 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001340
1341 // Names of modules to be overridden. Listed modules can only be other binaries
1342 // (in Make or Soong).
1343 // This does not completely prevent installation of the overridden binaries, but if both
1344 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
1345 // from PRODUCT_PACKAGES.
1346 Overrides []string
Baligh Uddin004d7172020-02-19 21:29:28 -08001347
1348 // Logging Parent value
1349 Logging_parent string
Jiyong Park5d790c32019-11-15 18:40:32 +09001350}
1351
Alex Light5098a612018-11-29 17:12:15 -08001352type apexPackaging int
1353
1354const (
1355 imageApex apexPackaging = iota
1356 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +09001357 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -08001358)
1359
Sundong Ahnabb64432019-10-22 13:58:29 +09001360// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -08001361func (a apexPackaging) suffix() string {
1362 switch a {
1363 case imageApex:
1364 return imageApexSuffix
1365 case zipApex:
1366 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -08001367 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001368 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001369 }
1370}
1371
1372func (a apexPackaging) name() string {
1373 switch a {
1374 case imageApex:
1375 return imageApexType
1376 case zipApex:
1377 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -08001378 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001379 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001380 }
1381}
1382
Jiyong Parkf653b052019-11-18 15:39:01 +09001383type apexFileClass int
1384
1385const (
1386 etc apexFileClass = iota
1387 nativeSharedLib
1388 nativeExecutable
1389 shBinary
1390 pyBinary
1391 goBinary
1392 javaSharedLib
1393 nativeTest
1394 app
1395)
1396
Jiyong Park8fd61922018-11-08 02:50:25 +09001397func (class apexFileClass) NameInMake() string {
1398 switch class {
1399 case etc:
1400 return "ETC"
1401 case nativeSharedLib:
1402 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -08001403 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +09001404 return "EXECUTABLES"
1405 case javaSharedLib:
1406 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +01001407 case nativeTest:
1408 return "NATIVE_TESTS"
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001409 case app:
Jiyong Parkf383f7c2019-10-11 20:46:25 +09001410 // b/142537672 Why isn't this APP? We want to have full control over
1411 // the paths and file names of the apk file under the flattend APEX.
1412 // If this is set to APP, then the paths and file names are modified
1413 // by the Make build system. For example, it is installed to
1414 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
1415 // /system/apex/<apexname>/app/<Appname> because the build system automatically
1416 // appends module name (which is <apexname>.<Appname> to the path.
1417 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +09001418 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001419 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +09001420 }
1421}
1422
Jiyong Parkf653b052019-11-18 15:39:01 +09001423// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +09001424type apexFile struct {
1425 builtFile android.Path
1426 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +09001427 installDir string
1428 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +09001429 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +09001430 // list of symlinks that will be created in installDir that point to this apexFile
1431 symlinks []string
1432 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +09001433 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +09001434
1435 requiredModuleNames []string
1436 targetRequiredModuleNames []string
1437 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +09001438
Colin Cross503c1d02020-01-28 14:00:53 -08001439 jacocoReportClassesFile android.Path // only for javalibs and apps
1440 certificate java.Certificate // only for apps
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001441 overriddenPackageName string // only for apps
Jiyong Parkf653b052019-11-18 15:39:01 +09001442}
1443
Jiyong Park1833cef2019-12-13 13:28:36 +09001444func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
1445 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +09001446 builtFile: builtFile,
1447 moduleName: moduleName,
1448 installDir: installDir,
1449 class: class,
1450 module: module,
1451 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001452 if module != nil {
1453 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +09001454 ret.requiredModuleNames = module.RequiredModuleNames()
1455 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
1456 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +09001457 }
1458 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +09001459}
1460
1461func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +09001462 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +09001463}
1464
Jiyong Park7cd10e32020-01-14 09:22:18 +09001465// Path() returns path of this apex file relative to the APEX root
1466func (af *apexFile) Path() string {
1467 return filepath.Join(af.installDir, af.builtFile.Base())
1468}
1469
1470// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
1471func (af *apexFile) SymlinkPaths() []string {
1472 var ret []string
1473 for _, symlink := range af.symlinks {
1474 ret = append(ret, filepath.Join(af.installDir, symlink))
1475 }
1476 return ret
1477}
1478
1479func (af *apexFile) AvailableToPlatform() bool {
1480 if af.module == nil {
1481 return false
1482 }
1483 if am, ok := af.module.(android.ApexModule); ok {
1484 return am.AvailableFor(android.AvailableToPlatform)
1485 }
1486 return false
1487}
1488
Jiyong Park678c8812020-02-07 17:25:49 +09001489type depInfo struct {
1490 to string
1491 from []string
1492 isExternal bool
1493}
1494
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001495type apexBundle struct {
1496 android.ModuleBase
1497 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +09001498 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +09001499 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001500
Jiyong Park5d790c32019-11-15 18:40:32 +09001501 properties apexBundleProperties
1502 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +09001503 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001504
Jooyung Hanf21c7972019-12-16 22:32:06 +09001505 // specific to apex_vndk modules
1506 vndkProperties apexVndkProperties
1507
Colin Crossa4925902018-11-16 11:36:28 -08001508 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +09001509 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -07001510 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +09001511
Jiyong Park03b68dd2019-07-26 23:20:40 +09001512 prebuiltFileToDelete string
1513
Jiyong Park42cca6c2019-04-01 11:15:50 +09001514 public_key_file android.Path
1515 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001516
1517 container_certificate_file android.Path
1518 container_private_key_file android.Path
1519
Jooyung Han54aca7b2019-11-20 02:26:02 +09001520 fileContexts android.Path
1521
Jiyong Park8fd61922018-11-08 02:50:25 +09001522 // list of files to be included in this apex
1523 filesInfo []apexFile
1524
Jiyong Park956305c2020-01-09 12:32:06 +09001525 // list of module names that should be installed along with this APEX
1526 requiredDeps []string
1527
Jiyong Park956305c2020-01-09 12:32:06 +09001528 // list of module names that this APEX is including (to be shown via *-deps-info target)
Jiyong Park678c8812020-02-07 17:25:49 +09001529 depInfos map[string]depInfo
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001530
Sundong Ahnabb64432019-10-22 13:58:29 +09001531 testApex bool
1532 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001533 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +09001534 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +09001535
Jooyung Han214bf372019-11-12 13:03:50 +09001536 manifestJsonOut android.WritablePath
1537 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +09001538
Jooyung Han002ab682020-01-08 01:57:58 +09001539 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +09001540 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +09001541 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +09001542 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
1543 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +09001544
1545 // Suffix of module name in Android.mk
1546 // ".flattened", ".apex", ".zipapex", or ""
1547 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +09001548
1549 installedFilesFile android.WritablePath
Jiyong Park7cd10e32020-01-14 09:22:18 +09001550
1551 // Whether to create symlink to the system file instead of having a file
1552 // inside the apex or not
1553 linkToSystemLib bool
Jiyong Park19972c72020-01-28 20:05:29 +09001554
1555 // Struct holding the merged notice file paths in different formats
1556 mergedNotices android.NoticeOutputs
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001557}
1558
Jiyong Park397e55e2018-10-24 21:09:55 +09001559func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +01001560 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001561 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +09001562 // Use *FarVariation* to be able to depend on modules having
1563 // conflicting variations with this module. This is required since
1564 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
1565 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001566 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +09001567 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +09001568 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +09001569 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001570 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001571
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001572 ctx.AddFarVariationDependencies(append(target.Variations(),
1573 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
1574 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +01001575
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001576 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001577 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001578 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001579 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001580}
1581
Alex Light9670d332019-01-29 18:07:33 -08001582func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
1583 if ctx.Os().Class == android.Device {
1584 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
1585 } else {
1586 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
1587 if ctx.Os().Bionic() {
1588 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
1589 } else {
1590 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
1591 }
1592 }
1593}
1594
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001595func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +09001596 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
1597 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1598 }
1599
Jiyong Park397e55e2018-10-24 21:09:55 +09001600 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +09001601 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -08001602
1603 a.combineProperties(ctx)
1604
Jiyong Park397e55e2018-10-24 21:09:55 +09001605 has32BitTarget := false
1606 for _, target := range targets {
1607 if target.Arch.ArchType.Multilib == "lib32" {
1608 has32BitTarget = true
1609 }
1610 }
1611 for i, target := range targets {
1612 // When multilib.* is omitted for native_shared_libs, it implies
1613 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001614 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +09001615 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001616 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001617 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001618
Roland Levillain630846d2019-06-26 12:48:34 +01001619 // When multilib.* is omitted for tests, it implies
1620 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001621 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001622 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001623 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001624 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +01001625
Jiyong Park397e55e2018-10-24 21:09:55 +09001626 // Add native modules targetting both ABIs
1627 addDependenciesForNativeModules(ctx,
1628 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001629 a.properties.Multilib.Both.Binaries,
1630 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001631 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001632 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001633
Alex Light3d673592019-01-18 14:37:31 -08001634 isPrimaryAbi := i == 0
1635 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +09001636 // When multilib.* is omitted for binaries, it implies
1637 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001638 ctx.AddFarVariationDependencies(append(target.Variations(),
1639 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
1640 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001641
1642 // Add native modules targetting the first ABI
1643 addDependenciesForNativeModules(ctx,
1644 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001645 a.properties.Multilib.First.Binaries,
1646 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001647 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001648 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001649 }
1650
1651 switch target.Arch.ArchType.Multilib {
1652 case "lib32":
1653 // Add native modules targetting 32-bit ABI
1654 addDependenciesForNativeModules(ctx,
1655 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001656 a.properties.Multilib.Lib32.Binaries,
1657 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001658 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001659 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001660
1661 addDependenciesForNativeModules(ctx,
1662 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001663 a.properties.Multilib.Prefer32.Binaries,
1664 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001665 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001666 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001667 case "lib64":
1668 // Add native modules targetting 64-bit ABI
1669 addDependenciesForNativeModules(ctx,
1670 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001671 a.properties.Multilib.Lib64.Binaries,
1672 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001673 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001674 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001675
1676 if !has32BitTarget {
1677 addDependenciesForNativeModules(ctx,
1678 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001679 a.properties.Multilib.Prefer32.Binaries,
1680 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001681 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001682 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001683 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001684
1685 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
1686 for _, sanitizer := range ctx.Config().SanitizeDevice() {
1687 if sanitizer == "hwaddress" {
1688 addDependenciesForNativeModules(ctx,
1689 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001690 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001691 break
1692 }
1693 }
1694 }
Jiyong Park397e55e2018-10-24 21:09:55 +09001695 }
1696
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001697 }
1698
Jiyong Parkce6aadc2019-11-20 13:58:28 +09001699 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
1700 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
1701 // b/144532908
1702 archForPrebuiltEtc := config.Arches()[0]
1703 for _, arch := range config.Arches() {
1704 // Prefer 64-bit arch if there is any
1705 if arch.ArchType.Multilib == "lib64" {
1706 archForPrebuiltEtc = arch
1707 break
1708 }
1709 }
1710 ctx.AddFarVariationDependencies([]blueprint.Variation{
1711 {Mutator: "os", Variation: ctx.Os().String()},
1712 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
1713 }, prebuiltTag, a.properties.Prebuilts...)
1714
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001715 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1716 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001717
Ulya Trafimovich44561882020-01-03 13:25:54 +00001718 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
1719 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
1720 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1721 javaLibTag, "jacocoagent")
1722 }
1723
Jiyong Park23c52b02019-02-02 13:13:47 +09001724 if String(a.properties.Key) == "" {
1725 ctx.ModuleErrorf("key is missing")
1726 return
1727 }
1728 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001729
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001730 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +09001731 if cert != "" {
1732 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001733 }
Jiyong Parkd1063c12019-07-17 20:08:41 +09001734
1735 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
1736 if len(a.properties.Uses_sdks) > 0 {
1737 sdkRefs := []android.SdkRef{}
1738 for _, str := range a.properties.Uses_sdks {
1739 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
1740 sdkRefs = append(sdkRefs, parsed)
1741 }
1742 a.BuildWithSdks(sdkRefs)
1743 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001744}
1745
Jiyong Park5d790c32019-11-15 18:40:32 +09001746func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
1747 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1748 androidAppTag, a.overridableProperties.Apps...)
1749}
1750
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001751func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1752 // direct deps of an APEX bundle are all part of the APEX bundle
1753 return true
1754}
1755
Colin Cross0ea8ba82019-06-06 14:33:29 -07001756func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001757 moduleName := ctx.ModuleName()
1758 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1759 // we check with the pseudo module name to see if its certificate is overridden.
1760 if a.vndkApex {
1761 moduleName = vndkApexName
1762 }
1763 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001764 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001765 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001766 }
1767 return String(a.properties.Certificate)
1768}
1769
Colin Cross41955e82019-05-29 14:40:35 -07001770func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1771 switch tag {
1772 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001773 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001774 default:
1775 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001776 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001777}
1778
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001779func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001780 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001781}
1782
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001783func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1784 return proptools.Bool(a.properties.Test_only_no_hashtree)
1785}
1786
Jiyong Park7c1dc612019-01-05 11:15:24 +09001787func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001788 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001789 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001790 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001791 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001792 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001793 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001794 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001795 }
1796}
1797
Jiyong Parkf97782b2019-02-13 20:28:58 +09001798func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1799 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1800 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1801 }
1802}
1803
Jiyong Park388ef3f2019-01-28 19:47:32 +09001804func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001805 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1806 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001807 }
1808
1809 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001810 globalSanitizerNames := []string{}
1811 if a.Host() {
1812 globalSanitizerNames = ctx.Config().SanitizeHost()
1813 } else {
1814 arches := ctx.Config().SanitizeDeviceArch()
1815 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1816 globalSanitizerNames = ctx.Config().SanitizeDevice()
1817 }
1818 }
1819 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001820}
1821
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001822func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
Oliver Nguyen1382ab62019-12-06 15:22:41 -08001823 return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled())
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001824}
1825
1826func (a *apexBundle) PreventInstall() {
1827 a.properties.PreventInstall = true
1828}
1829
1830func (a *apexBundle) HideFromMake() {
1831 a.properties.HideFromMake = true
1832}
1833
Jiyong Park956305c2020-01-09 12:32:06 +09001834func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1835 a.properties.IsCoverageVariant = coverage
1836}
1837
Jiyong Parkf653b052019-11-18 15:39:01 +09001838// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001839func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001840 // Decide the APEX-local directory by the multilib of the library
1841 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001842 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001843 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001844 case "lib32":
1845 dirInApex = "lib"
1846 case "lib64":
1847 dirInApex = "lib64"
1848 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001849 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001850 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001851 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001852 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001853 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001854 // Special case for Bionic libs and other libs installed with them. This is
1855 // to prevent those libs from being included in the search path
1856 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1857 // those libs in the Runtime APEX are available via the legacy paths in
1858 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1859 // to the legacy paths and thus will be loaded into the default linker
1860 // namespace (aka "platform" namespace). If the libs are directly in
1861 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1862 // into the runtime linker namespace, which will result in double loading of
1863 // them, which isn't supported.
1864 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001865 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001866
Jiyong Parkf653b052019-11-18 15:39:01 +09001867 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001868 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001869}
1870
Jiyong Park1833cef2019-12-13 13:28:36 +09001871func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001872 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001873 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001874 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001875 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001876 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001877 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001878 af.symlinks = cc.Symlinks()
1879 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001880}
1881
Jiyong Park1833cef2019-12-13 13:28:36 +09001882func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001883 dirInApex := "bin"
1884 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001885 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001886}
Jiyong Park1833cef2019-12-13 13:28:36 +09001887func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001888 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001889 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1890 if err != nil {
1891 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001892 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001893 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001894 fileToCopy := android.PathForOutput(ctx, s)
1895 // NB: Since go binaries are static we don't need the module for anything here, which is
1896 // good since the go tool is a blueprint.Module not an android.Module like we would
1897 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001898 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001899}
1900
Jiyong Park1833cef2019-12-13 13:28:36 +09001901func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001902 dirInApex := filepath.Join("bin", sh.SubDir())
1903 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001904 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001905 af.symlinks = sh.Symlinks()
1906 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001907}
1908
Jooyung Han58f26ab2019-12-18 15:34:32 +09001909// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1910type javaLibrary interface {
1911 android.Module
1912 java.Dependency
1913}
1914
1915func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001916 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001917 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001918 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1919 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1920 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001921}
1922
Jiyong Park1833cef2019-12-13 13:28:36 +09001923func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001924 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1925 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001926 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001927}
1928
atrost6e126252020-01-27 17:01:16 +00001929func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1930 dirInApex := filepath.Join("etc", config.SubDir())
1931 fileToCopy := config.CompatConfig()
1932 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1933}
1934
Jiyong Park1833cef2019-12-13 13:28:36 +09001935func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001936 android.Module
1937 Privileged() bool
1938 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001939 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001940 Certificate() java.Certificate
Jiyong Parkf653b052019-11-18 15:39:01 +09001941}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001942 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001943 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001944 appDir = "priv-app"
1945 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001946 dirInApex := filepath.Join(appDir, pkgName)
1947 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001948 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1949 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross503c1d02020-01-28 14:00:53 -08001950 af.certificate = aapp.Certificate()
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001951
1952 if app, ok := aapp.(interface {
1953 OverriddenManifestPackageName() string
1954 }); ok {
1955 af.overriddenPackageName = app.OverriddenManifestPackageName()
1956 }
Jiyong Park618922e2020-01-08 13:35:43 +09001957 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001958}
1959
Roland Levillain935639d2019-08-13 14:55:28 +01001960// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1961type flattenedApexContext struct {
1962 android.ModuleContext
1963}
1964
1965func (c *flattenedApexContext) InstallBypassMake() bool {
1966 return true
1967}
1968
Jiyong Park201cedd2020-02-07 17:25:49 +09001969// Visit dependencies that contributes to the payload of this APEX
1970func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext,
1971 do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) {
Jiyong Parkfa899442020-01-31 02:49:53 +09001972 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
1973 am, ok := child.(android.ApexModule)
1974 if !ok || !am.CanHaveApexVariants() {
1975 return false
1976 }
1977
1978 // Check for the direct dependencies that contribute to the payload
1979 if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
1980 if dt.payload {
Jiyong Park201cedd2020-02-07 17:25:49 +09001981 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001982 return true
1983 }
1984 return false
1985 }
1986
1987 // Check for the indirect dependencies if it is considered as part of the APEX
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001988 if am.ApexName() != "" {
Jiyong Park201cedd2020-02-07 17:25:49 +09001989 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001990 return true
1991 }
1992
Jiyong Park201cedd2020-02-07 17:25:49 +09001993 do(ctx, parent, am, true /* externalDep */)
1994
Jiyong Parkfa899442020-01-31 02:49:53 +09001995 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1996 return false
1997 })
1998}
1999
Jooyung Han0c4e0162020-02-26 22:45:42 +09002000func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
2001 ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
2002 if ver != "current" {
2003 minSdkVersion, err := strconv.Atoi(ver)
2004 if err != nil {
2005 ctx.PropertyErrorf("min_sdk_version", "should be \"current\" or <number>, but %q", ver)
2006 }
2007 return minSdkVersion
2008 }
2009 return android.FutureApiLevel
2010}
2011
Jiyong Park201cedd2020-02-07 17:25:49 +09002012// Ensures that the dependencies are marked as available for this APEX
2013func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
2014 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
2015 if ctx.Host() || a.testApex || a.vndkApex {
2016 return
2017 }
2018
2019 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2020 apexName := ctx.ModuleName()
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002021 fromName := ctx.OtherModuleName(from)
2022 toName := ctx.OtherModuleName(to)
2023 if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) {
Jiyong Park201cedd2020-02-07 17:25:49 +09002024 return
2025 }
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002026 ctx.ModuleErrorf("%q requires %q that is not available for the APEX.", fromName, toName)
Jiyong Park201cedd2020-02-07 17:25:49 +09002027 })
2028}
2029
Jiyong Park678c8812020-02-07 17:25:49 +09002030// Collects the list of module names that directly or indirectly contributes to the payload of this APEX
2031func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) {
2032 a.depInfos = make(map[string]depInfo)
2033 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2034 if from.Name() == to.Name() {
2035 // This can happen for cc.reuseObjTag. We are not interested in tracking this.
2036 return
2037 }
2038
2039 if info, exists := a.depInfos[to.Name()]; exists {
2040 if !android.InList(from.Name(), info.from) {
2041 info.from = append(info.from, from.Name())
2042 }
2043 info.isExternal = info.isExternal && externalDep
2044 a.depInfos[to.Name()] = info
2045 } else {
2046 a.depInfos[to.Name()] = depInfo{
2047 to: to.Name(),
2048 from: []string{from.Name()},
2049 isExternal: externalDep,
2050 }
2051 }
2052 })
2053}
2054
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002055func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09002056 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
2057 switch a.properties.ApexType {
2058 case imageApex:
2059 if buildFlattenedAsDefault {
2060 a.suffix = imageApexSuffix
2061 } else {
2062 a.suffix = ""
2063 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002064
2065 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09002066 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002067 }
Sundong Ahnabb64432019-10-22 13:58:29 +09002068 }
2069 case zipApex:
2070 if proptools.String(a.properties.Payload_type) == "zip" {
2071 a.suffix = ""
2072 a.primaryApexType = true
2073 } else {
2074 a.suffix = zipApexSuffix
2075 }
2076 case flattenedApex:
2077 if buildFlattenedAsDefault {
2078 a.suffix = ""
2079 a.primaryApexType = true
2080 } else {
2081 a.suffix = flattenedSuffix
2082 }
Alex Light5098a612018-11-29 17:12:15 -08002083 }
2084
Roland Levillain630846d2019-06-26 12:48:34 +01002085 if len(a.properties.Tests) > 0 && !a.testApex {
2086 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
2087 return
2088 }
2089
Jiyong Parkfa899442020-01-31 02:49:53 +09002090 a.checkApexAvailability(ctx)
2091
Jiyong Park678c8812020-02-07 17:25:49 +09002092 a.collectDepsInfo(ctx)
2093
Alex Lightfc0bd7c2019-01-29 18:31:59 -08002094 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
2095
Jooyung Hane1633032019-08-01 17:41:43 +09002096 // native lib dependencies
2097 var provideNativeLibs []string
2098 var requireNativeLibs []string
2099
Jooyung Han5c998b92019-06-27 11:30:33 +09002100 // Check if "uses" requirements are met with dependent apexBundles
2101 var providedNativeSharedLibs []string
2102 useVendor := proptools.Bool(a.properties.Use_vendor)
2103 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
2104 if ctx.OtherModuleDependencyTag(m) != usesTag {
2105 return
2106 }
2107 otherName := ctx.OtherModuleName(m)
2108 other, ok := m.(*apexBundle)
2109 if !ok {
2110 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
2111 return
2112 }
2113 if proptools.Bool(other.properties.Use_vendor) != useVendor {
2114 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
2115 return
2116 }
2117 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
2118 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
2119 return
2120 }
2121 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
2122 })
2123
Jiyong Parkf653b052019-11-18 15:39:01 +09002124 var filesInfo []apexFile
Jiyong Park678c8812020-02-07 17:25:49 +09002125 // TODO(jiyong) do this using walkPayloadDeps
Alex Light778127a2019-02-27 14:19:50 -08002126 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01002127 depTag := ctx.OtherModuleDependencyTag(child)
2128 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09002129 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002130 switch depTag {
2131 case sharedLibTag:
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002132 if c, ok := child.(*cc.Module); ok {
2133 // bootstrap bionic libs are treated as provided by system
2134 if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
2135 provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base())
Jooyung Hane1633032019-08-01 17:41:43 +09002136 }
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002137 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, c, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09002138 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002139 } else {
2140 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002141 }
2142 case executableTag:
2143 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002144 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09002145 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09002146 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002147 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08002148 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09002149 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08002150 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09002151 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002152 } else {
Alex Light778127a2019-02-27 14:19:50 -08002153 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 +09002154 }
2155 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09002156 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002157 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09002158 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09002159 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2160 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09002161 filesInfo = append(filesInfo, af)
2162 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09002163 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09002164 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
2165 af := apexFileForJavaLibrary(ctx, sdkLib)
2166 if !af.Ok() {
2167 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2168 return false
2169 }
2170 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09002171 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002172 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09002173 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002174 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002175 case androidAppTag:
2176 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
2177 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002178 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002179 return true // track transitive dependencies
2180 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002181 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00002182 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
2183 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002184 } else {
2185 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
2186 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002187 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09002188 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002189 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
atrost6e126252020-01-27 17:01:16 +00002190 } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
2191 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002192 } else {
atrost6e126252020-01-27 17:01:16 +00002193 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09002194 }
Roland Levillain630846d2019-06-26 12:48:34 +01002195 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01002196 if ccTest, ok := child.(*cc.Module); ok {
2197 if ccTest.IsTestPerSrcAllTestsVariation() {
2198 // Multiple-output test module (where `test_per_src: true`).
2199 //
2200 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
2201 // We do not add this variation to `filesInfo`, as it has no output;
2202 // however, we do add the other variations of this module as indirect
2203 // dependencies (see below).
2204 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01002205 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01002206 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09002207 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09002208 af.class = nativeTest
2209 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01002210 }
Roland Levillain630846d2019-06-26 12:48:34 +01002211 } else {
2212 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
2213 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09002214 case keyTag:
2215 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002216 a.private_key_file = key.private_key_file
2217 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09002218 } else {
2219 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002220 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002221 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002222 case certificateTag:
2223 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002224 a.container_certificate_file = dep.Certificate.Pem
2225 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002226 } else {
2227 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
2228 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09002229 case android.PrebuiltDepTag:
2230 // If the prebuilt is force disabled, remember to delete the prebuilt file
2231 // that might have been installed in the previous builds
2232 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
2233 a.prebuiltFileToDelete = prebuilt.InstallFilename()
2234 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002235 }
Jooyung Han8aee2042019-10-29 05:08:31 +09002236 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002237 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09002238 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01002239 // We cannot use a switch statement on `depTag` here as the checked
2240 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09002241 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002242 if cc, ok := child.(*cc.Module); ok {
2243 if android.InList(cc.Name(), providedNativeSharedLibs) {
2244 // If we're using a shared library which is provided from other APEX,
2245 // don't include it in this APEX
2246 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09002247 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09002248 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002249 // If the dependency is a stubs lib, don't include it in this APEX,
2250 // but make sure that the lib is installed on the device.
2251 // In case no APEX is having the lib, the lib is installed to the system
2252 // partition.
2253 //
2254 // Always include if we are a host-apex however since those won't have any
2255 // system libraries.
Jiyong Park956305c2020-01-09 12:32:06 +09002256 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
2257 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01002258 }
Jooyung Hane1633032019-08-01 17:41:43 +09002259 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01002260 // Don't track further
2261 return false
2262 }
Jiyong Park1833cef2019-12-13 13:28:36 +09002263 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09002264 af.transitiveDep = true
2265 filesInfo = append(filesInfo, af)
2266 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09002267 }
Roland Levillainf89cd092019-07-29 16:22:59 +01002268 } else if cc.IsTestPerSrcDepTag(depTag) {
2269 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002270 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01002271 // Handle modules created as `test_per_src` variations of a single test module:
2272 // use the name of the generated test binary (`fileToCopy`) instead of the name
2273 // of the original test module (`depName`, shared by all `test_per_src`
2274 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09002275 af.moduleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002276 // these are not considered transitive dep
2277 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09002278 filesInfo = append(filesInfo, af)
2279 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01002280 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09002281 } else if java.IsJniDepTag(depTag) {
Jooyung Han65041792020-02-25 16:59:29 +09002282 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
2283 return false
Jiyong Parke3833882020-02-17 17:28:10 +09002284 } else if java.IsXmlPermissionsFileDepTag(depTag) {
2285 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
2286 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
2287 }
Jooyung Han9c80bae2019-08-20 17:30:57 +09002288 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01002289 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002290 }
2291 }
2292 }
2293 return false
2294 })
2295
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002296 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
2297 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
2298 // via the global boot image config.
2299 if a.artApex {
2300 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
2301 dirInApex := filepath.Join("javalib", arch.String())
2302 for _, f := range files {
2303 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09002304 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09002305 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002306 }
2307 }
2308 }
2309
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002310 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09002311 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
2312 return
2313 }
2314
Jiyong Park8fd61922018-11-08 02:50:25 +09002315 // remove duplicates in filesInfo
2316 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002317 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002318 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002319 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002320 if e, ok := encountered[dest]; !ok {
2321 encountered[dest] = f
2322 } else {
2323 // If a module is directly included and also transitively depended on
2324 // consider it as directly included.
2325 e.transitiveDep = e.transitiveDep && f.transitiveDep
2326 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002327 }
2328 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002329 var result []apexFile
2330 for _, v := range encountered {
2331 result = append(result, v)
2332 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002333 return result
2334 }
2335 filesInfo = removeDup(filesInfo)
2336
2337 // to have consistent build rules
2338 sort.Slice(filesInfo, func(i, j int) bool {
2339 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
2340 })
2341
Jiyong Park8fd61922018-11-08 02:50:25 +09002342 a.installDir = android.PathForModuleInstall(ctx, "apex")
2343 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002344
Jooyung Han54aca7b2019-11-20 02:26:02 +09002345 if a.properties.ApexType != zipApex {
2346 if a.properties.File_contexts == nil {
2347 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
2348 } else {
2349 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
2350 if a.Platform() {
2351 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
2352 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
2353 }
2354 }
2355 }
2356 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
2357 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
2358 return
2359 }
2360 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002361 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2362 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2363 // the same library in the system partition, thus effectively sharing the same libraries
2364 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2365 // in the APEX.
2366 a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
2367 a.installable() &&
2368 !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002369
Jiyong Park9d677202020-02-19 16:29:35 +09002370 // We don't need the optimization for updatable APEXes, as it might give false signal
2371 // to the system health when the APEXes are still bundled (b/149805758)
2372 if proptools.Bool(a.properties.Updatable) && a.properties.ApexType == imageApex {
2373 a.linkToSystemLib = false
2374 }
2375
Jiyong Park9b964182020-02-26 18:27:19 +09002376 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2377 if ctx.Host() {
2378 a.linkToSystemLib = false
2379 }
2380
Jooyung Hand15aa1f2019-09-27 00:38:03 +09002381 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09002382 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
2383
2384 a.setCertificateAndPrivateKey(ctx)
2385 if a.properties.ApexType == flattenedApex {
2386 a.buildFlattenedApex(ctx)
2387 } else {
2388 a.buildUnflattenedApex(ctx)
2389 }
2390
Jooyung Han002ab682020-01-08 01:57:58 +09002391 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09002392
2393 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002394}
2395
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002396func whitelistedApexAvailable(apex, moduleName string) bool {
Anton Hansson5053c292020-01-10 15:12:39 +00002397 key := apex
2398 key = strings.Replace(key, "test_", "", 1)
2399 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
2400 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
2401
Jiyong Parkfa899442020-01-31 02:49:53 +09002402 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2403 // system. Trim the prefix for the check since they are confusing
2404 moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
2405 if strings.HasPrefix(moduleName, "libclang_rt.") {
2406 // This module has many arch variants that depend on the product being built.
2407 // We don't want to list them all
2408 moduleName = "libclang_rt"
Anton Hansson5053c292020-01-10 15:12:39 +00002409 }
2410
2411 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2412 return true
2413 }
2414
Jiyong Parkfa899442020-01-31 02:49:53 +09002415 key = "//any"
2416 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2417 return true
2418 }
2419
Anton Hansson5053c292020-01-10 15:12:39 +00002420 return false
2421}
2422
Jooyung Han344d5432019-08-23 11:17:39 +09002423func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09002424 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002425 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08002426 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09002427 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08002428 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09002429 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
2430 })
Alex Light5098a612018-11-29 17:12:15 -08002431 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002432 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09002433 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08002434 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002435 return module
2436}
Jiyong Park30ca9372019-02-07 16:27:23 +09002437
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002438func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002439 bundle := newApexBundle()
2440 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002441 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09002442 return bundle
2443}
2444
Jiyong Parkfce0b422020-02-11 03:56:06 +09002445// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2446// certain compatibility checks such as apex_available are not done for apex_test.
Jooyung Han344d5432019-08-23 11:17:39 +09002447func testApexBundleFactory() android.Module {
2448 bundle := newApexBundle()
2449 bundle.testApex = true
2450 return bundle
2451}
2452
Jiyong Parkfce0b422020-02-11 03:56:06 +09002453// apex packages other modules into an APEX file which is a packaging format for system-level
2454// components like binaries, shared libraries, etc.
Jiyong Parkd1063c12019-07-17 20:08:41 +09002455func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002456 return newApexBundle()
2457}
2458
Jiyong Park30ca9372019-02-07 16:27:23 +09002459//
2460// Defaults
2461//
2462type Defaults struct {
2463 android.ModuleBase
2464 android.DefaultsModuleBase
2465}
2466
Jiyong Park30ca9372019-02-07 16:27:23 +09002467func defaultsFactory() android.Module {
2468 return DefaultsFactory()
2469}
2470
2471func DefaultsFactory(props ...interface{}) android.Module {
2472 module := &Defaults{}
2473
2474 module.AddProperties(props...)
2475 module.AddProperties(
2476 &apexBundleProperties{},
2477 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09002478 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09002479 )
2480
2481 android.InitDefaultsModule(module)
2482 return module
2483}
Jiyong Park5d790c32019-11-15 18:40:32 +09002484
2485//
2486// OverrideApex
2487//
2488type OverrideApex struct {
2489 android.ModuleBase
2490 android.OverrideModuleBase
2491}
2492
2493func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2494 // All the overrides happen in the base module.
2495}
2496
2497// override_apex is used to create an apex module based on another apex module
2498// by overriding some of its properties.
2499func overrideApexFactory() android.Module {
2500 m := &OverrideApex{}
2501 m.AddProperties(&overridableProperties{})
2502
2503 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2504 android.InitOverrideModule(m)
2505 return m
2506}