blob: 268088b241259f5aac6747d08357db81ebfc5e83 [file] [log] [blame]
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package apex
16
17import (
18 "fmt"
Jooyung Han54aca7b2019-11-20 02:26:02 +090019 "path"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090020 "path/filepath"
Jiyong Parkab3ceb32018-10-10 14:05:29 +090021 "sort"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090022 "strings"
Jooyung Han344d5432019-08-23 11:17:39 +090023 "sync"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090024
25 "android/soong/android"
26 "android/soong/cc"
27 "android/soong/java"
Alex Light778127a2019-02-27 14:19:50 -080028 "android/soong/python"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090029
30 "github.com/google/blueprint"
Alex Light778127a2019-02-27 14:19:50 -080031 "github.com/google/blueprint/bootstrap"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090032 "github.com/google/blueprint/proptools"
33)
34
Jooyung Han72bd2f82019-10-23 16:46:38 +090035const (
36 imageApexSuffix = ".apex"
37 zipApexSuffix = ".zipapex"
Sundong Ahnabb64432019-10-22 13:58:29 +090038 flattenedSuffix = ".flattened"
Alex Light5098a612018-11-29 17:12:15 -080039
Sundong Ahnabb64432019-10-22 13:58:29 +090040 imageApexType = "image"
41 zipApexType = "zip"
42 flattenedApexType = "flattened"
Jooyung Han72bd2f82019-10-23 16:46:38 +090043)
Jiyong Park48ca7dc2018-10-10 14:01:00 +090044
45type dependencyTag struct {
46 blueprint.BaseDependencyTag
47 name string
Jiyong Parkfa899442020-01-31 02:49:53 +090048
49 // determines if the dependent will be part of the APEX payload
50 payload bool
Jiyong Park48ca7dc2018-10-10 14:01:00 +090051}
52
53var (
Jiyong Parkfa899442020-01-31 02:49:53 +090054 sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
55 executableTag = dependencyTag{name: "executable", payload: true}
56 javaLibTag = dependencyTag{name: "javaLib", payload: true}
57 prebuiltTag = dependencyTag{name: "prebuilt", payload: true}
58 testTag = dependencyTag{name: "test", payload: true}
Jiyong Parkc00cbd92018-10-30 21:20:05 +090059 keyTag = dependencyTag{name: "key"}
60 certificateTag = dependencyTag{name: "certificate"}
Jooyung Han5c998b92019-06-27 11:30:33 +090061 usesTag = dependencyTag{name: "uses"}
Jiyong Parkfa899442020-01-31 02:49:53 +090062 androidAppTag = dependencyTag{name: "androidApp", payload: true}
Anton Hansson5053c292020-01-10 15:12:39 +000063 apexAvailWl = makeApexAvailableWhitelist()
Jiyong Park48ca7dc2018-10-10 14:01:00 +090064)
65
Anton Hansson5053c292020-01-10 15:12:39 +000066// This is a map from apex to modules, which overrides the
67// apex_available setting for that particular module to make
68// it available for the apex regardless of its setting.
69// TODO(b/147364041): remove this
70func makeApexAvailableWhitelist() map[string][]string {
71 // The "Module separator"s below are employed to minimize merge conflicts.
72 m := make(map[string][]string)
73 //
74 // Module separator
75 //
Jiyong Parkfa899442020-01-31 02:49:53 +090076 m["com.android.adbd"] = []string{
77 "adbd",
78 "bcm_object",
79 "fmtlib",
80 "libadbconnection_server",
81 "libadbd",
82 "libadbd_auth",
83 "libadbd_core",
84 "libadbd_services",
85 "libasyncio",
86 "libbacktrace_headers",
87 "libbase",
88 "libbase_headers",
89 "libbuildversion",
90 "libc++",
91 "libcap",
92 "libcrypto",
93 "libcrypto_utils",
94 "libcutils",
95 "libcutils_headers",
96 "libdiagnose_usb",
Jiyong Parkfa899442020-01-31 02:49:53 +090097 "liblog_headers",
98 "libmdnssd",
99 "libminijail",
100 "libminijail_gen_constants",
101 "libminijail_gen_constants_obj",
102 "libminijail_gen_syscall",
103 "libminijail_gen_syscall_obj",
104 "libminijail_generated",
105 "libpackagelistparser",
106 "libpcre2",
107 "libprocessgroup_headers",
108 "libqemu_pipe",
109 "libselinux",
110 "libsystem_headers",
111 "libutils_headers",
112 }
113 //
114 // Module separator
115 //
Anton Hansson5053c292020-01-10 15:12:39 +0000116 m["com.android.art"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900117 "art_cmdlineparser_headers",
118 "art_disassembler_headers",
119 "art_libartbase_headers",
120 "bcm_object",
121 "bionic_libc_platform_headers",
122 "core-repackaged-icu4j",
123 "cpp-define-generator-asm-support",
124 "cpp-define-generator-definitions",
125 "crtbegin_dynamic",
126 "crtbegin_dynamic1",
127 "crtbegin_so1",
128 "crtbrand",
129 "conscrypt.module.intra.core.api.stubs",
130 "dex2oat_headers",
131 "dt_fd_forward_export",
132 "fmtlib",
133 "icu4c_extra_headers",
Anton Hanssonf17f2482020-01-16 09:11:57 +0000134 "jacocoagent",
Jiyong Parkfa899442020-01-31 02:49:53 +0900135 "javavm_headers",
136 "jni_platform_headers",
137 "libPlatformProperties",
138 "libadbconnection_client",
Anton Hansson5053c292020-01-10 15:12:39 +0000139 "libadbconnection_server",
Jiyong Parkfa899442020-01-31 02:49:53 +0900140 "libandroidicuinit",
141 "libart_runtime_headers_ndk",
Anton Hansson5053c292020-01-10 15:12:39 +0000142 "libartd-disassembler",
Jiyong Parkfa899442020-01-31 02:49:53 +0900143 "libasync_safe",
Anton Hansson5053c292020-01-10 15:12:39 +0000144 "libbacktrace",
145 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900146 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000147 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900148 "libc++_static",
149 "libc++abi",
150 "libc++demangle",
151 "libc_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000152 "libcrypto",
Jiyong Parkfa899442020-01-31 02:49:53 +0900153 "libdexfile_all_headers",
154 "libdexfile_external_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000155 "libdexfile_support",
Jiyong Parkfa899442020-01-31 02:49:53 +0900156 "libdmabufinfo",
Anton Hansson5053c292020-01-10 15:12:39 +0000157 "libexpat",
Jiyong Parkfa899442020-01-31 02:49:53 +0900158 "libfdlibm",
159 "libgtest_prod",
160 "libicui18n_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000161 "libicuuc",
Jiyong Parkfa899442020-01-31 02:49:53 +0900162 "libicuuc_headers",
163 "libicuuc_stubdata",
164 "libjdwp_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900165 "liblog_headers",
166 "liblz4",
Anton Hansson5053c292020-01-10 15:12:39 +0000167 "liblzma",
168 "libmeminfo",
Jiyong Parkfa899442020-01-31 02:49:53 +0900169 "libnativebridge-headers",
170 "libnativehelper_header_only",
171 "libnativeloader-headers",
172 "libnpt_headers",
173 "libopenjdkjvmti_headers",
174 "libperfetto_client_experimental",
Anton Hansson5053c292020-01-10 15:12:39 +0000175 "libprocinfo",
Jiyong Parkfa899442020-01-31 02:49:53 +0900176 "libprotobuf-cpp-lite",
177 "libunwind_llvm",
Anton Hansson5053c292020-01-10 15:12:39 +0000178 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900179 "libv8",
180 "libv8base",
181 "libv8gen",
182 "libv8platform",
183 "libv8sampler",
184 "libv8src",
Anton Hansson5053c292020-01-10 15:12:39 +0000185 "libvixl",
186 "libvixld",
187 "libz",
188 "libziparchive",
Jiyong Parkfa899442020-01-31 02:49:53 +0900189 "perfetto_trace_protos",
Anton Hansson5053c292020-01-10 15:12:39 +0000190 }
191 //
192 // Module separator
193 //
194 m["com.android.bluetooth.updatable"] = []string{
195 "android.hardware.audio.common@5.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000196 "android.hardware.bluetooth.a2dp@1.0",
197 "android.hardware.bluetooth.audio@2.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900198 "android.hardware.bluetooth@1.0",
199 "android.hardware.bluetooth@1.1",
200 "android.hardware.graphics.bufferqueue@1.0",
201 "android.hardware.graphics.bufferqueue@2.0",
202 "android.hardware.graphics.common@1.0",
203 "android.hardware.graphics.common@1.1",
204 "android.hardware.graphics.common@1.2",
205 "android.hardware.media@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000206 "android.hidl.safe_union@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900207 "android.hidl.token@1.0",
208 "android.hidl.token@1.0-utils",
209 "avrcp-target-service",
210 "avrcp_headers",
211 "bcm_object",
212 "bluetooth-protos-lite",
213 "bluetooth.mapsapi",
214 "com.android.vcard",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900215 "dnsresolver_aidl_interface-V2-java",
Jiyong Parkfa899442020-01-31 02:49:53 +0900216 "fmtlib",
217 "guava",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900218 "ipmemorystore-aidl-interfaces-V5-java",
219 "ipmemorystore-aidl-interfaces-java",
Jiyong Parkfa899442020-01-31 02:49:53 +0900220 "internal_include_headers",
221 "lib-bt-packets",
222 "lib-bt-packets-avrcp",
223 "lib-bt-packets-base",
224 "libFraunhoferAAC",
225 "libaudio-a2dp-hw-utils",
226 "libaudio-hearing-aid-hw-utils",
227 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000228 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900229 "libbase_headers",
230 "libbinder_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000231 "libbluetooth",
Jiyong Parkfa899442020-01-31 02:49:53 +0900232 "libbluetooth-types",
233 "libbluetooth-types-header",
234 "libbluetooth_gd",
235 "libbluetooth_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000236 "libbluetooth_jni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900237 "libbt-audio-hal-interface",
238 "libbt-bta",
239 "libbt-common",
240 "libbt-hci",
241 "libbt-platform-protos-lite",
242 "libbt-protos-lite",
243 "libbt-sbc-decoder",
244 "libbt-sbc-encoder",
245 "libbt-stack",
246 "libbt-utils",
247 "libbtcore",
248 "libbtdevice",
249 "libbte",
250 "libbtif",
Anton Hansson5053c292020-01-10 15:12:39 +0000251 "libc++",
252 "libchrome",
253 "libcrypto",
254 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900255 "libcutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000256 "libevent",
257 "libfmq",
Jiyong Parkfa899442020-01-31 02:49:53 +0900258 "libg722codec",
259 "libgtest_prod",
260 "libgui_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000261 "libhidlbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900262 "libhidlbase-impl-internal",
263 "libhidltransport-impl-internal",
264 "libhwbinder-impl-internal",
265 "libjsoncpp",
266 "liblog_headers",
267 "libmedia_headers",
268 "libmodpb64",
269 "libosi",
Anton Hansson5053c292020-01-10 15:12:39 +0000270 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900271 "libprocessgroup_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000272 "libprotobuf-cpp-lite",
Jiyong Parkfa899442020-01-31 02:49:53 +0900273 "libprotobuf-java-lite",
274 "libprotobuf-java-micro",
275 "libstagefright_foundation_headers",
276 "libstagefright_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000277 "libstatslog",
Jiyong Parkfa899442020-01-31 02:49:53 +0900278 "libstatssocket",
279 "libsystem_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000280 "libtinyxml2",
Jiyong Parkfa899442020-01-31 02:49:53 +0900281 "libudrv-uipc",
Jiyong Parkfa899442020-01-31 02:49:53 +0900282 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000283 "libz",
Jiyong Parkfa899442020-01-31 02:49:53 +0900284 "media_plugin_headers",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900285 "net-utils-services-common",
286 "netd_aidl_interface-unstable-java",
287 "netd_event_listener_interface-java",
288 "netlink-client",
289 "networkstack-aidl-interfaces-unstable-java",
290 "networkstack-client",
Jiyong Parkfa899442020-01-31 02:49:53 +0900291 "sap-api-java-static",
292 "services.net",
Anton Hansson5053c292020-01-10 15:12:39 +0000293 }
294 //
295 // Module separator
296 //
297 m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
298 //
299 // Module separator
300 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900301 m["com.android.conscrypt"] = []string{
302 "bcm_object",
303 "boringssl_self_test",
304 "libc++",
305 "libcrypto",
306 "libnativehelper_header_only",
307 "libssl",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900308 "unsupportedappusage",
Jiyong Parkfa899442020-01-31 02:49:53 +0900309 }
Anton Hansson5053c292020-01-10 15:12:39 +0000310 //
311 // Module separator
312 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900313 m["com.android.extservices"] = []string{
314 "flatbuffer_headers",
315 "liblua",
316 "libtextclassifier",
317 "libtextclassifier_hash_static",
318 "libtflite_static",
319 "libutf",
320 "libz_current",
321 "tensorflow_headers",
322 }
323 //
324 // Module separator
325 //
326 m["com.android.cronet"] = []string{
327 "cronet_impl_common_java",
328 "cronet_impl_native_java",
329 "cronet_impl_platform_java",
330 "libcronet.80.0.3986.0",
331 "org.chromium.net.cronet",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900332 "org.chromium.net.cronet.xml",
Jiyong Parkfa899442020-01-31 02:49:53 +0900333 "prebuilt_libcronet.80.0.3986.0",
334 }
335 //
336 // Module separator
337 //
338 m["com.android.neuralnetworks"] = []string{
339 "android.hardware.neuralnetworks@1.0",
340 "android.hardware.neuralnetworks@1.1",
341 "android.hardware.neuralnetworks@1.2",
342 "android.hardware.neuralnetworks@1.3",
343 "android.hidl.allocator@1.0",
344 "android.hidl.memory.token@1.0",
345 "android.hidl.memory@1.0",
346 "android.hidl.safe_union@1.0",
347 "bcm_object",
348 "fmtlib",
349 "gemmlowp_headers",
350 "libarect",
351 "libbacktrace_headers",
352 "libbase",
353 "libbase_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900354 "libbuildversion",
355 "libc++",
356 "libcrypto",
357 "libcrypto_static",
358 "libcutils",
359 "libcutils_headers",
360 "libeigen",
361 "libfmq",
362 "libhidlbase",
363 "libhidlbase-impl-internal",
364 "libhidlmemory",
365 "libhidltransport-impl-internal",
366 "libhwbinder-impl-internal",
367 "libjsoncpp",
368 "liblog_headers",
369 "libmath",
370 "libneuralnetworks_common",
371 "libneuralnetworks_headers",
372 "libprocessgroup",
373 "libprocessgroup_headers",
374 "libprocpartition",
375 "libsync",
376 "libsystem_headers",
377 "libtextclassifier_hash",
378 "libtextclassifier_hash_headers",
379 "libtextclassifier_hash_static",
380 "libtflite_kernel_utils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900381 "libutils_headers",
382 "philox_random",
383 "philox_random_headers",
384 "tensorflow_headers",
385 }
Anton Hansson5053c292020-01-10 15:12:39 +0000386 //
387 // Module separator
388 //
Anton Hansson5053c292020-01-10 15:12:39 +0000389 m["com.android.media"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900390 "android.frameworks.bufferhub@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000391 "android.hardware.cas.native@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900392 "android.hardware.cas@1.0",
393 "android.hardware.configstore-utils",
394 "android.hardware.configstore@1.0",
395 "android.hardware.configstore@1.1",
396 "android.hardware.graphics.allocator@2.0",
397 "android.hardware.graphics.allocator@3.0",
398 "android.hardware.graphics.bufferqueue@1.0",
399 "android.hardware.graphics.bufferqueue@2.0",
400 "android.hardware.graphics.common@1.0",
401 "android.hardware.graphics.common@1.1",
402 "android.hardware.graphics.common@1.2",
403 "android.hardware.graphics.mapper@2.0",
404 "android.hardware.graphics.mapper@2.1",
405 "android.hardware.graphics.mapper@3.0",
406 "android.hardware.media.omx@1.0",
407 "android.hardware.media@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000408 "android.hidl.allocator@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000409 "android.hidl.memory.token@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900410 "android.hidl.memory@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000411 "android.hidl.token@1.0",
412 "android.hidl.token@1.0-utils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900413 "bcm_object",
414 "bionic_libc_platform_headers",
415 "fmtlib",
416 "gl_headers",
417 "libEGL",
418 "libEGL_blobCache",
419 "libEGL_getProcAddress",
420 "libFLAC",
421 "libFLAC-config",
422 "libFLAC-headers",
423 "libGLESv2",
Anton Hansson5053c292020-01-10 15:12:39 +0000424 "libaacextractor",
425 "libamrextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900426 "libarect",
427 "libasync_safe",
428 "libaudio_system_headers",
429 "libaudioclient",
430 "libaudioclient_headers",
431 "libaudiofoundation",
432 "libaudiofoundation_headers",
433 "libaudiomanager",
434 "libaudiopolicy",
Anton Hansson5053c292020-01-10 15:12:39 +0000435 "libaudioutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900436 "libaudioutils_fixedfft",
437 "libbacktrace",
438 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000439 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900440 "libbase_headers",
441 "libbinder_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900442 "libbluetooth-types-header",
443 "libbufferhub",
444 "libbufferhub_headers",
445 "libbufferhubqueue",
Anton Hansson5053c292020-01-10 15:12:39 +0000446 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900447 "libc_headers",
448 "libc_malloc_debug_backtrace",
449 "libcamera_client",
450 "libcamera_metadata",
Anton Hansson5053c292020-01-10 15:12:39 +0000451 "libcrypto",
452 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900453 "libcutils_headers",
454 "libdexfile_external_headers",
455 "libdexfile_support",
456 "libdvr_headers",
457 "libexpat",
458 "libfifo",
Anton Hansson5053c292020-01-10 15:12:39 +0000459 "libflacextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900460 "libgrallocusage",
461 "libgraphicsenv",
462 "libgui",
463 "libgui_headers",
464 "libhardware_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000465 "libhidlbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900466 "libhidlbase-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000467 "libhidlmemory",
Jiyong Parkfa899442020-01-31 02:49:53 +0900468 "libhidltransport-impl-internal",
469 "libhwbinder-impl-internal",
470 "libinput",
471 "libjsoncpp",
472 "liblog_headers",
473 "liblzma",
474 "libmath",
475 "libmedia",
476 "libmedia_codeclist",
477 "libmedia_headers",
478 "libmedia_helper",
479 "libmedia_helper_headers",
480 "libmedia_midiiowrapper",
481 "libmedia_omx",
482 "libmediautils",
Anton Hansson5053c292020-01-10 15:12:39 +0000483 "libmidiextractor",
484 "libmkvextractor",
485 "libmp3extractor",
486 "libmp4extractor",
487 "libmpeg2extractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900488 "libnativebase_headers",
489 "libnativebridge-headers",
490 "libnativebridge_lazy",
491 "libnativeloader-headers",
492 "libnativeloader_lazy",
493 "libnativewindow_headers",
494 "libnblog",
Anton Hansson5053c292020-01-10 15:12:39 +0000495 "liboggextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900496 "libpackagelistparser",
497 "libpcre2",
498 "libpdx",
499 "libpdx_default_transport",
500 "libpdx_headers",
501 "libpdx_uds",
Anton Hansson5053c292020-01-10 15:12:39 +0000502 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900503 "libprocessgroup_headers",
504 "libprocinfo",
505 "libselinux",
506 "libsonivox",
Anton Hansson5053c292020-01-10 15:12:39 +0000507 "libspeexresampler",
Jiyong Parkfa899442020-01-31 02:49:53 +0900508 "libspeexresampler",
509 "libstagefright_esds",
Anton Hansson5053c292020-01-10 15:12:39 +0000510 "libstagefright_flacdec",
Jiyong Parkfa899442020-01-31 02:49:53 +0900511 "libstagefright_flacdec",
512 "libstagefright_foundation",
513 "libstagefright_foundation_headers",
514 "libstagefright_foundation_without_imemory",
515 "libstagefright_headers",
516 "libstagefright_id3",
517 "libstagefright_metadatautils",
518 "libstagefright_mpeg2extractor",
519 "libstagefright_mpeg2support",
520 "libsync",
521 "libsystem_headers",
522 "libui",
523 "libui_headers",
524 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900525 "libutils_headers",
526 "libvibrator",
527 "libvorbisidec",
Anton Hansson5053c292020-01-10 15:12:39 +0000528 "libwavextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900529 "libwebm",
530 "media_ndk_headers",
531 "media_plugin_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000532 "updatable-media",
533 }
534 //
535 // Module separator
536 //
537 m["com.android.media.swcodec"] = []string{
538 "android.frameworks.bufferhub@1.0",
539 "android.hardware.common-ndk_platform",
Jiyong Parkfa899442020-01-31 02:49:53 +0900540 "android.hardware.configstore-utils",
541 "android.hardware.configstore@1.0",
542 "android.hardware.configstore@1.1",
Anton Hansson5053c292020-01-10 15:12:39 +0000543 "android.hardware.graphics.allocator@2.0",
544 "android.hardware.graphics.allocator@3.0",
545 "android.hardware.graphics.allocator@4.0",
546 "android.hardware.graphics.bufferqueue@1.0",
547 "android.hardware.graphics.bufferqueue@2.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900548 "android.hardware.graphics.common-ndk_platform",
Anton Hansson5053c292020-01-10 15:12:39 +0000549 "android.hardware.graphics.common@1.0",
550 "android.hardware.graphics.common@1.1",
551 "android.hardware.graphics.common@1.2",
Anton Hansson5053c292020-01-10 15:12:39 +0000552 "android.hardware.graphics.mapper@2.0",
553 "android.hardware.graphics.mapper@2.1",
554 "android.hardware.graphics.mapper@3.0",
555 "android.hardware.graphics.mapper@4.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000556 "android.hardware.media.bufferpool@2.0",
557 "android.hardware.media.c2@1.0",
558 "android.hardware.media.c2@1.1",
559 "android.hardware.media.omx@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900560 "android.hardware.media@1.0",
561 "android.hardware.media@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000562 "android.hidl.memory.token@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900563 "android.hidl.memory@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000564 "android.hidl.safe_union@1.0",
565 "android.hidl.token@1.0",
566 "android.hidl.token@1.0-utils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900567 "fmtlib",
568 "libEGL",
569 "libFLAC",
570 "libFLAC-config",
571 "libFLAC-headers",
572 "libFraunhoferAAC",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900573 "libLibGuiProperties",
Jiyong Parkfa899442020-01-31 02:49:53 +0900574 "libarect",
575 "libasync_safe",
576 "libaudio_system_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000577 "libaudioutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900578 "libaudioutils",
579 "libaudioutils_fixedfft",
580 "libavcdec",
581 "libavcenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000582 "libavservices_minijail",
Jiyong Parkfa899442020-01-31 02:49:53 +0900583 "libavservices_minijail",
584 "libbacktrace",
585 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000586 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900587 "libbase_headers",
588 "libbinder_headers",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900589 "libbinderthreadstateutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900590 "libbluetooth-types-header",
591 "libbufferhub_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000592 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900593 "libc_scudo",
Anton Hansson5053c292020-01-10 15:12:39 +0000594 "libcap",
595 "libcodec2",
Jiyong Parkfa899442020-01-31 02:49:53 +0900596 "libcodec2_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000597 "libcodec2_hidl@1.0",
598 "libcodec2_hidl@1.1",
Jiyong Parkfa899442020-01-31 02:49:53 +0900599 "libcodec2_internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000600 "libcodec2_soft_aacdec",
601 "libcodec2_soft_aacenc",
602 "libcodec2_soft_amrnbdec",
603 "libcodec2_soft_amrnbenc",
604 "libcodec2_soft_amrwbdec",
605 "libcodec2_soft_amrwbenc",
606 "libcodec2_soft_av1dec_gav1",
607 "libcodec2_soft_avcdec",
608 "libcodec2_soft_avcenc",
609 "libcodec2_soft_common",
610 "libcodec2_soft_flacdec",
611 "libcodec2_soft_flacenc",
612 "libcodec2_soft_g711alawdec",
613 "libcodec2_soft_g711mlawdec",
614 "libcodec2_soft_gsmdec",
615 "libcodec2_soft_h263dec",
616 "libcodec2_soft_h263enc",
617 "libcodec2_soft_hevcdec",
618 "libcodec2_soft_hevcenc",
619 "libcodec2_soft_mp3dec",
620 "libcodec2_soft_mpeg2dec",
621 "libcodec2_soft_mpeg4dec",
622 "libcodec2_soft_mpeg4enc",
623 "libcodec2_soft_opusdec",
624 "libcodec2_soft_opusenc",
625 "libcodec2_soft_rawdec",
626 "libcodec2_soft_vorbisdec",
627 "libcodec2_soft_vp8dec",
628 "libcodec2_soft_vp8enc",
629 "libcodec2_soft_vp9dec",
630 "libcodec2_soft_vp9enc",
631 "libcodec2_vndk",
Anton Hansson5053c292020-01-10 15:12:39 +0000632 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900633 "libcutils_headers",
634 "libdexfile_support",
635 "libdvr_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000636 "libfmq",
Jiyong Parkfa899442020-01-31 02:49:53 +0900637 "libfmq",
638 "libgav1",
Anton Hansson5053c292020-01-10 15:12:39 +0000639 "libgralloctypes",
Jiyong Parkfa899442020-01-31 02:49:53 +0900640 "libgrallocusage",
641 "libgraphicsenv",
642 "libgsm",
643 "libgui_bufferqueue_static",
644 "libgui_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000645 "libhardware",
Jiyong Parkfa899442020-01-31 02:49:53 +0900646 "libhardware_headers",
647 "libhevcdec",
648 "libhevcenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000649 "libhidlbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900650 "libhidlbase-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000651 "libhidlmemory",
Jiyong Parkfa899442020-01-31 02:49:53 +0900652 "libhidltransport-impl-internal",
653 "libhwbinder-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000654 "libion",
Jiyong Parkfa899442020-01-31 02:49:53 +0900655 "libjpeg",
656 "libjsoncpp",
657 "liblog_headers",
658 "liblzma",
659 "libmath",
Anton Hansson5053c292020-01-10 15:12:39 +0000660 "libmedia_codecserviceregistrant",
Jiyong Parkfa899442020-01-31 02:49:53 +0900661 "libmedia_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000662 "libminijail",
Jiyong Parkfa899442020-01-31 02:49:53 +0900663 "libminijail_gen_constants",
664 "libminijail_gen_constants_obj",
665 "libminijail_gen_syscall",
666 "libminijail_gen_syscall_obj",
667 "libminijail_generated",
668 "libmpeg2dec",
669 "libnativebase_headers",
670 "libnativebridge_lazy",
671 "libnativeloader_lazy",
672 "libnativewindow_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000673 "libopus",
Jiyong Parkfa899442020-01-31 02:49:53 +0900674 "libpdx_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000675 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900676 "libprocessgroup_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000677 "libscudo_wrapper",
678 "libsfplugin_ccodec_utils",
679 "libspeexresampler",
680 "libstagefright_amrnb_common",
Jiyong Parkfa899442020-01-31 02:49:53 +0900681 "libstagefright_amrnbdec",
682 "libstagefright_amrnbenc",
683 "libstagefright_amrwbdec",
684 "libstagefright_amrwbenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000685 "libstagefright_bufferpool@2.0.1",
686 "libstagefright_bufferqueue_helper",
687 "libstagefright_enc_common",
688 "libstagefright_flacdec",
689 "libstagefright_foundation",
Jiyong Parkfa899442020-01-31 02:49:53 +0900690 "libstagefright_foundation_headers",
691 "libstagefright_headers",
692 "libstagefright_m4vh263dec",
693 "libstagefright_m4vh263enc",
694 "libstagefright_mp3dec",
Anton Hansson5053c292020-01-10 15:12:39 +0000695 "libsync",
Jiyong Parkfa899442020-01-31 02:49:53 +0900696 "libsystem_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000697 "libui",
Jiyong Parkfa899442020-01-31 02:49:53 +0900698 "libui_headers",
699 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900700 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000701 "libvorbisidec",
702 "libvpx",
Jiyong Parkfa899442020-01-31 02:49:53 +0900703 "libyuv",
704 "libyuv_static",
705 "media_ndk_headers",
706 "media_plugin_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000707 "mediaswcodec",
Anton Hansson5053c292020-01-10 15:12:39 +0000708 }
709 //
710 // Module separator
711 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900712 m["com.android.mediaprovider"] = []string{
713 "MediaProvider",
714 "MediaProviderGoogle",
715 "fmtlib_ndk",
716 "guava",
717 "libbase_ndk",
718 "libfuse",
719 "libfuse_jni",
720 "libnativehelper_header_only",
721 }
722 //
723 // Module separator
724 //
725 m["com.android.permission"] = []string{
726 "androidx.annotation_annotation",
727 "androidx.annotation_annotation-nodeps",
728 "androidx.lifecycle_lifecycle-common",
729 "androidx.lifecycle_lifecycle-common-java8",
730 "androidx.lifecycle_lifecycle-common-java8-nodeps",
731 "androidx.lifecycle_lifecycle-common-nodeps",
732 "kotlin-annotations",
733 "kotlin-stdlib",
734 "kotlin-stdlib-jdk7",
735 "kotlin-stdlib-jdk8",
736 "kotlinx-coroutines-android",
737 "kotlinx-coroutines-android-nodeps",
738 "kotlinx-coroutines-core",
739 "kotlinx-coroutines-core-nodeps",
740 "libprotobuf-java-lite",
741 "permissioncontroller-statsd",
Jiyong Park26fb6bd2020-02-06 16:47:54 +0900742 "GooglePermissionController",
743 "PermissionController",
Jiyong Parkfa899442020-01-31 02:49:53 +0900744 }
Anton Hansson5053c292020-01-10 15:12:39 +0000745 //
746 // Module separator
747 //
Anton Hansson5053c292020-01-10 15:12:39 +0000748 m["com.android.runtime"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900749 "bionic_libc_platform_headers",
750 "fmtlib",
751 "libarm-optimized-routines-math",
752 "libasync_safe",
753 "libasync_safe_headers",
754 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000755 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900756 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000757 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900758 "libc_aeabi",
759 "libc_bionic",
760 "libc_bionic_ndk",
761 "libc_bootstrap",
762 "libc_common",
763 "libc_common_shared",
764 "libc_common_static",
765 "libc_dns",
766 "libc_dynamic_dispatch",
767 "libc_fortify",
768 "libc_freebsd",
769 "libc_freebsd_large_stack",
770 "libc_gdtoa",
771 "libc_headers",
772 "libc_init_dynamic",
773 "libc_init_static",
774 "libc_jemalloc_wrapper",
775 "libc_netbsd",
776 "libc_nomalloc",
777 "libc_nopthread",
778 "libc_openbsd",
779 "libc_openbsd_large_stack",
780 "libc_openbsd_ndk",
781 "libc_pthread",
782 "libc_static_dispatch",
783 "libc_syscalls",
784 "libc_tzcode",
785 "libc_unwind_static",
786 "libcutils",
787 "libcutils_headers",
788 "libdebuggerd",
789 "libdebuggerd_common_headers",
790 "libdebuggerd_handler_core",
791 "libdebuggerd_handler_fallback",
792 "libdexfile_external_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000793 "libdexfile_support",
Jiyong Parkfa899442020-01-31 02:49:53 +0900794 "libdexfile_support_static",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900795 "libdl_static",
Jiyong Parkfa899442020-01-31 02:49:53 +0900796 "libgtest_prod",
797 "libjemalloc5",
798 "liblinker_main",
799 "liblinker_malloc",
Jiyong Parkfa899442020-01-31 02:49:53 +0900800 "liblog_headers",
801 "liblz4",
Anton Hansson5053c292020-01-10 15:12:39 +0000802 "liblzma",
Jiyong Parkfa899442020-01-31 02:49:53 +0900803 "libprocessgroup_headers",
804 "libprocinfo",
805 "libpropertyinfoparser",
806 "libscudo",
807 "libstdc++",
808 "libsystem_headers",
809 "libsystemproperties",
810 "libtombstoned_client_static",
Anton Hansson5053c292020-01-10 15:12:39 +0000811 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900812 "libutils_headers",
813 "libz",
814 "libziparchive",
Anton Hansson5053c292020-01-10 15:12:39 +0000815 }
816 //
817 // Module separator
818 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900819 m["com.android.resolv"] = []string{
820 "bcm_object",
821 "dnsresolver_aidl_interface-unstable-ndk_platform",
822 "fmtlib",
823 "libbacktrace_headers",
824 "libbase",
825 "libbase_headers",
826 "libc++",
827 "libcrypto",
828 "libcutils",
829 "libcutils_headers",
830 "libgtest_prod",
831 "libjsoncpp",
Jiyong Parkfa899442020-01-31 02:49:53 +0900832 "liblog_headers",
833 "libnativehelper_header_only",
834 "libnetd_client_headers",
835 "libnetd_resolv",
836 "libnetdutils",
837 "libprocessgroup",
838 "libprocessgroup_headers",
839 "libprotobuf-cpp-lite",
840 "libssl",
841 "libstatslog_resolv",
842 "libstatspush_compat",
843 "libstatssocket",
844 "libstatssocket_headers",
845 "libsystem_headers",
846 "libsysutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900847 "libutils_headers",
848 "netd_event_listener_interface-ndk_platform",
849 "server_configurable_flags",
850 "stats_proto",
851 }
Anton Hansson5053c292020-01-10 15:12:39 +0000852 //
853 // Module separator
854 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900855 m["com.android.tethering"] = []string{
856 "libbase",
857 "libc++",
858 "libnativehelper_compat_libc++",
859 "android.hardware.tetheroffload.config@1.0",
860 "fmtlib",
861 "libbacktrace_headers",
862 "libbase_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900863 "libcgrouprc",
864 "libcgrouprc_format",
865 "libcutils",
866 "libcutils_headers",
867 "libhidlbase",
868 "libhidlbase-impl-internal",
869 "libhidltransport-impl-internal",
870 "libhwbinder-impl-internal",
871 "libjsoncpp",
Jiyong Parkfa899442020-01-31 02:49:53 +0900872 "liblog_headers",
873 "libprocessgroup",
874 "libprocessgroup_headers",
875 "libsystem_headers",
876 "libtetherutilsjni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900877 "libutils_headers",
878 "libvndksupport",
879 "tethering-aidl-interfaces-java",
880 }
Anton Hansson5053c292020-01-10 15:12:39 +0000881 //
882 // Module separator
883 //
884 m["com.android.wifi"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900885 "PlatformProperties",
886 "android.hardware.wifi-V1.0-java",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900887 "android.hardware.wifi-V1.0-java-constants",
Jiyong Parkfa899442020-01-31 02:49:53 +0900888 "android.hardware.wifi-V1.1-java",
889 "android.hardware.wifi-V1.2-java",
890 "android.hardware.wifi-V1.3-java",
891 "android.hardware.wifi-V1.4-java",
892 "android.hardware.wifi.hostapd-V1.0-java",
893 "android.hardware.wifi.hostapd-V1.1-java",
894 "android.hardware.wifi.hostapd-V1.2-java",
895 "android.hardware.wifi.supplicant-V1.0-java",
896 "android.hardware.wifi.supplicant-V1.1-java",
897 "android.hardware.wifi.supplicant-V1.2-java",
898 "android.hardware.wifi.supplicant-V1.3-java",
899 "android.hidl.base-V1.0-java",
900 "android.hidl.manager-V1.0-java",
901 "android.hidl.manager-V1.1-java",
902 "android.hidl.manager-V1.2-java",
903 "androidx.annotation_annotation",
904 "androidx.annotation_annotation-nodeps",
905 "bouncycastle-unbundled",
906 "dnsresolver_aidl_interface-V2-java",
907 "error_prone_annotations",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900908 "framework-wifi-pre-jarjar",
909 "framework-wifi-util-lib",
Jiyong Parkfa899442020-01-31 02:49:53 +0900910 "ipmemorystore-aidl-interfaces-V3-java",
911 "ipmemorystore-aidl-interfaces-java",
912 "ksoap2",
913 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000914 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900915 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000916 "libc++",
917 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900918 "libcutils_headers",
919 "liblog_headers",
920 "libnanohttpd",
Anton Hansson5053c292020-01-10 15:12:39 +0000921 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900922 "libprocessgroup_headers",
923 "libprotobuf-java-lite",
924 "libprotobuf-java-nano",
925 "libsystem_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900926 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000927 "libwifi-jni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900928 "net-utils-services-common",
929 "netd_aidl_interface-V2-java",
930 "netd_aidl_interface-unstable-java",
931 "netd_event_listener_interface-java",
932 "netlink-client",
933 "networkstack-aidl-interfaces-unstable-java",
934 "networkstack-client",
935 "services.net",
936 "wifi-lite-protos",
937 "wifi-nano-protos",
938 "wifi-service-pre-jarjar",
Anton Hansson5053c292020-01-10 15:12:39 +0000939 "wifi-service-resources",
Jiyong Parkfa899442020-01-31 02:49:53 +0900940 "prebuilt_androidx.annotation_annotation-nodeps",
Anton Hansson5053c292020-01-10 15:12:39 +0000941 }
942 //
943 // Module separator
944 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900945 m["com.android.sdkext"] = []string{
946 "fmtlib_ndk",
947 "libbase_ndk",
948 "libprotobuf-cpp-lite-ndk",
949 }
950 //
951 // Module separator
952 //
953 m["com.android.os.statsd"] = []string{
954 "libbacktrace_headers",
955 "libbase_headers",
956 "libc++",
957 "libcutils",
958 "libcutils_headers",
959 "liblog_headers",
960 "libprocessgroup_headers",
961 "libstatssocket",
962 "libsystem_headers",
963 "libutils_headers",
964 }
965 //
966 // Module separator
967 //
968 m["//any"] = []string{
969 "crtbegin_dynamic",
970 "crtbegin_dynamic1",
971 "crtbegin_so",
972 "crtbegin_so1",
973 "crtbegin_static",
974 "crtbrand",
975 "crtend_android",
976 "crtend_so",
977 "libatomic",
978 "libc++_static",
979 "libc++abi",
980 "libc++demangle",
981 "libc_headers",
982 "libclang_rt",
983 "libgcc_stripped",
984 "libprofile-clang-extras",
985 "libprofile-clang-extras_ndk",
986 "libprofile-extras",
987 "libprofile-extras_ndk",
988 "libunwind_llvm",
989 "ndk_crtbegin_dynamic.27",
990 "ndk_crtbegin_so.16",
991 "ndk_crtbegin_so.19",
992 "ndk_crtbegin_so.21",
993 "ndk_crtbegin_so.24",
994 "ndk_crtbegin_so.27",
995 "ndk_crtend_android.27",
996 "ndk_crtend_so.16",
997 "ndk_crtend_so.19",
998 "ndk_crtend_so.21",
999 "ndk_crtend_so.24",
1000 "ndk_crtend_so.27",
1001 "ndk_libandroid_support",
1002 "ndk_libc++_static",
1003 "ndk_libc++abi",
1004 "ndk_libunwind",
1005 }
Anton Hansson5053c292020-01-10 15:12:39 +00001006 return m
1007}
1008
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001009func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +09001010 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -08001011 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +09001012 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +09001013 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -07001014 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +09001015 android.RegisterModuleType("override_apex", overrideApexFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001016
Jooyung Han31c470b2019-10-18 16:26:59 +09001017 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001018 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +09001019
1020 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
1021 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
1022 sort.Strings(*apexFileContextsInfos)
1023 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
1024 })
Jiyong Parkd1063c12019-07-17 20:08:41 +09001025}
1026
Jooyung Han31c470b2019-10-18 16:26:59 +09001027func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
1028 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
1029 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
1030}
1031
Jiyong Parkd1063c12019-07-17 20:08:41 +09001032func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parkf760cae2020-02-12 07:53:12 +09001033 ctx.TopDown("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001034 ctx.BottomUp("apex", apexMutator).Parallel()
1035 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
1036 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001037}
1038
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001039// Mark the direct and transitive dependencies of apex bundles so that they
1040// can be built for the apex bundles.
Jiyong Parkf760cae2020-02-12 07:53:12 +09001041func apexDepsMutator(mctx android.TopDownMutatorContext) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001042 var apexBundles []android.ApexInfo
Jiyong Parkf760cae2020-02-12 07:53:12 +09001043 var directDep bool
Jooyung Hana57af4a2020-01-23 05:36:59 +00001044 if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001045 apexBundles = []android.ApexInfo{android.ApexInfo{
1046 ApexName: mctx.ModuleName(),
1047 LegacyAndroid10Support: proptools.Bool(a.properties.Legacy_android10_support),
1048 }}
Jiyong Parkf760cae2020-02-12 07:53:12 +09001049 directDep = true
1050 } else if am, ok := mctx.Module().(android.ApexModule); ok {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001051 apexBundles = am.ApexVariations()
Jiyong Parkf760cae2020-02-12 07:53:12 +09001052 directDep = false
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001053 }
Jiyong Parkf760cae2020-02-12 07:53:12 +09001054
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001055 if len(apexBundles) == 0 {
Jiyong Parkf760cae2020-02-12 07:53:12 +09001056 return
1057 }
1058
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001059 cur := mctx.Module().(interface {
1060 DepIsInSameApex(android.BaseModuleContext, android.Module) bool
1061 })
1062
Jiyong Parkf760cae2020-02-12 07:53:12 +09001063 mctx.VisitDirectDeps(func(child android.Module) {
1064 depName := mctx.OtherModuleName(child)
1065 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001066 cur.DepIsInSameApex(mctx, child) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001067 android.UpdateApexDependency(apexBundles, depName, directDep)
1068 am.BuildForApexes(apexBundles)
Jiyong Parkf760cae2020-02-12 07:53:12 +09001069 }
1070 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001071}
1072
1073// Create apex variations if a module is included in APEX(s).
1074func apexMutator(mctx android.BottomUpMutatorContext) {
1075 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +09001076 am.CreateApexVariations(mctx)
Jooyung Hana57af4a2020-01-23 05:36:59 +00001077 } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001078 // apex bundle itself is mutated so that it and its modules have same
1079 // apex variant.
1080 apexBundleName := mctx.ModuleName()
1081 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +09001082 } else if o, ok := mctx.Module().(*OverrideApex); ok {
1083 apexBundleName := o.GetOverriddenModuleName()
1084 if apexBundleName == "" {
1085 mctx.ModuleErrorf("base property is not set")
1086 return
1087 }
1088 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001089 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001090
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001091}
Sundong Ahne9b55722019-09-06 17:37:42 +09001092
Jooyung Han7a78a922019-10-08 21:59:58 +09001093var (
1094 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
1095 apexFileContextsInfosMutex sync.Mutex
1096)
1097
1098func apexFileContextsInfos(config android.Config) *[]string {
1099 return config.Once(apexFileContextsInfosKey, func() interface{} {
1100 return &[]string{}
1101 }).(*[]string)
1102}
1103
Jooyung Han54aca7b2019-11-20 02:26:02 +09001104func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +09001105 apexFileContextsInfosMutex.Lock()
1106 defer apexFileContextsInfosMutex.Unlock()
1107 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +09001108 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +09001109}
1110
Sundong Ahne9b55722019-09-06 17:37:42 +09001111func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Sundong Ahne8fb7242019-09-17 13:50:45 +09001112 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +09001113 var variants []string
1114 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
1115 case "image":
1116 variants = append(variants, imageApexType, flattenedApexType)
1117 case "zip":
1118 variants = append(variants, zipApexType)
1119 case "both":
1120 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
1121 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001122 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +09001123 return
1124 }
1125
1126 modules := mctx.CreateLocalVariations(variants...)
1127
1128 for i, v := range variants {
1129 switch v {
1130 case imageApexType:
1131 modules[i].(*apexBundle).properties.ApexType = imageApex
1132 case zipApexType:
1133 modules[i].(*apexBundle).properties.ApexType = zipApex
1134 case flattenedApexType:
1135 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +09001136 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001137 modules[i].(*apexBundle).MakeAsSystemExt()
1138 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001139 }
Sundong Ahne9b55722019-09-06 17:37:42 +09001140 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001141 } else if _, ok := mctx.Module().(*OverrideApex); ok {
1142 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +09001143 }
1144}
1145
Jooyung Han5c998b92019-06-27 11:30:33 +09001146func apexUsesMutator(mctx android.BottomUpMutatorContext) {
1147 if ab, ok := mctx.Module().(*apexBundle); ok {
1148 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
1149 }
1150}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001151
Jooyung Handc782442019-11-01 03:14:38 +09001152var (
1153 useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
1154)
1155
1156// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
1157// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
1158// which may cause compatibility issues. (e.g. libbinder)
1159// Even though libbinder restricts its availability via 'apex_available' property and relies on
1160// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
1161// to avoid similar problems.
1162func useVendorWhitelist(config android.Config) []string {
1163 return config.Once(useVendorWhitelistKey, func() interface{} {
1164 return []string{
1165 // swcodec uses "vendor" variants for smaller size
1166 "com.android.media.swcodec",
1167 "test_com.android.media.swcodec",
1168 }
1169 }).([]string)
1170}
1171
1172// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
1173// called before the first call to useVendorWhitelist()
1174func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
1175 config.Once(useVendorWhitelistKey, func() interface{} {
1176 return whitelist
1177 })
1178}
1179
Alex Light9670d332019-01-29 18:07:33 -08001180type apexNativeDependencies struct {
1181 // List of native libraries
1182 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +09001183
Alex Light9670d332019-01-29 18:07:33 -08001184 // List of native executables
1185 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +09001186
Roland Levillain630846d2019-06-26 12:48:34 +01001187 // List of native tests
1188 Tests []string
Alex Light9670d332019-01-29 18:07:33 -08001189}
Jooyung Han344d5432019-08-23 11:17:39 +09001190
Alex Light9670d332019-01-29 18:07:33 -08001191type apexMultilibProperties struct {
1192 // Native dependencies whose compile_multilib is "first"
1193 First apexNativeDependencies
1194
1195 // Native dependencies whose compile_multilib is "both"
1196 Both apexNativeDependencies
1197
1198 // Native dependencies whose compile_multilib is "prefer32"
1199 Prefer32 apexNativeDependencies
1200
1201 // Native dependencies whose compile_multilib is "32"
1202 Lib32 apexNativeDependencies
1203
1204 // Native dependencies whose compile_multilib is "64"
1205 Lib64 apexNativeDependencies
1206}
1207
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001208type apexBundleProperties struct {
1209 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +00001210 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -08001211 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001212
Jiyong Park40e26a22019-02-08 02:53:06 +09001213 // AndroidManifest.xml file used for the zip container of this APEX bundle.
1214 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -08001215 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +09001216
Roland Levillain411c5842019-09-19 16:37:20 +01001217 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
1218 // device (/apex/<apex_name>).
1219 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +09001220 Apex_name *string
1221
Jiyong Parkd0a65ba2018-11-10 06:37:15 +09001222 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +09001223 // For platform APEXes, this should points to a file under /system/sepolicy
1224 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
1225 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001226
1227 // List of native shared libs that are embedded inside this APEX bundle
1228 Native_shared_libs []string
1229
Roland Levillain630846d2019-06-26 12:48:34 +01001230 // List of executables that are embedded inside this APEX bundle
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001231 Binaries []string
1232
1233 // List of java libraries that are embedded inside this APEX bundle
1234 Java_libs []string
1235
1236 // List of prebuilt files that are embedded inside this APEX bundle
1237 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +09001238
Roland Levillain630846d2019-06-26 12:48:34 +01001239 // List of tests that are embedded inside this APEX bundle
1240 Tests []string
1241
Jiyong Parkff1458f2018-10-12 21:49:38 +09001242 // Name of the apex_key module that provides the private key to sign APEX
1243 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +09001244
Alex Light5098a612018-11-29 17:12:15 -08001245 // The type of APEX to build. Controls what the APEX payload is. Either
1246 // 'image', 'zip' or 'both'. Default: 'image'.
1247 Payload_type *string
1248
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001249 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
1250 // or an android_app_certificate module name in the form ":module".
1251 Certificate *string
1252
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001253 // Whether this APEX is installable to one of the partitions. Default: true.
1254 Installable *bool
1255
Jiyong Parkda6eb592018-12-19 17:12:36 +09001256 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
1257 // Default is false.
1258 Use_vendor *bool
1259
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001260 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
1261 Ignore_system_library_special_case *bool
1262
Alex Light9670d332019-01-29 18:07:33 -08001263 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +09001264
Jiyong Parkf97782b2019-02-13 20:28:58 +09001265 // List of sanitizer names that this APEX is enabled for
1266 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +09001267
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001268 PreventInstall bool `blueprint:"mutated"`
1269
1270 HideFromMake bool `blueprint:"mutated"`
1271
Jooyung Han5c998b92019-06-27 11:30:33 +09001272 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
1273 Provide_cpp_shared_libs *bool
1274
1275 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
1276 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +01001277
1278 // A txt file containing list of files that are whitelisted to be included in this APEX.
1279 Whitelisted_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001280
Sundong Ahnabb64432019-10-22 13:58:29 +09001281 // package format of this apex variant; could be non-flattened, flattened, or zip.
1282 // imageApex, zipApex or flattened
1283 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +09001284
Jiyong Parkd1063c12019-07-17 20:08:41 +09001285 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
1286 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
1287 // is implied. This value affects all modules included in this APEX. In other words, they are
1288 // also built with the SDKs specified here.
1289 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +09001290
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001291 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
1292 // Should be only used in tests#.
1293 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +09001294
1295 // Whether this APEX should support Android10. Default is false. If this is set true, then apex_manifest.json is bundled as well
1296 // because Android10 requires legacy apex_manifest.json instead of apex_manifest.pb
1297 Legacy_android10_support *bool
Jiyong Park956305c2020-01-09 12:32:06 +09001298
1299 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park9d677202020-02-19 16:29:35 +09001300
1301 // Whether this APEX is considered updatable or not. When set to true, this will enforce additional
1302 // rules for making sure that the APEX is truely updatable. This will also disable the size optimizations
1303 // like symlinking to the system libs. Default is false.
1304 Updatable *bool
Colin Cross7365eaa2020-02-19 20:41:10 -08001305
1306 // The minimum SDK version that this apex must be compatible with.
1307 Min_sdk_version *string
Alex Light9670d332019-01-29 18:07:33 -08001308}
1309
1310type apexTargetBundleProperties struct {
1311 Target struct {
1312 // Multilib properties only for android.
1313 Android struct {
1314 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001315 }
Jooyung Han344d5432019-08-23 11:17:39 +09001316
Alex Light9670d332019-01-29 18:07:33 -08001317 // Multilib properties only for host.
1318 Host struct {
1319 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001320 }
Jooyung Han344d5432019-08-23 11:17:39 +09001321
Alex Light9670d332019-01-29 18:07:33 -08001322 // Multilib properties only for host linux_bionic.
1323 Linux_bionic struct {
1324 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001325 }
Jooyung Han344d5432019-08-23 11:17:39 +09001326
Alex Light9670d332019-01-29 18:07:33 -08001327 // Multilib properties only for host linux_glibc.
1328 Linux_glibc struct {
1329 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001330 }
1331 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001332}
1333
Jiyong Park5d790c32019-11-15 18:40:32 +09001334type overridableProperties struct {
1335 // List of APKs to package inside APEX
1336 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001337
1338 // Names of modules to be overridden. Listed modules can only be other binaries
1339 // (in Make or Soong).
1340 // This does not completely prevent installation of the overridden binaries, but if both
1341 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
1342 // from PRODUCT_PACKAGES.
1343 Overrides []string
Baligh Uddin004d7172020-02-19 21:29:28 -08001344
1345 // Logging Parent value
1346 Logging_parent string
Jiyong Park5d790c32019-11-15 18:40:32 +09001347}
1348
Alex Light5098a612018-11-29 17:12:15 -08001349type apexPackaging int
1350
1351const (
1352 imageApex apexPackaging = iota
1353 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +09001354 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -08001355)
1356
Sundong Ahnabb64432019-10-22 13:58:29 +09001357// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -08001358func (a apexPackaging) suffix() string {
1359 switch a {
1360 case imageApex:
1361 return imageApexSuffix
1362 case zipApex:
1363 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -08001364 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001365 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001366 }
1367}
1368
1369func (a apexPackaging) name() string {
1370 switch a {
1371 case imageApex:
1372 return imageApexType
1373 case zipApex:
1374 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -08001375 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001376 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001377 }
1378}
1379
Jiyong Parkf653b052019-11-18 15:39:01 +09001380type apexFileClass int
1381
1382const (
1383 etc apexFileClass = iota
1384 nativeSharedLib
1385 nativeExecutable
1386 shBinary
1387 pyBinary
1388 goBinary
1389 javaSharedLib
1390 nativeTest
1391 app
1392)
1393
Jiyong Park8fd61922018-11-08 02:50:25 +09001394func (class apexFileClass) NameInMake() string {
1395 switch class {
1396 case etc:
1397 return "ETC"
1398 case nativeSharedLib:
1399 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -08001400 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +09001401 return "EXECUTABLES"
1402 case javaSharedLib:
1403 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +01001404 case nativeTest:
1405 return "NATIVE_TESTS"
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001406 case app:
Jiyong Parkf383f7c2019-10-11 20:46:25 +09001407 // b/142537672 Why isn't this APP? We want to have full control over
1408 // the paths and file names of the apk file under the flattend APEX.
1409 // If this is set to APP, then the paths and file names are modified
1410 // by the Make build system. For example, it is installed to
1411 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
1412 // /system/apex/<apexname>/app/<Appname> because the build system automatically
1413 // appends module name (which is <apexname>.<Appname> to the path.
1414 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +09001415 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001416 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +09001417 }
1418}
1419
Jiyong Parkf653b052019-11-18 15:39:01 +09001420// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +09001421type apexFile struct {
1422 builtFile android.Path
1423 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +09001424 installDir string
1425 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +09001426 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +09001427 // list of symlinks that will be created in installDir that point to this apexFile
1428 symlinks []string
1429 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +09001430 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +09001431
1432 requiredModuleNames []string
1433 targetRequiredModuleNames []string
1434 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +09001435
Colin Cross503c1d02020-01-28 14:00:53 -08001436 jacocoReportClassesFile android.Path // only for javalibs and apps
1437 certificate java.Certificate // only for apps
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001438 overriddenPackageName string // only for apps
Jiyong Parkf653b052019-11-18 15:39:01 +09001439}
1440
Jiyong Park1833cef2019-12-13 13:28:36 +09001441func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
1442 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +09001443 builtFile: builtFile,
1444 moduleName: moduleName,
1445 installDir: installDir,
1446 class: class,
1447 module: module,
1448 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001449 if module != nil {
1450 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +09001451 ret.requiredModuleNames = module.RequiredModuleNames()
1452 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
1453 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +09001454 }
1455 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +09001456}
1457
1458func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +09001459 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +09001460}
1461
Jiyong Park7cd10e32020-01-14 09:22:18 +09001462// Path() returns path of this apex file relative to the APEX root
1463func (af *apexFile) Path() string {
1464 return filepath.Join(af.installDir, af.builtFile.Base())
1465}
1466
1467// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
1468func (af *apexFile) SymlinkPaths() []string {
1469 var ret []string
1470 for _, symlink := range af.symlinks {
1471 ret = append(ret, filepath.Join(af.installDir, symlink))
1472 }
1473 return ret
1474}
1475
1476func (af *apexFile) AvailableToPlatform() bool {
1477 if af.module == nil {
1478 return false
1479 }
1480 if am, ok := af.module.(android.ApexModule); ok {
1481 return am.AvailableFor(android.AvailableToPlatform)
1482 }
1483 return false
1484}
1485
Jiyong Park678c8812020-02-07 17:25:49 +09001486type depInfo struct {
1487 to string
1488 from []string
1489 isExternal bool
1490}
1491
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001492type apexBundle struct {
1493 android.ModuleBase
1494 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +09001495 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +09001496 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001497
Jiyong Park5d790c32019-11-15 18:40:32 +09001498 properties apexBundleProperties
1499 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +09001500 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001501
Jooyung Hanf21c7972019-12-16 22:32:06 +09001502 // specific to apex_vndk modules
1503 vndkProperties apexVndkProperties
1504
Colin Crossa4925902018-11-16 11:36:28 -08001505 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +09001506 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -07001507 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +09001508
Jiyong Park03b68dd2019-07-26 23:20:40 +09001509 prebuiltFileToDelete string
1510
Jiyong Park42cca6c2019-04-01 11:15:50 +09001511 public_key_file android.Path
1512 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001513
1514 container_certificate_file android.Path
1515 container_private_key_file android.Path
1516
Jooyung Han54aca7b2019-11-20 02:26:02 +09001517 fileContexts android.Path
1518
Jiyong Park8fd61922018-11-08 02:50:25 +09001519 // list of files to be included in this apex
1520 filesInfo []apexFile
1521
Jiyong Park956305c2020-01-09 12:32:06 +09001522 // list of module names that should be installed along with this APEX
1523 requiredDeps []string
1524
Jiyong Park956305c2020-01-09 12:32:06 +09001525 // list of module names that this APEX is including (to be shown via *-deps-info target)
Jiyong Park678c8812020-02-07 17:25:49 +09001526 depInfos map[string]depInfo
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001527
Sundong Ahnabb64432019-10-22 13:58:29 +09001528 testApex bool
1529 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001530 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +09001531 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +09001532
Jooyung Han214bf372019-11-12 13:03:50 +09001533 manifestJsonOut android.WritablePath
1534 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +09001535
Jooyung Han002ab682020-01-08 01:57:58 +09001536 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +09001537 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +09001538 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +09001539 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
1540 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +09001541
1542 // Suffix of module name in Android.mk
1543 // ".flattened", ".apex", ".zipapex", or ""
1544 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +09001545
1546 installedFilesFile android.WritablePath
Jiyong Park7cd10e32020-01-14 09:22:18 +09001547
1548 // Whether to create symlink to the system file instead of having a file
1549 // inside the apex or not
1550 linkToSystemLib bool
Jiyong Park19972c72020-01-28 20:05:29 +09001551
1552 // Struct holding the merged notice file paths in different formats
1553 mergedNotices android.NoticeOutputs
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001554}
1555
Jiyong Park397e55e2018-10-24 21:09:55 +09001556func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +01001557 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001558 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +09001559 // Use *FarVariation* to be able to depend on modules having
1560 // conflicting variations with this module. This is required since
1561 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
1562 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001563 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +09001564 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +09001565 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +09001566 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001567 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001568
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001569 ctx.AddFarVariationDependencies(append(target.Variations(),
1570 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
1571 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +01001572
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001573 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001574 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001575 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001576 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001577}
1578
Alex Light9670d332019-01-29 18:07:33 -08001579func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
1580 if ctx.Os().Class == android.Device {
1581 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
1582 } else {
1583 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
1584 if ctx.Os().Bionic() {
1585 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
1586 } else {
1587 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
1588 }
1589 }
1590}
1591
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001592func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +09001593 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
1594 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1595 }
1596
Jiyong Park397e55e2018-10-24 21:09:55 +09001597 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +09001598 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -08001599
1600 a.combineProperties(ctx)
1601
Jiyong Park397e55e2018-10-24 21:09:55 +09001602 has32BitTarget := false
1603 for _, target := range targets {
1604 if target.Arch.ArchType.Multilib == "lib32" {
1605 has32BitTarget = true
1606 }
1607 }
1608 for i, target := range targets {
1609 // When multilib.* is omitted for native_shared_libs, it implies
1610 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001611 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +09001612 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001613 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001614 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001615
Roland Levillain630846d2019-06-26 12:48:34 +01001616 // When multilib.* is omitted for tests, it implies
1617 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001618 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001619 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001620 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001621 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +01001622
Jiyong Park397e55e2018-10-24 21:09:55 +09001623 // Add native modules targetting both ABIs
1624 addDependenciesForNativeModules(ctx,
1625 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001626 a.properties.Multilib.Both.Binaries,
1627 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001628 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001629 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001630
Alex Light3d673592019-01-18 14:37:31 -08001631 isPrimaryAbi := i == 0
1632 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +09001633 // When multilib.* is omitted for binaries, it implies
1634 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001635 ctx.AddFarVariationDependencies(append(target.Variations(),
1636 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
1637 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001638
1639 // Add native modules targetting the first ABI
1640 addDependenciesForNativeModules(ctx,
1641 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001642 a.properties.Multilib.First.Binaries,
1643 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001644 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001645 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001646 }
1647
1648 switch target.Arch.ArchType.Multilib {
1649 case "lib32":
1650 // Add native modules targetting 32-bit ABI
1651 addDependenciesForNativeModules(ctx,
1652 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001653 a.properties.Multilib.Lib32.Binaries,
1654 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001655 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001656 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001657
1658 addDependenciesForNativeModules(ctx,
1659 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001660 a.properties.Multilib.Prefer32.Binaries,
1661 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001662 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001663 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001664 case "lib64":
1665 // Add native modules targetting 64-bit ABI
1666 addDependenciesForNativeModules(ctx,
1667 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001668 a.properties.Multilib.Lib64.Binaries,
1669 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001670 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001671 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001672
1673 if !has32BitTarget {
1674 addDependenciesForNativeModules(ctx,
1675 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001676 a.properties.Multilib.Prefer32.Binaries,
1677 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001678 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001679 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001680 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001681
1682 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
1683 for _, sanitizer := range ctx.Config().SanitizeDevice() {
1684 if sanitizer == "hwaddress" {
1685 addDependenciesForNativeModules(ctx,
1686 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001687 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001688 break
1689 }
1690 }
1691 }
Jiyong Park397e55e2018-10-24 21:09:55 +09001692 }
1693
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001694 }
1695
Jiyong Parkce6aadc2019-11-20 13:58:28 +09001696 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
1697 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
1698 // b/144532908
1699 archForPrebuiltEtc := config.Arches()[0]
1700 for _, arch := range config.Arches() {
1701 // Prefer 64-bit arch if there is any
1702 if arch.ArchType.Multilib == "lib64" {
1703 archForPrebuiltEtc = arch
1704 break
1705 }
1706 }
1707 ctx.AddFarVariationDependencies([]blueprint.Variation{
1708 {Mutator: "os", Variation: ctx.Os().String()},
1709 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
1710 }, prebuiltTag, a.properties.Prebuilts...)
1711
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001712 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1713 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001714
Ulya Trafimovich44561882020-01-03 13:25:54 +00001715 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
1716 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
1717 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1718 javaLibTag, "jacocoagent")
1719 }
1720
Jiyong Park23c52b02019-02-02 13:13:47 +09001721 if String(a.properties.Key) == "" {
1722 ctx.ModuleErrorf("key is missing")
1723 return
1724 }
1725 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001726
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001727 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +09001728 if cert != "" {
1729 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001730 }
Jiyong Parkd1063c12019-07-17 20:08:41 +09001731
1732 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
1733 if len(a.properties.Uses_sdks) > 0 {
1734 sdkRefs := []android.SdkRef{}
1735 for _, str := range a.properties.Uses_sdks {
1736 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
1737 sdkRefs = append(sdkRefs, parsed)
1738 }
1739 a.BuildWithSdks(sdkRefs)
1740 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001741}
1742
Jiyong Park5d790c32019-11-15 18:40:32 +09001743func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
1744 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1745 androidAppTag, a.overridableProperties.Apps...)
1746}
1747
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001748func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1749 // direct deps of an APEX bundle are all part of the APEX bundle
1750 return true
1751}
1752
Colin Cross0ea8ba82019-06-06 14:33:29 -07001753func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001754 moduleName := ctx.ModuleName()
1755 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1756 // we check with the pseudo module name to see if its certificate is overridden.
1757 if a.vndkApex {
1758 moduleName = vndkApexName
1759 }
1760 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001761 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001762 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001763 }
1764 return String(a.properties.Certificate)
1765}
1766
Colin Cross41955e82019-05-29 14:40:35 -07001767func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1768 switch tag {
1769 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001770 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001771 default:
1772 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001773 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001774}
1775
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001776func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001777 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001778}
1779
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001780func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1781 return proptools.Bool(a.properties.Test_only_no_hashtree)
1782}
1783
Jiyong Park7c1dc612019-01-05 11:15:24 +09001784func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001785 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001786 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001787 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001788 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001789 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001790 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001791 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001792 }
1793}
1794
Jiyong Parkf97782b2019-02-13 20:28:58 +09001795func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1796 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1797 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1798 }
1799}
1800
Jiyong Park388ef3f2019-01-28 19:47:32 +09001801func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001802 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1803 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001804 }
1805
1806 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001807 globalSanitizerNames := []string{}
1808 if a.Host() {
1809 globalSanitizerNames = ctx.Config().SanitizeHost()
1810 } else {
1811 arches := ctx.Config().SanitizeDeviceArch()
1812 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1813 globalSanitizerNames = ctx.Config().SanitizeDevice()
1814 }
1815 }
1816 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001817}
1818
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001819func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
Oliver Nguyen1382ab62019-12-06 15:22:41 -08001820 return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled())
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001821}
1822
1823func (a *apexBundle) PreventInstall() {
1824 a.properties.PreventInstall = true
1825}
1826
1827func (a *apexBundle) HideFromMake() {
1828 a.properties.HideFromMake = true
1829}
1830
Jiyong Park956305c2020-01-09 12:32:06 +09001831func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1832 a.properties.IsCoverageVariant = coverage
1833}
1834
Jiyong Parkf653b052019-11-18 15:39:01 +09001835// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001836func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001837 // Decide the APEX-local directory by the multilib of the library
1838 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001839 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001840 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001841 case "lib32":
1842 dirInApex = "lib"
1843 case "lib64":
1844 dirInApex = "lib64"
1845 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001846 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001847 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001848 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001849 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001850 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001851 // Special case for Bionic libs and other libs installed with them. This is
1852 // to prevent those libs from being included in the search path
1853 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1854 // those libs in the Runtime APEX are available via the legacy paths in
1855 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1856 // to the legacy paths and thus will be loaded into the default linker
1857 // namespace (aka "platform" namespace). If the libs are directly in
1858 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1859 // into the runtime linker namespace, which will result in double loading of
1860 // them, which isn't supported.
1861 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001862 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001863
Jiyong Parkf653b052019-11-18 15:39:01 +09001864 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001865 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001866}
1867
Jiyong Park1833cef2019-12-13 13:28:36 +09001868func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001869 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001870 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001871 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001872 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001873 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001874 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001875 af.symlinks = cc.Symlinks()
1876 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001877}
1878
Jiyong Park1833cef2019-12-13 13:28:36 +09001879func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001880 dirInApex := "bin"
1881 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001882 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001883}
Jiyong Park1833cef2019-12-13 13:28:36 +09001884func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001885 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001886 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1887 if err != nil {
1888 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001889 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001890 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001891 fileToCopy := android.PathForOutput(ctx, s)
1892 // NB: Since go binaries are static we don't need the module for anything here, which is
1893 // good since the go tool is a blueprint.Module not an android.Module like we would
1894 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001895 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001896}
1897
Jiyong Park1833cef2019-12-13 13:28:36 +09001898func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001899 dirInApex := filepath.Join("bin", sh.SubDir())
1900 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001901 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001902 af.symlinks = sh.Symlinks()
1903 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001904}
1905
Jooyung Han58f26ab2019-12-18 15:34:32 +09001906// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1907type javaLibrary interface {
1908 android.Module
1909 java.Dependency
1910}
1911
1912func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001913 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001914 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001915 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1916 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1917 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001918}
1919
Jiyong Park1833cef2019-12-13 13:28:36 +09001920func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001921 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1922 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001923 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001924}
1925
atrost6e126252020-01-27 17:01:16 +00001926func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1927 dirInApex := filepath.Join("etc", config.SubDir())
1928 fileToCopy := config.CompatConfig()
1929 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1930}
1931
Jiyong Park1833cef2019-12-13 13:28:36 +09001932func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001933 android.Module
1934 Privileged() bool
1935 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001936 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001937 Certificate() java.Certificate
Jiyong Parkf653b052019-11-18 15:39:01 +09001938}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001939 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001940 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001941 appDir = "priv-app"
1942 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001943 dirInApex := filepath.Join(appDir, pkgName)
1944 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001945 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1946 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross503c1d02020-01-28 14:00:53 -08001947 af.certificate = aapp.Certificate()
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001948
1949 if app, ok := aapp.(interface {
1950 OverriddenManifestPackageName() string
1951 }); ok {
1952 af.overriddenPackageName = app.OverriddenManifestPackageName()
1953 }
Jiyong Park618922e2020-01-08 13:35:43 +09001954 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001955}
1956
Roland Levillain935639d2019-08-13 14:55:28 +01001957// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1958type flattenedApexContext struct {
1959 android.ModuleContext
1960}
1961
1962func (c *flattenedApexContext) InstallBypassMake() bool {
1963 return true
1964}
1965
Jiyong Park201cedd2020-02-07 17:25:49 +09001966// Visit dependencies that contributes to the payload of this APEX
1967func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext,
1968 do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) {
Jiyong Parkfa899442020-01-31 02:49:53 +09001969 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
1970 am, ok := child.(android.ApexModule)
1971 if !ok || !am.CanHaveApexVariants() {
1972 return false
1973 }
1974
1975 // Check for the direct dependencies that contribute to the payload
1976 if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
1977 if dt.payload {
Jiyong Park201cedd2020-02-07 17:25:49 +09001978 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001979 return true
1980 }
1981 return false
1982 }
1983
1984 // Check for the indirect dependencies if it is considered as part of the APEX
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001985 if am.ApexName() != "" {
Jiyong Park201cedd2020-02-07 17:25:49 +09001986 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001987 return true
1988 }
1989
Jiyong Park201cedd2020-02-07 17:25:49 +09001990 do(ctx, parent, am, true /* externalDep */)
1991
Jiyong Parkfa899442020-01-31 02:49:53 +09001992 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1993 return false
1994 })
1995}
1996
Jiyong Park201cedd2020-02-07 17:25:49 +09001997// Ensures that the dependencies are marked as available for this APEX
1998func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
1999 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
2000 if ctx.Host() || a.testApex || a.vndkApex {
2001 return
2002 }
2003
2004 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2005 apexName := ctx.ModuleName()
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002006 fromName := ctx.OtherModuleName(from)
2007 toName := ctx.OtherModuleName(to)
2008 if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) {
Jiyong Park201cedd2020-02-07 17:25:49 +09002009 return
2010 }
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002011 ctx.ModuleErrorf("%q requires %q that is not available for the APEX.", fromName, toName)
Jiyong Park201cedd2020-02-07 17:25:49 +09002012 })
2013}
2014
Jiyong Park678c8812020-02-07 17:25:49 +09002015// Collects the list of module names that directly or indirectly contributes to the payload of this APEX
2016func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) {
2017 a.depInfos = make(map[string]depInfo)
2018 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2019 if from.Name() == to.Name() {
2020 // This can happen for cc.reuseObjTag. We are not interested in tracking this.
2021 return
2022 }
2023
2024 if info, exists := a.depInfos[to.Name()]; exists {
2025 if !android.InList(from.Name(), info.from) {
2026 info.from = append(info.from, from.Name())
2027 }
2028 info.isExternal = info.isExternal && externalDep
2029 a.depInfos[to.Name()] = info
2030 } else {
2031 a.depInfos[to.Name()] = depInfo{
2032 to: to.Name(),
2033 from: []string{from.Name()},
2034 isExternal: externalDep,
2035 }
2036 }
2037 })
2038}
2039
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002040func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09002041 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
2042 switch a.properties.ApexType {
2043 case imageApex:
2044 if buildFlattenedAsDefault {
2045 a.suffix = imageApexSuffix
2046 } else {
2047 a.suffix = ""
2048 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002049
2050 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09002051 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002052 }
Sundong Ahnabb64432019-10-22 13:58:29 +09002053 }
2054 case zipApex:
2055 if proptools.String(a.properties.Payload_type) == "zip" {
2056 a.suffix = ""
2057 a.primaryApexType = true
2058 } else {
2059 a.suffix = zipApexSuffix
2060 }
2061 case flattenedApex:
2062 if buildFlattenedAsDefault {
2063 a.suffix = ""
2064 a.primaryApexType = true
2065 } else {
2066 a.suffix = flattenedSuffix
2067 }
Alex Light5098a612018-11-29 17:12:15 -08002068 }
2069
Roland Levillain630846d2019-06-26 12:48:34 +01002070 if len(a.properties.Tests) > 0 && !a.testApex {
2071 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
2072 return
2073 }
2074
Jiyong Parkfa899442020-01-31 02:49:53 +09002075 a.checkApexAvailability(ctx)
2076
Jiyong Park678c8812020-02-07 17:25:49 +09002077 a.collectDepsInfo(ctx)
2078
Alex Lightfc0bd7c2019-01-29 18:31:59 -08002079 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
2080
Jooyung Hane1633032019-08-01 17:41:43 +09002081 // native lib dependencies
2082 var provideNativeLibs []string
2083 var requireNativeLibs []string
2084
Jooyung Han5c998b92019-06-27 11:30:33 +09002085 // Check if "uses" requirements are met with dependent apexBundles
2086 var providedNativeSharedLibs []string
2087 useVendor := proptools.Bool(a.properties.Use_vendor)
2088 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
2089 if ctx.OtherModuleDependencyTag(m) != usesTag {
2090 return
2091 }
2092 otherName := ctx.OtherModuleName(m)
2093 other, ok := m.(*apexBundle)
2094 if !ok {
2095 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
2096 return
2097 }
2098 if proptools.Bool(other.properties.Use_vendor) != useVendor {
2099 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
2100 return
2101 }
2102 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
2103 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
2104 return
2105 }
2106 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
2107 })
2108
Jiyong Parkf653b052019-11-18 15:39:01 +09002109 var filesInfo []apexFile
Jiyong Park678c8812020-02-07 17:25:49 +09002110 // TODO(jiyong) do this using walkPayloadDeps
Alex Light778127a2019-02-27 14:19:50 -08002111 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01002112 depTag := ctx.OtherModuleDependencyTag(child)
2113 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09002114 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002115 switch depTag {
2116 case sharedLibTag:
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002117 if c, ok := child.(*cc.Module); ok {
2118 // bootstrap bionic libs are treated as provided by system
2119 if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
2120 provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base())
Jooyung Hane1633032019-08-01 17:41:43 +09002121 }
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002122 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, c, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09002123 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002124 } else {
2125 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002126 }
2127 case executableTag:
2128 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002129 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09002130 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09002131 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002132 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08002133 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09002134 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08002135 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09002136 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002137 } else {
Alex Light778127a2019-02-27 14:19:50 -08002138 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 +09002139 }
2140 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09002141 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002142 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09002143 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09002144 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2145 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09002146 filesInfo = append(filesInfo, af)
2147 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09002148 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09002149 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
2150 af := apexFileForJavaLibrary(ctx, sdkLib)
2151 if !af.Ok() {
2152 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2153 return false
2154 }
2155 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09002156 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002157 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09002158 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002159 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002160 case androidAppTag:
2161 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
2162 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002163 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002164 return true // track transitive dependencies
2165 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002166 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00002167 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
2168 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002169 } else {
2170 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
2171 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002172 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09002173 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002174 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
atrost6e126252020-01-27 17:01:16 +00002175 } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
2176 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002177 } else {
atrost6e126252020-01-27 17:01:16 +00002178 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09002179 }
Roland Levillain630846d2019-06-26 12:48:34 +01002180 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01002181 if ccTest, ok := child.(*cc.Module); ok {
2182 if ccTest.IsTestPerSrcAllTestsVariation() {
2183 // Multiple-output test module (where `test_per_src: true`).
2184 //
2185 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
2186 // We do not add this variation to `filesInfo`, as it has no output;
2187 // however, we do add the other variations of this module as indirect
2188 // dependencies (see below).
2189 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01002190 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01002191 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09002192 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09002193 af.class = nativeTest
2194 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01002195 }
Roland Levillain630846d2019-06-26 12:48:34 +01002196 } else {
2197 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
2198 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09002199 case keyTag:
2200 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002201 a.private_key_file = key.private_key_file
2202 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09002203 } else {
2204 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002205 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002206 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002207 case certificateTag:
2208 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002209 a.container_certificate_file = dep.Certificate.Pem
2210 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002211 } else {
2212 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
2213 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09002214 case android.PrebuiltDepTag:
2215 // If the prebuilt is force disabled, remember to delete the prebuilt file
2216 // that might have been installed in the previous builds
2217 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
2218 a.prebuiltFileToDelete = prebuilt.InstallFilename()
2219 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002220 }
Jooyung Han8aee2042019-10-29 05:08:31 +09002221 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002222 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09002223 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01002224 // We cannot use a switch statement on `depTag` here as the checked
2225 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09002226 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002227 if cc, ok := child.(*cc.Module); ok {
2228 if android.InList(cc.Name(), providedNativeSharedLibs) {
2229 // If we're using a shared library which is provided from other APEX,
2230 // don't include it in this APEX
2231 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09002232 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09002233 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002234 // If the dependency is a stubs lib, don't include it in this APEX,
2235 // but make sure that the lib is installed on the device.
2236 // In case no APEX is having the lib, the lib is installed to the system
2237 // partition.
2238 //
2239 // Always include if we are a host-apex however since those won't have any
2240 // system libraries.
Jiyong Park956305c2020-01-09 12:32:06 +09002241 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
2242 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01002243 }
Jooyung Hane1633032019-08-01 17:41:43 +09002244 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01002245 // Don't track further
2246 return false
2247 }
Jiyong Park1833cef2019-12-13 13:28:36 +09002248 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09002249 af.transitiveDep = true
2250 filesInfo = append(filesInfo, af)
2251 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09002252 }
Roland Levillainf89cd092019-07-29 16:22:59 +01002253 } else if cc.IsTestPerSrcDepTag(depTag) {
2254 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002255 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01002256 // Handle modules created as `test_per_src` variations of a single test module:
2257 // use the name of the generated test binary (`fileToCopy`) instead of the name
2258 // of the original test module (`depName`, shared by all `test_per_src`
2259 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09002260 af.moduleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002261 // these are not considered transitive dep
2262 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09002263 filesInfo = append(filesInfo, af)
2264 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01002265 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09002266 } else if java.IsJniDepTag(depTag) {
Jooyung Han65041792020-02-25 16:59:29 +09002267 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
2268 return false
Jiyong Parke3833882020-02-17 17:28:10 +09002269 } else if java.IsXmlPermissionsFileDepTag(depTag) {
2270 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
2271 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
2272 }
Jooyung Han9c80bae2019-08-20 17:30:57 +09002273 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01002274 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002275 }
2276 }
2277 }
2278 return false
2279 })
2280
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002281 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
2282 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
2283 // via the global boot image config.
2284 if a.artApex {
2285 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
2286 dirInApex := filepath.Join("javalib", arch.String())
2287 for _, f := range files {
2288 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09002289 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09002290 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002291 }
2292 }
2293 }
2294
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002295 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09002296 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
2297 return
2298 }
2299
Jiyong Park8fd61922018-11-08 02:50:25 +09002300 // remove duplicates in filesInfo
2301 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002302 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002303 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002304 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002305 if e, ok := encountered[dest]; !ok {
2306 encountered[dest] = f
2307 } else {
2308 // If a module is directly included and also transitively depended on
2309 // consider it as directly included.
2310 e.transitiveDep = e.transitiveDep && f.transitiveDep
2311 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002312 }
2313 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002314 var result []apexFile
2315 for _, v := range encountered {
2316 result = append(result, v)
2317 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002318 return result
2319 }
2320 filesInfo = removeDup(filesInfo)
2321
2322 // to have consistent build rules
2323 sort.Slice(filesInfo, func(i, j int) bool {
2324 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
2325 })
2326
Jiyong Park8fd61922018-11-08 02:50:25 +09002327 a.installDir = android.PathForModuleInstall(ctx, "apex")
2328 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002329
Jooyung Han54aca7b2019-11-20 02:26:02 +09002330 if a.properties.ApexType != zipApex {
2331 if a.properties.File_contexts == nil {
2332 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
2333 } else {
2334 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
2335 if a.Platform() {
2336 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
2337 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
2338 }
2339 }
2340 }
2341 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
2342 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
2343 return
2344 }
2345 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002346 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2347 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2348 // the same library in the system partition, thus effectively sharing the same libraries
2349 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2350 // in the APEX.
2351 a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
2352 a.installable() &&
2353 !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002354
Jiyong Park9d677202020-02-19 16:29:35 +09002355 // We don't need the optimization for updatable APEXes, as it might give false signal
2356 // to the system health when the APEXes are still bundled (b/149805758)
2357 if proptools.Bool(a.properties.Updatable) && a.properties.ApexType == imageApex {
2358 a.linkToSystemLib = false
2359 }
2360
Jiyong Park9b964182020-02-26 18:27:19 +09002361 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2362 if ctx.Host() {
2363 a.linkToSystemLib = false
2364 }
2365
Jooyung Hand15aa1f2019-09-27 00:38:03 +09002366 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09002367 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
2368
2369 a.setCertificateAndPrivateKey(ctx)
2370 if a.properties.ApexType == flattenedApex {
2371 a.buildFlattenedApex(ctx)
2372 } else {
2373 a.buildUnflattenedApex(ctx)
2374 }
2375
Jooyung Han002ab682020-01-08 01:57:58 +09002376 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09002377
2378 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002379}
2380
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002381func whitelistedApexAvailable(apex, moduleName string) bool {
Anton Hansson5053c292020-01-10 15:12:39 +00002382 key := apex
2383 key = strings.Replace(key, "test_", "", 1)
2384 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
2385 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
2386
Jiyong Parkfa899442020-01-31 02:49:53 +09002387 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2388 // system. Trim the prefix for the check since they are confusing
2389 moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
2390 if strings.HasPrefix(moduleName, "libclang_rt.") {
2391 // This module has many arch variants that depend on the product being built.
2392 // We don't want to list them all
2393 moduleName = "libclang_rt"
Anton Hansson5053c292020-01-10 15:12:39 +00002394 }
2395
2396 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2397 return true
2398 }
2399
Jiyong Parkfa899442020-01-31 02:49:53 +09002400 key = "//any"
2401 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2402 return true
2403 }
2404
Anton Hansson5053c292020-01-10 15:12:39 +00002405 return false
2406}
2407
Jooyung Han344d5432019-08-23 11:17:39 +09002408func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09002409 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002410 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08002411 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09002412 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08002413 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09002414 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
2415 })
Alex Light5098a612018-11-29 17:12:15 -08002416 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002417 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09002418 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08002419 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002420 return module
2421}
Jiyong Park30ca9372019-02-07 16:27:23 +09002422
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002423func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002424 bundle := newApexBundle()
2425 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002426 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09002427 return bundle
2428}
2429
Jiyong Parkfce0b422020-02-11 03:56:06 +09002430// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2431// certain compatibility checks such as apex_available are not done for apex_test.
Jooyung Han344d5432019-08-23 11:17:39 +09002432func testApexBundleFactory() android.Module {
2433 bundle := newApexBundle()
2434 bundle.testApex = true
2435 return bundle
2436}
2437
Jiyong Parkfce0b422020-02-11 03:56:06 +09002438// apex packages other modules into an APEX file which is a packaging format for system-level
2439// components like binaries, shared libraries, etc.
Jiyong Parkd1063c12019-07-17 20:08:41 +09002440func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002441 return newApexBundle()
2442}
2443
Jiyong Park30ca9372019-02-07 16:27:23 +09002444//
2445// Defaults
2446//
2447type Defaults struct {
2448 android.ModuleBase
2449 android.DefaultsModuleBase
2450}
2451
Jiyong Park30ca9372019-02-07 16:27:23 +09002452func defaultsFactory() android.Module {
2453 return DefaultsFactory()
2454}
2455
2456func DefaultsFactory(props ...interface{}) android.Module {
2457 module := &Defaults{}
2458
2459 module.AddProperties(props...)
2460 module.AddProperties(
2461 &apexBundleProperties{},
2462 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09002463 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09002464 )
2465
2466 android.InitDefaultsModule(module)
2467 return module
2468}
Jiyong Park5d790c32019-11-15 18:40:32 +09002469
2470//
2471// OverrideApex
2472//
2473type OverrideApex struct {
2474 android.ModuleBase
2475 android.OverrideModuleBase
2476}
2477
2478func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2479 // All the overrides happen in the base module.
2480}
2481
2482// override_apex is used to create an apex module based on another apex module
2483// by overriding some of its properties.
2484func overrideApexFactory() android.Module {
2485 m := &OverrideApex{}
2486 m.AddProperties(&overridableProperties{})
2487
2488 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2489 android.InitOverrideModule(m)
2490 return m
2491}