blob: 1fbbaf4398c7f83375acbbb9fcf66c2de8cf7c23 [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 Hanb8fa86a2020-03-10 06:23:13 +09001046 apexBundles = []android.ApexInfo{android.ApexInfo{
Jooyung Han23b0adf2020-03-12 18:37:20 +09001047 ApexName: mctx.ModuleName(),
1048 MinSdkVersion: a.minSdkVersion(mctx),
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001049 }}
Jiyong Parkf760cae2020-02-12 07:53:12 +09001050 directDep = true
1051 } else if am, ok := mctx.Module().(android.ApexModule); ok {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001052 apexBundles = am.ApexVariations()
Jiyong Parkf760cae2020-02-12 07:53:12 +09001053 directDep = false
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001054 }
Jiyong Parkf760cae2020-02-12 07:53:12 +09001055
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001056 if len(apexBundles) == 0 {
Jiyong Parkf760cae2020-02-12 07:53:12 +09001057 return
1058 }
1059
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001060 cur := mctx.Module().(interface {
1061 DepIsInSameApex(android.BaseModuleContext, android.Module) bool
1062 })
1063
Jiyong Parkf760cae2020-02-12 07:53:12 +09001064 mctx.VisitDirectDeps(func(child android.Module) {
1065 depName := mctx.OtherModuleName(child)
1066 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001067 cur.DepIsInSameApex(mctx, child) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001068 android.UpdateApexDependency(apexBundles, depName, directDep)
1069 am.BuildForApexes(apexBundles)
Jiyong Parkf760cae2020-02-12 07:53:12 +09001070 }
1071 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001072}
1073
1074// Create apex variations if a module is included in APEX(s).
1075func apexMutator(mctx android.BottomUpMutatorContext) {
1076 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +09001077 am.CreateApexVariations(mctx)
Jooyung Hana57af4a2020-01-23 05:36:59 +00001078 } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001079 // apex bundle itself is mutated so that it and its modules have same
1080 // apex variant.
1081 apexBundleName := mctx.ModuleName()
1082 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +09001083 } else if o, ok := mctx.Module().(*OverrideApex); ok {
1084 apexBundleName := o.GetOverriddenModuleName()
1085 if apexBundleName == "" {
1086 mctx.ModuleErrorf("base property is not set")
1087 return
1088 }
1089 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001090 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001091
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001092}
Sundong Ahne9b55722019-09-06 17:37:42 +09001093
Jooyung Han7a78a922019-10-08 21:59:58 +09001094var (
1095 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
1096 apexFileContextsInfosMutex sync.Mutex
1097)
1098
1099func apexFileContextsInfos(config android.Config) *[]string {
1100 return config.Once(apexFileContextsInfosKey, func() interface{} {
1101 return &[]string{}
1102 }).(*[]string)
1103}
1104
Jooyung Han54aca7b2019-11-20 02:26:02 +09001105func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +09001106 apexFileContextsInfosMutex.Lock()
1107 defer apexFileContextsInfosMutex.Unlock()
1108 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +09001109 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +09001110}
1111
Sundong Ahne9b55722019-09-06 17:37:42 +09001112func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Sundong Ahne8fb7242019-09-17 13:50:45 +09001113 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +09001114 var variants []string
1115 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
1116 case "image":
1117 variants = append(variants, imageApexType, flattenedApexType)
1118 case "zip":
1119 variants = append(variants, zipApexType)
1120 case "both":
1121 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
1122 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001123 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +09001124 return
1125 }
1126
1127 modules := mctx.CreateLocalVariations(variants...)
1128
1129 for i, v := range variants {
1130 switch v {
1131 case imageApexType:
1132 modules[i].(*apexBundle).properties.ApexType = imageApex
1133 case zipApexType:
1134 modules[i].(*apexBundle).properties.ApexType = zipApex
1135 case flattenedApexType:
1136 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +09001137 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001138 modules[i].(*apexBundle).MakeAsSystemExt()
1139 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001140 }
Sundong Ahne9b55722019-09-06 17:37:42 +09001141 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001142 } else if _, ok := mctx.Module().(*OverrideApex); ok {
1143 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +09001144 }
1145}
1146
Jooyung Han5c998b92019-06-27 11:30:33 +09001147func apexUsesMutator(mctx android.BottomUpMutatorContext) {
1148 if ab, ok := mctx.Module().(*apexBundle); ok {
1149 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
1150 }
1151}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001152
Jooyung Handc782442019-11-01 03:14:38 +09001153var (
1154 useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
1155)
1156
1157// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
1158// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
1159// which may cause compatibility issues. (e.g. libbinder)
1160// Even though libbinder restricts its availability via 'apex_available' property and relies on
1161// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
1162// to avoid similar problems.
1163func useVendorWhitelist(config android.Config) []string {
1164 return config.Once(useVendorWhitelistKey, func() interface{} {
1165 return []string{
1166 // swcodec uses "vendor" variants for smaller size
1167 "com.android.media.swcodec",
1168 "test_com.android.media.swcodec",
1169 }
1170 }).([]string)
1171}
1172
1173// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
1174// called before the first call to useVendorWhitelist()
1175func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
1176 config.Once(useVendorWhitelistKey, func() interface{} {
1177 return whitelist
1178 })
1179}
1180
Alex Light9670d332019-01-29 18:07:33 -08001181type apexNativeDependencies struct {
1182 // List of native libraries
1183 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +09001184
Alex Light9670d332019-01-29 18:07:33 -08001185 // List of native executables
1186 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +09001187
Roland Levillain630846d2019-06-26 12:48:34 +01001188 // List of native tests
1189 Tests []string
Alex Light9670d332019-01-29 18:07:33 -08001190}
Jooyung Han344d5432019-08-23 11:17:39 +09001191
Alex Light9670d332019-01-29 18:07:33 -08001192type apexMultilibProperties struct {
1193 // Native dependencies whose compile_multilib is "first"
1194 First apexNativeDependencies
1195
1196 // Native dependencies whose compile_multilib is "both"
1197 Both apexNativeDependencies
1198
1199 // Native dependencies whose compile_multilib is "prefer32"
1200 Prefer32 apexNativeDependencies
1201
1202 // Native dependencies whose compile_multilib is "32"
1203 Lib32 apexNativeDependencies
1204
1205 // Native dependencies whose compile_multilib is "64"
1206 Lib64 apexNativeDependencies
1207}
1208
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001209type apexBundleProperties struct {
1210 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +00001211 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -08001212 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001213
Jiyong Park40e26a22019-02-08 02:53:06 +09001214 // AndroidManifest.xml file used for the zip container of this APEX bundle.
1215 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -08001216 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +09001217
Roland Levillain411c5842019-09-19 16:37:20 +01001218 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
1219 // device (/apex/<apex_name>).
1220 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +09001221 Apex_name *string
1222
Jiyong Parkd0a65ba2018-11-10 06:37:15 +09001223 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +09001224 // For platform APEXes, this should points to a file under /system/sepolicy
1225 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
1226 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001227
1228 // List of native shared libs that are embedded inside this APEX bundle
1229 Native_shared_libs []string
1230
Roland Levillain630846d2019-06-26 12:48:34 +01001231 // List of executables that are embedded inside this APEX bundle
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001232 Binaries []string
1233
1234 // List of java libraries that are embedded inside this APEX bundle
1235 Java_libs []string
1236
1237 // List of prebuilt files that are embedded inside this APEX bundle
1238 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +09001239
Roland Levillain630846d2019-06-26 12:48:34 +01001240 // List of tests that are embedded inside this APEX bundle
1241 Tests []string
1242
Jiyong Parkff1458f2018-10-12 21:49:38 +09001243 // Name of the apex_key module that provides the private key to sign APEX
1244 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +09001245
Alex Light5098a612018-11-29 17:12:15 -08001246 // The type of APEX to build. Controls what the APEX payload is. Either
1247 // 'image', 'zip' or 'both'. Default: 'image'.
1248 Payload_type *string
1249
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001250 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
1251 // or an android_app_certificate module name in the form ":module".
1252 Certificate *string
1253
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001254 // Whether this APEX is installable to one of the partitions. Default: true.
1255 Installable *bool
1256
Jiyong Parkda6eb592018-12-19 17:12:36 +09001257 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
1258 // Default is false.
1259 Use_vendor *bool
1260
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001261 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
1262 Ignore_system_library_special_case *bool
1263
Alex Light9670d332019-01-29 18:07:33 -08001264 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +09001265
Jiyong Parkf97782b2019-02-13 20:28:58 +09001266 // List of sanitizer names that this APEX is enabled for
1267 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +09001268
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001269 PreventInstall bool `blueprint:"mutated"`
1270
1271 HideFromMake bool `blueprint:"mutated"`
1272
Jooyung Han5c998b92019-06-27 11:30:33 +09001273 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
1274 Provide_cpp_shared_libs *bool
1275
1276 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
1277 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +01001278
1279 // A txt file containing list of files that are whitelisted to be included in this APEX.
1280 Whitelisted_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001281
Sundong Ahnabb64432019-10-22 13:58:29 +09001282 // package format of this apex variant; could be non-flattened, flattened, or zip.
1283 // imageApex, zipApex or flattened
1284 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +09001285
Jiyong Parkd1063c12019-07-17 20:08:41 +09001286 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
1287 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
1288 // is implied. This value affects all modules included in this APEX. In other words, they are
1289 // also built with the SDKs specified here.
1290 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +09001291
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001292 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
1293 // Should be only used in tests#.
1294 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +09001295
Jiyong Park956305c2020-01-09 12:32:06 +09001296 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park9d677202020-02-19 16:29:35 +09001297
1298 // Whether this APEX is considered updatable or not. When set to true, this will enforce additional
1299 // rules for making sure that the APEX is truely updatable. This will also disable the size optimizations
1300 // like symlinking to the system libs. Default is false.
1301 Updatable *bool
Colin Cross7365eaa2020-02-19 20:41:10 -08001302
1303 // The minimum SDK version that this apex must be compatible with.
1304 Min_sdk_version *string
Alex Light9670d332019-01-29 18:07:33 -08001305}
1306
1307type apexTargetBundleProperties struct {
1308 Target struct {
1309 // Multilib properties only for android.
1310 Android struct {
1311 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001312 }
Jooyung Han344d5432019-08-23 11:17:39 +09001313
Alex Light9670d332019-01-29 18:07:33 -08001314 // Multilib properties only for host.
1315 Host struct {
1316 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001317 }
Jooyung Han344d5432019-08-23 11:17:39 +09001318
Alex Light9670d332019-01-29 18:07:33 -08001319 // Multilib properties only for host linux_bionic.
1320 Linux_bionic struct {
1321 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001322 }
Jooyung Han344d5432019-08-23 11:17:39 +09001323
Alex Light9670d332019-01-29 18:07:33 -08001324 // Multilib properties only for host linux_glibc.
1325 Linux_glibc struct {
1326 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001327 }
1328 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001329}
1330
Jiyong Park5d790c32019-11-15 18:40:32 +09001331type overridableProperties struct {
1332 // List of APKs to package inside APEX
1333 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001334
1335 // Names of modules to be overridden. Listed modules can only be other binaries
1336 // (in Make or Soong).
1337 // This does not completely prevent installation of the overridden binaries, but if both
1338 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
1339 // from PRODUCT_PACKAGES.
1340 Overrides []string
Baligh Uddin004d7172020-02-19 21:29:28 -08001341
1342 // Logging Parent value
1343 Logging_parent string
Baligh Uddincb6aa122020-03-15 13:01:05 -07001344
1345 // Apex Container Package Name.
1346 // Override value for attribute package:name in AndroidManifest.xml
1347 Package_name string
Jiyong Park5d790c32019-11-15 18:40:32 +09001348}
1349
Alex Light5098a612018-11-29 17:12:15 -08001350type apexPackaging int
1351
1352const (
1353 imageApex apexPackaging = iota
1354 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +09001355 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -08001356)
1357
Sundong Ahnabb64432019-10-22 13:58:29 +09001358// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -08001359func (a apexPackaging) suffix() string {
1360 switch a {
1361 case imageApex:
1362 return imageApexSuffix
1363 case zipApex:
1364 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -08001365 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001366 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001367 }
1368}
1369
1370func (a apexPackaging) name() string {
1371 switch a {
1372 case imageApex:
1373 return imageApexType
1374 case zipApex:
1375 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -08001376 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001377 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001378 }
1379}
1380
Jiyong Parkf653b052019-11-18 15:39:01 +09001381type apexFileClass int
1382
1383const (
1384 etc apexFileClass = iota
1385 nativeSharedLib
1386 nativeExecutable
1387 shBinary
1388 pyBinary
1389 goBinary
1390 javaSharedLib
1391 nativeTest
1392 app
1393)
1394
Jiyong Park8fd61922018-11-08 02:50:25 +09001395func (class apexFileClass) NameInMake() string {
1396 switch class {
1397 case etc:
1398 return "ETC"
1399 case nativeSharedLib:
1400 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -08001401 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +09001402 return "EXECUTABLES"
1403 case javaSharedLib:
1404 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +01001405 case nativeTest:
1406 return "NATIVE_TESTS"
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001407 case app:
Jiyong Parkf383f7c2019-10-11 20:46:25 +09001408 // b/142537672 Why isn't this APP? We want to have full control over
1409 // the paths and file names of the apk file under the flattend APEX.
1410 // If this is set to APP, then the paths and file names are modified
1411 // by the Make build system. For example, it is installed to
1412 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
1413 // /system/apex/<apexname>/app/<Appname> because the build system automatically
1414 // appends module name (which is <apexname>.<Appname> to the path.
1415 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +09001416 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001417 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +09001418 }
1419}
1420
Jiyong Parkf653b052019-11-18 15:39:01 +09001421// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +09001422type apexFile struct {
1423 builtFile android.Path
1424 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +09001425 installDir string
1426 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +09001427 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +09001428 // list of symlinks that will be created in installDir that point to this apexFile
1429 symlinks []string
1430 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +09001431 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +09001432
1433 requiredModuleNames []string
1434 targetRequiredModuleNames []string
1435 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +09001436
Colin Cross503c1d02020-01-28 14:00:53 -08001437 jacocoReportClassesFile android.Path // only for javalibs and apps
1438 certificate java.Certificate // only for apps
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001439 overriddenPackageName string // only for apps
Jiyong Parkf653b052019-11-18 15:39:01 +09001440}
1441
Jiyong Park1833cef2019-12-13 13:28:36 +09001442func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
1443 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +09001444 builtFile: builtFile,
1445 moduleName: moduleName,
1446 installDir: installDir,
1447 class: class,
1448 module: module,
1449 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001450 if module != nil {
1451 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +09001452 ret.requiredModuleNames = module.RequiredModuleNames()
1453 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
1454 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +09001455 }
1456 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +09001457}
1458
1459func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +09001460 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +09001461}
1462
Jiyong Park7cd10e32020-01-14 09:22:18 +09001463// Path() returns path of this apex file relative to the APEX root
1464func (af *apexFile) Path() string {
1465 return filepath.Join(af.installDir, af.builtFile.Base())
1466}
1467
1468// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
1469func (af *apexFile) SymlinkPaths() []string {
1470 var ret []string
1471 for _, symlink := range af.symlinks {
1472 ret = append(ret, filepath.Join(af.installDir, symlink))
1473 }
1474 return ret
1475}
1476
1477func (af *apexFile) AvailableToPlatform() bool {
1478 if af.module == nil {
1479 return false
1480 }
1481 if am, ok := af.module.(android.ApexModule); ok {
1482 return am.AvailableFor(android.AvailableToPlatform)
1483 }
1484 return false
1485}
1486
Jiyong Park678c8812020-02-07 17:25:49 +09001487type depInfo struct {
1488 to string
1489 from []string
1490 isExternal bool
1491}
1492
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001493type apexBundle struct {
1494 android.ModuleBase
1495 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +09001496 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +09001497 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001498
Jiyong Park5d790c32019-11-15 18:40:32 +09001499 properties apexBundleProperties
1500 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +09001501 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001502
Jooyung Hanf21c7972019-12-16 22:32:06 +09001503 // specific to apex_vndk modules
1504 vndkProperties apexVndkProperties
1505
Colin Crossa4925902018-11-16 11:36:28 -08001506 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +09001507 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -07001508 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +09001509
Jiyong Park03b68dd2019-07-26 23:20:40 +09001510 prebuiltFileToDelete string
1511
Jiyong Park42cca6c2019-04-01 11:15:50 +09001512 public_key_file android.Path
1513 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001514
1515 container_certificate_file android.Path
1516 container_private_key_file android.Path
1517
Jooyung Han54aca7b2019-11-20 02:26:02 +09001518 fileContexts android.Path
1519
Jiyong Park8fd61922018-11-08 02:50:25 +09001520 // list of files to be included in this apex
1521 filesInfo []apexFile
1522
Jiyong Park956305c2020-01-09 12:32:06 +09001523 // list of module names that should be installed along with this APEX
1524 requiredDeps []string
1525
Jiyong Park956305c2020-01-09 12:32:06 +09001526 // list of module names that this APEX is including (to be shown via *-deps-info target)
Jiyong Park678c8812020-02-07 17:25:49 +09001527 depInfos map[string]depInfo
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001528
Sundong Ahnabb64432019-10-22 13:58:29 +09001529 testApex bool
1530 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001531 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +09001532 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +09001533
Jooyung Han214bf372019-11-12 13:03:50 +09001534 manifestJsonOut android.WritablePath
1535 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +09001536
Jooyung Han002ab682020-01-08 01:57:58 +09001537 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +09001538 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +09001539 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +09001540 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
1541 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +09001542
1543 // Suffix of module name in Android.mk
1544 // ".flattened", ".apex", ".zipapex", or ""
1545 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +09001546
1547 installedFilesFile android.WritablePath
Jiyong Park7cd10e32020-01-14 09:22:18 +09001548
1549 // Whether to create symlink to the system file instead of having a file
1550 // inside the apex or not
1551 linkToSystemLib bool
Jiyong Park19972c72020-01-28 20:05:29 +09001552
1553 // Struct holding the merged notice file paths in different formats
1554 mergedNotices android.NoticeOutputs
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001555}
1556
Jiyong Park397e55e2018-10-24 21:09:55 +09001557func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +01001558 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001559 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +09001560 // Use *FarVariation* to be able to depend on modules having
1561 // conflicting variations with this module. This is required since
1562 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
1563 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001564 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +09001565 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +09001566 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +09001567 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001568 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001569
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001570 ctx.AddFarVariationDependencies(append(target.Variations(),
1571 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
1572 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +01001573
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001574 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001575 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001576 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001577 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001578}
1579
Alex Light9670d332019-01-29 18:07:33 -08001580func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
1581 if ctx.Os().Class == android.Device {
1582 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
1583 } else {
1584 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
1585 if ctx.Os().Bionic() {
1586 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
1587 } else {
1588 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
1589 }
1590 }
1591}
1592
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001593func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +09001594 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
1595 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1596 }
1597
Jiyong Park397e55e2018-10-24 21:09:55 +09001598 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +09001599 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -08001600
1601 a.combineProperties(ctx)
1602
Jiyong Park397e55e2018-10-24 21:09:55 +09001603 has32BitTarget := false
1604 for _, target := range targets {
1605 if target.Arch.ArchType.Multilib == "lib32" {
1606 has32BitTarget = true
1607 }
1608 }
1609 for i, target := range targets {
1610 // When multilib.* is omitted for native_shared_libs, it implies
1611 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001612 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +09001613 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001614 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001615 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001616
Roland Levillain630846d2019-06-26 12:48:34 +01001617 // When multilib.* is omitted for tests, it implies
1618 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001619 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001620 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001621 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001622 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +01001623
Jiyong Park397e55e2018-10-24 21:09:55 +09001624 // Add native modules targetting both ABIs
1625 addDependenciesForNativeModules(ctx,
1626 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001627 a.properties.Multilib.Both.Binaries,
1628 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001629 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001630 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001631
Alex Light3d673592019-01-18 14:37:31 -08001632 isPrimaryAbi := i == 0
1633 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +09001634 // When multilib.* is omitted for binaries, it implies
1635 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001636 ctx.AddFarVariationDependencies(append(target.Variations(),
1637 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
1638 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001639
1640 // Add native modules targetting the first ABI
1641 addDependenciesForNativeModules(ctx,
1642 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001643 a.properties.Multilib.First.Binaries,
1644 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001645 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001646 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001647 }
1648
1649 switch target.Arch.ArchType.Multilib {
1650 case "lib32":
1651 // Add native modules targetting 32-bit ABI
1652 addDependenciesForNativeModules(ctx,
1653 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001654 a.properties.Multilib.Lib32.Binaries,
1655 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001656 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001657 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001658
1659 addDependenciesForNativeModules(ctx,
1660 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001661 a.properties.Multilib.Prefer32.Binaries,
1662 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001663 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001664 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001665 case "lib64":
1666 // Add native modules targetting 64-bit ABI
1667 addDependenciesForNativeModules(ctx,
1668 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001669 a.properties.Multilib.Lib64.Binaries,
1670 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001671 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001672 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001673
1674 if !has32BitTarget {
1675 addDependenciesForNativeModules(ctx,
1676 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001677 a.properties.Multilib.Prefer32.Binaries,
1678 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001679 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001680 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001681 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001682
1683 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
1684 for _, sanitizer := range ctx.Config().SanitizeDevice() {
1685 if sanitizer == "hwaddress" {
1686 addDependenciesForNativeModules(ctx,
1687 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001688 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001689 break
1690 }
1691 }
1692 }
Jiyong Park397e55e2018-10-24 21:09:55 +09001693 }
1694
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001695 }
1696
Jiyong Parkce6aadc2019-11-20 13:58:28 +09001697 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
1698 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
1699 // b/144532908
1700 archForPrebuiltEtc := config.Arches()[0]
1701 for _, arch := range config.Arches() {
1702 // Prefer 64-bit arch if there is any
1703 if arch.ArchType.Multilib == "lib64" {
1704 archForPrebuiltEtc = arch
1705 break
1706 }
1707 }
1708 ctx.AddFarVariationDependencies([]blueprint.Variation{
1709 {Mutator: "os", Variation: ctx.Os().String()},
1710 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
1711 }, prebuiltTag, a.properties.Prebuilts...)
1712
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001713 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1714 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001715
Ulya Trafimovich44561882020-01-03 13:25:54 +00001716 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
1717 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
1718 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1719 javaLibTag, "jacocoagent")
1720 }
1721
Jiyong Park23c52b02019-02-02 13:13:47 +09001722 if String(a.properties.Key) == "" {
1723 ctx.ModuleErrorf("key is missing")
1724 return
1725 }
1726 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001727
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001728 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +09001729 if cert != "" {
1730 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001731 }
Jiyong Parkd1063c12019-07-17 20:08:41 +09001732
1733 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
1734 if len(a.properties.Uses_sdks) > 0 {
1735 sdkRefs := []android.SdkRef{}
1736 for _, str := range a.properties.Uses_sdks {
1737 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
1738 sdkRefs = append(sdkRefs, parsed)
1739 }
1740 a.BuildWithSdks(sdkRefs)
1741 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001742}
1743
Jiyong Park5d790c32019-11-15 18:40:32 +09001744func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
1745 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1746 androidAppTag, a.overridableProperties.Apps...)
1747}
1748
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001749func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1750 // direct deps of an APEX bundle are all part of the APEX bundle
1751 return true
1752}
1753
Colin Cross0ea8ba82019-06-06 14:33:29 -07001754func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001755 moduleName := ctx.ModuleName()
1756 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1757 // we check with the pseudo module name to see if its certificate is overridden.
1758 if a.vndkApex {
1759 moduleName = vndkApexName
1760 }
1761 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001762 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001763 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001764 }
1765 return String(a.properties.Certificate)
1766}
1767
Colin Cross41955e82019-05-29 14:40:35 -07001768func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1769 switch tag {
1770 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001771 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001772 default:
1773 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001774 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001775}
1776
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001777func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001778 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001779}
1780
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001781func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1782 return proptools.Bool(a.properties.Test_only_no_hashtree)
1783}
1784
Jiyong Park7c1dc612019-01-05 11:15:24 +09001785func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001786 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001787 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001788 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001789 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001790 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001791 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001792 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001793 }
1794}
1795
Jiyong Parkf97782b2019-02-13 20:28:58 +09001796func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1797 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1798 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1799 }
1800}
1801
Jiyong Park388ef3f2019-01-28 19:47:32 +09001802func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001803 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1804 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001805 }
1806
1807 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001808 globalSanitizerNames := []string{}
1809 if a.Host() {
1810 globalSanitizerNames = ctx.Config().SanitizeHost()
1811 } else {
1812 arches := ctx.Config().SanitizeDeviceArch()
1813 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1814 globalSanitizerNames = ctx.Config().SanitizeDevice()
1815 }
1816 }
1817 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001818}
1819
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001820func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
Oliver Nguyen1382ab62019-12-06 15:22:41 -08001821 return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled())
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001822}
1823
1824func (a *apexBundle) PreventInstall() {
1825 a.properties.PreventInstall = true
1826}
1827
1828func (a *apexBundle) HideFromMake() {
1829 a.properties.HideFromMake = true
1830}
1831
Jiyong Park956305c2020-01-09 12:32:06 +09001832func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1833 a.properties.IsCoverageVariant = coverage
1834}
1835
Jiyong Parkf653b052019-11-18 15:39:01 +09001836// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001837func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001838 // Decide the APEX-local directory by the multilib of the library
1839 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001840 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001841 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001842 case "lib32":
1843 dirInApex = "lib"
1844 case "lib64":
1845 dirInApex = "lib64"
1846 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001847 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001848 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001849 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001850 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001851 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001852 // Special case for Bionic libs and other libs installed with them. This is
1853 // to prevent those libs from being included in the search path
1854 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1855 // those libs in the Runtime APEX are available via the legacy paths in
1856 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1857 // to the legacy paths and thus will be loaded into the default linker
1858 // namespace (aka "platform" namespace). If the libs are directly in
1859 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1860 // into the runtime linker namespace, which will result in double loading of
1861 // them, which isn't supported.
1862 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001863 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001864
Jiyong Parkf653b052019-11-18 15:39:01 +09001865 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001866 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001867}
1868
Jiyong Park1833cef2019-12-13 13:28:36 +09001869func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001870 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001871 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001872 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001873 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001874 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001875 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001876 af.symlinks = cc.Symlinks()
1877 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001878}
1879
Jiyong Park1833cef2019-12-13 13:28:36 +09001880func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001881 dirInApex := "bin"
1882 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001883 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001884}
Jiyong Park1833cef2019-12-13 13:28:36 +09001885func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001886 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001887 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1888 if err != nil {
1889 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001890 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001891 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001892 fileToCopy := android.PathForOutput(ctx, s)
1893 // NB: Since go binaries are static we don't need the module for anything here, which is
1894 // good since the go tool is a blueprint.Module not an android.Module like we would
1895 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001896 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001897}
1898
Jiyong Park1833cef2019-12-13 13:28:36 +09001899func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001900 dirInApex := filepath.Join("bin", sh.SubDir())
1901 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001902 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001903 af.symlinks = sh.Symlinks()
1904 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001905}
1906
Jooyung Han58f26ab2019-12-18 15:34:32 +09001907// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1908type javaLibrary interface {
1909 android.Module
1910 java.Dependency
1911}
1912
1913func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001914 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001915 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001916 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1917 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1918 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001919}
1920
Jiyong Park1833cef2019-12-13 13:28:36 +09001921func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001922 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1923 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001924 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001925}
1926
atrost6e126252020-01-27 17:01:16 +00001927func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1928 dirInApex := filepath.Join("etc", config.SubDir())
1929 fileToCopy := config.CompatConfig()
1930 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1931}
1932
Jiyong Park1833cef2019-12-13 13:28:36 +09001933func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001934 android.Module
1935 Privileged() bool
1936 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001937 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001938 Certificate() java.Certificate
Jiyong Parkf653b052019-11-18 15:39:01 +09001939}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001940 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001941 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001942 appDir = "priv-app"
1943 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001944 dirInApex := filepath.Join(appDir, pkgName)
1945 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001946 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1947 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross503c1d02020-01-28 14:00:53 -08001948 af.certificate = aapp.Certificate()
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001949
1950 if app, ok := aapp.(interface {
1951 OverriddenManifestPackageName() string
1952 }); ok {
1953 af.overriddenPackageName = app.OverriddenManifestPackageName()
1954 }
Jiyong Park618922e2020-01-08 13:35:43 +09001955 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001956}
1957
Roland Levillain935639d2019-08-13 14:55:28 +01001958// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1959type flattenedApexContext struct {
1960 android.ModuleContext
1961}
1962
1963func (c *flattenedApexContext) InstallBypassMake() bool {
1964 return true
1965}
1966
Jiyong Park201cedd2020-02-07 17:25:49 +09001967// Visit dependencies that contributes to the payload of this APEX
1968func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext,
1969 do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) {
Jiyong Parkfa899442020-01-31 02:49:53 +09001970 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
1971 am, ok := child.(android.ApexModule)
1972 if !ok || !am.CanHaveApexVariants() {
1973 return false
1974 }
1975
1976 // Check for the direct dependencies that contribute to the payload
1977 if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
1978 if dt.payload {
Jiyong Park201cedd2020-02-07 17:25:49 +09001979 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001980 return true
1981 }
1982 return false
1983 }
1984
1985 // Check for the indirect dependencies if it is considered as part of the APEX
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001986 if am.ApexName() != "" {
Jiyong Park201cedd2020-02-07 17:25:49 +09001987 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001988 return true
1989 }
1990
Jiyong Park201cedd2020-02-07 17:25:49 +09001991 do(ctx, parent, am, true /* externalDep */)
1992
Jiyong Parkfa899442020-01-31 02:49:53 +09001993 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1994 return false
1995 })
1996}
1997
Jooyung Han0c4e0162020-02-26 22:45:42 +09001998func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
1999 ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
2000 if ver != "current" {
2001 minSdkVersion, err := strconv.Atoi(ver)
2002 if err != nil {
2003 ctx.PropertyErrorf("min_sdk_version", "should be \"current\" or <number>, but %q", ver)
2004 }
2005 return minSdkVersion
2006 }
2007 return android.FutureApiLevel
2008}
2009
Jiyong Park201cedd2020-02-07 17:25:49 +09002010// Ensures that the dependencies are marked as available for this APEX
2011func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
2012 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
2013 if ctx.Host() || a.testApex || a.vndkApex {
2014 return
2015 }
2016
2017 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2018 apexName := ctx.ModuleName()
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002019 fromName := ctx.OtherModuleName(from)
2020 toName := ctx.OtherModuleName(to)
2021 if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) {
Jiyong Park201cedd2020-02-07 17:25:49 +09002022 return
2023 }
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002024 ctx.ModuleErrorf("%q requires %q that is not available for the APEX.", fromName, toName)
Jiyong Park201cedd2020-02-07 17:25:49 +09002025 })
2026}
2027
Jiyong Park678c8812020-02-07 17:25:49 +09002028// Collects the list of module names that directly or indirectly contributes to the payload of this APEX
2029func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) {
2030 a.depInfos = make(map[string]depInfo)
2031 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2032 if from.Name() == to.Name() {
2033 // This can happen for cc.reuseObjTag. We are not interested in tracking this.
2034 return
2035 }
2036
2037 if info, exists := a.depInfos[to.Name()]; exists {
2038 if !android.InList(from.Name(), info.from) {
2039 info.from = append(info.from, from.Name())
2040 }
2041 info.isExternal = info.isExternal && externalDep
2042 a.depInfos[to.Name()] = info
2043 } else {
2044 a.depInfos[to.Name()] = depInfo{
2045 to: to.Name(),
2046 from: []string{from.Name()},
2047 isExternal: externalDep,
2048 }
2049 }
2050 })
2051}
2052
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002053func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09002054 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
2055 switch a.properties.ApexType {
2056 case imageApex:
2057 if buildFlattenedAsDefault {
2058 a.suffix = imageApexSuffix
2059 } else {
2060 a.suffix = ""
2061 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002062
2063 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09002064 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002065 }
Sundong Ahnabb64432019-10-22 13:58:29 +09002066 }
2067 case zipApex:
2068 if proptools.String(a.properties.Payload_type) == "zip" {
2069 a.suffix = ""
2070 a.primaryApexType = true
2071 } else {
2072 a.suffix = zipApexSuffix
2073 }
2074 case flattenedApex:
2075 if buildFlattenedAsDefault {
2076 a.suffix = ""
2077 a.primaryApexType = true
2078 } else {
2079 a.suffix = flattenedSuffix
2080 }
Alex Light5098a612018-11-29 17:12:15 -08002081 }
2082
Roland Levillain630846d2019-06-26 12:48:34 +01002083 if len(a.properties.Tests) > 0 && !a.testApex {
2084 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
2085 return
2086 }
2087
Jiyong Parkfa899442020-01-31 02:49:53 +09002088 a.checkApexAvailability(ctx)
2089
Jiyong Park678c8812020-02-07 17:25:49 +09002090 a.collectDepsInfo(ctx)
2091
Alex Lightfc0bd7c2019-01-29 18:31:59 -08002092 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
2093
Jooyung Hane1633032019-08-01 17:41:43 +09002094 // native lib dependencies
2095 var provideNativeLibs []string
2096 var requireNativeLibs []string
2097
Jooyung Han5c998b92019-06-27 11:30:33 +09002098 // Check if "uses" requirements are met with dependent apexBundles
2099 var providedNativeSharedLibs []string
2100 useVendor := proptools.Bool(a.properties.Use_vendor)
2101 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
2102 if ctx.OtherModuleDependencyTag(m) != usesTag {
2103 return
2104 }
2105 otherName := ctx.OtherModuleName(m)
2106 other, ok := m.(*apexBundle)
2107 if !ok {
2108 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
2109 return
2110 }
2111 if proptools.Bool(other.properties.Use_vendor) != useVendor {
2112 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
2113 return
2114 }
2115 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
2116 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
2117 return
2118 }
2119 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
2120 })
2121
Jiyong Parkf653b052019-11-18 15:39:01 +09002122 var filesInfo []apexFile
Jiyong Park678c8812020-02-07 17:25:49 +09002123 // TODO(jiyong) do this using walkPayloadDeps
Alex Light778127a2019-02-27 14:19:50 -08002124 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01002125 depTag := ctx.OtherModuleDependencyTag(child)
2126 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09002127 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002128 switch depTag {
2129 case sharedLibTag:
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002130 if c, ok := child.(*cc.Module); ok {
2131 // bootstrap bionic libs are treated as provided by system
2132 if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
2133 provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base())
Jooyung Hane1633032019-08-01 17:41:43 +09002134 }
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002135 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, c, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09002136 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002137 } else {
2138 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002139 }
2140 case executableTag:
2141 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002142 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09002143 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09002144 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002145 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08002146 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09002147 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08002148 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09002149 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002150 } else {
Alex Light778127a2019-02-27 14:19:50 -08002151 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 +09002152 }
2153 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09002154 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002155 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09002156 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09002157 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2158 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09002159 filesInfo = append(filesInfo, af)
2160 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09002161 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09002162 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
2163 af := apexFileForJavaLibrary(ctx, sdkLib)
2164 if !af.Ok() {
2165 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2166 return false
2167 }
2168 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09002169 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002170 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09002171 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002172 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002173 case androidAppTag:
2174 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
2175 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002176 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002177 return true // track transitive dependencies
2178 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002179 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00002180 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
2181 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002182 } else {
2183 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
2184 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002185 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09002186 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002187 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
atrost6e126252020-01-27 17:01:16 +00002188 } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
2189 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002190 } else {
atrost6e126252020-01-27 17:01:16 +00002191 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09002192 }
Roland Levillain630846d2019-06-26 12:48:34 +01002193 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01002194 if ccTest, ok := child.(*cc.Module); ok {
2195 if ccTest.IsTestPerSrcAllTestsVariation() {
2196 // Multiple-output test module (where `test_per_src: true`).
2197 //
2198 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
2199 // We do not add this variation to `filesInfo`, as it has no output;
2200 // however, we do add the other variations of this module as indirect
2201 // dependencies (see below).
2202 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01002203 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01002204 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09002205 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09002206 af.class = nativeTest
2207 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01002208 }
Roland Levillain630846d2019-06-26 12:48:34 +01002209 } else {
2210 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
2211 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09002212 case keyTag:
2213 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002214 a.private_key_file = key.private_key_file
2215 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09002216 } else {
2217 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002218 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002219 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002220 case certificateTag:
2221 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002222 a.container_certificate_file = dep.Certificate.Pem
2223 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002224 } else {
2225 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
2226 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09002227 case android.PrebuiltDepTag:
2228 // If the prebuilt is force disabled, remember to delete the prebuilt file
2229 // that might have been installed in the previous builds
2230 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
2231 a.prebuiltFileToDelete = prebuilt.InstallFilename()
2232 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002233 }
Jooyung Han8aee2042019-10-29 05:08:31 +09002234 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002235 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09002236 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01002237 // We cannot use a switch statement on `depTag` here as the checked
2238 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09002239 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002240 if cc, ok := child.(*cc.Module); ok {
2241 if android.InList(cc.Name(), providedNativeSharedLibs) {
2242 // If we're using a shared library which is provided from other APEX,
2243 // don't include it in this APEX
2244 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09002245 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09002246 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002247 // If the dependency is a stubs lib, don't include it in this APEX,
2248 // but make sure that the lib is installed on the device.
2249 // In case no APEX is having the lib, the lib is installed to the system
2250 // partition.
2251 //
2252 // Always include if we are a host-apex however since those won't have any
2253 // system libraries.
Jiyong Park956305c2020-01-09 12:32:06 +09002254 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
2255 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01002256 }
Jooyung Hane1633032019-08-01 17:41:43 +09002257 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01002258 // Don't track further
2259 return false
2260 }
Jiyong Park1833cef2019-12-13 13:28:36 +09002261 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09002262 af.transitiveDep = true
2263 filesInfo = append(filesInfo, af)
2264 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09002265 }
Roland Levillainf89cd092019-07-29 16:22:59 +01002266 } else if cc.IsTestPerSrcDepTag(depTag) {
2267 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002268 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01002269 // Handle modules created as `test_per_src` variations of a single test module:
2270 // use the name of the generated test binary (`fileToCopy`) instead of the name
2271 // of the original test module (`depName`, shared by all `test_per_src`
2272 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09002273 af.moduleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002274 // these are not considered transitive dep
2275 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09002276 filesInfo = append(filesInfo, af)
2277 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01002278 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09002279 } else if java.IsJniDepTag(depTag) {
Jooyung Han65041792020-02-25 16:59:29 +09002280 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
2281 return false
Jiyong Parke3833882020-02-17 17:28:10 +09002282 } else if java.IsXmlPermissionsFileDepTag(depTag) {
2283 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
2284 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
2285 }
Jooyung Han9c80bae2019-08-20 17:30:57 +09002286 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01002287 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002288 }
2289 }
2290 }
2291 return false
2292 })
2293
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002294 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
2295 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
2296 // via the global boot image config.
2297 if a.artApex {
2298 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
2299 dirInApex := filepath.Join("javalib", arch.String())
2300 for _, f := range files {
2301 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09002302 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09002303 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002304 }
2305 }
2306 }
2307
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002308 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09002309 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
2310 return
2311 }
2312
Jiyong Park8fd61922018-11-08 02:50:25 +09002313 // remove duplicates in filesInfo
2314 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002315 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002316 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002317 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002318 if e, ok := encountered[dest]; !ok {
2319 encountered[dest] = f
2320 } else {
2321 // If a module is directly included and also transitively depended on
2322 // consider it as directly included.
2323 e.transitiveDep = e.transitiveDep && f.transitiveDep
2324 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002325 }
2326 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002327 var result []apexFile
2328 for _, v := range encountered {
2329 result = append(result, v)
2330 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002331 return result
2332 }
2333 filesInfo = removeDup(filesInfo)
2334
2335 // to have consistent build rules
2336 sort.Slice(filesInfo, func(i, j int) bool {
2337 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
2338 })
2339
Jiyong Park8fd61922018-11-08 02:50:25 +09002340 a.installDir = android.PathForModuleInstall(ctx, "apex")
2341 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002342
Jooyung Han54aca7b2019-11-20 02:26:02 +09002343 if a.properties.ApexType != zipApex {
2344 if a.properties.File_contexts == nil {
2345 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
2346 } else {
2347 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
2348 if a.Platform() {
2349 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
2350 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
2351 }
2352 }
2353 }
2354 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
2355 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
2356 return
2357 }
2358 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002359 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2360 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2361 // the same library in the system partition, thus effectively sharing the same libraries
2362 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2363 // in the APEX.
2364 a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
2365 a.installable() &&
2366 !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002367
Jiyong Park9d677202020-02-19 16:29:35 +09002368 // We don't need the optimization for updatable APEXes, as it might give false signal
2369 // to the system health when the APEXes are still bundled (b/149805758)
2370 if proptools.Bool(a.properties.Updatable) && a.properties.ApexType == imageApex {
2371 a.linkToSystemLib = false
2372 }
2373
Jiyong Park9b964182020-02-26 18:27:19 +09002374 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2375 if ctx.Host() {
2376 a.linkToSystemLib = false
2377 }
2378
Jooyung Hand15aa1f2019-09-27 00:38:03 +09002379 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09002380 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
2381
2382 a.setCertificateAndPrivateKey(ctx)
2383 if a.properties.ApexType == flattenedApex {
2384 a.buildFlattenedApex(ctx)
2385 } else {
2386 a.buildUnflattenedApex(ctx)
2387 }
2388
Jooyung Han002ab682020-01-08 01:57:58 +09002389 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09002390
2391 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002392}
2393
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002394func whitelistedApexAvailable(apex, moduleName string) bool {
Anton Hansson5053c292020-01-10 15:12:39 +00002395 key := apex
2396 key = strings.Replace(key, "test_", "", 1)
2397 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
2398 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
2399
Jiyong Parkfa899442020-01-31 02:49:53 +09002400 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2401 // system. Trim the prefix for the check since they are confusing
2402 moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
2403 if strings.HasPrefix(moduleName, "libclang_rt.") {
2404 // This module has many arch variants that depend on the product being built.
2405 // We don't want to list them all
2406 moduleName = "libclang_rt"
Anton Hansson5053c292020-01-10 15:12:39 +00002407 }
2408
2409 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2410 return true
2411 }
2412
Jiyong Parkfa899442020-01-31 02:49:53 +09002413 key = "//any"
2414 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2415 return true
2416 }
2417
Anton Hansson5053c292020-01-10 15:12:39 +00002418 return false
2419}
2420
Jooyung Han344d5432019-08-23 11:17:39 +09002421func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09002422 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002423 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08002424 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09002425 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08002426 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09002427 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
2428 })
Alex Light5098a612018-11-29 17:12:15 -08002429 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002430 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09002431 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08002432 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002433 return module
2434}
Jiyong Park30ca9372019-02-07 16:27:23 +09002435
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002436func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002437 bundle := newApexBundle()
2438 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002439 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09002440 return bundle
2441}
2442
Jiyong Parkfce0b422020-02-11 03:56:06 +09002443// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2444// certain compatibility checks such as apex_available are not done for apex_test.
Jooyung Han344d5432019-08-23 11:17:39 +09002445func testApexBundleFactory() android.Module {
2446 bundle := newApexBundle()
2447 bundle.testApex = true
2448 return bundle
2449}
2450
Jiyong Parkfce0b422020-02-11 03:56:06 +09002451// apex packages other modules into an APEX file which is a packaging format for system-level
2452// components like binaries, shared libraries, etc.
Jiyong Parkd1063c12019-07-17 20:08:41 +09002453func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002454 return newApexBundle()
2455}
2456
Jiyong Park30ca9372019-02-07 16:27:23 +09002457//
2458// Defaults
2459//
2460type Defaults struct {
2461 android.ModuleBase
2462 android.DefaultsModuleBase
2463}
2464
Jiyong Park30ca9372019-02-07 16:27:23 +09002465func defaultsFactory() android.Module {
2466 return DefaultsFactory()
2467}
2468
2469func DefaultsFactory(props ...interface{}) android.Module {
2470 module := &Defaults{}
2471
2472 module.AddProperties(props...)
2473 module.AddProperties(
2474 &apexBundleProperties{},
2475 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09002476 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09002477 )
2478
2479 android.InitDefaultsModule(module)
2480 return module
2481}
Jiyong Park5d790c32019-11-15 18:40:32 +09002482
2483//
2484// OverrideApex
2485//
2486type OverrideApex struct {
2487 android.ModuleBase
2488 android.OverrideModuleBase
2489}
2490
2491func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2492 // All the overrides happen in the base module.
2493}
2494
2495// override_apex is used to create an apex module based on another apex module
2496// by overriding some of its properties.
2497func overrideApexFactory() android.Module {
2498 m := &OverrideApex{}
2499 m.AddProperties(&overridableProperties{})
2500
2501 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2502 android.InitOverrideModule(m)
2503 return m
2504}