blob: 00963655b7a1af0dd7fa9ed2bdf5ae1f48a3e98f [file] [log] [blame]
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package apex
16
17import (
18 "fmt"
Jooyung Han54aca7b2019-11-20 02:26:02 +090019 "path"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090020 "path/filepath"
Jiyong Parkab3ceb32018-10-10 14:05:29 +090021 "sort"
Jooyung Han0c4e0162020-02-26 22:45:42 +090022 "strconv"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090023 "strings"
Jooyung Han344d5432019-08-23 11:17:39 +090024 "sync"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090025
26 "android/soong/android"
27 "android/soong/cc"
28 "android/soong/java"
Alex Light778127a2019-02-27 14:19:50 -080029 "android/soong/python"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090030
31 "github.com/google/blueprint"
Alex Light778127a2019-02-27 14:19:50 -080032 "github.com/google/blueprint/bootstrap"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090033 "github.com/google/blueprint/proptools"
34)
35
Jooyung Han72bd2f82019-10-23 16:46:38 +090036const (
37 imageApexSuffix = ".apex"
38 zipApexSuffix = ".zipapex"
Sundong Ahnabb64432019-10-22 13:58:29 +090039 flattenedSuffix = ".flattened"
Alex Light5098a612018-11-29 17:12:15 -080040
Sundong Ahnabb64432019-10-22 13:58:29 +090041 imageApexType = "image"
42 zipApexType = "zip"
43 flattenedApexType = "flattened"
Jooyung Han72bd2f82019-10-23 16:46:38 +090044)
Jiyong Park48ca7dc2018-10-10 14:01:00 +090045
46type dependencyTag struct {
47 blueprint.BaseDependencyTag
48 name string
Jiyong Parkfa899442020-01-31 02:49:53 +090049
50 // determines if the dependent will be part of the APEX payload
51 payload bool
Jiyong Park48ca7dc2018-10-10 14:01:00 +090052}
53
54var (
Jiyong Parkfa899442020-01-31 02:49:53 +090055 sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
56 executableTag = dependencyTag{name: "executable", payload: true}
57 javaLibTag = dependencyTag{name: "javaLib", payload: true}
58 prebuiltTag = dependencyTag{name: "prebuilt", payload: true}
59 testTag = dependencyTag{name: "test", payload: true}
Jiyong Parkc00cbd92018-10-30 21:20:05 +090060 keyTag = dependencyTag{name: "key"}
61 certificateTag = dependencyTag{name: "certificate"}
Jooyung Han5c998b92019-06-27 11:30:33 +090062 usesTag = dependencyTag{name: "uses"}
Jiyong Parkfa899442020-01-31 02:49:53 +090063 androidAppTag = dependencyTag{name: "androidApp", payload: true}
Anton Hansson5053c292020-01-10 15:12:39 +000064 apexAvailWl = makeApexAvailableWhitelist()
Jiyong Park48ca7dc2018-10-10 14:01:00 +090065)
66
Anton Hansson5053c292020-01-10 15:12:39 +000067// This is a map from apex to modules, which overrides the
68// apex_available setting for that particular module to make
69// it available for the apex regardless of its setting.
70// TODO(b/147364041): remove this
71func makeApexAvailableWhitelist() map[string][]string {
72 // The "Module separator"s below are employed to minimize merge conflicts.
73 m := make(map[string][]string)
74 //
75 // Module separator
76 //
Jiyong Parkfa899442020-01-31 02:49:53 +090077 m["com.android.adbd"] = []string{
78 "adbd",
79 "bcm_object",
80 "fmtlib",
81 "libadbconnection_server",
82 "libadbd",
83 "libadbd_auth",
84 "libadbd_core",
85 "libadbd_services",
86 "libasyncio",
87 "libbacktrace_headers",
88 "libbase",
89 "libbase_headers",
90 "libbuildversion",
91 "libc++",
92 "libcap",
93 "libcrypto",
94 "libcrypto_utils",
95 "libcutils",
96 "libcutils_headers",
97 "libdiagnose_usb",
Jiyong Parkfa899442020-01-31 02:49:53 +090098 "liblog_headers",
99 "libmdnssd",
100 "libminijail",
101 "libminijail_gen_constants",
102 "libminijail_gen_constants_obj",
103 "libminijail_gen_syscall",
104 "libminijail_gen_syscall_obj",
105 "libminijail_generated",
106 "libpackagelistparser",
107 "libpcre2",
108 "libprocessgroup_headers",
109 "libqemu_pipe",
Jiyong Parkfa899442020-01-31 02:49:53 +0900110 "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",
Jiyong Parkfa899442020-01-31 02:49:53 +0900505 "libsonivox",
Anton Hansson5053c292020-01-10 15:12:39 +0000506 "libspeexresampler",
Jiyong Parkfa899442020-01-31 02:49:53 +0900507 "libspeexresampler",
508 "libstagefright_esds",
Anton Hansson5053c292020-01-10 15:12:39 +0000509 "libstagefright_flacdec",
Jiyong Parkfa899442020-01-31 02:49:53 +0900510 "libstagefright_flacdec",
511 "libstagefright_foundation",
512 "libstagefright_foundation_headers",
513 "libstagefright_foundation_without_imemory",
514 "libstagefright_headers",
515 "libstagefright_id3",
516 "libstagefright_metadatautils",
517 "libstagefright_mpeg2extractor",
518 "libstagefright_mpeg2support",
519 "libsync",
520 "libsystem_headers",
521 "libui",
522 "libui_headers",
523 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900524 "libutils_headers",
525 "libvibrator",
526 "libvorbisidec",
Anton Hansson5053c292020-01-10 15:12:39 +0000527 "libwavextractor",
Jiyong Parkfa899442020-01-31 02:49:53 +0900528 "libwebm",
529 "media_ndk_headers",
530 "media_plugin_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000531 "updatable-media",
532 }
533 //
534 // Module separator
535 //
536 m["com.android.media.swcodec"] = []string{
537 "android.frameworks.bufferhub@1.0",
538 "android.hardware.common-ndk_platform",
Jiyong Parkfa899442020-01-31 02:49:53 +0900539 "android.hardware.configstore-utils",
540 "android.hardware.configstore@1.0",
541 "android.hardware.configstore@1.1",
Anton Hansson5053c292020-01-10 15:12:39 +0000542 "android.hardware.graphics.allocator@2.0",
543 "android.hardware.graphics.allocator@3.0",
544 "android.hardware.graphics.allocator@4.0",
545 "android.hardware.graphics.bufferqueue@1.0",
546 "android.hardware.graphics.bufferqueue@2.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900547 "android.hardware.graphics.common-ndk_platform",
Anton Hansson5053c292020-01-10 15:12:39 +0000548 "android.hardware.graphics.common@1.0",
549 "android.hardware.graphics.common@1.1",
550 "android.hardware.graphics.common@1.2",
Anton Hansson5053c292020-01-10 15:12:39 +0000551 "android.hardware.graphics.mapper@2.0",
552 "android.hardware.graphics.mapper@2.1",
553 "android.hardware.graphics.mapper@3.0",
554 "android.hardware.graphics.mapper@4.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000555 "android.hardware.media.bufferpool@2.0",
556 "android.hardware.media.c2@1.0",
557 "android.hardware.media.c2@1.1",
558 "android.hardware.media.omx@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900559 "android.hardware.media@1.0",
560 "android.hardware.media@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000561 "android.hidl.memory.token@1.0",
Jiyong Parkfa899442020-01-31 02:49:53 +0900562 "android.hidl.memory@1.0",
Anton Hansson5053c292020-01-10 15:12:39 +0000563 "android.hidl.safe_union@1.0",
564 "android.hidl.token@1.0",
565 "android.hidl.token@1.0-utils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900566 "fmtlib",
567 "libEGL",
568 "libFLAC",
569 "libFLAC-config",
570 "libFLAC-headers",
571 "libFraunhoferAAC",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900572 "libLibGuiProperties",
Jiyong Parkfa899442020-01-31 02:49:53 +0900573 "libarect",
574 "libasync_safe",
575 "libaudio_system_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000576 "libaudioutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900577 "libaudioutils",
578 "libaudioutils_fixedfft",
579 "libavcdec",
580 "libavcenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000581 "libavservices_minijail",
Jiyong Parkfa899442020-01-31 02:49:53 +0900582 "libavservices_minijail",
583 "libbacktrace",
584 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000585 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900586 "libbase_headers",
587 "libbinder_headers",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900588 "libbinderthreadstateutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900589 "libbluetooth-types-header",
590 "libbufferhub_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000591 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900592 "libc_scudo",
Anton Hansson5053c292020-01-10 15:12:39 +0000593 "libcap",
594 "libcodec2",
Jiyong Parkfa899442020-01-31 02:49:53 +0900595 "libcodec2_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000596 "libcodec2_hidl@1.0",
597 "libcodec2_hidl@1.1",
Jiyong Parkfa899442020-01-31 02:49:53 +0900598 "libcodec2_internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000599 "libcodec2_soft_aacdec",
600 "libcodec2_soft_aacenc",
601 "libcodec2_soft_amrnbdec",
602 "libcodec2_soft_amrnbenc",
603 "libcodec2_soft_amrwbdec",
604 "libcodec2_soft_amrwbenc",
605 "libcodec2_soft_av1dec_gav1",
606 "libcodec2_soft_avcdec",
607 "libcodec2_soft_avcenc",
608 "libcodec2_soft_common",
609 "libcodec2_soft_flacdec",
610 "libcodec2_soft_flacenc",
611 "libcodec2_soft_g711alawdec",
612 "libcodec2_soft_g711mlawdec",
613 "libcodec2_soft_gsmdec",
614 "libcodec2_soft_h263dec",
615 "libcodec2_soft_h263enc",
616 "libcodec2_soft_hevcdec",
617 "libcodec2_soft_hevcenc",
618 "libcodec2_soft_mp3dec",
619 "libcodec2_soft_mpeg2dec",
620 "libcodec2_soft_mpeg4dec",
621 "libcodec2_soft_mpeg4enc",
622 "libcodec2_soft_opusdec",
623 "libcodec2_soft_opusenc",
624 "libcodec2_soft_rawdec",
625 "libcodec2_soft_vorbisdec",
626 "libcodec2_soft_vp8dec",
627 "libcodec2_soft_vp8enc",
628 "libcodec2_soft_vp9dec",
629 "libcodec2_soft_vp9enc",
630 "libcodec2_vndk",
Anton Hansson5053c292020-01-10 15:12:39 +0000631 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900632 "libcutils_headers",
633 "libdexfile_support",
634 "libdvr_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000635 "libfmq",
Jiyong Parkfa899442020-01-31 02:49:53 +0900636 "libfmq",
637 "libgav1",
Anton Hansson5053c292020-01-10 15:12:39 +0000638 "libgralloctypes",
Jiyong Parkfa899442020-01-31 02:49:53 +0900639 "libgrallocusage",
640 "libgraphicsenv",
641 "libgsm",
642 "libgui_bufferqueue_static",
643 "libgui_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000644 "libhardware",
Jiyong Parkfa899442020-01-31 02:49:53 +0900645 "libhardware_headers",
646 "libhevcdec",
647 "libhevcenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000648 "libhidlbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900649 "libhidlbase-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000650 "libhidlmemory",
Jiyong Parkfa899442020-01-31 02:49:53 +0900651 "libhidltransport-impl-internal",
652 "libhwbinder-impl-internal",
Anton Hansson5053c292020-01-10 15:12:39 +0000653 "libion",
Jiyong Parkfa899442020-01-31 02:49:53 +0900654 "libjpeg",
655 "libjsoncpp",
656 "liblog_headers",
657 "liblzma",
658 "libmath",
Anton Hansson5053c292020-01-10 15:12:39 +0000659 "libmedia_codecserviceregistrant",
Jiyong Parkfa899442020-01-31 02:49:53 +0900660 "libmedia_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000661 "libminijail",
Jiyong Parkfa899442020-01-31 02:49:53 +0900662 "libminijail_gen_constants",
663 "libminijail_gen_constants_obj",
664 "libminijail_gen_syscall",
665 "libminijail_gen_syscall_obj",
666 "libminijail_generated",
667 "libmpeg2dec",
668 "libnativebase_headers",
669 "libnativebridge_lazy",
670 "libnativeloader_lazy",
671 "libnativewindow_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000672 "libopus",
Jiyong Parkfa899442020-01-31 02:49:53 +0900673 "libpdx_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000674 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900675 "libprocessgroup_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000676 "libscudo_wrapper",
677 "libsfplugin_ccodec_utils",
678 "libspeexresampler",
679 "libstagefright_amrnb_common",
Jiyong Parkfa899442020-01-31 02:49:53 +0900680 "libstagefright_amrnbdec",
681 "libstagefright_amrnbenc",
682 "libstagefright_amrwbdec",
683 "libstagefright_amrwbenc",
Anton Hansson5053c292020-01-10 15:12:39 +0000684 "libstagefright_bufferpool@2.0.1",
685 "libstagefright_bufferqueue_helper",
686 "libstagefright_enc_common",
687 "libstagefright_flacdec",
688 "libstagefright_foundation",
Jiyong Parkfa899442020-01-31 02:49:53 +0900689 "libstagefright_foundation_headers",
690 "libstagefright_headers",
691 "libstagefright_m4vh263dec",
692 "libstagefright_m4vh263enc",
693 "libstagefright_mp3dec",
Anton Hansson5053c292020-01-10 15:12:39 +0000694 "libsync",
Jiyong Parkfa899442020-01-31 02:49:53 +0900695 "libsystem_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000696 "libui",
Jiyong Parkfa899442020-01-31 02:49:53 +0900697 "libui_headers",
698 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900699 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000700 "libvorbisidec",
701 "libvpx",
Jiyong Parkfa899442020-01-31 02:49:53 +0900702 "libyuv",
703 "libyuv_static",
704 "media_ndk_headers",
705 "media_plugin_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000706 "mediaswcodec",
Anton Hansson5053c292020-01-10 15:12:39 +0000707 }
708 //
709 // Module separator
710 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900711 m["com.android.mediaprovider"] = []string{
712 "MediaProvider",
713 "MediaProviderGoogle",
714 "fmtlib_ndk",
715 "guava",
716 "libbase_ndk",
717 "libfuse",
718 "libfuse_jni",
719 "libnativehelper_header_only",
720 }
721 //
722 // Module separator
723 //
724 m["com.android.permission"] = []string{
725 "androidx.annotation_annotation",
726 "androidx.annotation_annotation-nodeps",
727 "androidx.lifecycle_lifecycle-common",
728 "androidx.lifecycle_lifecycle-common-java8",
729 "androidx.lifecycle_lifecycle-common-java8-nodeps",
730 "androidx.lifecycle_lifecycle-common-nodeps",
731 "kotlin-annotations",
732 "kotlin-stdlib",
733 "kotlin-stdlib-jdk7",
734 "kotlin-stdlib-jdk8",
735 "kotlinx-coroutines-android",
736 "kotlinx-coroutines-android-nodeps",
737 "kotlinx-coroutines-core",
738 "kotlinx-coroutines-core-nodeps",
739 "libprotobuf-java-lite",
740 "permissioncontroller-statsd",
Jiyong Park26fb6bd2020-02-06 16:47:54 +0900741 "GooglePermissionController",
742 "PermissionController",
Jiyong Parkfa899442020-01-31 02:49:53 +0900743 }
Anton Hansson5053c292020-01-10 15:12:39 +0000744 //
745 // Module separator
746 //
Anton Hansson5053c292020-01-10 15:12:39 +0000747 m["com.android.runtime"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900748 "bionic_libc_platform_headers",
749 "fmtlib",
750 "libarm-optimized-routines-math",
751 "libasync_safe",
752 "libasync_safe_headers",
753 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000754 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900755 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000756 "libc++",
Jiyong Parkfa899442020-01-31 02:49:53 +0900757 "libc_aeabi",
758 "libc_bionic",
759 "libc_bionic_ndk",
760 "libc_bootstrap",
761 "libc_common",
762 "libc_common_shared",
763 "libc_common_static",
764 "libc_dns",
765 "libc_dynamic_dispatch",
766 "libc_fortify",
767 "libc_freebsd",
768 "libc_freebsd_large_stack",
769 "libc_gdtoa",
770 "libc_headers",
771 "libc_init_dynamic",
772 "libc_init_static",
773 "libc_jemalloc_wrapper",
774 "libc_netbsd",
775 "libc_nomalloc",
776 "libc_nopthread",
777 "libc_openbsd",
778 "libc_openbsd_large_stack",
779 "libc_openbsd_ndk",
780 "libc_pthread",
781 "libc_static_dispatch",
782 "libc_syscalls",
783 "libc_tzcode",
784 "libc_unwind_static",
785 "libcutils",
786 "libcutils_headers",
787 "libdebuggerd",
788 "libdebuggerd_common_headers",
789 "libdebuggerd_handler_core",
790 "libdebuggerd_handler_fallback",
791 "libdexfile_external_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000792 "libdexfile_support",
Jiyong Parkfa899442020-01-31 02:49:53 +0900793 "libdexfile_support_static",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900794 "libdl_static",
Jiyong Parkfa899442020-01-31 02:49:53 +0900795 "libgtest_prod",
796 "libjemalloc5",
797 "liblinker_main",
798 "liblinker_malloc",
Jiyong Parkfa899442020-01-31 02:49:53 +0900799 "liblog_headers",
800 "liblz4",
Anton Hansson5053c292020-01-10 15:12:39 +0000801 "liblzma",
Jiyong Parkfa899442020-01-31 02:49:53 +0900802 "libprocessgroup_headers",
803 "libprocinfo",
804 "libpropertyinfoparser",
805 "libscudo",
806 "libstdc++",
807 "libsystem_headers",
808 "libsystemproperties",
809 "libtombstoned_client_static",
Anton Hansson5053c292020-01-10 15:12:39 +0000810 "libunwindstack",
Jiyong Parkfa899442020-01-31 02:49:53 +0900811 "libutils_headers",
812 "libz",
813 "libziparchive",
Anton Hansson5053c292020-01-10 15:12:39 +0000814 }
815 //
816 // Module separator
817 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900818 m["com.android.resolv"] = []string{
819 "bcm_object",
820 "dnsresolver_aidl_interface-unstable-ndk_platform",
821 "fmtlib",
822 "libbacktrace_headers",
823 "libbase",
824 "libbase_headers",
825 "libc++",
826 "libcrypto",
827 "libcutils",
828 "libcutils_headers",
829 "libgtest_prod",
830 "libjsoncpp",
Jiyong Parkfa899442020-01-31 02:49:53 +0900831 "liblog_headers",
832 "libnativehelper_header_only",
833 "libnetd_client_headers",
834 "libnetd_resolv",
835 "libnetdutils",
836 "libprocessgroup",
837 "libprocessgroup_headers",
838 "libprotobuf-cpp-lite",
839 "libssl",
840 "libstatslog_resolv",
841 "libstatspush_compat",
842 "libstatssocket",
843 "libstatssocket_headers",
844 "libsystem_headers",
845 "libsysutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900846 "libutils_headers",
847 "netd_event_listener_interface-ndk_platform",
848 "server_configurable_flags",
849 "stats_proto",
850 }
Anton Hansson5053c292020-01-10 15:12:39 +0000851 //
852 // Module separator
853 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900854 m["com.android.tethering"] = []string{
855 "libbase",
856 "libc++",
857 "libnativehelper_compat_libc++",
858 "android.hardware.tetheroffload.config@1.0",
859 "fmtlib",
860 "libbacktrace_headers",
861 "libbase_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900862 "libcgrouprc",
863 "libcgrouprc_format",
864 "libcutils",
865 "libcutils_headers",
866 "libhidlbase",
867 "libhidlbase-impl-internal",
868 "libhidltransport-impl-internal",
869 "libhwbinder-impl-internal",
870 "libjsoncpp",
Jiyong Parkfa899442020-01-31 02:49:53 +0900871 "liblog_headers",
872 "libprocessgroup",
873 "libprocessgroup_headers",
874 "libsystem_headers",
875 "libtetherutilsjni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900876 "libutils_headers",
877 "libvndksupport",
878 "tethering-aidl-interfaces-java",
879 }
Anton Hansson5053c292020-01-10 15:12:39 +0000880 //
881 // Module separator
882 //
883 m["com.android.wifi"] = []string{
Jiyong Parkfa899442020-01-31 02:49:53 +0900884 "PlatformProperties",
885 "android.hardware.wifi-V1.0-java",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900886 "android.hardware.wifi-V1.0-java-constants",
Jiyong Parkfa899442020-01-31 02:49:53 +0900887 "android.hardware.wifi-V1.1-java",
888 "android.hardware.wifi-V1.2-java",
889 "android.hardware.wifi-V1.3-java",
890 "android.hardware.wifi-V1.4-java",
891 "android.hardware.wifi.hostapd-V1.0-java",
892 "android.hardware.wifi.hostapd-V1.1-java",
893 "android.hardware.wifi.hostapd-V1.2-java",
894 "android.hardware.wifi.supplicant-V1.0-java",
895 "android.hardware.wifi.supplicant-V1.1-java",
896 "android.hardware.wifi.supplicant-V1.2-java",
897 "android.hardware.wifi.supplicant-V1.3-java",
898 "android.hidl.base-V1.0-java",
899 "android.hidl.manager-V1.0-java",
900 "android.hidl.manager-V1.1-java",
901 "android.hidl.manager-V1.2-java",
902 "androidx.annotation_annotation",
903 "androidx.annotation_annotation-nodeps",
904 "bouncycastle-unbundled",
905 "dnsresolver_aidl_interface-V2-java",
906 "error_prone_annotations",
Jooyung Hanb8fa86a2020-03-10 06:23:13 +0900907 "framework-wifi-pre-jarjar",
908 "framework-wifi-util-lib",
Jiyong Parkfa899442020-01-31 02:49:53 +0900909 "ipmemorystore-aidl-interfaces-V3-java",
910 "ipmemorystore-aidl-interfaces-java",
911 "ksoap2",
912 "libbacktrace_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000913 "libbase",
Jiyong Parkfa899442020-01-31 02:49:53 +0900914 "libbase_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000915 "libc++",
916 "libcutils",
Jiyong Parkfa899442020-01-31 02:49:53 +0900917 "libcutils_headers",
918 "liblog_headers",
919 "libnanohttpd",
Anton Hansson5053c292020-01-10 15:12:39 +0000920 "libprocessgroup",
Jiyong Parkfa899442020-01-31 02:49:53 +0900921 "libprocessgroup_headers",
922 "libprotobuf-java-lite",
923 "libprotobuf-java-nano",
924 "libsystem_headers",
Jiyong Parkfa899442020-01-31 02:49:53 +0900925 "libutils_headers",
Anton Hansson5053c292020-01-10 15:12:39 +0000926 "libwifi-jni",
Jiyong Parkfa899442020-01-31 02:49:53 +0900927 "net-utils-services-common",
928 "netd_aidl_interface-V2-java",
929 "netd_aidl_interface-unstable-java",
930 "netd_event_listener_interface-java",
931 "netlink-client",
932 "networkstack-aidl-interfaces-unstable-java",
933 "networkstack-client",
934 "services.net",
935 "wifi-lite-protos",
936 "wifi-nano-protos",
937 "wifi-service-pre-jarjar",
Anton Hansson5053c292020-01-10 15:12:39 +0000938 "wifi-service-resources",
Jiyong Parkfa899442020-01-31 02:49:53 +0900939 "prebuilt_androidx.annotation_annotation-nodeps",
Anton Hansson5053c292020-01-10 15:12:39 +0000940 }
941 //
942 // Module separator
943 //
Jiyong Parkfa899442020-01-31 02:49:53 +0900944 m["com.android.sdkext"] = []string{
945 "fmtlib_ndk",
946 "libbase_ndk",
947 "libprotobuf-cpp-lite-ndk",
948 }
949 //
950 // Module separator
951 //
952 m["com.android.os.statsd"] = []string{
953 "libbacktrace_headers",
954 "libbase_headers",
955 "libc++",
956 "libcutils",
957 "libcutils_headers",
958 "liblog_headers",
959 "libprocessgroup_headers",
960 "libstatssocket",
961 "libsystem_headers",
962 "libutils_headers",
963 }
964 //
965 // Module separator
966 //
967 m["//any"] = []string{
968 "crtbegin_dynamic",
969 "crtbegin_dynamic1",
970 "crtbegin_so",
971 "crtbegin_so1",
972 "crtbegin_static",
973 "crtbrand",
974 "crtend_android",
975 "crtend_so",
976 "libatomic",
977 "libc++_static",
978 "libc++abi",
979 "libc++demangle",
980 "libc_headers",
981 "libclang_rt",
982 "libgcc_stripped",
983 "libprofile-clang-extras",
984 "libprofile-clang-extras_ndk",
985 "libprofile-extras",
986 "libprofile-extras_ndk",
987 "libunwind_llvm",
988 "ndk_crtbegin_dynamic.27",
989 "ndk_crtbegin_so.16",
990 "ndk_crtbegin_so.19",
991 "ndk_crtbegin_so.21",
992 "ndk_crtbegin_so.24",
993 "ndk_crtbegin_so.27",
994 "ndk_crtend_android.27",
995 "ndk_crtend_so.16",
996 "ndk_crtend_so.19",
997 "ndk_crtend_so.21",
998 "ndk_crtend_so.24",
999 "ndk_crtend_so.27",
1000 "ndk_libandroid_support",
1001 "ndk_libc++_static",
1002 "ndk_libc++abi",
1003 "ndk_libunwind",
1004 }
Anton Hansson5053c292020-01-10 15:12:39 +00001005 return m
1006}
1007
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001008func init() {
Jiyong Parkd1063c12019-07-17 20:08:41 +09001009 android.RegisterModuleType("apex", BundleFactory)
Alex Light0851b882019-02-07 13:20:53 -08001010 android.RegisterModuleType("apex_test", testApexBundleFactory)
Jooyung Han344d5432019-08-23 11:17:39 +09001011 android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
Jiyong Park30ca9372019-02-07 16:27:23 +09001012 android.RegisterModuleType("apex_defaults", defaultsFactory)
Jaewoong Jung939ebd52019-03-26 15:07:36 -07001013 android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
Jiyong Park5d790c32019-11-15 18:40:32 +09001014 android.RegisterModuleType("override_apex", overrideApexFactory)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001015
Jooyung Han31c470b2019-10-18 16:26:59 +09001016 android.PreDepsMutators(RegisterPreDepsMutators)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001017 android.PostDepsMutators(RegisterPostDepsMutators)
Jooyung Han7a78a922019-10-08 21:59:58 +09001018
1019 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
1020 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
1021 sort.Strings(*apexFileContextsInfos)
1022 ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " "))
1023 })
Jiyong Parkd1063c12019-07-17 20:08:41 +09001024}
1025
Jooyung Han31c470b2019-10-18 16:26:59 +09001026func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
1027 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
1028 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
1029}
1030
Jiyong Parkd1063c12019-07-17 20:08:41 +09001031func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Jiyong Parkf760cae2020-02-12 07:53:12 +09001032 ctx.TopDown("apex_deps", apexDepsMutator)
Jiyong Parkd1063c12019-07-17 20:08:41 +09001033 ctx.BottomUp("apex", apexMutator).Parallel()
1034 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
1035 ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001036}
1037
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001038// Mark the direct and transitive dependencies of apex bundles so that they
1039// can be built for the apex bundles.
Jiyong Parkf760cae2020-02-12 07:53:12 +09001040func apexDepsMutator(mctx android.TopDownMutatorContext) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001041 var apexBundles []android.ApexInfo
Jiyong Parkf760cae2020-02-12 07:53:12 +09001042 var directDep bool
Jooyung Hana57af4a2020-01-23 05:36:59 +00001043 if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001044 apexBundles = []android.ApexInfo{android.ApexInfo{
Jooyung Han23b0adf2020-03-12 18:37:20 +09001045 ApexName: mctx.ModuleName(),
1046 MinSdkVersion: a.minSdkVersion(mctx),
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001047 }}
Jiyong Parkf760cae2020-02-12 07:53:12 +09001048 directDep = true
1049 } else if am, ok := mctx.Module().(android.ApexModule); ok {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001050 apexBundles = am.ApexVariations()
Jiyong Parkf760cae2020-02-12 07:53:12 +09001051 directDep = false
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001052 }
Jiyong Parkf760cae2020-02-12 07:53:12 +09001053
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001054 if len(apexBundles) == 0 {
Jiyong Parkf760cae2020-02-12 07:53:12 +09001055 return
1056 }
1057
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001058 cur := mctx.Module().(interface {
1059 DepIsInSameApex(android.BaseModuleContext, android.Module) bool
1060 })
1061
Jiyong Parkf760cae2020-02-12 07:53:12 +09001062 mctx.VisitDirectDeps(func(child android.Module) {
1063 depName := mctx.OtherModuleName(child)
1064 if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() &&
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001065 cur.DepIsInSameApex(mctx, child) {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001066 android.UpdateApexDependency(apexBundles, depName, directDep)
1067 am.BuildForApexes(apexBundles)
Jiyong Parkf760cae2020-02-12 07:53:12 +09001068 }
1069 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001070}
1071
1072// Create apex variations if a module is included in APEX(s).
1073func apexMutator(mctx android.BottomUpMutatorContext) {
1074 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Jiyong Park0ddfcd12018-12-11 01:35:25 +09001075 am.CreateApexVariations(mctx)
Jooyung Hana57af4a2020-01-23 05:36:59 +00001076 } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001077 // apex bundle itself is mutated so that it and its modules have same
1078 // apex variant.
1079 apexBundleName := mctx.ModuleName()
1080 mctx.CreateVariations(apexBundleName)
Jiyong Park5d790c32019-11-15 18:40:32 +09001081 } else if o, ok := mctx.Module().(*OverrideApex); ok {
1082 apexBundleName := o.GetOverriddenModuleName()
1083 if apexBundleName == "" {
1084 mctx.ModuleErrorf("base property is not set")
1085 return
1086 }
1087 mctx.CreateVariations(apexBundleName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001088 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001089
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001090}
Sundong Ahne9b55722019-09-06 17:37:42 +09001091
Jooyung Han7a78a922019-10-08 21:59:58 +09001092var (
1093 apexFileContextsInfosKey = android.NewOnceKey("apexFileContextsInfosKey")
1094 apexFileContextsInfosMutex sync.Mutex
1095)
1096
1097func apexFileContextsInfos(config android.Config) *[]string {
1098 return config.Once(apexFileContextsInfosKey, func() interface{} {
1099 return &[]string{}
1100 }).(*[]string)
1101}
1102
Jooyung Han54aca7b2019-11-20 02:26:02 +09001103func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsInfo string) {
Jooyung Han7a78a922019-10-08 21:59:58 +09001104 apexFileContextsInfosMutex.Lock()
1105 defer apexFileContextsInfosMutex.Unlock()
1106 apexFileContextsInfos := apexFileContextsInfos(ctx.Config())
Jooyung Han54aca7b2019-11-20 02:26:02 +09001107 *apexFileContextsInfos = append(*apexFileContextsInfos, fileContextsInfo)
Jooyung Han7a78a922019-10-08 21:59:58 +09001108}
1109
Sundong Ahne9b55722019-09-06 17:37:42 +09001110func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Sundong Ahne8fb7242019-09-17 13:50:45 +09001111 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +09001112 var variants []string
1113 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
1114 case "image":
1115 variants = append(variants, imageApexType, flattenedApexType)
1116 case "zip":
1117 variants = append(variants, zipApexType)
1118 case "both":
1119 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
1120 default:
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001121 mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +09001122 return
1123 }
1124
1125 modules := mctx.CreateLocalVariations(variants...)
1126
1127 for i, v := range variants {
1128 switch v {
1129 case imageApexType:
1130 modules[i].(*apexBundle).properties.ApexType = imageApex
1131 case zipApexType:
1132 modules[i].(*apexBundle).properties.ApexType = zipApex
1133 case flattenedApexType:
1134 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jooyung Han91df2082019-11-20 01:49:42 +09001135 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001136 modules[i].(*apexBundle).MakeAsSystemExt()
1137 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001138 }
Sundong Ahne9b55722019-09-06 17:37:42 +09001139 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001140 } else if _, ok := mctx.Module().(*OverrideApex); ok {
1141 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +09001142 }
1143}
1144
Jooyung Han5c998b92019-06-27 11:30:33 +09001145func apexUsesMutator(mctx android.BottomUpMutatorContext) {
1146 if ab, ok := mctx.Module().(*apexBundle); ok {
1147 mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
1148 }
1149}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001150
Jooyung Handc782442019-11-01 03:14:38 +09001151var (
1152 useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
1153)
1154
1155// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
1156// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
1157// which may cause compatibility issues. (e.g. libbinder)
1158// Even though libbinder restricts its availability via 'apex_available' property and relies on
1159// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
1160// to avoid similar problems.
1161func useVendorWhitelist(config android.Config) []string {
1162 return config.Once(useVendorWhitelistKey, func() interface{} {
1163 return []string{
1164 // swcodec uses "vendor" variants for smaller size
1165 "com.android.media.swcodec",
1166 "test_com.android.media.swcodec",
1167 }
1168 }).([]string)
1169}
1170
1171// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
1172// called before the first call to useVendorWhitelist()
1173func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
1174 config.Once(useVendorWhitelistKey, func() interface{} {
1175 return whitelist
1176 })
1177}
1178
Alex Light9670d332019-01-29 18:07:33 -08001179type apexNativeDependencies struct {
1180 // List of native libraries
1181 Native_shared_libs []string
Jooyung Han344d5432019-08-23 11:17:39 +09001182
Alex Light9670d332019-01-29 18:07:33 -08001183 // List of native executables
1184 Binaries []string
Jooyung Han344d5432019-08-23 11:17:39 +09001185
Roland Levillain630846d2019-06-26 12:48:34 +01001186 // List of native tests
1187 Tests []string
Alex Light9670d332019-01-29 18:07:33 -08001188}
Jooyung Han344d5432019-08-23 11:17:39 +09001189
Alex Light9670d332019-01-29 18:07:33 -08001190type apexMultilibProperties struct {
1191 // Native dependencies whose compile_multilib is "first"
1192 First apexNativeDependencies
1193
1194 // Native dependencies whose compile_multilib is "both"
1195 Both apexNativeDependencies
1196
1197 // Native dependencies whose compile_multilib is "prefer32"
1198 Prefer32 apexNativeDependencies
1199
1200 // Native dependencies whose compile_multilib is "32"
1201 Lib32 apexNativeDependencies
1202
1203 // Native dependencies whose compile_multilib is "64"
1204 Lib64 apexNativeDependencies
1205}
1206
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001207type apexBundleProperties struct {
1208 // Json manifest file describing meta info of this APEX bundle. Default:
Dario Freni4abb1dc2018-11-20 18:04:58 +00001209 // "apex_manifest.json"
Colin Cross27b922f2019-03-04 22:35:41 -08001210 Manifest *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001211
Jiyong Park40e26a22019-02-08 02:53:06 +09001212 // AndroidManifest.xml file used for the zip container of this APEX bundle.
1213 // If unspecified, a default one is automatically generated.
Colin Cross27b922f2019-03-04 22:35:41 -08001214 AndroidManifest *string `android:"path"`
Jiyong Park40e26a22019-02-08 02:53:06 +09001215
Roland Levillain411c5842019-09-19 16:37:20 +01001216 // Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
1217 // device (/apex/<apex_name>).
1218 // If unspecified, defaults to the value of name.
Jiyong Park05e70dd2019-03-18 14:26:32 +09001219 Apex_name *string
1220
Jiyong Parkd0a65ba2018-11-10 06:37:15 +09001221 // Determines the file contexts file for setting security context to each file in this APEX bundle.
Jooyung Han54aca7b2019-11-20 02:26:02 +09001222 // For platform APEXes, this should points to a file under /system/sepolicy
1223 // Default: /system/sepolicy/apex/<module_name>_file_contexts.
1224 File_contexts *string `android:"path"`
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001225
1226 // List of native shared libs that are embedded inside this APEX bundle
1227 Native_shared_libs []string
1228
Roland Levillain630846d2019-06-26 12:48:34 +01001229 // List of executables that are embedded inside this APEX bundle
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001230 Binaries []string
1231
1232 // List of java libraries that are embedded inside this APEX bundle
1233 Java_libs []string
1234
1235 // List of prebuilt files that are embedded inside this APEX bundle
1236 Prebuilts []string
Jiyong Parkff1458f2018-10-12 21:49:38 +09001237
Roland Levillain630846d2019-06-26 12:48:34 +01001238 // List of tests that are embedded inside this APEX bundle
1239 Tests []string
1240
Jiyong Parkff1458f2018-10-12 21:49:38 +09001241 // Name of the apex_key module that provides the private key to sign APEX
1242 Key *string
Jiyong Park397e55e2018-10-24 21:09:55 +09001243
Alex Light5098a612018-11-29 17:12:15 -08001244 // The type of APEX to build. Controls what the APEX payload is. Either
1245 // 'image', 'zip' or 'both'. Default: 'image'.
1246 Payload_type *string
1247
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001248 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
1249 // or an android_app_certificate module name in the form ":module".
1250 Certificate *string
1251
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001252 // Whether this APEX is installable to one of the partitions. Default: true.
1253 Installable *bool
1254
Jiyong Parkda6eb592018-12-19 17:12:36 +09001255 // For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
1256 // Default is false.
1257 Use_vendor *bool
1258
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001259 // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
1260 Ignore_system_library_special_case *bool
1261
Alex Light9670d332019-01-29 18:07:33 -08001262 Multilib apexMultilibProperties
Jiyong Park235e67c2019-02-09 11:50:56 +09001263
Jiyong Parkf97782b2019-02-13 20:28:58 +09001264 // List of sanitizer names that this APEX is enabled for
1265 SanitizerNames []string `blueprint:"mutated"`
Jooyung Han5c998b92019-06-27 11:30:33 +09001266
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001267 PreventInstall bool `blueprint:"mutated"`
1268
1269 HideFromMake bool `blueprint:"mutated"`
1270
Jooyung Han5c998b92019-06-27 11:30:33 +09001271 // Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
1272 Provide_cpp_shared_libs *bool
1273
1274 // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
1275 Uses []string
Nikita Ioffe5d5ae762019-08-31 14:38:05 +01001276
1277 // A txt file containing list of files that are whitelisted to be included in this APEX.
1278 Whitelisted_files *string
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001279
Sundong Ahnabb64432019-10-22 13:58:29 +09001280 // package format of this apex variant; could be non-flattened, flattened, or zip.
1281 // imageApex, zipApex or flattened
1282 ApexType apexPackaging `blueprint:"mutated"`
Sundong Ahne8fb7242019-09-17 13:50:45 +09001283
Jiyong Parkd1063c12019-07-17 20:08:41 +09001284 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
1285 // `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
1286 // is implied. This value affects all modules included in this APEX. In other words, they are
1287 // also built with the SDKs specified here.
1288 Uses_sdks []string
Jiyong Park5d790c32019-11-15 18:40:32 +09001289
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001290 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
1291 // Should be only used in tests#.
1292 Test_only_no_hashtree *bool
Jooyung Han214bf372019-11-12 13:03:50 +09001293
Jiyong Park956305c2020-01-09 12:32:06 +09001294 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park9d677202020-02-19 16:29:35 +09001295
1296 // Whether this APEX is considered updatable or not. When set to true, this will enforce additional
1297 // rules for making sure that the APEX is truely updatable. This will also disable the size optimizations
1298 // like symlinking to the system libs. Default is false.
1299 Updatable *bool
Colin Cross7365eaa2020-02-19 20:41:10 -08001300
1301 // The minimum SDK version that this apex must be compatible with.
1302 Min_sdk_version *string
Alex Light9670d332019-01-29 18:07:33 -08001303}
1304
1305type apexTargetBundleProperties struct {
1306 Target struct {
1307 // Multilib properties only for android.
1308 Android struct {
1309 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001310 }
Jooyung Han344d5432019-08-23 11:17:39 +09001311
Alex Light9670d332019-01-29 18:07:33 -08001312 // Multilib properties only for host.
1313 Host 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 linux_bionic.
1318 Linux_bionic 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_glibc.
1323 Linux_glibc struct {
1324 Multilib apexMultilibProperties
Jiyong Park397e55e2018-10-24 21:09:55 +09001325 }
1326 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001327}
1328
Jiyong Park5d790c32019-11-15 18:40:32 +09001329type overridableProperties struct {
1330 // List of APKs to package inside APEX
1331 Apps []string
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08001332
1333 // Names of modules to be overridden. Listed modules can only be other binaries
1334 // (in Make or Soong).
1335 // This does not completely prevent installation of the overridden binaries, but if both
1336 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
1337 // from PRODUCT_PACKAGES.
1338 Overrides []string
Baligh Uddin004d7172020-02-19 21:29:28 -08001339
1340 // Logging Parent value
1341 Logging_parent string
Baligh Uddincb6aa122020-03-15 13:01:05 -07001342
1343 // Apex Container Package Name.
1344 // Override value for attribute package:name in AndroidManifest.xml
1345 Package_name string
Jiyong Park5d790c32019-11-15 18:40:32 +09001346}
1347
Alex Light5098a612018-11-29 17:12:15 -08001348type apexPackaging int
1349
1350const (
1351 imageApex apexPackaging = iota
1352 zipApex
Sundong Ahnabb64432019-10-22 13:58:29 +09001353 flattenedApex
Alex Light5098a612018-11-29 17:12:15 -08001354)
1355
Sundong Ahnabb64432019-10-22 13:58:29 +09001356// The suffix for the output "file", not the module
Alex Light5098a612018-11-29 17:12:15 -08001357func (a apexPackaging) suffix() string {
1358 switch a {
1359 case imageApex:
1360 return imageApexSuffix
1361 case zipApex:
1362 return zipApexSuffix
Alex Light5098a612018-11-29 17:12:15 -08001363 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001364 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001365 }
1366}
1367
1368func (a apexPackaging) name() string {
1369 switch a {
1370 case imageApex:
1371 return imageApexType
1372 case zipApex:
1373 return zipApexType
Alex Light5098a612018-11-29 17:12:15 -08001374 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001375 panic(fmt.Errorf("unknown APEX type %d", a))
Alex Light5098a612018-11-29 17:12:15 -08001376 }
1377}
1378
Jiyong Parkf653b052019-11-18 15:39:01 +09001379type apexFileClass int
1380
1381const (
1382 etc apexFileClass = iota
1383 nativeSharedLib
1384 nativeExecutable
1385 shBinary
1386 pyBinary
1387 goBinary
1388 javaSharedLib
1389 nativeTest
1390 app
1391)
1392
Jiyong Park8fd61922018-11-08 02:50:25 +09001393func (class apexFileClass) NameInMake() string {
1394 switch class {
1395 case etc:
1396 return "ETC"
1397 case nativeSharedLib:
1398 return "SHARED_LIBRARIES"
Alex Light778127a2019-02-27 14:19:50 -08001399 case nativeExecutable, shBinary, pyBinary, goBinary:
Jiyong Park8fd61922018-11-08 02:50:25 +09001400 return "EXECUTABLES"
1401 case javaSharedLib:
1402 return "JAVA_LIBRARIES"
Roland Levillain630846d2019-06-26 12:48:34 +01001403 case nativeTest:
1404 return "NATIVE_TESTS"
Sundong Ahne1f05aa2019-08-27 13:55:42 +09001405 case app:
Jiyong Parkf383f7c2019-10-11 20:46:25 +09001406 // b/142537672 Why isn't this APP? We want to have full control over
1407 // the paths and file names of the apk file under the flattend APEX.
1408 // If this is set to APP, then the paths and file names are modified
1409 // by the Make build system. For example, it is installed to
1410 // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
1411 // /system/apex/<apexname>/app/<Appname> because the build system automatically
1412 // appends module name (which is <apexname>.<Appname> to the path.
1413 return "ETC"
Jiyong Park8fd61922018-11-08 02:50:25 +09001414 default:
Roland Levillain4644b222019-07-31 14:09:17 +01001415 panic(fmt.Errorf("unknown class %d", class))
Jiyong Park8fd61922018-11-08 02:50:25 +09001416 }
1417}
1418
Jiyong Parkf653b052019-11-18 15:39:01 +09001419// apexFile represents a file in an APEX bundle
Jiyong Park8fd61922018-11-08 02:50:25 +09001420type apexFile struct {
1421 builtFile android.Path
1422 moduleName string
Jiyong Park8fd61922018-11-08 02:50:25 +09001423 installDir string
1424 class apexFileClass
Jiyong Parka8894842018-12-19 17:36:39 +09001425 module android.Module
Jiyong Parkf653b052019-11-18 15:39:01 +09001426 // list of symlinks that will be created in installDir that point to this apexFile
1427 symlinks []string
1428 transitiveDep bool
Jiyong Park1833cef2019-12-13 13:28:36 +09001429 moduleDir string
Jiyong Park7afd1072019-12-30 16:56:33 +09001430
1431 requiredModuleNames []string
1432 targetRequiredModuleNames []string
1433 hostRequiredModuleNames []string
Jiyong Park618922e2020-01-08 13:35:43 +09001434
Colin Cross503c1d02020-01-28 14:00:53 -08001435 jacocoReportClassesFile android.Path // only for javalibs and apps
1436 certificate java.Certificate // only for apps
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001437 overriddenPackageName string // only for apps
Jiyong Parkf653b052019-11-18 15:39:01 +09001438}
1439
Jiyong Park1833cef2019-12-13 13:28:36 +09001440func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
1441 ret := apexFile{
Jiyong Parkf653b052019-11-18 15:39:01 +09001442 builtFile: builtFile,
1443 moduleName: moduleName,
1444 installDir: installDir,
1445 class: class,
1446 module: module,
1447 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001448 if module != nil {
1449 ret.moduleDir = ctx.OtherModuleDir(module)
Jiyong Park7afd1072019-12-30 16:56:33 +09001450 ret.requiredModuleNames = module.RequiredModuleNames()
1451 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
1452 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park1833cef2019-12-13 13:28:36 +09001453 }
1454 return ret
Jiyong Parkf653b052019-11-18 15:39:01 +09001455}
1456
1457func (af *apexFile) Ok() bool {
Jiyong Park479321d2019-12-16 11:47:12 +09001458 return af.builtFile != nil && af.builtFile.String() != ""
Jiyong Park8fd61922018-11-08 02:50:25 +09001459}
1460
Jiyong Park7cd10e32020-01-14 09:22:18 +09001461// Path() returns path of this apex file relative to the APEX root
1462func (af *apexFile) Path() string {
1463 return filepath.Join(af.installDir, af.builtFile.Base())
1464}
1465
1466// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
1467func (af *apexFile) SymlinkPaths() []string {
1468 var ret []string
1469 for _, symlink := range af.symlinks {
1470 ret = append(ret, filepath.Join(af.installDir, symlink))
1471 }
1472 return ret
1473}
1474
1475func (af *apexFile) AvailableToPlatform() bool {
1476 if af.module == nil {
1477 return false
1478 }
1479 if am, ok := af.module.(android.ApexModule); ok {
1480 return am.AvailableFor(android.AvailableToPlatform)
1481 }
1482 return false
1483}
1484
Jiyong Park678c8812020-02-07 17:25:49 +09001485type depInfo struct {
1486 to string
1487 from []string
1488 isExternal bool
1489}
1490
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001491type apexBundle struct {
1492 android.ModuleBase
1493 android.DefaultableModuleBase
Jiyong Park5d790c32019-11-15 18:40:32 +09001494 android.OverridableModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +09001495 android.SdkBase
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001496
Jiyong Park5d790c32019-11-15 18:40:32 +09001497 properties apexBundleProperties
1498 targetProperties apexTargetBundleProperties
Jiyong Park5d790c32019-11-15 18:40:32 +09001499 overridableProperties overridableProperties
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001500
Jooyung Hanf21c7972019-12-16 22:32:06 +09001501 // specific to apex_vndk modules
1502 vndkProperties apexVndkProperties
1503
Colin Crossa4925902018-11-16 11:36:28 -08001504 bundleModuleFile android.WritablePath
Sundong Ahnabb64432019-10-22 13:58:29 +09001505 outputFile android.WritablePath
Colin Cross70dda7e2019-10-01 22:05:35 -07001506 installDir android.InstallPath
Jiyong Park8fd61922018-11-08 02:50:25 +09001507
Jiyong Park03b68dd2019-07-26 23:20:40 +09001508 prebuiltFileToDelete string
1509
Jiyong Park42cca6c2019-04-01 11:15:50 +09001510 public_key_file android.Path
1511 private_key_file android.Path
Jiyong Park0ca3ce82019-02-18 15:25:04 +09001512
1513 container_certificate_file android.Path
1514 container_private_key_file android.Path
1515
Jooyung Han54aca7b2019-11-20 02:26:02 +09001516 fileContexts android.Path
1517
Jiyong Park8fd61922018-11-08 02:50:25 +09001518 // list of files to be included in this apex
1519 filesInfo []apexFile
1520
Jiyong Park956305c2020-01-09 12:32:06 +09001521 // list of module names that should be installed along with this APEX
1522 requiredDeps []string
1523
Jiyong Park956305c2020-01-09 12:32:06 +09001524 // list of module names that this APEX is including (to be shown via *-deps-info target)
Jiyong Park678c8812020-02-07 17:25:49 +09001525 depInfos map[string]depInfo
Jiyong Parkac2bacd2019-02-20 21:49:26 +09001526
Sundong Ahnabb64432019-10-22 13:58:29 +09001527 testApex bool
1528 vndkApex bool
Ulyana Trafimovichde534412019-11-08 10:51:01 +00001529 artApex bool
Sundong Ahnabb64432019-10-22 13:58:29 +09001530 primaryApexType bool
Jooyung Hane1633032019-08-01 17:41:43 +09001531
Jooyung Han214bf372019-11-12 13:03:50 +09001532 manifestJsonOut android.WritablePath
1533 manifestPbOut android.WritablePath
Jooyung Han72bd2f82019-10-23 16:46:38 +09001534
Jooyung Han002ab682020-01-08 01:57:58 +09001535 // list of commands to create symlinks for backward compatibility.
Jooyung Han72bd2f82019-10-23 16:46:38 +09001536 // these commands will be attached as LOCAL_POST_INSTALL_CMD to
Jooyung Han002ab682020-01-08 01:57:58 +09001537 // apex package itself(for unflattened build) or apex_manifest(for flattened build)
Jooyung Han72bd2f82019-10-23 16:46:38 +09001538 // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
1539 compatSymlinks []string
Sundong Ahnabb64432019-10-22 13:58:29 +09001540
1541 // Suffix of module name in Android.mk
1542 // ".flattened", ".apex", ".zipapex", or ""
1543 suffix string
Jiyong Park3a1602e2020-01-14 14:39:19 +09001544
1545 installedFilesFile android.WritablePath
Jiyong Park7cd10e32020-01-14 09:22:18 +09001546
1547 // Whether to create symlink to the system file instead of having a file
1548 // inside the apex or not
1549 linkToSystemLib bool
Jiyong Park19972c72020-01-28 20:05:29 +09001550
1551 // Struct holding the merged notice file paths in different formats
1552 mergedNotices android.NoticeOutputs
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001553}
1554
Jiyong Park397e55e2018-10-24 21:09:55 +09001555func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
Roland Levillain630846d2019-06-26 12:48:34 +01001556 native_shared_libs []string, binaries []string, tests []string,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001557 target android.Target, imageVariation string) {
Jiyong Park397e55e2018-10-24 21:09:55 +09001558 // Use *FarVariation* to be able to depend on modules having
1559 // conflicting variations with this module. This is required since
1560 // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
1561 // for native shared libs.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001562 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Parkda6eb592018-12-19 17:12:36 +09001563 {Mutator: "image", Variation: imageVariation},
Jiyong Park397e55e2018-10-24 21:09:55 +09001564 {Mutator: "link", Variation: "shared"},
Jiyong Park28d395a2018-12-07 22:42:47 +09001565 {Mutator: "version", Variation: ""}, // "" is the non-stub variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001566 }...), sharedLibTag, native_shared_libs...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001567
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001568 ctx.AddFarVariationDependencies(append(target.Variations(),
1569 blueprint.Variation{Mutator: "image", Variation: imageVariation}),
1570 executableTag, binaries...)
Roland Levillain630846d2019-06-26 12:48:34 +01001571
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001572 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001573 {Mutator: "image", Variation: imageVariation},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001574 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001575 }...), testTag, tests...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001576}
1577
Alex Light9670d332019-01-29 18:07:33 -08001578func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
1579 if ctx.Os().Class == android.Device {
1580 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
1581 } else {
1582 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
1583 if ctx.Os().Bionic() {
1584 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
1585 } else {
1586 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
1587 }
1588 }
1589}
1590
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001591func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
Jooyung Handc782442019-11-01 03:14:38 +09001592 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
1593 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1594 }
1595
Jiyong Park397e55e2018-10-24 21:09:55 +09001596 targets := ctx.MultiTargets()
Jiyong Park7c1dc612019-01-05 11:15:24 +09001597 config := ctx.DeviceConfig()
Alex Light9670d332019-01-29 18:07:33 -08001598
1599 a.combineProperties(ctx)
1600
Jiyong Park397e55e2018-10-24 21:09:55 +09001601 has32BitTarget := false
1602 for _, target := range targets {
1603 if target.Arch.ArchType.Multilib == "lib32" {
1604 has32BitTarget = true
1605 }
1606 }
1607 for i, target := range targets {
1608 // When multilib.* is omitted for native_shared_libs, it implies
1609 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001610 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Jiyong Park7c1dc612019-01-05 11:15:24 +09001611 {Mutator: "image", Variation: a.getImageVariation(config)},
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001612 {Mutator: "link", Variation: "shared"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001613 }...), sharedLibTag, a.properties.Native_shared_libs...)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001614
Roland Levillain630846d2019-06-26 12:48:34 +01001615 // When multilib.* is omitted for tests, it implies
1616 // multilib.both.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001617 ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
Roland Levillain630846d2019-06-26 12:48:34 +01001618 {Mutator: "image", Variation: a.getImageVariation(config)},
Roland Levillain9b5fde92019-06-28 15:41:19 +01001619 {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001620 }...), testTag, a.properties.Tests...)
Roland Levillain630846d2019-06-26 12:48:34 +01001621
Jiyong Park397e55e2018-10-24 21:09:55 +09001622 // Add native modules targetting both ABIs
1623 addDependenciesForNativeModules(ctx,
1624 a.properties.Multilib.Both.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001625 a.properties.Multilib.Both.Binaries,
1626 a.properties.Multilib.Both.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001627 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001628 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001629
Alex Light3d673592019-01-18 14:37:31 -08001630 isPrimaryAbi := i == 0
1631 if isPrimaryAbi {
Jiyong Park397e55e2018-10-24 21:09:55 +09001632 // When multilib.* is omitted for binaries, it implies
1633 // multilib.first.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001634 ctx.AddFarVariationDependencies(append(target.Variations(),
1635 blueprint.Variation{Mutator: "image", Variation: a.getImageVariation(config)}),
1636 executableTag, a.properties.Binaries...)
Jiyong Park397e55e2018-10-24 21:09:55 +09001637
1638 // Add native modules targetting the first ABI
1639 addDependenciesForNativeModules(ctx,
1640 a.properties.Multilib.First.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001641 a.properties.Multilib.First.Binaries,
1642 a.properties.Multilib.First.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001643 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001644 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001645 }
1646
1647 switch target.Arch.ArchType.Multilib {
1648 case "lib32":
1649 // Add native modules targetting 32-bit ABI
1650 addDependenciesForNativeModules(ctx,
1651 a.properties.Multilib.Lib32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001652 a.properties.Multilib.Lib32.Binaries,
1653 a.properties.Multilib.Lib32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001654 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001655 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001656
1657 addDependenciesForNativeModules(ctx,
1658 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001659 a.properties.Multilib.Prefer32.Binaries,
1660 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001661 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001662 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001663 case "lib64":
1664 // Add native modules targetting 64-bit ABI
1665 addDependenciesForNativeModules(ctx,
1666 a.properties.Multilib.Lib64.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001667 a.properties.Multilib.Lib64.Binaries,
1668 a.properties.Multilib.Lib64.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001669 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001670 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001671
1672 if !has32BitTarget {
1673 addDependenciesForNativeModules(ctx,
1674 a.properties.Multilib.Prefer32.Native_shared_libs,
Roland Levillain630846d2019-06-26 12:48:34 +01001675 a.properties.Multilib.Prefer32.Binaries,
1676 a.properties.Multilib.Prefer32.Tests,
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001677 target,
Jiyong Park7c1dc612019-01-05 11:15:24 +09001678 a.getImageVariation(config))
Jiyong Park397e55e2018-10-24 21:09:55 +09001679 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001680
1681 if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
1682 for _, sanitizer := range ctx.Config().SanitizeDevice() {
1683 if sanitizer == "hwaddress" {
1684 addDependenciesForNativeModules(ctx,
1685 []string{"libclang_rt.hwasan-aarch64-android"},
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001686 nil, nil, target, a.getImageVariation(config))
Peter Collingbourne3478bb22019-04-24 14:41:12 -07001687 break
1688 }
1689 }
1690 }
Jiyong Park397e55e2018-10-24 21:09:55 +09001691 }
1692
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001693 }
1694
Jiyong Parkce6aadc2019-11-20 13:58:28 +09001695 // For prebuilt_etc, use the first variant (64 on 64/32bit device,
1696 // 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
1697 // b/144532908
1698 archForPrebuiltEtc := config.Arches()[0]
1699 for _, arch := range config.Arches() {
1700 // Prefer 64-bit arch if there is any
1701 if arch.ArchType.Multilib == "lib64" {
1702 archForPrebuiltEtc = arch
1703 break
1704 }
1705 }
1706 ctx.AddFarVariationDependencies([]blueprint.Variation{
1707 {Mutator: "os", Variation: ctx.Os().String()},
1708 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
1709 }, prebuiltTag, a.properties.Prebuilts...)
1710
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001711 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1712 javaLibTag, a.properties.Java_libs...)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001713
Ulya Trafimovich44561882020-01-03 13:25:54 +00001714 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
1715 if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
1716 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1717 javaLibTag, "jacocoagent")
1718 }
1719
Jiyong Park23c52b02019-02-02 13:13:47 +09001720 if String(a.properties.Key) == "" {
1721 ctx.ModuleErrorf("key is missing")
1722 return
1723 }
1724 ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001725
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001726 cert := android.SrcIsModule(a.getCertString(ctx))
Jiyong Park23c52b02019-02-02 13:13:47 +09001727 if cert != "" {
1728 ctx.AddDependency(ctx.Module(), certificateTag, cert)
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001729 }
Jiyong Parkd1063c12019-07-17 20:08:41 +09001730
1731 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
1732 if len(a.properties.Uses_sdks) > 0 {
1733 sdkRefs := []android.SdkRef{}
1734 for _, str := range a.properties.Uses_sdks {
1735 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
1736 sdkRefs = append(sdkRefs, parsed)
1737 }
1738 a.BuildWithSdks(sdkRefs)
1739 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001740}
1741
Jiyong Park5d790c32019-11-15 18:40:32 +09001742func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
1743 ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
1744 androidAppTag, a.overridableProperties.Apps...)
1745}
1746
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001747func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1748 // direct deps of an APEX bundle are all part of the APEX bundle
1749 return true
1750}
1751
Colin Cross0ea8ba82019-06-06 14:33:29 -07001752func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001753 moduleName := ctx.ModuleName()
1754 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
1755 // we check with the pseudo module name to see if its certificate is overridden.
1756 if a.vndkApex {
1757 moduleName = vndkApexName
1758 }
1759 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001760 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001761 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001762 }
1763 return String(a.properties.Certificate)
1764}
1765
Colin Cross41955e82019-05-29 14:40:35 -07001766func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1767 switch tag {
1768 case "":
Sundong Ahnabb64432019-10-22 13:58:29 +09001769 return android.Paths{a.outputFile}, nil
Colin Cross41955e82019-05-29 14:40:35 -07001770 default:
1771 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Jiyong Park5a832022018-12-20 09:54:35 +09001772 }
Jiyong Park74e240b2018-11-27 21:27:08 +09001773}
1774
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001775func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001776 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001777}
1778
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001779func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
1780 return proptools.Bool(a.properties.Test_only_no_hashtree)
1781}
1782
Jiyong Park7c1dc612019-01-05 11:15:24 +09001783func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
Jooyung Han31c470b2019-10-18 16:26:59 +09001784 if a.vndkApex {
Colin Cross7228ecd2019-11-18 16:00:16 -08001785 return cc.VendorVariationPrefix + a.vndkVersion(config)
Jooyung Han31c470b2019-10-18 16:26:59 +09001786 }
Jiyong Park7c1dc612019-01-05 11:15:24 +09001787 if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
Colin Cross7228ecd2019-11-18 16:00:16 -08001788 return cc.VendorVariationPrefix + config.PlatformVndkVersion()
Jiyong Parkda6eb592018-12-19 17:12:36 +09001789 } else {
Colin Cross7228ecd2019-11-18 16:00:16 -08001790 return android.CoreVariation
Jiyong Parkda6eb592018-12-19 17:12:36 +09001791 }
1792}
1793
Jiyong Parkf97782b2019-02-13 20:28:58 +09001794func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1795 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1796 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1797 }
1798}
1799
Jiyong Park388ef3f2019-01-28 19:47:32 +09001800func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001801 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1802 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001803 }
1804
1805 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001806 globalSanitizerNames := []string{}
1807 if a.Host() {
1808 globalSanitizerNames = ctx.Config().SanitizeHost()
1809 } else {
1810 arches := ctx.Config().SanitizeDeviceArch()
1811 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1812 globalSanitizerNames = ctx.Config().SanitizeDevice()
1813 }
1814 }
1815 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001816}
1817
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001818func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
Oliver Nguyen1382ab62019-12-06 15:22:41 -08001819 return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled())
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001820}
1821
1822func (a *apexBundle) PreventInstall() {
1823 a.properties.PreventInstall = true
1824}
1825
1826func (a *apexBundle) HideFromMake() {
1827 a.properties.HideFromMake = true
1828}
1829
Jiyong Park956305c2020-01-09 12:32:06 +09001830func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1831 a.properties.IsCoverageVariant = coverage
1832}
1833
Jiyong Parkf653b052019-11-18 15:39:01 +09001834// TODO(jiyong) move apexFileFor* close to the apexFile type definition
Jiyong Park1833cef2019-12-13 13:28:36 +09001835func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001836 // Decide the APEX-local directory by the multilib of the library
1837 // In the future, we may query this to the module.
Jiyong Parkf653b052019-11-18 15:39:01 +09001838 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001839 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001840 case "lib32":
1841 dirInApex = "lib"
1842 case "lib64":
1843 dirInApex = "lib64"
1844 }
Martin Stjernholm279de572019-09-10 23:18:20 +01001845 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001846 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001847 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001848 }
Jiyong Park1833cef2019-12-13 13:28:36 +09001849 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Martin Stjernholm279de572019-09-10 23:18:20 +01001850 // Special case for Bionic libs and other libs installed with them. This is
1851 // to prevent those libs from being included in the search path
1852 // /apex/com.android.runtime/${LIB}. This exclusion is required because
1853 // those libs in the Runtime APEX are available via the legacy paths in
1854 // /system/lib/. By the init process, the libs in the APEX are bind-mounted
1855 // to the legacy paths and thus will be loaded into the default linker
1856 // namespace (aka "platform" namespace). If the libs are directly in
1857 // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
1858 // into the runtime linker namespace, which will result in double loading of
1859 // them, which isn't supported.
1860 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001861 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001862
Jiyong Parkf653b052019-11-18 15:39:01 +09001863 fileToCopy := ccMod.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001864 return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001865}
1866
Jiyong Park1833cef2019-12-13 13:28:36 +09001867func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001868 dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
Colin Cross3b19f5d2019-09-17 14:45:31 -07001869 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001870 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001871 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001872 fileToCopy := cc.OutputFile().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001873 af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001874 af.symlinks = cc.Symlinks()
1875 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001876}
1877
Jiyong Park1833cef2019-12-13 13:28:36 +09001878func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001879 dirInApex := "bin"
1880 fileToCopy := py.HostToolPath().Path()
Jiyong Park1833cef2019-12-13 13:28:36 +09001881 return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001882}
Jiyong Park1833cef2019-12-13 13:28:36 +09001883func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001884 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001885 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1886 if err != nil {
1887 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001888 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001889 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001890 fileToCopy := android.PathForOutput(ctx, s)
1891 // NB: Since go binaries are static we don't need the module for anything here, which is
1892 // good since the go tool is a blueprint.Module not an android.Module like we would
1893 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001894 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001895}
1896
Jiyong Park1833cef2019-12-13 13:28:36 +09001897func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001898 dirInApex := filepath.Join("bin", sh.SubDir())
1899 fileToCopy := sh.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001900 af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001901 af.symlinks = sh.Symlinks()
1902 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001903}
1904
Jooyung Han58f26ab2019-12-18 15:34:32 +09001905// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
1906type javaLibrary interface {
1907 android.Module
1908 java.Dependency
1909}
1910
1911func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001912 dirInApex := "javalib"
Jooyung Han58f26ab2019-12-18 15:34:32 +09001913 fileToCopy := lib.DexJar()
Jiyong Park618922e2020-01-08 13:35:43 +09001914 af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
1915 af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
1916 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001917}
1918
Jiyong Park1833cef2019-12-13 13:28:36 +09001919func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001920 dirInApex := filepath.Join("etc", prebuilt.SubDir())
1921 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001922 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001923}
1924
atrost6e126252020-01-27 17:01:16 +00001925func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1926 dirInApex := filepath.Join("etc", config.SubDir())
1927 fileToCopy := config.CompatConfig()
1928 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1929}
1930
Jiyong Park1833cef2019-12-13 13:28:36 +09001931func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001932 android.Module
1933 Privileged() bool
1934 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001935 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001936 Certificate() java.Certificate
Jiyong Parkf653b052019-11-18 15:39:01 +09001937}, pkgName string) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001938 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001939 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001940 appDir = "priv-app"
1941 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001942 dirInApex := filepath.Join(appDir, pkgName)
1943 fileToCopy := aapp.OutputFile()
Jiyong Park618922e2020-01-08 13:35:43 +09001944 af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
1945 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross503c1d02020-01-28 14:00:53 -08001946 af.certificate = aapp.Certificate()
Jiyong Parkaf8998c2020-02-28 16:51:07 +09001947
1948 if app, ok := aapp.(interface {
1949 OverriddenManifestPackageName() string
1950 }); ok {
1951 af.overriddenPackageName = app.OverriddenManifestPackageName()
1952 }
Jiyong Park618922e2020-01-08 13:35:43 +09001953 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001954}
1955
Roland Levillain935639d2019-08-13 14:55:28 +01001956// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
1957type flattenedApexContext struct {
1958 android.ModuleContext
1959}
1960
1961func (c *flattenedApexContext) InstallBypassMake() bool {
1962 return true
1963}
1964
Jiyong Park201cedd2020-02-07 17:25:49 +09001965// Visit dependencies that contributes to the payload of this APEX
1966func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext,
1967 do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) {
Jiyong Parkfa899442020-01-31 02:49:53 +09001968 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
1969 am, ok := child.(android.ApexModule)
1970 if !ok || !am.CanHaveApexVariants() {
1971 return false
1972 }
1973
1974 // Check for the direct dependencies that contribute to the payload
1975 if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
1976 if dt.payload {
Jiyong Park201cedd2020-02-07 17:25:49 +09001977 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001978 return true
1979 }
1980 return false
1981 }
1982
1983 // Check for the indirect dependencies if it is considered as part of the APEX
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09001984 if am.ApexName() != "" {
Jiyong Park201cedd2020-02-07 17:25:49 +09001985 do(ctx, parent, am, false /* externalDep */)
Jiyong Parkfa899442020-01-31 02:49:53 +09001986 return true
1987 }
1988
Jiyong Park201cedd2020-02-07 17:25:49 +09001989 do(ctx, parent, am, true /* externalDep */)
1990
Jiyong Parkfa899442020-01-31 02:49:53 +09001991 // As soon as the dependency graph crosses the APEX boundary, don't go further.
1992 return false
1993 })
1994}
1995
Jooyung Han0c4e0162020-02-26 22:45:42 +09001996func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
1997 ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
1998 if ver != "current" {
1999 minSdkVersion, err := strconv.Atoi(ver)
2000 if err != nil {
2001 ctx.PropertyErrorf("min_sdk_version", "should be \"current\" or <number>, but %q", ver)
2002 }
2003 return minSdkVersion
2004 }
2005 return android.FutureApiLevel
2006}
2007
Jiyong Park201cedd2020-02-07 17:25:49 +09002008// Ensures that the dependencies are marked as available for this APEX
2009func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
2010 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
2011 if ctx.Host() || a.testApex || a.vndkApex {
2012 return
2013 }
2014
2015 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2016 apexName := ctx.ModuleName()
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002017 fromName := ctx.OtherModuleName(from)
2018 toName := ctx.OtherModuleName(to)
2019 if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) {
Jiyong Park201cedd2020-02-07 17:25:49 +09002020 return
2021 }
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002022 ctx.ModuleErrorf("%q requires %q that is not available for the APEX.", fromName, toName)
Jiyong Park201cedd2020-02-07 17:25:49 +09002023 })
2024}
2025
Jiyong Park678c8812020-02-07 17:25:49 +09002026// Collects the list of module names that directly or indirectly contributes to the payload of this APEX
2027func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) {
2028 a.depInfos = make(map[string]depInfo)
2029 a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
2030 if from.Name() == to.Name() {
2031 // This can happen for cc.reuseObjTag. We are not interested in tracking this.
2032 return
2033 }
2034
2035 if info, exists := a.depInfos[to.Name()]; exists {
2036 if !android.InList(from.Name(), info.from) {
2037 info.from = append(info.from, from.Name())
2038 }
2039 info.isExternal = info.isExternal && externalDep
2040 a.depInfos[to.Name()] = info
2041 } else {
2042 a.depInfos[to.Name()] = depInfo{
2043 to: to.Name(),
2044 from: []string{from.Name()},
2045 isExternal: externalDep,
2046 }
2047 }
2048 })
2049}
2050
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002051func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahnabb64432019-10-22 13:58:29 +09002052 buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
2053 switch a.properties.ApexType {
2054 case imageApex:
2055 if buildFlattenedAsDefault {
2056 a.suffix = imageApexSuffix
2057 } else {
2058 a.suffix = ""
2059 a.primaryApexType = true
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002060
2061 if ctx.Config().InstallExtraFlattenedApexes() {
Jiyong Park956305c2020-01-09 12:32:06 +09002062 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
Jooyung Han3ab2c3e2019-12-05 16:27:44 +09002063 }
Sundong Ahnabb64432019-10-22 13:58:29 +09002064 }
2065 case zipApex:
2066 if proptools.String(a.properties.Payload_type) == "zip" {
2067 a.suffix = ""
2068 a.primaryApexType = true
2069 } else {
2070 a.suffix = zipApexSuffix
2071 }
2072 case flattenedApex:
2073 if buildFlattenedAsDefault {
2074 a.suffix = ""
2075 a.primaryApexType = true
2076 } else {
2077 a.suffix = flattenedSuffix
2078 }
Alex Light5098a612018-11-29 17:12:15 -08002079 }
2080
Roland Levillain630846d2019-06-26 12:48:34 +01002081 if len(a.properties.Tests) > 0 && !a.testApex {
2082 ctx.PropertyErrorf("tests", "property not allowed in apex module type")
2083 return
2084 }
2085
Jiyong Parkfa899442020-01-31 02:49:53 +09002086 a.checkApexAvailability(ctx)
2087
Jiyong Park678c8812020-02-07 17:25:49 +09002088 a.collectDepsInfo(ctx)
2089
Alex Lightfc0bd7c2019-01-29 18:31:59 -08002090 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
2091
Jooyung Hane1633032019-08-01 17:41:43 +09002092 // native lib dependencies
2093 var provideNativeLibs []string
2094 var requireNativeLibs []string
2095
Jooyung Han5c998b92019-06-27 11:30:33 +09002096 // Check if "uses" requirements are met with dependent apexBundles
2097 var providedNativeSharedLibs []string
2098 useVendor := proptools.Bool(a.properties.Use_vendor)
2099 ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
2100 if ctx.OtherModuleDependencyTag(m) != usesTag {
2101 return
2102 }
2103 otherName := ctx.OtherModuleName(m)
2104 other, ok := m.(*apexBundle)
2105 if !ok {
2106 ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
2107 return
2108 }
2109 if proptools.Bool(other.properties.Use_vendor) != useVendor {
2110 ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
2111 return
2112 }
2113 if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
2114 ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
2115 return
2116 }
2117 providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
2118 })
2119
Jiyong Parkf653b052019-11-18 15:39:01 +09002120 var filesInfo []apexFile
Jiyong Park678c8812020-02-07 17:25:49 +09002121 // TODO(jiyong) do this using walkPayloadDeps
Alex Light778127a2019-02-27 14:19:50 -08002122 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01002123 depTag := ctx.OtherModuleDependencyTag(child)
2124 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09002125 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002126 switch depTag {
2127 case sharedLibTag:
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002128 if c, ok := child.(*cc.Module); ok {
2129 // bootstrap bionic libs are treated as provided by system
2130 if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
2131 provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base())
Jooyung Hane1633032019-08-01 17:41:43 +09002132 }
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09002133 filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, c, handleSpecialLibs))
Jiyong Parkf653b052019-11-18 15:39:01 +09002134 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002135 } else {
2136 ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002137 }
2138 case executableTag:
2139 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002140 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09002141 return true // track transitive dependencies
Jiyong Park04480cf2019-02-06 00:16:29 +09002142 } else if sh, ok := child.(*android.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002143 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08002144 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09002145 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08002146 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09002147 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002148 } else {
Alex Light778127a2019-02-27 14:19:50 -08002149 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 +09002150 }
2151 case javaLibTag:
Jiyong Park9e6c2422019-08-09 20:39:45 +09002152 if javaLib, ok := child.(*java.Library); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002153 af := apexFileForJavaLibrary(ctx, javaLib)
Jiyong Parkf653b052019-11-18 15:39:01 +09002154 if !af.Ok() {
Jiyong Park8fd61922018-11-08 02:50:25 +09002155 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2156 } else {
Jiyong Parkf653b052019-11-18 15:39:01 +09002157 filesInfo = append(filesInfo, af)
2158 return true // track transitive dependencies
Jiyong Park9e6c2422019-08-09 20:39:45 +09002159 }
Jooyung Han58f26ab2019-12-18 15:34:32 +09002160 } else if sdkLib, ok := child.(*java.SdkLibrary); ok {
2161 af := apexFileForJavaLibrary(ctx, sdkLib)
2162 if !af.Ok() {
2163 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
2164 return false
2165 }
2166 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09002167 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09002168 } else {
Jiyong Park9e6c2422019-08-09 20:39:45 +09002169 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002170 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002171 case androidAppTag:
2172 pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
2173 if ap, ok := child.(*java.AndroidApp); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002174 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002175 return true // track transitive dependencies
2176 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002177 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Dario Freni6f3937c2019-12-20 22:58:03 +00002178 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
2179 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
Jiyong Parkf653b052019-11-18 15:39:01 +09002180 } else {
2181 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
2182 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002183 case prebuiltTag:
Jooyung Han39edb6c2019-11-06 16:53:07 +09002184 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002185 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
atrost6e126252020-01-27 17:01:16 +00002186 } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
2187 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09002188 } else {
atrost6e126252020-01-27 17:01:16 +00002189 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09002190 }
Roland Levillain630846d2019-06-26 12:48:34 +01002191 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01002192 if ccTest, ok := child.(*cc.Module); ok {
2193 if ccTest.IsTestPerSrcAllTestsVariation() {
2194 // Multiple-output test module (where `test_per_src: true`).
2195 //
2196 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
2197 // We do not add this variation to `filesInfo`, as it has no output;
2198 // however, we do add the other variations of this module as indirect
2199 // dependencies (see below).
2200 return true
Roland Levillain9b5fde92019-06-28 15:41:19 +01002201 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01002202 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09002203 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09002204 af.class = nativeTest
2205 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01002206 }
Roland Levillain630846d2019-06-26 12:48:34 +01002207 } else {
2208 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
2209 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09002210 case keyTag:
2211 if key, ok := child.(*apexKey); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002212 a.private_key_file = key.private_key_file
2213 a.public_key_file = key.public_key_file
Jiyong Parkff1458f2018-10-12 21:49:38 +09002214 } else {
2215 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002216 }
Jiyong Parkf653b052019-11-18 15:39:01 +09002217 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002218 case certificateTag:
2219 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002220 a.container_certificate_file = dep.Certificate.Pem
2221 a.container_private_key_file = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09002222 } else {
2223 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
2224 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09002225 case android.PrebuiltDepTag:
2226 // If the prebuilt is force disabled, remember to delete the prebuilt file
2227 // that might have been installed in the previous builds
2228 if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
2229 a.prebuiltFileToDelete = prebuilt.InstallFilename()
2230 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002231 }
Jooyung Han8aee2042019-10-29 05:08:31 +09002232 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002233 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09002234 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01002235 // We cannot use a switch statement on `depTag` here as the checked
2236 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09002237 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002238 if cc, ok := child.(*cc.Module); ok {
2239 if android.InList(cc.Name(), providedNativeSharedLibs) {
2240 // If we're using a shared library which is provided from other APEX,
2241 // don't include it in this APEX
2242 return false
Jiyong Parkac2bacd2019-02-20 21:49:26 +09002243 }
Jooyung Han671f1ce2019-12-17 12:47:13 +09002244 if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01002245 // If the dependency is a stubs lib, don't include it in this APEX,
2246 // but make sure that the lib is installed on the device.
2247 // In case no APEX is having the lib, the lib is installed to the system
2248 // partition.
2249 //
2250 // Always include if we are a host-apex however since those won't have any
2251 // system libraries.
Jiyong Park956305c2020-01-09 12:32:06 +09002252 if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.Name(), a.requiredDeps) {
2253 a.requiredDeps = append(a.requiredDeps, cc.Name())
Roland Levillainf89cd092019-07-29 16:22:59 +01002254 }
Jooyung Hane1633032019-08-01 17:41:43 +09002255 requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
Roland Levillainf89cd092019-07-29 16:22:59 +01002256 // Don't track further
2257 return false
2258 }
Jiyong Park1833cef2019-12-13 13:28:36 +09002259 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
Jiyong Parkf653b052019-11-18 15:39:01 +09002260 af.transitiveDep = true
2261 filesInfo = append(filesInfo, af)
2262 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09002263 }
Roland Levillainf89cd092019-07-29 16:22:59 +01002264 } else if cc.IsTestPerSrcDepTag(depTag) {
2265 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09002266 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01002267 // Handle modules created as `test_per_src` variations of a single test module:
2268 // use the name of the generated test binary (`fileToCopy`) instead of the name
2269 // of the original test module (`depName`, shared by all `test_per_src`
2270 // variations of that module).
Jiyong Parkf653b052019-11-18 15:39:01 +09002271 af.moduleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002272 // these are not considered transitive dep
2273 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09002274 filesInfo = append(filesInfo, af)
2275 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01002276 }
Jiyong Park52cd06f2019-11-11 10:14:32 +09002277 } else if java.IsJniDepTag(depTag) {
Jooyung Han65041792020-02-25 16:59:29 +09002278 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
2279 return false
Jiyong Parke3833882020-02-17 17:28:10 +09002280 } else if java.IsXmlPermissionsFileDepTag(depTag) {
2281 if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
2282 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
2283 }
Jooyung Han9c80bae2019-08-20 17:30:57 +09002284 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Roland Levillainf89cd092019-07-29 16:22:59 +01002285 ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002286 }
2287 }
2288 }
2289 return false
2290 })
2291
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002292 // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
2293 // Build rules are generated by the dexpreopt singleton, and here we access build artifacts
2294 // via the global boot image config.
2295 if a.artApex {
2296 for arch, files := range java.DexpreoptedArtApexJars(ctx) {
2297 dirInApex := filepath.Join("javalib", arch.String())
2298 for _, f := range files {
2299 localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
Jiyong Park1833cef2019-12-13 13:28:36 +09002300 af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
Jiyong Parkf653b052019-11-18 15:39:01 +09002301 filesInfo = append(filesInfo, af)
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002302 }
2303 }
2304 }
2305
Jiyong Park0ca3ce82019-02-18 15:25:04 +09002306 if a.private_key_file == nil {
Jiyong Parkfa0a3732018-11-09 05:52:26 +09002307 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
2308 return
2309 }
2310
Jiyong Park8fd61922018-11-08 02:50:25 +09002311 // remove duplicates in filesInfo
2312 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002313 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002314 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002315 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002316 if e, ok := encountered[dest]; !ok {
2317 encountered[dest] = f
2318 } else {
2319 // If a module is directly included and also transitively depended on
2320 // consider it as directly included.
2321 e.transitiveDep = e.transitiveDep && f.transitiveDep
2322 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002323 }
2324 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002325 var result []apexFile
2326 for _, v := range encountered {
2327 result = append(result, v)
2328 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002329 return result
2330 }
2331 filesInfo = removeDup(filesInfo)
2332
2333 // to have consistent build rules
2334 sort.Slice(filesInfo, func(i, j int) bool {
2335 return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
2336 })
2337
Jiyong Park8fd61922018-11-08 02:50:25 +09002338 a.installDir = android.PathForModuleInstall(ctx, "apex")
2339 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002340
Jooyung Han54aca7b2019-11-20 02:26:02 +09002341 if a.properties.ApexType != zipApex {
2342 if a.properties.File_contexts == nil {
2343 a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts")
2344 } else {
2345 a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts)
2346 if a.Platform() {
2347 if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched {
2348 ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts)
2349 }
2350 }
2351 }
2352 if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() {
2353 ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts)
2354 return
2355 }
2356 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002357 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2358 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2359 // the same library in the system partition, thus effectively sharing the same libraries
2360 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2361 // in the APEX.
2362 a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
2363 a.installable() &&
2364 !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002365
Jiyong Park9d677202020-02-19 16:29:35 +09002366 // We don't need the optimization for updatable APEXes, as it might give false signal
2367 // to the system health when the APEXes are still bundled (b/149805758)
2368 if proptools.Bool(a.properties.Updatable) && a.properties.ApexType == imageApex {
2369 a.linkToSystemLib = false
2370 }
2371
Jiyong Park9b964182020-02-26 18:27:19 +09002372 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2373 if ctx.Host() {
2374 a.linkToSystemLib = false
2375 }
2376
Jooyung Hand15aa1f2019-09-27 00:38:03 +09002377 // prepare apex_manifest.json
Jooyung Han01a3ee22019-11-02 02:52:25 +09002378 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
2379
2380 a.setCertificateAndPrivateKey(ctx)
2381 if a.properties.ApexType == flattenedApex {
2382 a.buildFlattenedApex(ctx)
2383 } else {
2384 a.buildUnflattenedApex(ctx)
2385 }
2386
Jooyung Han002ab682020-01-08 01:57:58 +09002387 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
Jiyong Park956305c2020-01-09 12:32:06 +09002388
2389 a.buildApexDependencyInfo(ctx)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002390}
2391
Jooyung Hanb8fa86a2020-03-10 06:23:13 +09002392func whitelistedApexAvailable(apex, moduleName string) bool {
Anton Hansson5053c292020-01-10 15:12:39 +00002393 key := apex
2394 key = strings.Replace(key, "test_", "", 1)
2395 key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
2396 key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
2397
Jiyong Parkfa899442020-01-31 02:49:53 +09002398 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2399 // system. Trim the prefix for the check since they are confusing
2400 moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
2401 if strings.HasPrefix(moduleName, "libclang_rt.") {
2402 // This module has many arch variants that depend on the product being built.
2403 // We don't want to list them all
2404 moduleName = "libclang_rt"
Anton Hansson5053c292020-01-10 15:12:39 +00002405 }
2406
2407 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2408 return true
2409 }
2410
Jiyong Parkfa899442020-01-31 02:49:53 +09002411 key = "//any"
2412 if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
2413 return true
2414 }
2415
Anton Hansson5053c292020-01-10 15:12:39 +00002416 return false
2417}
2418
Jooyung Han344d5432019-08-23 11:17:39 +09002419func newApexBundle() *apexBundle {
Sundong Ahnabb64432019-10-22 13:58:29 +09002420 module := &apexBundle{}
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002421 module.AddProperties(&module.properties)
Alex Light9670d332019-01-29 18:07:33 -08002422 module.AddProperties(&module.targetProperties)
Jiyong Park5d790c32019-11-15 18:40:32 +09002423 module.AddProperties(&module.overridableProperties)
Alex Light5098a612018-11-29 17:12:15 -08002424 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
Jiyong Park397e55e2018-10-24 21:09:55 +09002425 return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
2426 })
Alex Light5098a612018-11-29 17:12:15 -08002427 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002428 android.InitDefaultableModule(module)
Jiyong Parkd1063c12019-07-17 20:08:41 +09002429 android.InitSdkAwareModule(module)
Jaewoong Jung7abcf8e2019-12-19 17:32:06 -08002430 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002431 return module
2432}
Jiyong Park30ca9372019-02-07 16:27:23 +09002433
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002434func ApexBundleFactory(testApex bool, artApex bool) android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002435 bundle := newApexBundle()
2436 bundle.testApex = testApex
Ulyana Trafimovichde534412019-11-08 10:51:01 +00002437 bundle.artApex = artApex
Jooyung Han344d5432019-08-23 11:17:39 +09002438 return bundle
2439}
2440
Jiyong Parkfce0b422020-02-11 03:56:06 +09002441// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2442// certain compatibility checks such as apex_available are not done for apex_test.
Jooyung Han344d5432019-08-23 11:17:39 +09002443func testApexBundleFactory() android.Module {
2444 bundle := newApexBundle()
2445 bundle.testApex = true
2446 return bundle
2447}
2448
Jiyong Parkfce0b422020-02-11 03:56:06 +09002449// apex packages other modules into an APEX file which is a packaging format for system-level
2450// components like binaries, shared libraries, etc.
Jiyong Parkd1063c12019-07-17 20:08:41 +09002451func BundleFactory() android.Module {
Jooyung Han344d5432019-08-23 11:17:39 +09002452 return newApexBundle()
2453}
2454
Jiyong Park30ca9372019-02-07 16:27:23 +09002455//
2456// Defaults
2457//
2458type Defaults struct {
2459 android.ModuleBase
2460 android.DefaultsModuleBase
2461}
2462
Jiyong Park30ca9372019-02-07 16:27:23 +09002463func defaultsFactory() android.Module {
2464 return DefaultsFactory()
2465}
2466
2467func DefaultsFactory(props ...interface{}) android.Module {
2468 module := &Defaults{}
2469
2470 module.AddProperties(props...)
2471 module.AddProperties(
2472 &apexBundleProperties{},
2473 &apexTargetBundleProperties{},
Jooyung Hanf21c7972019-12-16 22:32:06 +09002474 &overridableProperties{},
Jiyong Park30ca9372019-02-07 16:27:23 +09002475 )
2476
2477 android.InitDefaultsModule(module)
2478 return module
2479}
Jiyong Park5d790c32019-11-15 18:40:32 +09002480
2481//
2482// OverrideApex
2483//
2484type OverrideApex struct {
2485 android.ModuleBase
2486 android.OverrideModuleBase
2487}
2488
2489func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2490 // All the overrides happen in the base module.
2491}
2492
2493// override_apex is used to create an apex module based on another apex module
2494// by overriding some of its properties.
2495func overrideApexFactory() android.Module {
2496 m := &OverrideApex{}
2497 m.AddProperties(&overridableProperties{})
2498
2499 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2500 android.InitOverrideModule(m)
2501 return m
2502}