blob: e8bb9b7acdab5703d02f4ead38dc1352d83af43c [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
Jiyong Parkc0ec6f92020-11-19 23:00:52 +090015// package apex implements build rules for creating the APEX files which are container for
16// lower-level system components. See https://source.android.com/devices/tech/ota/apex
Jiyong Park48ca7dc2018-10-10 14:01:00 +090017package apex
18
19import (
20 "fmt"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090021 "path/filepath"
Jiyong Parkab3ceb32018-10-10 14:05:29 +090022 "sort"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090023 "strings"
24
Jiyong Park48ca7dc2018-10-10 14:01:00 +090025 "github.com/google/blueprint"
Alex Light778127a2019-02-27 14:19:50 -080026 "github.com/google/blueprint/bootstrap"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090027 "github.com/google/blueprint/proptools"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070028
29 "android/soong/android"
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040030 "android/soong/bazel"
markchien2f59ec92020-09-02 16:23:38 +080031 "android/soong/bpf"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070032 "android/soong/cc"
33 prebuilt_etc "android/soong/etc"
Jiyong Park12a719c2021-01-07 15:31:24 +090034 "android/soong/filesystem"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070035 "android/soong/java"
36 "android/soong/python"
Jiyong Park99644e92020-11-17 22:21:02 +090037 "android/soong/rust"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070038 "android/soong/sh"
Jiyong Park48ca7dc2018-10-10 14:01:00 +090039)
40
Jiyong Park8e6d52f2020-11-19 14:37:47 +090041func init() {
Paul Duffin667893c2021-03-09 22:34:13 +000042 registerApexBuildComponents(android.InitRegistrationContext)
43}
Jiyong Park8e6d52f2020-11-19 14:37:47 +090044
Paul Duffin667893c2021-03-09 22:34:13 +000045func registerApexBuildComponents(ctx android.RegistrationContext) {
46 ctx.RegisterModuleType("apex", BundleFactory)
47 ctx.RegisterModuleType("apex_test", testApexBundleFactory)
48 ctx.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
49 ctx.RegisterModuleType("apex_defaults", defaultsFactory)
50 ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
51 ctx.RegisterModuleType("override_apex", overrideApexFactory)
52 ctx.RegisterModuleType("apex_set", apexSetFactory)
53
Paul Duffin5dda3e32021-05-05 14:13:27 +010054 ctx.PreArchMutators(registerPreArchMutators)
Paul Duffin667893c2021-03-09 22:34:13 +000055 ctx.PreDepsMutators(RegisterPreDepsMutators)
56 ctx.PostDepsMutators(RegisterPostDepsMutators)
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -040057
58 android.RegisterBp2BuildMutator("apex", ApexBundleBp2Build)
Jiyong Park8e6d52f2020-11-19 14:37:47 +090059}
60
Paul Duffin5dda3e32021-05-05 14:13:27 +010061func registerPreArchMutators(ctx android.RegisterMutatorsContext) {
62 ctx.TopDown("prebuilt_apex_module_creator", prebuiltApexModuleCreatorMutator).Parallel()
63}
64
Jiyong Park8e6d52f2020-11-19 14:37:47 +090065func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
66 ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
67 ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
68}
69
70func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
Paul Duffin949abc02020-12-08 10:34:30 +000071 ctx.TopDown("apex_info", apexInfoMutator).Parallel()
Jiyong Park8e6d52f2020-11-19 14:37:47 +090072 ctx.BottomUp("apex_unique", apexUniqueVariationsMutator).Parallel()
73 ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator).Parallel()
74 ctx.BottomUp("apex_test_for", apexTestForMutator).Parallel()
Paul Duffin28bf7ee2021-05-12 16:41:35 +010075 // Run mark_platform_availability before the apexMutator as the apexMutator needs to know whether
76 // it should create a platform variant.
77 ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel()
Jiyong Park8e6d52f2020-11-19 14:37:47 +090078 ctx.BottomUp("apex", apexMutator).Parallel()
79 ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel()
80 ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
Jiyong Park8e6d52f2020-11-19 14:37:47 +090081}
82
83type apexBundleProperties struct {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +090084 // Json manifest file describing meta info of this APEX bundle. Refer to
85 // system/apex/proto/apex_manifest.proto for the schema. Default: "apex_manifest.json"
Jiyong Park8e6d52f2020-11-19 14:37:47 +090086 Manifest *string `android:"path"`
87
Jiyong Parkc0ec6f92020-11-19 23:00:52 +090088 // AndroidManifest.xml file used for the zip container of this APEX bundle. If unspecified,
89 // a default one is automatically generated.
Jiyong Park8e6d52f2020-11-19 14:37:47 +090090 AndroidManifest *string `android:"path"`
91
Jiyong Parkc0ec6f92020-11-19 23:00:52 +090092 // Canonical name of this APEX bundle. Used to determine the path to the activated APEX on
93 // device (/apex/<apex_name>). If unspecified, follows the name property.
Jiyong Park8e6d52f2020-11-19 14:37:47 +090094 Apex_name *string
95
Jiyong Parkc0ec6f92020-11-19 23:00:52 +090096 // Determines the file contexts file for setting the security contexts to files in this APEX
97 // bundle. For platform APEXes, this should points to a file under /system/sepolicy Default:
98 // /system/sepolicy/apex/<module_name>_file_contexts.
Jiyong Park8e6d52f2020-11-19 14:37:47 +090099 File_contexts *string `android:"path"`
100
101 ApexNativeDependencies
102
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900103 Multilib apexMultilibProperties
104
Paul Duffin4b64ba02021-03-29 11:02:53 +0100105 // List of bootclasspath fragments that are embedded inside this APEX bundle.
106 Bootclasspath_fragments []string
107
satayev333a1732021-05-17 21:35:26 +0100108 // List of systemserverclasspath fragments that are embedded inside this APEX bundle.
109 Systemserverclasspath_fragments []string
110
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900111 // List of java libraries that are embedded inside this APEX bundle.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900112 Java_libs []string
113
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900114 // List of prebuilt files that are embedded inside this APEX bundle.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900115 Prebuilts []string
116
Paul Duffin3abc1742021-03-15 19:32:23 +0000117 // List of platform_compat_config files that are embedded inside this APEX bundle.
118 Compat_configs []string
119
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900120 // List of BPF programs inside this APEX bundle.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900121 Bpfs []string
122
Jiyong Park12a719c2021-01-07 15:31:24 +0900123 // List of filesystem images that are embedded inside this APEX bundle.
124 Filesystems []string
125
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900126 // The minimum SDK version that this APEX must support at minimum. This is usually set to
127 // the SDK version that the APEX was first introduced.
128 Min_sdk_version *string
129
130 // Whether this APEX is considered updatable or not. When set to true, this will enforce
131 // additional rules for making sure that the APEX is truly updatable. To be updatable,
132 // min_sdk_version should be set as well. This will also disable the size optimizations like
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +0000133 // symlinking to the system libs. Default is true.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900134 Updatable *bool
135
Jiyong Park9477c262021-06-22 20:23:05 +0900136 // Whether this APEX can use platform APIs or not. Can be set to true only when `updatable:
137 // false`. Default is false.
138 Platform_apis *bool
139
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900140 // Whether this APEX is installable to one of the partitions like system, vendor, etc.
141 // Default: true.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900142 Installable *bool
143
Mohammad Samiul Islam3cd005d2020-11-26 13:32:26 +0000144 // Whether this APEX can be compressed or not. Setting this property to false means this
145 // APEX will never be compressed. When set to true, APEX will be compressed if other
146 // conditions, e.g, target device needs to support APEX compression, are also fulfilled.
147 // Default: true.
148 Compressible *bool
149
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900150 // For native libraries and binaries, use the vendor variant instead of the core (platform)
151 // variant. Default is false. DO NOT use this for APEXes that are installed to the system or
152 // system_ext partition.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900153 Use_vendor *bool
154
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900155 // If set true, VNDK libs are considered as stable libs and are not included in this APEX.
156 // Should be only used in non-system apexes (e.g. vendor: true). Default is false.
157 Use_vndk_as_stable *bool
158
159 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
160 // `name#version` or `name` which is an alias for `name#current`. If left empty,
161 // `platform#current` is implied. This value affects all modules included in this APEX. In
162 // other words, they are also built with the SDKs specified here.
163 Uses_sdks []string
164
165 // The type of APEX to build. Controls what the APEX payload is. Either 'image', 'zip' or
166 // 'both'. When set to image, contents are stored in a filesystem image inside a zip
167 // container. When set to zip, contents are stored in a zip container directly. This type is
168 // mostly for host-side debugging. When set to both, the two types are both built. Default
169 // is 'image'.
170 Payload_type *string
171
172 // The type of filesystem to use when the payload_type is 'image'. Either 'ext4' or 'f2fs'.
173 // Default 'ext4'.
174 Payload_fs_type *string
175
176 // For telling the APEX to ignore special handling for system libraries such as bionic.
177 // Default is false.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900178 Ignore_system_library_special_case *bool
179
Nikita Ioffe9d9960f2021-06-09 19:43:46 +0100180 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
Nikita Ioffee261ae62021-06-16 18:15:03 +0100181 // Default value is true.
Nikita Ioffe9d9960f2021-06-09 19:43:46 +0100182 Generate_hashtree *bool
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900183
184 // Whenever apex_payload.img of the APEX should not be dm-verity signed. Should be only
185 // used in tests.
186 Test_only_unsigned_payload *bool
187
Mohammad Samiul Islama8008f92020-12-22 10:47:50 +0000188 // Whenever apex should be compressed, regardless of product flag used. Should be only
189 // used in tests.
190 Test_only_force_compression *bool
191
Martin Stjernholmbfffae72021-06-24 14:37:13 +0100192 // Canonical name of this APEX bundle. Used to determine the path to the
193 // activated APEX on device (i.e. /apex/<apexVariationName>), and used for the
194 // apex mutator variations. For override_apex modules, this is the name of the
195 // overridden base module.
196 ApexVariationName string `blueprint:"mutated"`
197
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900198 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900199
200 // List of sanitizer names that this APEX is enabled for
201 SanitizerNames []string `blueprint:"mutated"`
202
203 PreventInstall bool `blueprint:"mutated"`
204
205 HideFromMake bool `blueprint:"mutated"`
206
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900207 // Internal package method for this APEX. When payload_type is image, this can be either
208 // imageApex or flattenedApex depending on Config.FlattenApex(). When payload_type is zip,
209 // this becomes zipApex.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900210 ApexType apexPackaging `blueprint:"mutated"`
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900211}
212
213type ApexNativeDependencies struct {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900214 // List of native libraries that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900215 Native_shared_libs []string
216
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900217 // List of JNI libraries that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900218 Jni_libs []string
219
Jiyong Park99644e92020-11-17 22:21:02 +0900220 // List of rust dyn libraries
221 Rust_dyn_libs []string
222
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900223 // List of native executables that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900224 Binaries []string
225
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900226 // List of native tests that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900227 Tests []string
Jiyong Park06711462021-02-15 17:54:43 +0900228
229 // List of filesystem images that are embedded inside this APEX bundle.
230 Filesystems []string
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900231}
232
233type apexMultilibProperties struct {
234 // Native dependencies whose compile_multilib is "first"
235 First ApexNativeDependencies
236
237 // Native dependencies whose compile_multilib is "both"
238 Both ApexNativeDependencies
239
240 // Native dependencies whose compile_multilib is "prefer32"
241 Prefer32 ApexNativeDependencies
242
243 // Native dependencies whose compile_multilib is "32"
244 Lib32 ApexNativeDependencies
245
246 // Native dependencies whose compile_multilib is "64"
247 Lib64 ApexNativeDependencies
248}
249
250type apexTargetBundleProperties struct {
251 Target struct {
252 // Multilib properties only for android.
253 Android struct {
254 Multilib apexMultilibProperties
255 }
256
257 // Multilib properties only for host.
258 Host struct {
259 Multilib apexMultilibProperties
260 }
261
262 // Multilib properties only for host linux_bionic.
263 Linux_bionic struct {
264 Multilib apexMultilibProperties
265 }
266
267 // Multilib properties only for host linux_glibc.
268 Linux_glibc struct {
269 Multilib apexMultilibProperties
270 }
271 }
272}
273
Jiyong Park59140302020-12-14 18:44:04 +0900274type apexArchBundleProperties struct {
275 Arch struct {
276 Arm struct {
277 ApexNativeDependencies
278 }
279 Arm64 struct {
280 ApexNativeDependencies
281 }
282 X86 struct {
283 ApexNativeDependencies
284 }
285 X86_64 struct {
286 ApexNativeDependencies
287 }
288 }
289}
290
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900291// These properties can be used in override_apex to override the corresponding properties in the
292// base apex.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900293type overridableProperties struct {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900294 // List of APKs that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900295 Apps []string
296
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900297 // List of runtime resource overlays (RROs) that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900298 Rros []string
299
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900300 // Names of modules to be overridden. Listed modules can only be other binaries (in Make or
301 // Soong). This does not completely prevent installation of the overridden binaries, but if
302 // both binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will
303 // be removed from PRODUCT_PACKAGES.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900304 Overrides []string
305
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900306 // Logging parent value.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900307 Logging_parent string
308
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900309 // Apex Container package name. Override value for attribute package:name in
310 // AndroidManifest.xml
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900311 Package_name string
312
313 // A txt file containing list of files that are allowed to be included in this APEX.
314 Allowed_files *string `android:"path"`
Jaewoong Jung4cfdf7d2021-04-20 16:21:24 -0700315
316 // Name of the apex_key module that provides the private key to sign this APEX bundle.
317 Key *string
318
319 // Specifies the certificate and the private key to sign the zip container of this APEX. If
320 // this is "foo", foo.x509.pem and foo.pk8 under PRODUCT_DEFAULT_DEV_CERTIFICATE are used
321 // as the certificate and the private key, respectively. If this is ":module", then the
322 // certificate and the private key are provided from the android_app_certificate module
323 // named "module".
324 Certificate *string
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900325}
326
327type apexBundle struct {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900328 // Inherited structs
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900329 android.ModuleBase
330 android.DefaultableModuleBase
331 android.OverridableModuleBase
332 android.SdkBase
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400333 android.BazelModuleBase
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900334
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900335 // Properties
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900336 properties apexBundleProperties
337 targetProperties apexTargetBundleProperties
Jiyong Park59140302020-12-14 18:44:04 +0900338 archProperties apexArchBundleProperties
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900339 overridableProperties overridableProperties
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900340 vndkProperties apexVndkProperties // only for apex_vndk modules
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900341
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900342 ///////////////////////////////////////////////////////////////////////////////////////////
343 // Inputs
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900344
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900345 // Keys for apex_paylaod.img
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800346 publicKeyFile android.Path
347 privateKeyFile android.Path
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900348
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900349 // Cert/priv-key for the zip container
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800350 containerCertificateFile android.Path
351 containerPrivateKeyFile android.Path
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900352
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900353 // Flags for special variants of APEX
354 testApex bool
355 vndkApex bool
356 artApex bool
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900357
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900358 // Tells whether this variant of the APEX bundle is the primary one or not. Only the primary
359 // one gets installed to the device.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900360 primaryApexType bool
361
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900362 // Suffix of module name in Android.mk ".flattened", ".apex", ".zipapex", or ""
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900363 suffix string
364
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900365 // File system type of apex_payload.img
366 payloadFsType fsType
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900367
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900368 // Whether to create symlink to the system file instead of having a file inside the apex or
369 // not
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900370 linkToSystemLib bool
371
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900372 // List of files to be included in this APEX. This is filled in the first part of
373 // GenerateAndroidBuildActions.
374 filesInfo []apexFile
375
376 // List of other module names that should be installed when this APEX gets installed.
377 requiredDeps []string
378
379 ///////////////////////////////////////////////////////////////////////////////////////////
380 // Outputs (final and intermediates)
381
382 // Processed apex manifest in JSONson format (for Q)
383 manifestJsonOut android.WritablePath
384
385 // Processed apex manifest in PB format (for R+)
386 manifestPbOut android.WritablePath
387
388 // Processed file_contexts files
389 fileContexts android.WritablePath
390
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900391 // Struct holding the merged notice file paths in different formats
392 mergedNotices android.NoticeOutputs
393
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900394 // The built APEX file. This is the main product.
395 outputFile android.WritablePath
396
397 // The built APEX file in app bundle format. This file is not directly installed to the
398 // device. For an APEX, multiple app bundles are created each of which is for a specific ABI
399 // like arm, arm64, x86, etc. Then they are processed again (outside of the Android build
400 // system) to be merged into a single app bundle file that Play accepts. See
401 // vendor/google/build/build_unbundled_mainline_module.sh for more detail.
402 bundleModuleFile android.WritablePath
403
404 // Target path to install this APEX. Usually out/target/product/<device>/<partition>/apex.
405 installDir android.InstallPath
406
407 // List of commands to create symlinks for backward compatibility. These commands will be
408 // attached as LOCAL_POST_INSTALL_CMD to apex package itself (for unflattened build) or
409 // apex_manifest (for flattened build) so that compat symlinks are always installed
410 // regardless of TARGET_FLATTEN_APEX setting.
411 compatSymlinks []string
412
413 // Text file having the list of individual files that are included in this APEX. Used for
414 // debugging purpose.
415 installedFilesFile android.WritablePath
416
417 // List of module names that this APEX is including (to be shown via *-deps-info target).
418 // Used for debugging purpose.
419 android.ApexBundleDepsInfo
420
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900421 // Optional list of lint report zip files for apexes that contain java or app modules
422 lintReports android.Paths
423
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900424 prebuiltFileToDelete string
sophiezc80a2b32020-11-12 16:39:19 +0000425
Mohammad Samiul Islam3cd005d2020-11-26 13:32:26 +0000426 isCompressed bool
427
sophiezc80a2b32020-11-12 16:39:19 +0000428 // Path of API coverage generate file
sophiez6bde0b52021-01-09 01:03:42 +0000429 apisUsedByModuleFile android.ModuleOutPath
430 apisBackedByModuleFile android.ModuleOutPath
braleeb0c1f0c2021-06-07 22:49:13 +0800431
432 // Collect the module directory for IDE info in java/jdeps.go.
433 modulePaths []string
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900434}
435
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900436// apexFileClass represents a type of file that can be included in APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900437type apexFileClass int
438
Jooyung Han72bd2f82019-10-23 16:46:38 +0900439const (
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900440 app apexFileClass = iota
441 appSet
442 etc
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900443 goBinary
444 javaSharedLib
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900445 nativeExecutable
446 nativeSharedLib
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900447 nativeTest
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900448 pyBinary
449 shBinary
Jooyung Han72bd2f82019-10-23 16:46:38 +0900450)
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900451
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900452// apexFile represents a file in an APEX bundle. This is created during the first half of
453// GenerateAndroidBuildActions by traversing the dependencies of the APEX. Then in the second half
454// of the function, this is used to create commands that copies the files into a staging directory,
455// where they are packaged into the APEX file. This struct is also used for creating Make modules
456// for each of the files in case when the APEX is flattened.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900457type apexFile struct {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900458 // buildFile is put in the installDir inside the APEX.
459 builtFile android.Path
460 noticeFiles android.Paths
461 installDir string
462 customStem string
463 symlinks []string // additional symlinks
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900464
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900465 // Info for Android.mk Module name of `module` in AndroidMk. Note the generated AndroidMk
466 // module for apexFile is named something like <AndroidMk module name>.<apex name>[<apex
467 // suffix>]
468 androidMkModuleName string // becomes LOCAL_MODULE
469 class apexFileClass // becomes LOCAL_MODULE_CLASS
470 moduleDir string // becomes LOCAL_PATH
471 requiredModuleNames []string // becomes LOCAL_REQUIRED_MODULES
472 targetRequiredModuleNames []string // becomes LOCAL_TARGET_REQUIRED_MODULES
473 hostRequiredModuleNames []string // becomes LOCAL_HOST_REQUIRED_MODULES
474 dataPaths []android.DataPath // becomes LOCAL_TEST_DATA
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900475
476 jacocoReportClassesFile android.Path // only for javalibs and apps
477 lintDepSets java.LintDepSets // only for javalibs and apps
478 certificate java.Certificate // only for apps
479 overriddenPackageName string // only for apps
480
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900481 transitiveDep bool
482 isJniLib bool
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900483
Jiyong Park57621b22021-01-20 20:33:11 +0900484 multilib string
485
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900486 // TODO(jiyong): remove this
487 module android.Module
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900488}
489
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900490// TODO(jiyong): shorten the arglist using an option struct
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900491func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile {
492 ret := apexFile{
493 builtFile: builtFile,
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900494 installDir: installDir,
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900495 androidMkModuleName: androidMkModuleName,
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900496 class: class,
497 module: module,
498 }
499 if module != nil {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900500 ret.noticeFiles = module.NoticeFiles()
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900501 ret.moduleDir = ctx.OtherModuleDir(module)
502 ret.requiredModuleNames = module.RequiredModuleNames()
503 ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
504 ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
Jiyong Park57621b22021-01-20 20:33:11 +0900505 ret.multilib = module.Target().Arch.ArchType.Multilib
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900506 }
507 return ret
508}
509
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900510func (af *apexFile) ok() bool {
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900511 return af.builtFile != nil && af.builtFile.String() != ""
512}
513
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900514// apexRelativePath returns the relative path of the given path from the install directory of this
515// apexFile.
516// TODO(jiyong): rename this
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900517func (af *apexFile) apexRelativePath(path string) string {
518 return filepath.Join(af.installDir, path)
519}
520
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900521// path returns path of this apex file relative to the APEX root
522func (af *apexFile) path() string {
523 return af.apexRelativePath(af.stem())
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900524}
525
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900526// stem returns the base filename of this apex file
527func (af *apexFile) stem() string {
528 if af.customStem != "" {
529 return af.customStem
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900530 }
531 return af.builtFile.Base()
532}
533
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900534// symlinkPaths returns paths of the symlinks (if any) relative to the APEX root
535func (af *apexFile) symlinkPaths() []string {
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900536 var ret []string
537 for _, symlink := range af.symlinks {
538 ret = append(ret, af.apexRelativePath(symlink))
539 }
540 return ret
541}
542
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900543// availableToPlatform tests whether this apexFile is from a module that can be installed to the
544// platform.
545func (af *apexFile) availableToPlatform() bool {
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900546 if af.module == nil {
547 return false
548 }
549 if am, ok := af.module.(android.ApexModule); ok {
550 return am.AvailableFor(android.AvailableToPlatform)
551 }
552 return false
553}
554
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900555////////////////////////////////////////////////////////////////////////////////////////////////////
556// Mutators
557//
558// Brief description about mutators for APEX. The following three mutators are the most important
559// ones.
560//
561// 1) DepsMutator: from the properties like native_shared_libs, java_libs, etc., modules are added
562// to the (direct) dependencies of this APEX bundle.
563//
Paul Duffin949abc02020-12-08 10:34:30 +0000564// 2) apexInfoMutator: this is a post-deps mutator, so runs after DepsMutator. Its goal is to
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900565// collect modules that are direct and transitive dependencies of each APEX bundle. The collected
566// modules are marked as being included in the APEX via BuildForApex().
567//
Paul Duffin949abc02020-12-08 10:34:30 +0000568// 3) apexMutator: this is a post-deps mutator that runs after apexInfoMutator. For each module that
569// are marked by the apexInfoMutator, apex variations are created using CreateApexVariations().
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900570
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900571type dependencyTag struct {
572 blueprint.BaseDependencyTag
573 name string
574
575 // Determines if the dependent will be part of the APEX payload. Can be false for the
576 // dependencies to the signing key module, etc.
577 payload bool
Paul Duffin8c535da2021-03-17 14:51:03 +0000578
579 // True if the dependent can only be a source module, false if a prebuilt module is a suitable
580 // replacement. This is needed because some prebuilt modules do not provide all the information
581 // needed by the apex.
582 sourceOnly bool
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900583}
584
Paul Duffin8c535da2021-03-17 14:51:03 +0000585func (d dependencyTag) ReplaceSourceWithPrebuilt() bool {
586 return !d.sourceOnly
587}
588
589var _ android.ReplaceSourceWithPrebuilt = &dependencyTag{}
590
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900591var (
Paul Duffin0b817782021-03-17 15:02:19 +0000592 androidAppTag = dependencyTag{name: "androidApp", payload: true}
593 bpfTag = dependencyTag{name: "bpf", payload: true}
594 certificateTag = dependencyTag{name: "certificate"}
595 executableTag = dependencyTag{name: "executable", payload: true}
596 fsTag = dependencyTag{name: "filesystem", payload: true}
Paul Duffin94f19632021-04-20 12:40:07 +0100597 bcpfTag = dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true}
satayev333a1732021-05-17 21:35:26 +0100598 sscpfTag = dependencyTag{name: "systemserverclasspathFragment", payload: true, sourceOnly: true}
Paul Duffin1b29e002021-03-16 15:06:54 +0000599 compatConfigTag = dependencyTag{name: "compatConfig", payload: true, sourceOnly: true}
Paul Duffin0b817782021-03-17 15:02:19 +0000600 javaLibTag = dependencyTag{name: "javaLib", payload: true}
601 jniLibTag = dependencyTag{name: "jniLib", payload: true}
602 keyTag = dependencyTag{name: "key"}
603 prebuiltTag = dependencyTag{name: "prebuilt", payload: true}
604 rroTag = dependencyTag{name: "rro", payload: true}
605 sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
606 testForTag = dependencyTag{name: "test for"}
607 testTag = dependencyTag{name: "test", payload: true}
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900608)
609
610// TODO(jiyong): shorten this function signature
611func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeModules ApexNativeDependencies, target android.Target, imageVariation string) {
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900612 binVariations := target.Variations()
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900613 libVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
Jiyong Park99644e92020-11-17 22:21:02 +0900614 rustLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "rust_libraries", Variation: "dylib"})
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900615
616 if ctx.Device() {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900617 binVariations = append(binVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation})
Jiyong Parkf2cc1b72020-12-09 00:20:45 +0900618 libVariations = append(libVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation})
619 rustLibVariations = append(rustLibVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation})
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900620 }
621
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900622 // Use *FarVariation* to be able to depend on modules having conflicting variations with
623 // this module. This is required since arch variant of an APEX bundle is 'common' but it is
624 // 'arm' or 'arm64' for native shared libs.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900625 ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900626 ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900627 ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...)
628 ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...)
Jiyong Park99644e92020-11-17 22:21:02 +0900629 ctx.AddFarVariationDependencies(rustLibVariations, sharedLibTag, nativeModules.Rust_dyn_libs...)
Jiyong Park06711462021-02-15 17:54:43 +0900630 ctx.AddFarVariationDependencies(target.Variations(), fsTag, nativeModules.Filesystems...)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900631}
632
633func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900634 if ctx.Device() {
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900635 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
636 } else {
637 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
638 if ctx.Os().Bionic() {
639 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
640 } else {
641 proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
642 }
643 }
644}
645
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900646// getImageVariation returns the image variant name for this apexBundle. In most cases, it's simply
647// android.CoreVariation, but gets complicated for the vendor APEXes and the VNDK APEX.
648func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) string {
649 deviceConfig := ctx.DeviceConfig()
650 if a.vndkApex {
651 return cc.VendorVariationPrefix + a.vndkVersion(deviceConfig)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900652 }
653
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900654 var prefix string
655 var vndkVersion string
656 if deviceConfig.VndkVersion() != "" {
657 if proptools.Bool(a.properties.Use_vendor) {
658 prefix = cc.VendorVariationPrefix
659 vndkVersion = deviceConfig.PlatformVndkVersion()
660 } else if a.SocSpecific() || a.DeviceSpecific() {
661 prefix = cc.VendorVariationPrefix
662 vndkVersion = deviceConfig.VndkVersion()
663 } else if a.ProductSpecific() {
664 prefix = cc.ProductVariationPrefix
665 vndkVersion = deviceConfig.ProductVndkVersion()
666 }
667 }
668 if vndkVersion == "current" {
669 vndkVersion = deviceConfig.PlatformVndkVersion()
670 }
671 if vndkVersion != "" {
672 return prefix + vndkVersion
673 }
674
675 return android.CoreVariation // The usual case
676}
677
678func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
679 // TODO(jiyong): move this kind of checks to GenerateAndroidBuildActions?
680 checkUseVendorProperty(ctx, a)
681
682 // apexBundle is a multi-arch targets module. Arch variant of apexBundle is set to 'common'.
683 // arch-specific targets are enabled by the compile_multilib setting of the apex bundle. For
684 // each target os/architectures, appropriate dependencies are selected by their
685 // target.<os>.multilib.<type> groups and are added as (direct) dependencies.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900686 targets := ctx.MultiTargets()
687 config := ctx.DeviceConfig()
688 imageVariation := a.getImageVariation(ctx)
689
690 a.combineProperties(ctx)
691
692 has32BitTarget := false
693 for _, target := range targets {
694 if target.Arch.ArchType.Multilib == "lib32" {
695 has32BitTarget = true
Paul Duffin7d74e7b2020-03-06 12:30:13 +0000696 }
697 }
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900698 for i, target := range targets {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900699 // Don't include artifacts for the host cross targets because there is no way for us
700 // to run those artifacts natively on host
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900701 if target.HostCross {
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900702 continue
703 }
Paul Duffin7d74e7b2020-03-06 12:30:13 +0000704
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900705 var depsList []ApexNativeDependencies
Paul Duffin7d74e7b2020-03-06 12:30:13 +0000706
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900707 // Add native modules targeting both ABIs. When multilib.* is omitted for
708 // native_shared_libs/jni_libs/tests, it implies multilib.both
709 depsList = append(depsList, a.properties.Multilib.Both)
710 depsList = append(depsList, ApexNativeDependencies{
711 Native_shared_libs: a.properties.Native_shared_libs,
712 Tests: a.properties.Tests,
713 Jni_libs: a.properties.Jni_libs,
714 Binaries: nil,
715 })
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900716
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900717 // Add native modules targeting the first ABI When multilib.* is omitted for
718 // binaries, it implies multilib.first
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900719 isPrimaryAbi := i == 0
720 if isPrimaryAbi {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900721 depsList = append(depsList, a.properties.Multilib.First)
722 depsList = append(depsList, ApexNativeDependencies{
723 Native_shared_libs: nil,
724 Tests: nil,
725 Jni_libs: nil,
726 Binaries: a.properties.Binaries,
727 })
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900728 }
729
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900730 // Add native modules targeting either 32-bit or 64-bit ABI
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900731 switch target.Arch.ArchType.Multilib {
732 case "lib32":
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900733 depsList = append(depsList, a.properties.Multilib.Lib32)
734 depsList = append(depsList, a.properties.Multilib.Prefer32)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900735 case "lib64":
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900736 depsList = append(depsList, a.properties.Multilib.Lib64)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900737 if !has32BitTarget {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900738 depsList = append(depsList, a.properties.Multilib.Prefer32)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900739 }
740 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900741
Jiyong Park59140302020-12-14 18:44:04 +0900742 // Add native modules targeting a specific arch variant
743 switch target.Arch.ArchType {
744 case android.Arm:
745 depsList = append(depsList, a.archProperties.Arch.Arm.ApexNativeDependencies)
746 case android.Arm64:
747 depsList = append(depsList, a.archProperties.Arch.Arm64.ApexNativeDependencies)
748 case android.X86:
749 depsList = append(depsList, a.archProperties.Arch.X86.ApexNativeDependencies)
750 case android.X86_64:
751 depsList = append(depsList, a.archProperties.Arch.X86_64.ApexNativeDependencies)
752 default:
753 panic(fmt.Errorf("unsupported arch %v\n", ctx.Arch().ArchType))
754 }
755
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900756 for _, d := range depsList {
757 addDependenciesForNativeModules(ctx, d, target, imageVariation)
758 }
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900759 }
760
Martin Stjernholmdf298b32021-05-21 20:57:29 +0100761 if prebuilts := a.properties.Prebuilts; len(prebuilts) > 0 {
762 // For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device)
763 // regardless of the TARGET_PREFER_* setting. See b/144532908
764 archForPrebuiltEtc := config.Arches()[0]
765 for _, arch := range config.Arches() {
766 // Prefer 64-bit arch if there is any
767 if arch.ArchType.Multilib == "lib64" {
768 archForPrebuiltEtc = arch
769 break
770 }
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900771 }
Martin Stjernholmdf298b32021-05-21 20:57:29 +0100772 ctx.AddFarVariationDependencies([]blueprint.Variation{
773 {Mutator: "os", Variation: ctx.Os().String()},
774 {Mutator: "arch", Variation: archForPrebuiltEtc.String()},
775 }, prebuiltTag, prebuilts...)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900776 }
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900777
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900778 // Common-arch dependencies come next
779 commonVariation := ctx.Config().AndroidCommonTarget.Variations()
Paul Duffin94f19632021-04-20 12:40:07 +0100780 ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...)
satayev333a1732021-05-17 21:35:26 +0100781 ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments...)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900782 ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...)
783 ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.properties.Bpfs...)
Jiyong Park12a719c2021-01-07 15:31:24 +0900784 ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
Paul Duffin0b817782021-03-17 15:02:19 +0000785 ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900786
Ulya Trafimovicha4a1c4e2021-01-15 18:40:04 +0000787 if a.artApex {
788 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
789 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
790 ctx.AddFarVariationDependencies(commonVariation, javaLibTag, "jacocoagent")
791 }
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900792 }
793
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900794 // Marks that this APEX (in fact all the modules in it) has to be built with the given SDKs.
795 // This field currently isn't used.
796 // TODO(jiyong): consider dropping this feature
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900797 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
798 if len(a.properties.Uses_sdks) > 0 {
799 sdkRefs := []android.SdkRef{}
800 for _, str := range a.properties.Uses_sdks {
801 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
802 sdkRefs = append(sdkRefs, parsed)
803 }
804 a.BuildWithSdks(sdkRefs)
Andrei Onea115e7e72020-06-05 21:14:03 +0100805 }
806}
807
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900808// DepsMutator for the overridden properties.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900809func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
810 if a.overridableProperties.Allowed_files != nil {
811 android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files)
Andrei Onea115e7e72020-06-05 21:14:03 +0100812 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900813
814 commonVariation := ctx.Config().AndroidCommonTarget.Variations()
815 ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...)
816 ctx.AddFarVariationDependencies(commonVariation, rroTag, a.overridableProperties.Rros...)
Jaewoong Jung4cfdf7d2021-04-20 16:21:24 -0700817
818 // Dependencies for signing
819 if String(a.overridableProperties.Key) == "" {
820 ctx.PropertyErrorf("key", "missing")
821 return
822 }
823 ctx.AddDependency(ctx.Module(), keyTag, String(a.overridableProperties.Key))
824
825 cert := android.SrcIsModule(a.getCertString(ctx))
826 if cert != "" {
827 ctx.AddDependency(ctx.Module(), certificateTag, cert)
828 // empty cert is not an error. Cert and private keys will be directly found under
829 // PRODUCT_DEFAULT_DEV_CERTIFICATE
830 }
Andrei Onea115e7e72020-06-05 21:14:03 +0100831}
832
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900833type ApexBundleInfo struct {
834 Contents *android.ApexContents
Andrei Onea115e7e72020-06-05 21:14:03 +0100835}
836
Paul Duffin949abc02020-12-08 10:34:30 +0000837var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_info")
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900838
Paul Duffina7d6a892020-12-07 17:39:59 +0000839var _ ApexInfoMutator = (*apexBundle)(nil)
840
Martin Stjernholmbfffae72021-06-24 14:37:13 +0100841func (a *apexBundle) ApexVariationName() string {
842 return a.properties.ApexVariationName
843}
844
Paul Duffina7d6a892020-12-07 17:39:59 +0000845// ApexInfoMutator is responsible for collecting modules that need to have apex variants. They are
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900846// identified by doing a graph walk starting from an apexBundle. Basically, all the (direct and
847// indirect) dependencies are collected. But a few types of modules that shouldn't be included in
848// the apexBundle (e.g. stub libraries) are not collected. Note that a single module can be depended
849// on by multiple apexBundles. In that case, the module is collected for all of the apexBundles.
Paul Duffin949abc02020-12-08 10:34:30 +0000850//
851// For each dependency between an apex and an ApexModule an ApexInfo object describing the apex
852// is passed to that module's BuildForApex(ApexInfo) method which collates them all in a list.
853// The apexMutator uses that list to create module variants for the apexes to which it belongs.
854// The relationship between module variants and apexes is not one-to-one as variants will be
855// shared between compatible apexes.
Paul Duffina7d6a892020-12-07 17:39:59 +0000856func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
Jooyung Handf78e212020-07-22 15:54:47 +0900857
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900858 // The VNDK APEX is special. For the APEX, the membership is described in a very different
859 // way. There is no dependency from the VNDK APEX to the VNDK libraries. Instead, VNDK
860 // libraries are self-identified by their vndk.enabled properties. There is no need to run
861 // this mutator for the APEX as nothing will be collected. So, let's return fast.
862 if a.vndkApex {
863 return
864 }
865
866 // Special casing for APEXes on non-system (e.g., vendor, odm, etc.) partitions. They are
867 // provided with a property named use_vndk_as_stable, which when set to true doesn't collect
868 // VNDK libraries as transitive dependencies. This option is useful for reducing the size of
869 // the non-system APEXes because the VNDK libraries won't be included (and duped) in the
870 // APEX, but shared across APEXes via the VNDK APEX.
Jooyung Handf78e212020-07-22 15:54:47 +0900871 useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface())
872 excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable)
873 if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) {
874 mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes")
875 return
876 }
877
Colin Cross56a83212020-09-15 18:30:11 -0700878 continueApexDepsWalk := func(child, parent android.Module) bool {
Jooyung Han698dd9f2020-07-22 15:17:19 +0900879 am, ok := child.(android.ApexModule)
880 if !ok || !am.CanHaveApexVariants() {
881 return false
Jiyong Parkf760cae2020-02-12 07:53:12 +0900882 }
Paul Duffin573989d2021-03-17 13:25:29 +0000883 depTag := mctx.OtherModuleDependencyTag(child)
884
885 // Check to see if the tag always requires that the child module has an apex variant for every
886 // apex variant of the parent module. If it does not then it is still possible for something
887 // else, e.g. the DepIsInSameApex(...) method to decide that a variant is required.
888 if required, ok := depTag.(android.AlwaysRequireApexVariantTag); ok && required.AlwaysRequireApexVariant() {
889 return true
890 }
Paul Duffin4c3e8e22021-03-18 15:41:29 +0000891 if !android.IsDepInSameApex(mctx, parent, child) {
Jooyung Han698dd9f2020-07-22 15:17:19 +0900892 return false
893 }
Jooyung Handf78e212020-07-22 15:54:47 +0900894 if excludeVndkLibs {
895 if c, ok := child.(*cc.Module); ok && c.IsVndk() {
896 return false
897 }
898 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900899 // By default, all the transitive dependencies are collected, unless filtered out
900 // above.
Colin Cross56a83212020-09-15 18:30:11 -0700901 return true
902 }
903
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900904 // Records whether a certain module is included in this apexBundle via direct dependency or
905 // inndirect dependency.
906 contents := make(map[string]android.ApexMembership)
Colin Cross56a83212020-09-15 18:30:11 -0700907 mctx.WalkDeps(func(child, parent android.Module) bool {
908 if !continueApexDepsWalk(child, parent) {
909 return false
910 }
Jooyung Han698dd9f2020-07-22 15:17:19 +0900911 // If the parent is apexBundle, this child is directly depended.
912 _, directDep := parent.(*apexBundle)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900913 depName := mctx.OtherModuleName(child)
Colin Cross56a83212020-09-15 18:30:11 -0700914 contents[depName] = contents[depName].Add(directDep)
915 return true
916 })
917
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900918 // The membership information is saved for later access
Jiyong Parke4758ed2020-11-18 01:34:22 +0900919 apexContents := android.NewApexContents(contents)
Colin Cross56a83212020-09-15 18:30:11 -0700920 mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{
921 Contents: apexContents,
922 })
923
Jooyung Haned124c32021-01-26 11:43:46 +0900924 minSdkVersion := a.minSdkVersion(mctx)
925 // When min_sdk_version is not set, the apex is built against FutureApiLevel.
926 if minSdkVersion.IsNone() {
927 minSdkVersion = android.FutureApiLevel
928 }
929
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900930 // This is the main part of this mutator. Mark the collected dependencies that they need to
931 // be built for this apexBundle.
Jiyong Park78349b52021-05-12 17:13:56 +0900932
Martin Stjernholmbfffae72021-06-24 14:37:13 +0100933 apexVariationName := proptools.StringDefault(a.properties.Apex_name, mctx.ModuleName()) // could be com.android.foo
934 a.properties.ApexVariationName = apexVariationName
Colin Cross56a83212020-09-15 18:30:11 -0700935 apexInfo := android.ApexInfo{
Martin Stjernholmbfffae72021-06-24 14:37:13 +0100936 ApexVariationName: apexVariationName,
Jiyong Park4eab21d2021-04-15 15:17:54 +0900937 MinSdkVersion: minSdkVersion,
Colin Cross56a83212020-09-15 18:30:11 -0700938 RequiredSdks: a.RequiredSdks(),
939 Updatable: a.Updatable(),
Jiyong Park9477c262021-06-22 20:23:05 +0900940 UsePlatformApis: a.UsePlatformApis(),
Martin Stjernholmbfffae72021-06-24 14:37:13 +0100941 InApexVariants: []string{apexVariationName},
942 InApexModules: []string{a.Name()}, // could be com.mycompany.android.foo
Colin Cross56a83212020-09-15 18:30:11 -0700943 ApexContents: []*android.ApexContents{apexContents},
944 }
Colin Cross56a83212020-09-15 18:30:11 -0700945 mctx.WalkDeps(func(child, parent android.Module) bool {
946 if !continueApexDepsWalk(child, parent) {
947 return false
948 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900949 child.(android.ApexModule).BuildForApex(apexInfo) // leave a mark!
Jooyung Han698dd9f2020-07-22 15:17:19 +0900950 return true
Jiyong Parkf760cae2020-02-12 07:53:12 +0900951 })
Jiyong Park48ca7dc2018-10-10 14:01:00 +0900952}
953
Paul Duffina7d6a892020-12-07 17:39:59 +0000954type ApexInfoMutator interface {
Martin Stjernholmbfffae72021-06-24 14:37:13 +0100955 // ApexVariationName returns the name of the APEX variation to use in the apex
956 // mutator etc. It is the same name as ApexInfo.ApexVariationName.
957 ApexVariationName() string
958
Paul Duffina7d6a892020-12-07 17:39:59 +0000959 // ApexInfoMutator implementations must call BuildForApex(ApexInfo) on any modules that are
960 // depended upon by an apex and which require an apex specific variant.
961 ApexInfoMutator(android.TopDownMutatorContext)
962}
963
964// apexInfoMutator delegates the work of identifying which modules need an ApexInfo and apex
965// specific variant to modules that support the ApexInfoMutator.
966func apexInfoMutator(mctx android.TopDownMutatorContext) {
967 if !mctx.Module().Enabled() {
968 return
969 }
970
971 if a, ok := mctx.Module().(ApexInfoMutator); ok {
972 a.ApexInfoMutator(mctx)
973 return
974 }
975}
976
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900977// apexUniqueVariationsMutator checks if any dependencies use unique apex variations. If so, use
978// unique apex variations for this module. See android/apex.go for more about unique apex variant.
979// TODO(jiyong): move this to android/apex.go?
Colin Crossaede88c2020-08-11 12:17:01 -0700980func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
981 if !mctx.Module().Enabled() {
982 return
983 }
984 if am, ok := mctx.Module().(android.ApexModule); ok {
Colin Cross56a83212020-09-15 18:30:11 -0700985 android.UpdateUniqueApexVariationsForDeps(mctx, am)
986 }
987}
988
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900989// apexTestForDepsMutator checks if this module is a test for an apex. If so, add a dependency on
990// the apex in order to retrieve its contents later.
991// TODO(jiyong): move this to android/apex.go?
Colin Cross56a83212020-09-15 18:30:11 -0700992func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
993 if !mctx.Module().Enabled() {
994 return
995 }
Colin Cross56a83212020-09-15 18:30:11 -0700996 if am, ok := mctx.Module().(android.ApexModule); ok {
997 if testFor := am.TestFor(); len(testFor) > 0 {
998 mctx.AddFarVariationDependencies([]blueprint.Variation{
999 {Mutator: "os", Variation: am.Target().OsVariation()},
1000 {"arch", "common"},
1001 }, testForTag, testFor...)
1002 }
1003 }
1004}
1005
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001006// TODO(jiyong): move this to android/apex.go?
Colin Cross56a83212020-09-15 18:30:11 -07001007func apexTestForMutator(mctx android.BottomUpMutatorContext) {
1008 if !mctx.Module().Enabled() {
1009 return
1010 }
Colin Cross56a83212020-09-15 18:30:11 -07001011 if _, ok := mctx.Module().(android.ApexModule); ok {
1012 var contents []*android.ApexContents
1013 for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) {
1014 abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo)
1015 contents = append(contents, abInfo.Contents)
1016 }
1017 mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{
1018 ApexContents: contents,
1019 })
Colin Crossaede88c2020-08-11 12:17:01 -07001020 }
1021}
1022
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001023// markPlatformAvailability marks whether or not a module can be available to platform. A module
1024// cannot be available to platform if 1) it is explicitly marked as not available (i.e.
1025// "//apex_available:platform" is absent) or 2) it depends on another module that isn't (or can't
1026// be) available to platform
1027// TODO(jiyong): move this to android/apex.go?
Jiyong Park89e850a2020-04-07 16:37:39 +09001028func markPlatformAvailability(mctx android.BottomUpMutatorContext) {
1029 // Host and recovery are not considered as platform
1030 if mctx.Host() || mctx.Module().InstallInRecovery() {
1031 return
1032 }
1033
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001034 am, ok := mctx.Module().(android.ApexModule)
1035 if !ok {
1036 return
1037 }
Jiyong Park89e850a2020-04-07 16:37:39 +09001038
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001039 availableToPlatform := am.AvailableFor(android.AvailableToPlatform)
Jiyong Park89e850a2020-04-07 16:37:39 +09001040
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001041 // If any of the dep is not available to platform, this module is also considered as being
1042 // not available to platform even if it has "//apex_available:platform"
1043 mctx.VisitDirectDeps(func(child android.Module) {
Paul Duffin4c3e8e22021-03-18 15:41:29 +00001044 if !android.IsDepInSameApex(mctx, am, child) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001045 // if the dependency crosses apex boundary, don't consider it
1046 return
Jiyong Park89e850a2020-04-07 16:37:39 +09001047 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001048 if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() {
1049 availableToPlatform = false
1050 // TODO(b/154889534) trigger an error when 'am' has
1051 // "//apex_available:platform"
Jiyong Park89e850a2020-04-07 16:37:39 +09001052 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001053 })
Jiyong Park89e850a2020-04-07 16:37:39 +09001054
Paul Duffinb5769c12021-05-12 16:16:51 +01001055 // Exception 1: check to see if the module always requires it.
1056 if am.AlwaysRequiresPlatformApexVariant() {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001057 availableToPlatform = true
1058 }
1059
1060 // Exception 2: bootstrap bionic libraries are also always available to platform
1061 if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) {
1062 availableToPlatform = true
1063 }
1064
1065 if !availableToPlatform {
1066 am.SetNotAvailableForPlatform()
Jiyong Park89e850a2020-04-07 16:37:39 +09001067 }
1068}
1069
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001070// apexMutator visits each module and creates apex variations if the module was marked in the
Paul Duffin949abc02020-12-08 10:34:30 +00001071// previous run of apexInfoMutator.
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001072func apexMutator(mctx android.BottomUpMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +09001073 if !mctx.Module().Enabled() {
1074 return
1075 }
Colin Cross56a83212020-09-15 18:30:11 -07001076
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001077 // This is the usual path.
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001078 if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
Colin Cross56a83212020-09-15 18:30:11 -07001079 android.CreateApexVariations(mctx, am)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001080 return
1081 }
1082
1083 // apexBundle itself is mutated so that it and its dependencies have the same apex variant.
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001084 if ai, ok := mctx.Module().(ApexInfoMutator); ok && apexModuleTypeRequiresVariant(ai) {
1085 apexBundleName := ai.ApexVariationName()
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001086 mctx.CreateVariations(apexBundleName)
Martin Stjernholmec009002021-03-27 15:18:31 +00001087 if strings.HasPrefix(apexBundleName, "com.android.art") {
1088 // Create an alias from the platform variant. This is done to make
1089 // test_for dependencies work for modules that are split by the APEX
1090 // mutator, since test_for dependencies always go to the platform variant.
1091 // This doesn't happen for normal APEXes that are disjunct, so only do
1092 // this for the overlapping ART APEXes.
1093 // TODO(b/183882457): Remove this if the test_for functionality is
1094 // refactored to depend on the proper APEX variants instead of platform.
1095 mctx.CreateAliasVariation("", apexBundleName)
1096 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001097 } else if o, ok := mctx.Module().(*OverrideApex); ok {
1098 apexBundleName := o.GetOverriddenModuleName()
1099 if apexBundleName == "" {
1100 mctx.ModuleErrorf("base property is not set")
1101 return
1102 }
Paul Duffin6717d882021-06-15 19:09:41 +01001103 // Workaround the issue reported in b/191269918 by using the unprefixed module name of this
1104 // module as the default variation to use if dependencies of this module do not have the correct
1105 // apex variant name. This name matches the name used to create the variations of modules for
1106 // which apexModuleTypeRequiresVariant return true.
1107 // TODO(b/191269918): Remove this workaround.
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001108 unprefixedModuleName := android.RemoveOptionalPrebuiltPrefix(mctx.ModuleName())
Paul Duffin6717d882021-06-15 19:09:41 +01001109 mctx.SetDefaultDependencyVariation(&unprefixedModuleName)
Jiyong Park5d790c32019-11-15 18:40:32 +09001110 mctx.CreateVariations(apexBundleName)
Martin Stjernholmec009002021-03-27 15:18:31 +00001111 if strings.HasPrefix(apexBundleName, "com.android.art") {
1112 // TODO(b/183882457): See note for CreateAliasVariation above.
1113 mctx.CreateAliasVariation("", apexBundleName)
1114 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001115 }
1116}
Sundong Ahne9b55722019-09-06 17:37:42 +09001117
Paul Duffin6717d882021-06-15 19:09:41 +01001118// apexModuleTypeRequiresVariant determines whether the module supplied requires an apex specific
1119// variant.
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001120func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool {
Paul Duffin6717d882021-06-15 19:09:41 +01001121 if a, ok := module.(*apexBundle); ok {
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001122 // TODO(jiyong): document the reason why the VNDK APEX is an exception here.
Paul Duffin6717d882021-06-15 19:09:41 +01001123 return !a.vndkApex
1124 }
1125
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001126 return true
Paul Duffin6717d882021-06-15 19:09:41 +01001127}
1128
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001129// See android.UpdateDirectlyInAnyApex
1130// TODO(jiyong): move this to android/apex.go?
Colin Cross56a83212020-09-15 18:30:11 -07001131func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {
1132 if !mctx.Module().Enabled() {
1133 return
1134 }
1135 if am, ok := mctx.Module().(android.ApexModule); ok {
1136 android.UpdateDirectlyInAnyApex(mctx, am)
1137 }
1138}
1139
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001140// apexPackaging represents a specific packaging method for an APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001141type apexPackaging int
1142
1143const (
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001144 // imageApex is a packaging method where contents are included in a filesystem image which
1145 // is then included in a zip container. This is the most typical way of packaging.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001146 imageApex apexPackaging = iota
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001147
1148 // zipApex is a packaging method where contents are directly included in the zip container.
1149 // This is used for host-side testing - because the contents are easily accessible by
1150 // unzipping the container.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001151 zipApex
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001152
1153 // flattendApex is a packaging method where contents are not included in the APEX file, but
1154 // installed to /apex/<apexname> directory on the device. This packaging method is used for
1155 // old devices where the filesystem-based APEX file can't be supported.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001156 flattenedApex
1157)
1158
1159const (
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001160 // File extensions of an APEX for different packaging methods
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001161 imageApexSuffix = ".apex"
1162 zipApexSuffix = ".zipapex"
1163 flattenedSuffix = ".flattened"
1164
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001165 // variant names each of which is for a packaging method
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001166 imageApexType = "image"
1167 zipApexType = "zip"
1168 flattenedApexType = "flattened"
1169
1170 ext4FsType = "ext4"
1171 f2fsFsType = "f2fs"
1172)
1173
1174// The suffix for the output "file", not the module
1175func (a apexPackaging) suffix() string {
1176 switch a {
1177 case imageApex:
1178 return imageApexSuffix
1179 case zipApex:
1180 return zipApexSuffix
1181 default:
1182 panic(fmt.Errorf("unknown APEX type %d", a))
1183 }
1184}
1185
1186func (a apexPackaging) name() string {
1187 switch a {
1188 case imageApex:
1189 return imageApexType
1190 case zipApex:
1191 return zipApexType
1192 default:
1193 panic(fmt.Errorf("unknown APEX type %d", a))
1194 }
1195}
1196
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001197// apexFlattenedMutator creates one or more variations each of which is for a packaging method.
1198// TODO(jiyong): give a better name to this mutator
Sundong Ahne9b55722019-09-06 17:37:42 +09001199func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +09001200 if !mctx.Module().Enabled() {
1201 return
1202 }
Sundong Ahne8fb7242019-09-17 13:50:45 +09001203 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +09001204 var variants []string
1205 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
1206 case "image":
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001207 // This is the normal case. Note that both image and flattend APEXes are
1208 // created. The image type is installed to the system partition, while the
1209 // flattened APEX is (optionally) installed to the system_ext partition.
1210 // This is mostly for GSI which has to support wide range of devices. If GSI
1211 // is installed on a newer (APEX-capable) device, the image APEX in the
1212 // system will be used. However, if the same GSI is installed on an old
1213 // device which can't support image APEX, the flattened APEX in the
1214 // system_ext partion (which still is part of GSI) is used instead.
Sundong Ahnabb64432019-10-22 13:58:29 +09001215 variants = append(variants, imageApexType, flattenedApexType)
1216 case "zip":
1217 variants = append(variants, zipApexType)
1218 case "both":
1219 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
1220 default:
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001221 mctx.PropertyErrorf("payload_type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +09001222 return
1223 }
1224
1225 modules := mctx.CreateLocalVariations(variants...)
1226
1227 for i, v := range variants {
1228 switch v {
1229 case imageApexType:
1230 modules[i].(*apexBundle).properties.ApexType = imageApex
1231 case zipApexType:
1232 modules[i].(*apexBundle).properties.ApexType = zipApex
1233 case flattenedApexType:
1234 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001235 // See the comment above for why system_ext.
Jooyung Han91df2082019-11-20 01:49:42 +09001236 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001237 modules[i].(*apexBundle).MakeAsSystemExt()
1238 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001239 }
Sundong Ahne9b55722019-09-06 17:37:42 +09001240 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001241 } else if _, ok := mctx.Module().(*OverrideApex); ok {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001242 // payload_type is forcibly overridden to "image"
1243 // TODO(jiyong): is this the right decision?
Jiyong Park5d790c32019-11-15 18:40:32 +09001244 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +09001245 }
1246}
1247
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001248// checkUseVendorProperty checks if the use of `use_vendor` property is allowed for the given APEX.
1249// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
1250// which may cause compatibility issues. (e.g. libbinder) Even though libbinder restricts its
1251// availability via 'apex_available' property and relies on yet another macro
1252// __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules to avoid
1253// similar problems.
1254func checkUseVendorProperty(ctx android.BottomUpMutatorContext, a *apexBundle) {
1255 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) {
1256 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1257 }
1258}
1259
Jooyung Handc782442019-11-01 03:14:38 +09001260var (
Colin Cross440e0d02020-06-11 11:32:11 -07001261 useVendorAllowListKey = android.NewOnceKey("useVendorAllowList")
Jooyung Handc782442019-11-01 03:14:38 +09001262)
1263
Colin Cross440e0d02020-06-11 11:32:11 -07001264func useVendorAllowList(config android.Config) []string {
1265 return config.Once(useVendorAllowListKey, func() interface{} {
Jooyung Handc782442019-11-01 03:14:38 +09001266 return []string{
1267 // swcodec uses "vendor" variants for smaller size
1268 "com.android.media.swcodec",
1269 "test_com.android.media.swcodec",
1270 }
1271 }).([]string)
1272}
1273
Paul Duffin0a49fdc2021-03-08 11:28:25 +00001274// setUseVendorAllowListForTest returns a FixturePreparer that overrides useVendorAllowList and
1275// must be called before the first call to useVendorAllowList()
1276func setUseVendorAllowListForTest(allowList []string) android.FixturePreparer {
1277 return android.FixtureModifyConfig(func(config android.Config) {
1278 config.Once(useVendorAllowListKey, func() interface{} {
1279 return allowList
1280 })
Jooyung Handc782442019-11-01 03:14:38 +09001281 })
1282}
1283
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001284var _ android.DepIsInSameApex = (*apexBundle)(nil)
Theotime Combes4ba38c12020-06-12 12:46:59 +00001285
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001286// Implements android.DepInInSameApex
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001287func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1288 // direct deps of an APEX bundle are all part of the APEX bundle
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001289 // TODO(jiyong): shouldn't we look into the payload field of the dependencyTag?
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001290 return true
1291}
1292
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001293var _ android.OutputFileProducer = (*apexBundle)(nil)
1294
1295// Implements android.OutputFileProducer
1296func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1297 switch tag {
Paul Duffin74f05592020-11-25 16:37:46 +00001298 case "", android.DefaultDistTag:
1299 // This is the default dist path.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001300 return android.Paths{a.outputFile}, nil
1301 default:
1302 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
1303 }
1304}
1305
1306var _ cc.Coverage = (*apexBundle)(nil)
1307
1308// Implements cc.Coverage
1309func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
1310 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
1311}
1312
1313// Implements cc.Coverage
Ivan Lozanod7586b62021-04-01 09:49:36 -04001314func (a *apexBundle) SetPreventInstall() {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001315 a.properties.PreventInstall = true
1316}
1317
1318// Implements cc.Coverage
1319func (a *apexBundle) HideFromMake() {
1320 a.properties.HideFromMake = true
Colin Crosse6a83e62020-12-17 18:22:34 -08001321 // This HideFromMake is shadowing the ModuleBase one, call through to it for now.
1322 // TODO(ccross): untangle these
1323 a.ModuleBase.HideFromMake()
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001324}
1325
1326// Implements cc.Coverage
1327func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1328 a.properties.IsCoverageVariant = coverage
1329}
1330
1331// Implements cc.Coverage
1332func (a *apexBundle) EnableCoverageIfNeeded() {}
1333
1334var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil)
1335
1336// Implements android.ApexBudleDepsInfoIntf
1337func (a *apexBundle) Updatable() bool {
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +00001338 return proptools.BoolDefault(a.properties.Updatable, true)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001339}
1340
Jiyong Park9477c262021-06-22 20:23:05 +09001341func (a *apexBundle) UsePlatformApis() bool {
1342 return proptools.BoolDefault(a.properties.Platform_apis, false)
1343}
1344
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001345// getCertString returns the name of the cert that should be used to sign this APEX. This is
1346// basically from the "certificate" property, but could be overridden by the device config.
Colin Cross0ea8ba82019-06-06 14:33:29 -07001347func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001348 moduleName := ctx.ModuleName()
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001349 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the
1350 // OVERRIDE_* list, we check with the pseudo module name to see if its certificate is
1351 // overridden.
Jooyung Han27151d92019-12-16 17:45:32 +09001352 if a.vndkApex {
1353 moduleName = vndkApexName
1354 }
1355 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001356 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001357 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001358 }
Jaewoong Jung4cfdf7d2021-04-20 16:21:24 -07001359 return String(a.overridableProperties.Certificate)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001360}
1361
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001362// See the installable property
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001363func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001364 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001365}
1366
Nikita Ioffe9d9960f2021-06-09 19:43:46 +01001367// See the generate_hashtree property
1368func (a *apexBundle) shouldGenerateHashtree() bool {
Nikita Ioffee261ae62021-06-16 18:15:03 +01001369 return proptools.BoolDefault(a.properties.Generate_hashtree, true)
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001370}
1371
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001372// See the test_only_unsigned_payload property
Dario Frenica913392020-04-27 18:21:11 +01001373func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool {
1374 return proptools.Bool(a.properties.Test_only_unsigned_payload)
1375}
1376
Mohammad Samiul Islama8008f92020-12-22 10:47:50 +00001377// See the test_only_force_compression property
1378func (a *apexBundle) testOnlyShouldForceCompression() bool {
1379 return proptools.Bool(a.properties.Test_only_force_compression)
1380}
1381
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001382// These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its
1383// members) can be sanitized, either forcibly, or by the global configuration. For some of the
1384// sanitizers, extra dependencies can be forcibly added as well.
Jiyong Parkda6eb592018-12-19 17:12:36 +09001385
Jiyong Parkf97782b2019-02-13 20:28:58 +09001386func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1387 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1388 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1389 }
1390}
1391
Jiyong Park388ef3f2019-01-28 19:47:32 +09001392func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001393 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1394 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001395 }
1396
1397 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001398 globalSanitizerNames := []string{}
1399 if a.Host() {
1400 globalSanitizerNames = ctx.Config().SanitizeHost()
1401 } else {
1402 arches := ctx.Config().SanitizeDeviceArch()
1403 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1404 globalSanitizerNames = ctx.Config().SanitizeDevice()
1405 }
1406 }
1407 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001408}
1409
Jooyung Han8ce8db92020-05-15 19:05:05 +09001410func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001411 // TODO(jiyong): move this info (the sanitizer name, the lib name, etc.) to cc/sanitize.go
1412 // Keep only the mechanism here.
Jooyung Han8ce8db92020-05-15 19:05:05 +09001413 if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001414 imageVariation := a.getImageVariation(ctx)
Jooyung Han8ce8db92020-05-15 19:05:05 +09001415 for _, target := range ctx.MultiTargets() {
1416 if target.Arch.ArchType.Multilib == "lib64" {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001417 addDependenciesForNativeModules(ctx, ApexNativeDependencies{
1418 Native_shared_libs: []string{"libclang_rt.hwasan-aarch64-android"},
1419 Tests: nil,
1420 Jni_libs: nil,
1421 Binaries: nil,
1422 }, target, imageVariation)
Jooyung Han8ce8db92020-05-15 19:05:05 +09001423 break
1424 }
1425 }
1426 }
1427}
1428
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001429// apexFileFor<Type> functions below create an apexFile struct for a given Soong module. The
1430// returned apexFile saves information about the Soong module that will be used for creating the
1431// build rules.
Jiyong Park1833cef2019-12-13 13:28:36 +09001432func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001433 // Decide the APEX-local directory by the multilib of the library In the future, we may
1434 // query this to the module.
1435 // TODO(jiyong): use the new PackagingSpec
Jiyong Parkf653b052019-11-18 15:39:01 +09001436 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001437 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001438 case "lib32":
1439 dirInApex = "lib"
1440 case "lib64":
1441 dirInApex = "lib64"
1442 }
Colin Cross3b19f5d2019-09-17 14:45:31 -07001443 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001444 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001445 }
Jooyung Han35155c42020-02-06 17:33:20 +09001446 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Jiyong Park1833cef2019-12-13 13:28:36 +09001447 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001448 // Special case for Bionic libs and other libs installed with them. This is to
1449 // prevent those libs from being included in the search path
1450 // /apex/com.android.runtime/${LIB}. This exclusion is required because those libs
1451 // in the Runtime APEX are available via the legacy paths in /system/lib/. By the
1452 // init process, the libs in the APEX are bind-mounted to the legacy paths and thus
1453 // will be loaded into the default linker namespace (aka "platform" namespace). If
1454 // the libs are directly in /apex/com.android.runtime/${LIB} then the same libs will
1455 // be loaded again into the runtime linker namespace, which will result in double
1456 // loading of them, which isn't supported.
Martin Stjernholm279de572019-09-10 23:18:20 +01001457 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001458 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001459
Jiyong Parkf653b052019-11-18 15:39:01 +09001460 fileToCopy := ccMod.OutputFile().Path()
Yo Chiange8128052020-07-23 20:09:18 +08001461 androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName
1462 return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001463}
1464
Jiyong Park1833cef2019-12-13 13:28:36 +09001465func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jooyung Han35155c42020-02-06 17:33:20 +09001466 dirInApex := "bin"
Colin Cross3b19f5d2019-09-17 14:45:31 -07001467 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001468 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001469 }
Jooyung Han35155c42020-02-06 17:33:20 +09001470 dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001471 fileToCopy := cc.OutputFile().Path()
Yo Chiange8128052020-07-23 20:09:18 +08001472 androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName
1473 af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001474 af.symlinks = cc.Symlinks()
Liz Kammer1c14a212020-05-12 15:26:55 -07001475 af.dataPaths = cc.DataPaths()
Jiyong Parkf653b052019-11-18 15:39:01 +09001476 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001477}
1478
Jiyong Park99644e92020-11-17 22:21:02 +09001479func apexFileForRustExecutable(ctx android.BaseModuleContext, rustm *rust.Module) apexFile {
1480 dirInApex := "bin"
1481 if rustm.Target().NativeBridge == android.NativeBridgeEnabled {
1482 dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath)
1483 }
1484 fileToCopy := rustm.OutputFile().Path()
1485 androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName
1486 af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, rustm)
1487 return af
1488}
1489
1490func apexFileForRustLibrary(ctx android.BaseModuleContext, rustm *rust.Module) apexFile {
1491 // Decide the APEX-local directory by the multilib of the library
1492 // In the future, we may query this to the module.
1493 var dirInApex string
1494 switch rustm.Arch().ArchType.Multilib {
1495 case "lib32":
1496 dirInApex = "lib"
1497 case "lib64":
1498 dirInApex = "lib64"
1499 }
1500 if rustm.Target().NativeBridge == android.NativeBridgeEnabled {
1501 dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath)
1502 }
1503 fileToCopy := rustm.OutputFile().Path()
1504 androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName
1505 return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, rustm)
1506}
1507
Jiyong Park1833cef2019-12-13 13:28:36 +09001508func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001509 dirInApex := "bin"
1510 fileToCopy := py.HostToolPath().Path()
Yo Chiange8128052020-07-23 20:09:18 +08001511 return newApexFile(ctx, fileToCopy, py.BaseModuleName(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001512}
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001513
Jiyong Park1833cef2019-12-13 13:28:36 +09001514func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001515 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001516 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1517 if err != nil {
1518 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001519 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001520 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001521 fileToCopy := android.PathForOutput(ctx, s)
1522 // NB: Since go binaries are static we don't need the module for anything here, which is
1523 // good since the go tool is a blueprint.Module not an android.Module like we would
1524 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001525 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001526}
1527
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001528func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001529 dirInApex := filepath.Join("bin", sh.SubDir())
1530 fileToCopy := sh.OutputFile()
Yo Chiange8128052020-07-23 20:09:18 +08001531 af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001532 af.symlinks = sh.Symlinks()
1533 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001534}
1535
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001536func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
Jooyung Han0703fd82020-08-26 22:11:53 +09001537 dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir())
Jiyong Parkf653b052019-11-18 15:39:01 +09001538 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001539 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001540}
1541
atrost6e126252020-01-27 17:01:16 +00001542func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1543 dirInApex := filepath.Join("etc", config.SubDir())
1544 fileToCopy := config.CompatConfig()
1545 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1546}
1547
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001548// javaModule is an interface to handle all Java modules (java_library, dex_import, etc) in the same
1549// way.
1550type javaModule interface {
1551 android.Module
1552 BaseModuleName() string
1553 DexJarBuildPath() android.Path
1554 JacocoReportClassesFile() android.Path
1555 LintDepSets() java.LintDepSets
1556 Stem() string
1557}
1558
1559var _ javaModule = (*java.Library)(nil)
Bill Peckhama41a6962021-01-11 10:58:54 -08001560var _ javaModule = (*java.Import)(nil)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001561var _ javaModule = (*java.SdkLibrary)(nil)
1562var _ javaModule = (*java.DexImport)(nil)
1563var _ javaModule = (*java.SdkLibraryImport)(nil)
1564
Paul Duffin190fdef2021-04-26 10:33:59 +01001565// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001566func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile {
Paul Duffin190fdef2021-04-26 10:33:59 +01001567 return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath())
1568}
1569
1570// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
1571func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001572 dirInApex := "javalib"
Paul Duffin190fdef2021-04-26 10:33:59 +01001573 af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001574 af.jacocoReportClassesFile = module.JacocoReportClassesFile()
1575 af.lintDepSets = module.LintDepSets()
1576 af.customStem = module.Stem() + ".jar"
1577 return af
1578}
1579
1580// androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in
1581// the same way.
1582type androidApp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001583 android.Module
1584 Privileged() bool
Jooyung Han39ee1192020-03-23 20:21:11 +09001585 InstallApkName() string
Jiyong Parkf653b052019-11-18 15:39:01 +09001586 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001587 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001588 Certificate() java.Certificate
Yo Chiange8128052020-07-23 20:09:18 +08001589 BaseModuleName() string
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001590}
1591
1592var _ androidApp = (*java.AndroidApp)(nil)
1593var _ androidApp = (*java.AndroidAppImport)(nil)
1594
1595func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001596 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001597 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001598 appDir = "priv-app"
1599 }
Jooyung Han39ee1192020-03-23 20:21:11 +09001600 dirInApex := filepath.Join(appDir, aapp.InstallApkName())
Jiyong Parkf653b052019-11-18 15:39:01 +09001601 fileToCopy := aapp.OutputFile()
Yo Chiange8128052020-07-23 20:09:18 +08001602 af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp)
Jiyong Park618922e2020-01-08 13:35:43 +09001603 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross503c1d02020-01-28 14:00:53 -08001604 af.certificate = aapp.Certificate()
Jiyong Parkcfaa1642020-02-28 16:51:07 +09001605
1606 if app, ok := aapp.(interface {
1607 OverriddenManifestPackageName() string
1608 }); ok {
1609 af.overriddenPackageName = app.OverriddenManifestPackageName()
1610 }
Jiyong Park618922e2020-01-08 13:35:43 +09001611 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001612}
1613
Jiyong Park69aeba92020-04-24 21:16:36 +09001614func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile {
1615 rroDir := "overlay"
1616 dirInApex := filepath.Join(rroDir, rro.Theme())
1617 fileToCopy := rro.OutputFile()
1618 af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro)
1619 af.certificate = rro.Certificate()
1620
1621 if a, ok := rro.(interface {
1622 OverriddenManifestPackageName() string
1623 }); ok {
1624 af.overriddenPackageName = a.OverriddenManifestPackageName()
1625 }
1626 return af
1627}
1628
markchien2f59ec92020-09-02 16:23:38 +08001629func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile {
1630 dirInApex := filepath.Join("etc", "bpf")
1631 return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram)
1632}
1633
Jiyong Park12a719c2021-01-07 15:31:24 +09001634func apexFileForFilesystem(ctx android.BaseModuleContext, buildFile android.Path, fs filesystem.Filesystem) apexFile {
1635 dirInApex := filepath.Join("etc", "fs")
1636 return newApexFile(ctx, buildFile, buildFile.Base(), dirInApex, etc, fs)
1637}
1638
Paul Duffin064b70c2020-11-02 17:32:38 +00001639// WalkPayloadDeps visits dependencies that contributes to the payload of this APEX. For each of the
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001640// visited module, the `do` callback is executed. Returning true in the callback continues the visit
1641// to the child modules. Returning false makes the visit to continue in the sibling or the parent
1642// modules. This is used in check* functions below.
Jooyung Han749dc692020-04-15 11:03:39 +09001643func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) {
Paul Duffindf915ff2020-03-30 17:58:21 +01001644 ctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0f80c182020-01-31 02:49:53 +09001645 am, ok := child.(android.ApexModule)
1646 if !ok || !am.CanHaveApexVariants() {
1647 return false
1648 }
1649
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001650 // Filter-out unwanted depedendencies
1651 depTag := ctx.OtherModuleDependencyTag(child)
1652 if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
1653 return false
1654 }
1655 if dt, ok := depTag.(dependencyTag); ok && !dt.payload {
Martin Stjernholm58c33f02020-07-06 22:56:01 +01001656 return false
1657 }
1658
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001659 ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
Jiyong Parkab50b072021-05-12 17:13:56 +09001660 externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants)
Jiyong Park0f80c182020-01-31 02:49:53 +09001661
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001662 // Visit actually
1663 return do(ctx, parent, am, externalDep)
Jiyong Park0f80c182020-01-31 02:49:53 +09001664 })
1665}
1666
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001667// filesystem type of the apex_payload.img inside the APEX. Currently, ext4 and f2fs are supported.
1668type fsType int
Jooyung Han03b51852020-02-26 22:45:42 +09001669
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001670const (
1671 ext4 fsType = iota
1672 f2fs
1673)
Artur Satayev849f8442020-04-28 14:57:42 +01001674
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001675func (f fsType) string() string {
1676 switch f {
1677 case ext4:
1678 return ext4FsType
1679 case f2fs:
1680 return f2fsFsType
1681 default:
1682 panic(fmt.Errorf("unknown APEX payload type %d", f))
Jooyung Han548640b2020-04-27 12:10:30 +09001683 }
1684}
1685
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001686// Creates build rules for an APEX. It consists of the following major steps:
1687//
1688// 1) do some validity checks such as apex_available, min_sdk_version, etc.
1689// 2) traverse the dependency tree to collect apexFile structs from them.
1690// 3) some fields in apexBundle struct are configured
1691// 4) generate the build rules to create the APEX. This is mostly done in builder.go.
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001692func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001693 ////////////////////////////////////////////////////////////////////////////////////////////
1694 // 1) do some validity checks such as apex_available, min_sdk_version, etc.
Jiyong Park0f80c182020-01-31 02:49:53 +09001695 a.checkApexAvailability(ctx)
Jooyung Han548640b2020-04-27 12:10:30 +09001696 a.checkUpdatable(ctx)
Jooyung Han749dc692020-04-15 11:03:39 +09001697 a.checkMinSdkVersion(ctx)
Jiyong Park7d95a512020-05-10 15:16:24 +09001698 a.checkStaticLinkingToStubLibraries(ctx)
Jiyong Park192600a2021-08-03 07:52:17 +00001699 a.checkStaticExecutables(ctx)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001700 if len(a.properties.Tests) > 0 && !a.testApex {
1701 ctx.PropertyErrorf("tests", "property allowed only in apex_test module type")
1702 return
1703 }
Jiyong Park678c8812020-02-07 17:25:49 +09001704
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001705 ////////////////////////////////////////////////////////////////////////////////////////////
1706 // 2) traverse the dependency tree to collect apexFile structs from them.
1707
1708 // all the files that will be included in this APEX
1709 var filesInfo []apexFile
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001710
Jooyung Hane1633032019-08-01 17:41:43 +09001711 // native lib dependencies
1712 var provideNativeLibs []string
1713 var requireNativeLibs []string
1714
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001715 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1716
braleeb0c1f0c2021-06-07 22:49:13 +08001717 // Collect the module directory for IDE info in java/jdeps.go.
1718 a.modulePaths = append(a.modulePaths, ctx.ModuleDir())
1719
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001720 // TODO(jiyong): do this using WalkPayloadDeps
1721 // TODO(jiyong): make this clean!!!
Alex Light778127a2019-02-27 14:19:50 -08001722 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001723 depTag := ctx.OtherModuleDependencyTag(child)
Paul Duffindddd5462020-04-07 15:25:44 +01001724 if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
1725 return false
1726 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001727 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001728 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001729 switch depTag {
Jooyung Han643adc42020-02-27 13:50:06 +09001730 case sharedLibTag, jniLibTag:
1731 isJniLib := depTag == jniLibTag
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09001732 if c, ok := child.(*cc.Module); ok {
Jooyung Han643adc42020-02-27 13:50:06 +09001733 fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
1734 fi.isJniLib = isJniLib
1735 filesInfo = append(filesInfo, fi)
Jooyung Han45a96772020-06-15 14:59:42 +09001736 // Collect the list of stub-providing libs except:
1737 // - VNDK libs are only for vendors
1738 // - bootstrap bionic libs are treated as provided by system
1739 if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001740 provideNativeLibs = append(provideNativeLibs, fi.stem())
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001741 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001742 return true // track transitive dependencies
Jiyong Parkf2cc1b72020-12-09 00:20:45 +09001743 } else if r, ok := child.(*rust.Module); ok {
1744 fi := apexFileForRustLibrary(ctx, r)
1745 filesInfo = append(filesInfo, fi)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001746 } else {
Jooyung Han643adc42020-02-27 13:50:06 +09001747 propertyName := "native_shared_libs"
1748 if isJniLib {
1749 propertyName = "jni_libs"
1750 }
1751 ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001752 }
1753 case executableTag:
1754 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001755 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001756 return true // track transitive dependencies
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001757 } else if sh, ok := child.(*sh.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001758 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001759 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001760 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001761 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001762 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Park99644e92020-11-17 22:21:02 +09001763 } else if rust, ok := child.(*rust.Module); ok {
1764 filesInfo = append(filesInfo, apexFileForRustExecutable(ctx, rust))
1765 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001766 } else {
Jiyong Park99644e92020-11-17 22:21:02 +09001767 ctx.PropertyErrorf("binaries", "%q is neither cc_binary, rust_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001768 }
Paul Duffin94f19632021-04-20 12:40:07 +01001769 case bcpfTag:
Paul Duffina1d60252021-01-21 18:13:43 +00001770 {
Paul Duffin7771eba2021-04-23 14:25:28 +01001771 if _, ok := child.(*java.BootclasspathFragmentModule); !ok {
Paul Duffincc33ec82021-04-25 23:14:55 +01001772 ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a bootclasspath_fragment module", depName)
Paul Duffina1d60252021-01-21 18:13:43 +00001773 return false
1774 }
Paul Duffin4d101b62021-03-24 15:42:20 +00001775
Paul Duffincc33ec82021-04-25 23:14:55 +01001776 filesToAdd := apexBootclasspathFragmentFiles(ctx, child)
1777 filesInfo = append(filesInfo, filesToAdd...)
Paul Duffin4d101b62021-03-24 15:42:20 +00001778 return true
Paul Duffina1d60252021-01-21 18:13:43 +00001779 }
satayev333a1732021-05-17 21:35:26 +01001780 case sscpfTag:
1781 {
1782 if _, ok := child.(*java.SystemServerClasspathModule); !ok {
1783 ctx.PropertyErrorf("systemserverclasspath_fragments", "%q is not a systemserverclasspath_fragment module", depName)
1784 return false
1785 }
satayevb98371c2021-06-15 16:49:50 +01001786 if af := apexClasspathFragmentProtoFile(ctx, child); af != nil {
1787 filesInfo = append(filesInfo, *af)
1788 }
satayev333a1732021-05-17 21:35:26 +01001789 return true
1790 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001791 case javaLibTag:
Jiyong Park77acec62020-06-01 21:39:15 +09001792 switch child.(type) {
Bill Peckhama41a6962021-01-11 10:58:54 -08001793 case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport, *java.Import:
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001794 af := apexFileForJavaModule(ctx, child.(javaModule))
1795 if !af.ok() {
Jooyung Han58f26ab2019-12-18 15:34:32 +09001796 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1797 return false
1798 }
1799 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09001800 return true // track transitive dependencies
Jiyong Park77acec62020-06-01 21:39:15 +09001801 default:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001802 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001803 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001804 case androidAppTag:
Jiyong Parkf653b052019-11-18 15:39:01 +09001805 if ap, ok := child.(*java.AndroidApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001806 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Jiyong Parkf653b052019-11-18 15:39:01 +09001807 return true // track transitive dependencies
1808 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001809 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Dario Freni6f3937c2019-12-20 22:58:03 +00001810 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001811 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001812 } else if ap, ok := child.(*java.AndroidAppSet); ok {
1813 appDir := "app"
1814 if ap.Privileged() {
1815 appDir = "priv-app"
1816 }
Yo Chiange8128052020-07-23 20:09:18 +08001817 af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(),
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001818 filepath.Join(appDir, ap.BaseModuleName()), appSet, ap)
1819 af.certificate = java.PresignedCertificate
1820 filesInfo = append(filesInfo, af)
Jiyong Parkf653b052019-11-18 15:39:01 +09001821 } else {
1822 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
1823 }
Jiyong Park69aeba92020-04-24 21:16:36 +09001824 case rroTag:
1825 if rro, ok := child.(java.RuntimeResourceOverlayModule); ok {
1826 filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro))
1827 } else {
1828 ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
1829 }
markchien2f59ec92020-09-02 16:23:38 +08001830 case bpfTag:
1831 if bpfProgram, ok := child.(bpf.BpfModule); ok {
1832 filesToCopy, _ := bpfProgram.OutputFiles("")
1833 for _, bpfFile := range filesToCopy {
1834 filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram))
1835 }
1836 } else {
1837 ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName)
1838 }
Jiyong Park12a719c2021-01-07 15:31:24 +09001839 case fsTag:
1840 if fs, ok := child.(filesystem.Filesystem); ok {
1841 filesInfo = append(filesInfo, apexFileForFilesystem(ctx, fs.OutputPath(), fs))
1842 } else {
1843 ctx.PropertyErrorf("filesystems", "%q is not a filesystem module", depName)
1844 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001845 case prebuiltTag:
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001846 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001847 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001848 } else {
Paul Duffin1bc21dc2021-03-15 19:43:17 +00001849 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001850 }
Paul Duffin0b817782021-03-17 15:02:19 +00001851 case compatConfigTag:
Paul Duffin3abc1742021-03-15 19:32:23 +00001852 if compatConfig, ok := child.(java.PlatformCompatConfigIntf); ok {
1853 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, compatConfig, depName))
1854 } else {
1855 ctx.PropertyErrorf("compat_configs", "%q is not a platform_compat_config module", depName)
1856 }
Roland Levillain630846d2019-06-26 12:48:34 +01001857 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01001858 if ccTest, ok := child.(*cc.Module); ok {
1859 if ccTest.IsTestPerSrcAllTestsVariation() {
1860 // Multiple-output test module (where `test_per_src: true`).
1861 //
1862 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
1863 // We do not add this variation to `filesInfo`, as it has no output;
1864 // however, we do add the other variations of this module as indirect
1865 // dependencies (see below).
Roland Levillain9b5fde92019-06-28 15:41:19 +01001866 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01001867 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09001868 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09001869 af.class = nativeTest
1870 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01001871 }
Jiyong Parkaf9539f2020-05-04 10:31:32 +09001872 return true // track transitive dependencies
Roland Levillain630846d2019-06-26 12:48:34 +01001873 } else {
1874 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
1875 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09001876 case keyTag:
1877 if key, ok := child.(*apexKey); ok {
Jaewoong Jung18aefc12020-12-21 09:11:10 -08001878 a.privateKeyFile = key.privateKeyFile
1879 a.publicKeyFile = key.publicKeyFile
Jiyong Parkff1458f2018-10-12 21:49:38 +09001880 } else {
1881 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001882 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001883 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001884 case certificateTag:
1885 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jaewoong Jung18aefc12020-12-21 09:11:10 -08001886 a.containerCertificateFile = dep.Certificate.Pem
1887 a.containerPrivateKeyFile = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001888 } else {
1889 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
1890 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09001891 case android.PrebuiltDepTag:
1892 // If the prebuilt is force disabled, remember to delete the prebuilt file
1893 // that might have been installed in the previous builds
Jiyong Park10e926b2020-07-16 21:38:56 +09001894 if prebuilt, ok := child.(prebuilt); ok && prebuilt.isForceDisabled() {
Jiyong Park03b68dd2019-07-26 23:20:40 +09001895 a.prebuiltFileToDelete = prebuilt.InstallFilename()
1896 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001897 }
Jooyung Han8aee2042019-10-29 05:08:31 +09001898 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001899 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09001900 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01001901 // We cannot use a switch statement on `depTag` here as the checked
1902 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09001903 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001904 if cc, ok := child.(*cc.Module); ok {
Jooyung Handf78e212020-07-22 15:54:47 +09001905 if cc.UseVndk() && proptools.Bool(a.properties.Use_vndk_as_stable) && cc.IsVndk() {
Jooyung Han6c4cc9c2020-07-29 16:00:54 +09001906 requireNativeLibs = append(requireNativeLibs, ":vndk")
Jooyung Handf78e212020-07-22 15:54:47 +09001907 return false
1908 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001909 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
1910 af.transitiveDep = true
Martin Stjernholmf2635ec2020-12-16 01:01:59 +00001911
1912 // Always track transitive dependencies for host.
1913 if a.Host() {
1914 filesInfo = append(filesInfo, af)
1915 return true
1916 }
1917
Colin Cross56a83212020-09-15 18:30:11 -07001918 abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
Martin Stjernholmf2635ec2020-12-16 01:01:59 +00001919 if !abInfo.Contents.DirectlyInApex(depName) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001920 // If the dependency is a stubs lib, don't include it in this APEX,
1921 // but make sure that the lib is installed on the device.
1922 // In case no APEX is having the lib, the lib is installed to the system
1923 // partition.
1924 //
1925 // Always include if we are a host-apex however since those won't have any
1926 // system libraries.
Colin Cross56a83212020-09-15 18:30:11 -07001927 if !am.DirectlyInAnyApex() {
Jooyung Hanefb184e2020-06-25 17:14:25 +09001928 // we need a module name for Make
Martin Stjernholm2856c662020-12-02 15:03:42 +00001929 name := cc.ImplementationModuleNameForMake(ctx)
Colin Cross0477b422020-10-13 18:43:54 -07001930
1931 if !proptools.Bool(a.properties.Use_vendor) {
Jooyung Hanefb184e2020-06-25 17:14:25 +09001932 // we don't use subName(.vendor) for a "use_vendor: true" apex
1933 // which is supposed to be installed in /system
Colin Cross0477b422020-10-13 18:43:54 -07001934 name += cc.Properties.SubName
Jooyung Hanefb184e2020-06-25 17:14:25 +09001935 }
1936 if !android.InList(name, a.requiredDeps) {
1937 a.requiredDeps = append(a.requiredDeps, name)
1938 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001939 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001940 requireNativeLibs = append(requireNativeLibs, af.stem())
Roland Levillainf89cd092019-07-29 16:22:59 +01001941 // Don't track further
1942 return false
1943 }
Jiyong Parke3867542020-12-03 17:28:25 +09001944
1945 // If the dep is not considered to be in the same
1946 // apex, don't add it to filesInfo so that it is not
1947 // included in this APEX.
1948 // TODO(jiyong): move this to at the top of the
1949 // else-if clause for the indirect dependencies.
1950 // Currently, that's impossible because we would
1951 // like to record requiredNativeLibs even when
Martin Stjernholmf2635ec2020-12-16 01:01:59 +00001952 // DepIsInSameAPex is false. We also shouldn't do
1953 // this for host.
Paul Duffin4c3e8e22021-03-18 15:41:29 +00001954 //
1955 // TODO(jiyong): explain why the same module is passed in twice.
1956 // Switching the first am to parent breaks lots of tests.
1957 if !android.IsDepInSameApex(ctx, am, am) {
Jiyong Parke3867542020-12-03 17:28:25 +09001958 return false
1959 }
1960
Jiyong Parkf653b052019-11-18 15:39:01 +09001961 filesInfo = append(filesInfo, af)
1962 return true // track transitive dependencies
Jiyong Parkf2cc1b72020-12-09 00:20:45 +09001963 } else if rm, ok := child.(*rust.Module); ok {
1964 af := apexFileForRustLibrary(ctx, rm)
1965 af.transitiveDep = true
1966 filesInfo = append(filesInfo, af)
1967 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09001968 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001969 } else if cc.IsTestPerSrcDepTag(depTag) {
1970 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001971 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01001972 // Handle modules created as `test_per_src` variations of a single test module:
1973 // use the name of the generated test binary (`fileToCopy`) instead of the name
1974 // of the original test module (`depName`, shared by all `test_per_src`
1975 // variations of that module).
Yo Chiange8128052020-07-23 20:09:18 +08001976 af.androidMkModuleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09001977 // these are not considered transitive dep
1978 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09001979 filesInfo = append(filesInfo, af)
1980 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01001981 }
Jiyong Park1ad8e162020-12-01 23:40:09 +09001982 } else if cc.IsHeaderDepTag(depTag) {
1983 // nothing
Jiyong Park52cd06f2019-11-11 10:14:32 +09001984 } else if java.IsJniDepTag(depTag) {
Jooyung Hanb7bebe22020-02-25 16:59:29 +09001985 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
1986 return false
Jiyong Parke3833882020-02-17 17:28:10 +09001987 } else if java.IsXmlPermissionsFileDepTag(depTag) {
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001988 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Parke3833882020-02-17 17:28:10 +09001989 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
1990 }
Jiyong Park99644e92020-11-17 22:21:02 +09001991 } else if rust.IsDylibDepTag(depTag) {
1992 if rustm, ok := child.(*rust.Module); ok && rustm.IsInstallableToApex() {
1993 af := apexFileForRustLibrary(ctx, rustm)
1994 af.transitiveDep = true
1995 filesInfo = append(filesInfo, af)
1996 return true // track transitive dependencies
1997 }
Jiyong Park94e22fd2021-04-08 18:19:15 +09001998 } else if rust.IsRlibDepTag(depTag) {
1999 // Rlib is statically linked, but it might have shared lib
2000 // dependencies. Track them.
2001 return true
Paul Duffin65898052021-04-20 22:47:03 +01002002 } else if java.IsBootclasspathFragmentContentDepTag(depTag) {
Paul Duffin94f19632021-04-20 12:40:07 +01002003 // Add the contents of the bootclasspath fragment to the apex.
Paul Duffin4d101b62021-03-24 15:42:20 +00002004 switch child.(type) {
2005 case *java.Library, *java.SdkLibrary:
Paul Duffincc33ec82021-04-25 23:14:55 +01002006 javaModule := child.(javaModule)
Paul Duffin190fdef2021-04-26 10:33:59 +01002007 af := apexFileForBootclasspathFragmentContentModule(ctx, parent, javaModule)
Paul Duffin4d101b62021-03-24 15:42:20 +00002008 if !af.ok() {
Paul Duffin94f19632021-04-20 12:40:07 +01002009 ctx.PropertyErrorf("bootclasspath_fragments", "bootclasspath_fragment content %q is not configured to be compiled into dex", depName)
Paul Duffin4d101b62021-03-24 15:42:20 +00002010 return false
2011 }
2012 filesInfo = append(filesInfo, af)
2013 return true // track transitive dependencies
2014 default:
Paul Duffin94f19632021-04-20 12:40:07 +01002015 ctx.PropertyErrorf("bootclasspath_fragments", "bootclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
Paul Duffin4d101b62021-03-24 15:42:20 +00002016 }
satayev333a1732021-05-17 21:35:26 +01002017 } else if java.IsSystemServerClasspathFragmentContentDepTag(depTag) {
2018 // Add the contents of the systemserverclasspath fragment to the apex.
2019 switch child.(type) {
2020 case *java.Library, *java.SdkLibrary:
2021 af := apexFileForJavaModule(ctx, child.(javaModule))
2022 filesInfo = append(filesInfo, af)
2023 return true // track transitive dependencies
2024 default:
2025 ctx.PropertyErrorf("systemserverclasspath_fragments", "systemserverclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
2026 }
Colin Cross56a83212020-09-15 18:30:11 -07002027 } else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok {
2028 // nothing
Jooyung Han9c80bae2019-08-20 17:30:57 +09002029 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Jiyong Park1c7e9622020-05-07 16:12:13 +09002030 ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002031 }
2032 }
2033 }
2034 return false
2035 })
Jaewoong Jung18aefc12020-12-21 09:11:10 -08002036 if a.privateKeyFile == nil {
Jaewoong Jung4cfdf7d2021-04-20 16:21:24 -07002037 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.overridableProperties.Key))
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002038 return
2039 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002040
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002041 // Remove duplicates in filesInfo
Jiyong Park8fd61922018-11-08 02:50:25 +09002042 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002043 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002044 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002045 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002046 if e, ok := encountered[dest]; !ok {
2047 encountered[dest] = f
2048 } else {
2049 // If a module is directly included and also transitively depended on
2050 // consider it as directly included.
2051 e.transitiveDep = e.transitiveDep && f.transitiveDep
2052 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002053 }
2054 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002055 var result []apexFile
2056 for _, v := range encountered {
2057 result = append(result, v)
2058 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002059 return result
2060 }
2061 filesInfo = removeDup(filesInfo)
2062
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002063 // Sort to have consistent build rules
Jiyong Park8fd61922018-11-08 02:50:25 +09002064 sort.Slice(filesInfo, func(i, j int) bool {
Paul Duffin56060292021-05-15 19:34:05 +01002065 // Sort by destination path so as to ensure consistent ordering even if the source of the files
2066 // changes.
2067 return filesInfo[i].path() < filesInfo[j].path()
Jiyong Park8fd61922018-11-08 02:50:25 +09002068 })
2069
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002070 ////////////////////////////////////////////////////////////////////////////////////////////
2071 // 3) some fields in apexBundle struct are configured
Jiyong Park8fd61922018-11-08 02:50:25 +09002072 a.installDir = android.PathForModuleInstall(ctx, "apex")
2073 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002074
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002075 // Set suffix and primaryApexType depending on the ApexType
Martin Stjernholmcb3ff1e2021-05-25 00:28:27 +01002076 buildFlattenedAsDefault := ctx.Config().FlattenApex()
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002077 switch a.properties.ApexType {
2078 case imageApex:
2079 if buildFlattenedAsDefault {
2080 a.suffix = imageApexSuffix
2081 } else {
2082 a.suffix = ""
2083 a.primaryApexType = true
2084
2085 if ctx.Config().InstallExtraFlattenedApexes() {
2086 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
2087 }
2088 }
2089 case zipApex:
2090 if proptools.String(a.properties.Payload_type) == "zip" {
2091 a.suffix = ""
2092 a.primaryApexType = true
2093 } else {
2094 a.suffix = zipApexSuffix
2095 }
2096 case flattenedApex:
2097 if buildFlattenedAsDefault {
2098 a.suffix = ""
2099 a.primaryApexType = true
2100 } else {
2101 a.suffix = flattenedSuffix
2102 }
2103 }
2104
Theotime Combes4ba38c12020-06-12 12:46:59 +00002105 switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) {
2106 case ext4FsType:
2107 a.payloadFsType = ext4
2108 case f2fsFsType:
2109 a.payloadFsType = f2fs
2110 default:
2111 ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs]", *a.properties.Payload_fs_type)
2112 }
2113
Jiyong Park7cd10e32020-01-14 09:22:18 +09002114 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2115 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2116 // the same library in the system partition, thus effectively sharing the same libraries
2117 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2118 // in the APEX.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002119 a.linkToSystemLib = !ctx.Config().UnbundledBuild() && a.installable() && !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002120
Jooyung Han85d61762020-06-24 23:50:26 +09002121 // APEXes targeting other than system/system_ext partitions use vendor/product variants.
2122 // So we can't link them to /system/lib libs which are core variants.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002123 if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
Jooyung Han85d61762020-06-24 23:50:26 +09002124 a.linkToSystemLib = false
2125 }
2126
Jiyong Park4da07972021-01-05 21:01:11 +09002127 forced := ctx.Config().ForceApexSymlinkOptimization()
2128
Jiyong Park9d677202020-02-19 16:29:35 +09002129 // We don't need the optimization for updatable APEXes, as it might give false signal
Jiyong Park4da07972021-01-05 21:01:11 +09002130 // to the system health when the APEXes are still bundled (b/149805758).
2131 if !forced && a.Updatable() && a.properties.ApexType == imageApex {
Jiyong Park9d677202020-02-19 16:29:35 +09002132 a.linkToSystemLib = false
2133 }
2134
Jiyong Park638d30e2020-02-26 18:27:19 +09002135 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2136 if ctx.Host() {
2137 a.linkToSystemLib = false
2138 }
2139
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002140 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
2141
2142 ////////////////////////////////////////////////////////////////////////////////////////////
2143 // 4) generate the build rules to create the APEX. This is done in builder.go.
2144 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002145 if a.properties.ApexType == flattenedApex {
2146 a.buildFlattenedApex(ctx)
2147 } else {
2148 a.buildUnflattenedApex(ctx)
2149 }
Jiyong Park956305c2020-01-09 12:32:06 +09002150 a.buildApexDependencyInfo(ctx)
Colin Cross08dca382020-07-21 20:31:17 -07002151 a.buildLintReports(ctx)
Jiyong Parkb81b9902020-11-24 19:51:18 +09002152
2153 // Append meta-files to the filesInfo list so that they are reflected in Android.mk as well.
2154 if a.installable() {
2155 // For flattened APEX, make sure that APEX manifest and apex_pubkey are also copied
2156 // along with other ordinary files. (Note that this is done by apexer for
2157 // non-flattened APEXes)
2158 a.filesInfo = append(a.filesInfo, newApexFile(ctx, a.manifestPbOut, "apex_manifest.pb", ".", etc, nil))
2159
2160 // Place the public key as apex_pubkey. This is also done by apexer for
2161 // non-flattened APEXes case.
2162 // TODO(jiyong): Why do we need this CP rule?
2163 copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
2164 ctx.Build(pctx, android.BuildParams{
2165 Rule: android.Cp,
Jaewoong Jung18aefc12020-12-21 09:11:10 -08002166 Input: a.publicKeyFile,
Jiyong Parkb81b9902020-11-24 19:51:18 +09002167 Output: copiedPubkey,
2168 })
2169 a.filesInfo = append(a.filesInfo, newApexFile(ctx, copiedPubkey, "apex_pubkey", ".", etc, nil))
2170 }
Jooyung Han01a3ee22019-11-02 02:52:25 +09002171}
2172
Paul Duffincc33ec82021-04-25 23:14:55 +01002173// apexBootclasspathFragmentFiles returns the list of apexFile structures defining the files that
2174// the bootclasspath_fragment contributes to the apex.
2175func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint.Module) []apexFile {
2176 bootclasspathFragmentInfo := ctx.OtherModuleProvider(module, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
2177 var filesToAdd []apexFile
2178
2179 // Add the boot image files, e.g. .art, .oat and .vdex files.
2180 for arch, files := range bootclasspathFragmentInfo.AndroidBootImageFilesByArchType() {
2181 dirInApex := filepath.Join("javalib", arch.String())
2182 for _, f := range files {
2183 androidMkModuleName := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
2184 // TODO(b/177892522) - consider passing in the bootclasspath fragment module here instead of nil
2185 af := newApexFile(ctx, f, androidMkModuleName, dirInApex, etc, nil)
2186 filesToAdd = append(filesToAdd, af)
2187 }
2188 }
2189
satayev3db35472021-05-06 23:59:58 +01002190 // Add classpaths.proto config.
satayevb98371c2021-06-15 16:49:50 +01002191 if af := apexClasspathFragmentProtoFile(ctx, module); af != nil {
2192 filesToAdd = append(filesToAdd, *af)
2193 }
satayev3db35472021-05-06 23:59:58 +01002194
Paul Duffincc33ec82021-04-25 23:14:55 +01002195 return filesToAdd
2196}
2197
satayevb98371c2021-06-15 16:49:50 +01002198// apexClasspathFragmentProtoFile returns *apexFile structure defining the classpath.proto config that
2199// the module contributes to the apex; or nil if the proto config was not generated.
2200func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) *apexFile {
2201 info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
2202 if !info.ClasspathFragmentProtoGenerated {
2203 return nil
2204 }
2205 classpathProtoOutput := info.ClasspathFragmentProtoOutput
2206 af := newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), info.ClasspathFragmentProtoInstallDir.Rel(), etc, nil)
2207 return &af
satayev14e49132021-05-17 21:03:07 +01002208}
2209
Paul Duffincc33ec82021-04-25 23:14:55 +01002210// apexFileForBootclasspathFragmentContentModule creates an apexFile for a bootclasspath_fragment
2211// content module, i.e. a library that is part of the bootclasspath.
Paul Duffin190fdef2021-04-26 10:33:59 +01002212func apexFileForBootclasspathFragmentContentModule(ctx android.ModuleContext, fragmentModule blueprint.Module, javaModule javaModule) apexFile {
2213 bootclasspathFragmentInfo := ctx.OtherModuleProvider(fragmentModule, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
2214
2215 // Get the dexBootJar from the bootclasspath_fragment as that is responsible for performing the
2216 // hidden API encpding.
Paul Duffin1a8010a2021-05-15 12:39:23 +01002217 dexBootJar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(javaModule)
2218 if err != nil {
2219 ctx.ModuleErrorf("%s", err)
2220 }
Paul Duffin190fdef2021-04-26 10:33:59 +01002221
2222 // Create an apexFile as for a normal java module but with the dex boot jar provided by the
2223 // bootclasspath_fragment.
2224 af := apexFileForJavaModuleWithFile(ctx, javaModule, dexBootJar)
2225 return af
Paul Duffincc33ec82021-04-25 23:14:55 +01002226}
2227
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002228///////////////////////////////////////////////////////////////////////////////////////////////////
2229// Factory functions
2230//
2231
2232func newApexBundle() *apexBundle {
2233 module := &apexBundle{}
2234
2235 module.AddProperties(&module.properties)
2236 module.AddProperties(&module.targetProperties)
Jiyong Park59140302020-12-14 18:44:04 +09002237 module.AddProperties(&module.archProperties)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002238 module.AddProperties(&module.overridableProperties)
2239
2240 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
2241 android.InitDefaultableModule(module)
2242 android.InitSdkAwareModule(module)
2243 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jingwen Chenf59a8e12021-07-16 09:28:53 +00002244 android.InitBazelModule(module)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002245 return module
2246}
2247
2248func ApexBundleFactory(testApex bool, artApex bool) android.Module {
2249 bundle := newApexBundle()
2250 bundle.testApex = testApex
2251 bundle.artApex = artApex
2252 return bundle
2253}
2254
2255// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2256// certain compatibility checks such as apex_available are not done for apex_test.
2257func testApexBundleFactory() android.Module {
2258 bundle := newApexBundle()
2259 bundle.testApex = true
2260 return bundle
2261}
2262
2263// apex packages other modules into an APEX file which is a packaging format for system-level
2264// components like binaries, shared libraries, etc.
2265func BundleFactory() android.Module {
2266 return newApexBundle()
2267}
2268
2269type Defaults struct {
2270 android.ModuleBase
2271 android.DefaultsModuleBase
2272}
2273
2274// apex_defaults provides defaultable properties to other apex modules.
2275func defaultsFactory() android.Module {
2276 return DefaultsFactory()
2277}
2278
2279func DefaultsFactory(props ...interface{}) android.Module {
2280 module := &Defaults{}
2281
2282 module.AddProperties(props...)
2283 module.AddProperties(
2284 &apexBundleProperties{},
2285 &apexTargetBundleProperties{},
2286 &overridableProperties{},
2287 )
2288
2289 android.InitDefaultsModule(module)
2290 return module
2291}
2292
2293type OverrideApex struct {
2294 android.ModuleBase
2295 android.OverrideModuleBase
2296}
2297
2298func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2299 // All the overrides happen in the base module.
2300}
2301
2302// override_apex is used to create an apex module based on another apex module by overriding some of
2303// its properties.
2304func overrideApexFactory() android.Module {
2305 m := &OverrideApex{}
2306
2307 m.AddProperties(&overridableProperties{})
2308
2309 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2310 android.InitOverrideModule(m)
2311 return m
2312}
2313
2314///////////////////////////////////////////////////////////////////////////////////////////////////
2315// Vality check routines
2316//
2317// These are called in at the very beginning of GenerateAndroidBuildActions to flag an error when
2318// certain conditions are not met.
2319//
2320// TODO(jiyong): move these checks to a separate go file.
2321
2322// Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version
2323// of this apexBundle.
2324func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) {
2325 if a.testApex || a.vndkApex {
2326 return
2327 }
2328 // Meaningless to check min_sdk_version when building use_vendor modules against non-Trebleized targets
2329 if proptools.Bool(a.properties.Use_vendor) && ctx.DeviceConfig().VndkVersion() == "" {
2330 return
2331 }
2332 // apexBundle::minSdkVersion reports its own errors.
2333 minSdkVersion := a.minSdkVersion(ctx)
2334 android.CheckMinSdkVersion(a, ctx, minSdkVersion)
2335}
2336
2337func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel {
2338 ver := proptools.String(a.properties.Min_sdk_version)
2339 if ver == "" {
Jooyung Haned124c32021-01-26 11:43:46 +09002340 return android.NoneApiLevel
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002341 }
2342 apiLevel, err := android.ApiLevelFromUser(ctx, ver)
2343 if err != nil {
2344 ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
2345 return android.NoneApiLevel
2346 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002347 return apiLevel
2348}
2349
2350// Ensures that a lib providing stub isn't statically linked
2351func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) {
2352 // Practically, we only care about regular APEXes on the device.
2353 if ctx.Host() || a.testApex || a.vndkApex {
2354 return
2355 }
2356
2357 abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
2358
2359 a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
2360 if ccm, ok := to.(*cc.Module); ok {
2361 apexName := ctx.ModuleName()
2362 fromName := ctx.OtherModuleName(from)
2363 toName := ctx.OtherModuleName(to)
2364
2365 // If `to` is not actually in the same APEX as `from` then it does not need
2366 // apex_available and neither do any of its dependencies.
Paul Duffin4c3e8e22021-03-18 15:41:29 +00002367 //
2368 // It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps().
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002369 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
2370 // As soon as the dependency graph crosses the APEX boundary, don't go further.
2371 return false
2372 }
2373
2374 // The dynamic linker and crash_dump tool in the runtime APEX is the only
2375 // exception to this rule. It can't make the static dependencies dynamic
2376 // because it can't do the dynamic linking for itself.
Kiyoung Kim4098c7e2020-11-30 14:42:14 +09002377 // Same rule should be applied to linkerconfig, because it should be executed
2378 // only with static linked libraries before linker is available with ld.config.txt
2379 if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump" || fromName == "linkerconfig") {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002380 return false
2381 }
2382
2383 isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName)
2384 if isStubLibraryFromOtherApex && !externalDep {
2385 ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
2386 "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))
2387 }
2388
2389 }
2390 return true
2391 })
2392}
2393
satayevb98371c2021-06-15 16:49:50 +01002394// checkUpdatable enforces APEX and its transitive dep properties to have desired values for updatable APEXes.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002395func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
2396 if a.Updatable() {
2397 if String(a.properties.Min_sdk_version) == "" {
2398 ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
2399 }
Jiyong Park9477c262021-06-22 20:23:05 +09002400 if a.UsePlatformApis() {
2401 ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs")
2402 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002403 a.checkJavaStableSdkVersion(ctx)
satayevb98371c2021-06-15 16:49:50 +01002404 a.checkClasspathFragments(ctx)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002405 }
2406}
2407
satayevb98371c2021-06-15 16:49:50 +01002408// checkClasspathFragments enforces that all classpath fragments in deps generate classpaths.proto config.
2409func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) {
2410 ctx.VisitDirectDeps(func(module android.Module) {
2411 if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag {
2412 info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
2413 if !info.ClasspathFragmentProtoGenerated {
2414 ctx.OtherModuleErrorf(module, "is included in updatable apex %v, it must not set generate_classpaths_proto to false", ctx.ModuleName())
2415 }
2416 }
2417 })
2418}
2419
2420// checkJavaStableSdkVersion enforces that all Java deps are using stable SDKs to compile.
Artur Satayev8cf899a2020-04-15 17:29:42 +01002421func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002422 // Visit direct deps only. As long as we guarantee top-level deps are using stable SDKs,
2423 // java's checkLinkType guarantees correct usage for transitive deps
Artur Satayev8cf899a2020-04-15 17:29:42 +01002424 ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
2425 tag := ctx.OtherModuleDependencyTag(module)
2426 switch tag {
2427 case javaLibTag, androidAppTag:
Jiyong Park92315372021-04-02 08:45:46 +09002428 if m, ok := module.(interface {
2429 CheckStableSdkVersion(ctx android.BaseModuleContext) error
2430 }); ok {
2431 if err := m.CheckStableSdkVersion(ctx); err != nil {
Artur Satayev8cf899a2020-04-15 17:29:42 +01002432 ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err)
2433 }
2434 }
2435 }
2436 })
2437}
2438
satayevb98371c2021-06-15 16:49:50 +01002439// checkApexAvailability ensures that the all the dependencies are marked as available for this APEX.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002440func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
2441 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
2442 if ctx.Host() || a.testApex || a.vndkApex {
2443 return
2444 }
2445
2446 // Because APEXes targeting other than system/system_ext partitions can't set
2447 // apex_available, we skip checks for these APEXes
2448 if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
2449 return
2450 }
2451
2452 // Coverage build adds additional dependencies for the coverage-only runtime libraries.
2453 // Requiring them and their transitive depencies with apex_available is not right
2454 // because they just add noise.
2455 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) {
2456 return
2457 }
2458
2459 a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
2460 // As soon as the dependency graph crosses the APEX boundary, don't go further.
2461 if externalDep {
2462 return false
2463 }
2464
2465 apexName := ctx.ModuleName()
2466 fromName := ctx.OtherModuleName(from)
2467 toName := ctx.OtherModuleName(to)
2468
2469 // If `to` is not actually in the same APEX as `from` then it does not need
2470 // apex_available and neither do any of its dependencies.
Paul Duffin4c3e8e22021-03-18 15:41:29 +00002471 //
2472 // It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps().
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002473 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
2474 // As soon as the dependency graph crosses the APEX boundary, don't go
2475 // further.
2476 return false
2477 }
2478
2479 if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
2480 return true
2481 }
Jiyong Park767dbd92021-03-04 13:03:10 +09002482 ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'."+
2483 "\n\nDependency path:%s\n\n"+
2484 "Consider adding %q to 'apex_available' property of %q",
2485 fromName, toName, ctx.GetPathString(true), apexName, toName)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002486 // Visit this module's dependencies to check and report any issues with their availability.
2487 return true
2488 })
2489}
2490
Jiyong Park192600a2021-08-03 07:52:17 +00002491// checkStaticExecutable ensures that executables in an APEX are not static.
2492func (a *apexBundle) checkStaticExecutables(ctx android.ModuleContext) {
2493 ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
2494 if ctx.OtherModuleDependencyTag(module) != executableTag {
2495 return
2496 }
2497 if cc, ok := module.(*cc.Module); ok && cc.StaticExecutable() {
2498 apex := a.ApexVariationName()
2499 exec := ctx.OtherModuleName(module)
2500 if isStaticExecutableAllowed(apex, exec) {
2501 return
2502 }
2503 ctx.ModuleErrorf("executable %s is static", ctx.OtherModuleName(module))
2504 }
2505 })
2506}
2507
2508// A small list of exceptions where static executables are allowed in APEXes.
2509func isStaticExecutableAllowed(apex string, exec string) bool {
2510 m := map[string][]string{
2511 "com.android.runtime": []string{
2512 "linker",
2513 "linkerconfig",
2514 },
2515 }
2516 execNames, ok := m[apex]
2517 return ok && android.InList(exec, execNames)
2518}
2519
braleeb0c1f0c2021-06-07 22:49:13 +08002520// Collect information for opening IDE project files in java/jdeps.go.
2521func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
2522 dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
2523 dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...)
2524 dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments...)
2525 dpInfo.Paths = append(dpInfo.Paths, a.modulePaths...)
2526}
2527
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002528var (
2529 apexAvailBaseline = makeApexAvailableBaseline()
2530 inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline)
2531)
2532
Colin Cross440e0d02020-06-11 11:32:11 -07002533func baselineApexAvailable(apex, moduleName string) bool {
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002534 key := apex
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002535 moduleName = normalizeModuleName(moduleName)
2536
Colin Cross440e0d02020-06-11 11:32:11 -07002537 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002538 return true
2539 }
2540
2541 key = android.AvailableToAnyApex
Colin Cross440e0d02020-06-11 11:32:11 -07002542 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002543 return true
2544 }
2545
2546 return false
2547}
2548
2549func normalizeModuleName(moduleName string) string {
Jiyong Park0f80c182020-01-31 02:49:53 +09002550 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2551 // system. Trim the prefix for the check since they are confusing
Paul Duffind23c7262020-12-11 18:13:08 +00002552 moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName)
Jiyong Park0f80c182020-01-31 02:49:53 +09002553 if strings.HasPrefix(moduleName, "libclang_rt.") {
2554 // This module has many arch variants that depend on the product being built.
2555 // We don't want to list them all
2556 moduleName = "libclang_rt"
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002557 }
Jooyung Hanacc7bbe2020-05-20 09:06:00 +09002558 if strings.HasPrefix(moduleName, "androidx.") {
2559 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries
2560 moduleName = "androidx"
2561 }
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002562 return moduleName
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002563}
2564
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002565// Transform the map of apex -> modules to module -> apexes.
2566func invertApexBaseline(m map[string][]string) map[string][]string {
2567 r := make(map[string][]string)
2568 for apex, modules := range m {
2569 for _, module := range modules {
2570 r[module] = append(r[module], apex)
2571 }
2572 }
2573 return r
2574}
2575
2576// Retrieve the baseline of apexes to which the supplied module belongs.
2577func BaselineApexAvailable(moduleName string) []string {
2578 return inverseApexAvailBaseline[normalizeModuleName(moduleName)]
2579}
2580
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002581// This is a map from apex to modules, which overrides the apex_available setting for that
2582// particular module to make it available for the apex regardless of its setting.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002583// TODO(b/147364041): remove this
2584func makeApexAvailableBaseline() map[string][]string {
2585 // The "Module separator"s below are employed to minimize merge conflicts.
2586 m := make(map[string][]string)
2587 //
2588 // Module separator
2589 //
2590 m["com.android.appsearch"] = []string{
2591 "icing-java-proto-lite",
2592 "libprotobuf-java-lite",
2593 }
2594 //
2595 // Module separator
2596 //
2597 m["com.android.bluetooth.updatable"] = []string{
2598 "android.hardware.audio.common@5.0",
2599 "android.hardware.bluetooth.a2dp@1.0",
2600 "android.hardware.bluetooth.audio@2.0",
2601 "android.hardware.bluetooth@1.0",
2602 "android.hardware.bluetooth@1.1",
2603 "android.hardware.graphics.bufferqueue@1.0",
2604 "android.hardware.graphics.bufferqueue@2.0",
2605 "android.hardware.graphics.common@1.0",
2606 "android.hardware.graphics.common@1.1",
2607 "android.hardware.graphics.common@1.2",
2608 "android.hardware.media@1.0",
2609 "android.hidl.safe_union@1.0",
2610 "android.hidl.token@1.0",
2611 "android.hidl.token@1.0-utils",
2612 "avrcp-target-service",
2613 "avrcp_headers",
2614 "bluetooth-protos-lite",
2615 "bluetooth.mapsapi",
2616 "com.android.vcard",
2617 "dnsresolver_aidl_interface-V2-java",
2618 "ipmemorystore-aidl-interfaces-V5-java",
2619 "ipmemorystore-aidl-interfaces-java",
2620 "internal_include_headers",
2621 "lib-bt-packets",
2622 "lib-bt-packets-avrcp",
2623 "lib-bt-packets-base",
2624 "libFraunhoferAAC",
2625 "libaudio-a2dp-hw-utils",
2626 "libaudio-hearing-aid-hw-utils",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002627 "libbluetooth",
2628 "libbluetooth-types",
2629 "libbluetooth-types-header",
2630 "libbluetooth_gd",
2631 "libbluetooth_headers",
2632 "libbluetooth_jni",
2633 "libbt-audio-hal-interface",
2634 "libbt-bta",
2635 "libbt-common",
2636 "libbt-hci",
2637 "libbt-platform-protos-lite",
2638 "libbt-protos-lite",
2639 "libbt-sbc-decoder",
2640 "libbt-sbc-encoder",
2641 "libbt-stack",
2642 "libbt-utils",
2643 "libbtcore",
2644 "libbtdevice",
2645 "libbte",
2646 "libbtif",
2647 "libchrome",
2648 "libevent",
2649 "libfmq",
2650 "libg722codec",
2651 "libgui_headers",
2652 "libmedia_headers",
2653 "libmodpb64",
2654 "libosi",
2655 "libstagefright_foundation_headers",
2656 "libstagefright_headers",
2657 "libstatslog",
2658 "libstatssocket",
2659 "libtinyxml2",
2660 "libudrv-uipc",
2661 "libz",
2662 "media_plugin_headers",
2663 "net-utils-services-common",
2664 "netd_aidl_interface-unstable-java",
2665 "netd_event_listener_interface-java",
2666 "netlink-client",
2667 "networkstack-client",
2668 "sap-api-java-static",
2669 "services.net",
2670 }
2671 //
2672 // Module separator
2673 //
2674 m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
2675 //
2676 // Module separator
2677 //
2678 m["com.android.extservices"] = []string{
2679 "error_prone_annotations",
2680 "ExtServices-core",
2681 "ExtServices",
2682 "libtextclassifier-java",
2683 "libz_current",
2684 "textclassifier-statsd",
2685 "TextClassifierNotificationLibNoManifest",
2686 "TextClassifierServiceLibNoManifest",
2687 }
2688 //
2689 // Module separator
2690 //
2691 m["com.android.neuralnetworks"] = []string{
2692 "android.hardware.neuralnetworks@1.0",
2693 "android.hardware.neuralnetworks@1.1",
2694 "android.hardware.neuralnetworks@1.2",
2695 "android.hardware.neuralnetworks@1.3",
2696 "android.hidl.allocator@1.0",
2697 "android.hidl.memory.token@1.0",
2698 "android.hidl.memory@1.0",
2699 "android.hidl.safe_union@1.0",
2700 "libarect",
2701 "libbuildversion",
2702 "libmath",
2703 "libprocpartition",
2704 "libsync",
2705 }
2706 //
2707 // Module separator
2708 //
2709 m["com.android.media"] = []string{
2710 "android.frameworks.bufferhub@1.0",
2711 "android.hardware.cas.native@1.0",
2712 "android.hardware.cas@1.0",
2713 "android.hardware.configstore-utils",
2714 "android.hardware.configstore@1.0",
2715 "android.hardware.configstore@1.1",
2716 "android.hardware.graphics.allocator@2.0",
2717 "android.hardware.graphics.allocator@3.0",
2718 "android.hardware.graphics.bufferqueue@1.0",
2719 "android.hardware.graphics.bufferqueue@2.0",
2720 "android.hardware.graphics.common@1.0",
2721 "android.hardware.graphics.common@1.1",
2722 "android.hardware.graphics.common@1.2",
2723 "android.hardware.graphics.mapper@2.0",
2724 "android.hardware.graphics.mapper@2.1",
2725 "android.hardware.graphics.mapper@3.0",
2726 "android.hardware.media.omx@1.0",
2727 "android.hardware.media@1.0",
2728 "android.hidl.allocator@1.0",
2729 "android.hidl.memory.token@1.0",
2730 "android.hidl.memory@1.0",
2731 "android.hidl.token@1.0",
2732 "android.hidl.token@1.0-utils",
2733 "bionic_libc_platform_headers",
2734 "exoplayer2-extractor",
2735 "exoplayer2-extractor-annotation-stubs",
2736 "gl_headers",
2737 "jsr305",
2738 "libEGL",
2739 "libEGL_blobCache",
2740 "libEGL_getProcAddress",
2741 "libFLAC",
2742 "libFLAC-config",
2743 "libFLAC-headers",
2744 "libGLESv2",
2745 "libaacextractor",
2746 "libamrextractor",
2747 "libarect",
2748 "libaudio_system_headers",
2749 "libaudioclient",
2750 "libaudioclient_headers",
2751 "libaudiofoundation",
2752 "libaudiofoundation_headers",
2753 "libaudiomanager",
2754 "libaudiopolicy",
2755 "libaudioutils",
2756 "libaudioutils_fixedfft",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002757 "libbluetooth-types-header",
2758 "libbufferhub",
2759 "libbufferhub_headers",
2760 "libbufferhubqueue",
2761 "libc_malloc_debug_backtrace",
2762 "libcamera_client",
2763 "libcamera_metadata",
2764 "libdvr_headers",
2765 "libexpat",
2766 "libfifo",
2767 "libflacextractor",
2768 "libgrallocusage",
2769 "libgraphicsenv",
2770 "libgui",
2771 "libgui_headers",
2772 "libhardware_headers",
2773 "libinput",
2774 "liblzma",
2775 "libmath",
2776 "libmedia",
2777 "libmedia_codeclist",
2778 "libmedia_headers",
2779 "libmedia_helper",
2780 "libmedia_helper_headers",
2781 "libmedia_midiiowrapper",
2782 "libmedia_omx",
2783 "libmediautils",
2784 "libmidiextractor",
2785 "libmkvextractor",
2786 "libmp3extractor",
2787 "libmp4extractor",
2788 "libmpeg2extractor",
2789 "libnativebase_headers",
2790 "libnativewindow_headers",
2791 "libnblog",
2792 "liboggextractor",
2793 "libpackagelistparser",
2794 "libpdx",
2795 "libpdx_default_transport",
2796 "libpdx_headers",
2797 "libpdx_uds",
2798 "libprocinfo",
2799 "libspeexresampler",
2800 "libspeexresampler",
2801 "libstagefright_esds",
2802 "libstagefright_flacdec",
2803 "libstagefright_flacdec",
2804 "libstagefright_foundation",
2805 "libstagefright_foundation_headers",
2806 "libstagefright_foundation_without_imemory",
2807 "libstagefright_headers",
2808 "libstagefright_id3",
2809 "libstagefright_metadatautils",
2810 "libstagefright_mpeg2extractor",
2811 "libstagefright_mpeg2support",
2812 "libsync",
2813 "libui",
2814 "libui_headers",
2815 "libunwindstack",
2816 "libvibrator",
2817 "libvorbisidec",
2818 "libwavextractor",
2819 "libwebm",
2820 "media_ndk_headers",
2821 "media_plugin_headers",
2822 "updatable-media",
2823 }
2824 //
2825 // Module separator
2826 //
2827 m["com.android.media.swcodec"] = []string{
2828 "android.frameworks.bufferhub@1.0",
2829 "android.hardware.common-ndk_platform",
2830 "android.hardware.configstore-utils",
2831 "android.hardware.configstore@1.0",
2832 "android.hardware.configstore@1.1",
2833 "android.hardware.graphics.allocator@2.0",
2834 "android.hardware.graphics.allocator@3.0",
2835 "android.hardware.graphics.allocator@4.0",
2836 "android.hardware.graphics.bufferqueue@1.0",
2837 "android.hardware.graphics.bufferqueue@2.0",
2838 "android.hardware.graphics.common-ndk_platform",
2839 "android.hardware.graphics.common@1.0",
2840 "android.hardware.graphics.common@1.1",
2841 "android.hardware.graphics.common@1.2",
2842 "android.hardware.graphics.mapper@2.0",
2843 "android.hardware.graphics.mapper@2.1",
2844 "android.hardware.graphics.mapper@3.0",
2845 "android.hardware.graphics.mapper@4.0",
2846 "android.hardware.media.bufferpool@2.0",
2847 "android.hardware.media.c2@1.0",
2848 "android.hardware.media.c2@1.1",
2849 "android.hardware.media.omx@1.0",
2850 "android.hardware.media@1.0",
2851 "android.hardware.media@1.0",
2852 "android.hidl.memory.token@1.0",
2853 "android.hidl.memory@1.0",
2854 "android.hidl.safe_union@1.0",
2855 "android.hidl.token@1.0",
2856 "android.hidl.token@1.0-utils",
2857 "libEGL",
2858 "libFLAC",
2859 "libFLAC-config",
2860 "libFLAC-headers",
2861 "libFraunhoferAAC",
2862 "libLibGuiProperties",
2863 "libarect",
2864 "libaudio_system_headers",
2865 "libaudioutils",
2866 "libaudioutils",
2867 "libaudioutils_fixedfft",
2868 "libavcdec",
2869 "libavcenc",
2870 "libavservices_minijail",
2871 "libavservices_minijail",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002872 "libbinderthreadstateutils",
2873 "libbluetooth-types-header",
2874 "libbufferhub_headers",
2875 "libcodec2",
2876 "libcodec2_headers",
2877 "libcodec2_hidl@1.0",
2878 "libcodec2_hidl@1.1",
2879 "libcodec2_internal",
2880 "libcodec2_soft_aacdec",
2881 "libcodec2_soft_aacenc",
2882 "libcodec2_soft_amrnbdec",
2883 "libcodec2_soft_amrnbenc",
2884 "libcodec2_soft_amrwbdec",
2885 "libcodec2_soft_amrwbenc",
2886 "libcodec2_soft_av1dec_gav1",
2887 "libcodec2_soft_avcdec",
2888 "libcodec2_soft_avcenc",
2889 "libcodec2_soft_common",
2890 "libcodec2_soft_flacdec",
2891 "libcodec2_soft_flacenc",
2892 "libcodec2_soft_g711alawdec",
2893 "libcodec2_soft_g711mlawdec",
2894 "libcodec2_soft_gsmdec",
2895 "libcodec2_soft_h263dec",
2896 "libcodec2_soft_h263enc",
2897 "libcodec2_soft_hevcdec",
2898 "libcodec2_soft_hevcenc",
2899 "libcodec2_soft_mp3dec",
2900 "libcodec2_soft_mpeg2dec",
2901 "libcodec2_soft_mpeg4dec",
2902 "libcodec2_soft_mpeg4enc",
2903 "libcodec2_soft_opusdec",
2904 "libcodec2_soft_opusenc",
2905 "libcodec2_soft_rawdec",
2906 "libcodec2_soft_vorbisdec",
2907 "libcodec2_soft_vp8dec",
2908 "libcodec2_soft_vp8enc",
2909 "libcodec2_soft_vp9dec",
2910 "libcodec2_soft_vp9enc",
2911 "libcodec2_vndk",
2912 "libdvr_headers",
2913 "libfmq",
2914 "libfmq",
2915 "libgav1",
2916 "libgralloctypes",
2917 "libgrallocusage",
2918 "libgraphicsenv",
2919 "libgsm",
2920 "libgui_bufferqueue_static",
2921 "libgui_headers",
2922 "libhardware",
2923 "libhardware_headers",
2924 "libhevcdec",
2925 "libhevcenc",
2926 "libion",
2927 "libjpeg",
2928 "liblzma",
2929 "libmath",
2930 "libmedia_codecserviceregistrant",
2931 "libmedia_headers",
2932 "libmpeg2dec",
2933 "libnativebase_headers",
2934 "libnativewindow_headers",
2935 "libpdx_headers",
2936 "libscudo_wrapper",
2937 "libsfplugin_ccodec_utils",
2938 "libspeexresampler",
2939 "libstagefright_amrnb_common",
2940 "libstagefright_amrnbdec",
2941 "libstagefright_amrnbenc",
2942 "libstagefright_amrwbdec",
2943 "libstagefright_amrwbenc",
2944 "libstagefright_bufferpool@2.0.1",
2945 "libstagefright_bufferqueue_helper",
2946 "libstagefright_enc_common",
2947 "libstagefright_flacdec",
2948 "libstagefright_foundation",
2949 "libstagefright_foundation_headers",
2950 "libstagefright_headers",
2951 "libstagefright_m4vh263dec",
2952 "libstagefright_m4vh263enc",
2953 "libstagefright_mp3dec",
2954 "libsync",
2955 "libui",
2956 "libui_headers",
2957 "libunwindstack",
2958 "libvorbisidec",
2959 "libvpx",
2960 "libyuv",
2961 "libyuv_static",
2962 "media_ndk_headers",
2963 "media_plugin_headers",
2964 "mediaswcodec",
2965 }
2966 //
2967 // Module separator
2968 //
2969 m["com.android.mediaprovider"] = []string{
2970 "MediaProvider",
2971 "MediaProviderGoogle",
2972 "fmtlib_ndk",
2973 "libbase_ndk",
2974 "libfuse",
2975 "libfuse_jni",
2976 }
2977 //
2978 // Module separator
2979 //
2980 m["com.android.permission"] = []string{
2981 "car-ui-lib",
2982 "iconloader",
2983 "kotlin-annotations",
2984 "kotlin-stdlib",
2985 "kotlin-stdlib-jdk7",
2986 "kotlin-stdlib-jdk8",
2987 "kotlinx-coroutines-android",
2988 "kotlinx-coroutines-android-nodeps",
2989 "kotlinx-coroutines-core",
2990 "kotlinx-coroutines-core-nodeps",
2991 "permissioncontroller-statsd",
2992 "GooglePermissionController",
2993 "PermissionController",
2994 "SettingsLibActionBarShadow",
2995 "SettingsLibAppPreference",
2996 "SettingsLibBarChartPreference",
2997 "SettingsLibLayoutPreference",
2998 "SettingsLibProgressBar",
2999 "SettingsLibSearchWidget",
3000 "SettingsLibSettingsTheme",
3001 "SettingsLibRestrictedLockUtils",
3002 "SettingsLibHelpUtils",
3003 }
3004 //
3005 // Module separator
3006 //
3007 m["com.android.runtime"] = []string{
3008 "bionic_libc_platform_headers",
3009 "libarm-optimized-routines-math",
3010 "libc_aeabi",
3011 "libc_bionic",
3012 "libc_bionic_ndk",
3013 "libc_bootstrap",
3014 "libc_common",
3015 "libc_common_shared",
3016 "libc_common_static",
3017 "libc_dns",
3018 "libc_dynamic_dispatch",
3019 "libc_fortify",
3020 "libc_freebsd",
3021 "libc_freebsd_large_stack",
3022 "libc_gdtoa",
3023 "libc_init_dynamic",
3024 "libc_init_static",
3025 "libc_jemalloc_wrapper",
3026 "libc_netbsd",
3027 "libc_nomalloc",
3028 "libc_nopthread",
3029 "libc_openbsd",
3030 "libc_openbsd_large_stack",
3031 "libc_openbsd_ndk",
3032 "libc_pthread",
3033 "libc_static_dispatch",
3034 "libc_syscalls",
3035 "libc_tzcode",
3036 "libc_unwind_static",
3037 "libdebuggerd",
3038 "libdebuggerd_common_headers",
3039 "libdebuggerd_handler_core",
3040 "libdebuggerd_handler_fallback",
3041 "libdl_static",
3042 "libjemalloc5",
3043 "liblinker_main",
3044 "liblinker_malloc",
3045 "liblz4",
3046 "liblzma",
3047 "libprocinfo",
3048 "libpropertyinfoparser",
3049 "libscudo",
3050 "libstdc++",
3051 "libsystemproperties",
3052 "libtombstoned_client_static",
3053 "libunwindstack",
3054 "libz",
3055 "libziparchive",
3056 }
3057 //
3058 // Module separator
3059 //
3060 m["com.android.tethering"] = []string{
3061 "android.hardware.tetheroffload.config-V1.0-java",
3062 "android.hardware.tetheroffload.control-V1.0-java",
3063 "android.hidl.base-V1.0-java",
3064 "libcgrouprc",
3065 "libcgrouprc_format",
3066 "libtetherutilsjni",
3067 "libvndksupport",
3068 "net-utils-framework-common",
3069 "netd_aidl_interface-V3-java",
3070 "netlink-client",
3071 "networkstack-aidl-interfaces-java",
3072 "tethering-aidl-interfaces-java",
3073 "TetheringApiCurrentLib",
3074 }
3075 //
3076 // Module separator
3077 //
3078 m["com.android.wifi"] = []string{
3079 "PlatformProperties",
3080 "android.hardware.wifi-V1.0-java",
3081 "android.hardware.wifi-V1.0-java-constants",
3082 "android.hardware.wifi-V1.1-java",
3083 "android.hardware.wifi-V1.2-java",
3084 "android.hardware.wifi-V1.3-java",
3085 "android.hardware.wifi-V1.4-java",
3086 "android.hardware.wifi.hostapd-V1.0-java",
3087 "android.hardware.wifi.hostapd-V1.1-java",
3088 "android.hardware.wifi.hostapd-V1.2-java",
3089 "android.hardware.wifi.supplicant-V1.0-java",
3090 "android.hardware.wifi.supplicant-V1.1-java",
3091 "android.hardware.wifi.supplicant-V1.2-java",
3092 "android.hardware.wifi.supplicant-V1.3-java",
3093 "android.hidl.base-V1.0-java",
3094 "android.hidl.manager-V1.0-java",
3095 "android.hidl.manager-V1.1-java",
3096 "android.hidl.manager-V1.2-java",
3097 "bouncycastle-unbundled",
3098 "dnsresolver_aidl_interface-V2-java",
3099 "error_prone_annotations",
3100 "framework-wifi-pre-jarjar",
3101 "framework-wifi-util-lib",
3102 "ipmemorystore-aidl-interfaces-V3-java",
3103 "ipmemorystore-aidl-interfaces-java",
3104 "ksoap2",
3105 "libnanohttpd",
3106 "libwifi-jni",
3107 "net-utils-services-common",
3108 "netd_aidl_interface-V2-java",
3109 "netd_aidl_interface-unstable-java",
3110 "netd_event_listener_interface-java",
3111 "netlink-client",
3112 "networkstack-client",
3113 "services.net",
3114 "wifi-lite-protos",
3115 "wifi-nano-protos",
3116 "wifi-service-pre-jarjar",
3117 "wifi-service-resources",
3118 }
3119 //
3120 // Module separator
3121 //
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003122 m["com.android.os.statsd"] = []string{
3123 "libstatssocket",
3124 }
3125 //
3126 // Module separator
3127 //
3128 m[android.AvailableToAnyApex] = []string{
3129 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries
3130 "androidx",
3131 "androidx-constraintlayout_constraintlayout",
3132 "androidx-constraintlayout_constraintlayout-nodeps",
3133 "androidx-constraintlayout_constraintlayout-solver",
3134 "androidx-constraintlayout_constraintlayout-solver-nodeps",
3135 "com.google.android.material_material",
3136 "com.google.android.material_material-nodeps",
3137
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003138 "libclang_rt",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003139 "libprofile-clang-extras",
3140 "libprofile-clang-extras_ndk",
3141 "libprofile-extras",
3142 "libprofile-extras_ndk",
Ryan Prichardb35a85e2021-01-13 19:18:53 -08003143 "libunwind",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003144 }
3145 return m
3146}
3147
3148func init() {
3149 android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...)
3150 android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...)
3151}
3152
3153func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule {
3154 rules := make([]android.Rule, 0, len(modules_packages))
3155 for module_name, module_packages := range modules_packages {
Jaewoong Jung18aefc12020-12-21 09:11:10 -08003156 permittedPackagesRule := android.NeverAllow().
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003157 BootclasspathJar().
3158 With("apex_available", module_name).
3159 WithMatcher("permitted_packages", android.NotInList(module_packages)).
3160 Because("jars that are part of the " + module_name +
3161 " module may only allow these packages: " + strings.Join(module_packages, ",") +
3162 ". Please jarjar or move code around.")
Jaewoong Jung18aefc12020-12-21 09:11:10 -08003163 rules = append(rules, permittedPackagesRule)
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003164 }
3165 return rules
3166}
3167
3168// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
3169// Adding code to the bootclasspath in new packages will cause issues on module update.
3170func qModulesPackages() map[string][]string {
3171 return map[string][]string{
3172 "com.android.conscrypt": []string{
3173 "android.net.ssl",
3174 "com.android.org.conscrypt",
3175 },
3176 "com.android.media": []string{
3177 "android.media",
3178 },
3179 }
3180}
3181
3182// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
3183// Adding code to the bootclasspath in new packages will cause issues on module update.
3184func rModulesPackages() map[string][]string {
3185 return map[string][]string{
3186 "com.android.mediaprovider": []string{
3187 "android.provider",
3188 },
3189 "com.android.permission": []string{
3190 "android.permission",
3191 "android.app.role",
3192 "com.android.permission",
3193 "com.android.role",
3194 },
3195 "com.android.sdkext": []string{
3196 "android.os.ext",
3197 },
3198 "com.android.os.statsd": []string{
3199 "android.app",
3200 "android.os",
3201 "android.util",
3202 "com.android.internal.statsd",
3203 "com.android.server.stats",
3204 },
3205 "com.android.wifi": []string{
3206 "com.android.server.wifi",
3207 "com.android.wifi.x",
3208 "android.hardware.wifi",
3209 "android.net.wifi",
3210 },
3211 "com.android.tethering": []string{
3212 "android.net",
3213 },
3214 }
3215}
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003216
3217// For Bazel / bp2build
3218
3219type bazelApexBundleAttributes struct {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -04003220 Manifest bazel.LabelAttribute
3221 Android_manifest bazel.LabelAttribute
3222 File_contexts bazel.LabelAttribute
3223 Key bazel.LabelAttribute
3224 Certificate bazel.LabelAttribute
3225 Min_sdk_version string
3226 Updatable bazel.BoolAttribute
3227 Installable bazel.BoolAttribute
3228 Native_shared_libs bazel.LabelListAttribute
3229 Binaries bazel.StringListAttribute
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003230}
3231
3232type bazelApexBundle struct {
3233 android.BazelTargetModuleBase
3234 bazelApexBundleAttributes
3235}
3236
3237func BazelApexBundleFactory() android.Module {
3238 module := &bazelApexBundle{}
3239 module.AddProperties(&module.bazelApexBundleAttributes)
3240 android.InitBazelTargetModule(module)
3241 return module
3242}
3243
3244func ApexBundleBp2Build(ctx android.TopDownMutatorContext) {
3245 module, ok := ctx.Module().(*apexBundle)
3246 if !ok {
3247 // Not an APEX bundle
3248 return
3249 }
3250 if !module.ConvertWithBp2build(ctx) {
3251 return
3252 }
3253 if ctx.ModuleType() != "apex" {
3254 return
3255 }
3256
3257 apexBundleBp2BuildInternal(ctx, module)
3258}
3259
3260func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexBundle) {
3261 var manifestLabelAttribute bazel.LabelAttribute
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003262 if module.properties.Manifest != nil {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -04003263 manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.Manifest))
3264 }
3265
3266 var androidManifestLabelAttribute bazel.LabelAttribute
3267 if module.properties.AndroidManifest != nil {
3268 androidManifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.AndroidManifest))
3269 }
3270
3271 var fileContextsLabelAttribute bazel.LabelAttribute
3272 if module.properties.File_contexts != nil {
3273 fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.properties.File_contexts))
3274 }
3275
3276 var minSdkVersion string
3277 if module.properties.Min_sdk_version != nil {
3278 minSdkVersion = *module.properties.Min_sdk_version
3279 }
3280
3281 var keyLabelAttribute bazel.LabelAttribute
3282 if module.overridableProperties.Key != nil {
3283 keyLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.overridableProperties.Key))
3284 }
3285
3286 var certificateLabelAttribute bazel.LabelAttribute
3287 if module.overridableProperties.Certificate != nil {
3288 certificateLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.overridableProperties.Certificate))
3289 }
3290
3291 nativeSharedLibs := module.properties.ApexNativeDependencies.Native_shared_libs
3292 nativeSharedLibsLabelList := android.BazelLabelForModuleDeps(ctx, nativeSharedLibs)
3293 nativeSharedLibsLabelListAttribute := bazel.MakeLabelListAttribute(nativeSharedLibsLabelList)
3294
3295 binaries := module.properties.ApexNativeDependencies.Binaries
3296 binariesStringListAttribute := bazel.MakeStringListAttribute(binaries)
3297
3298 var updatableAttribute bazel.BoolAttribute
3299 if module.properties.Updatable != nil {
3300 updatableAttribute.Value = module.properties.Updatable
3301 }
3302
3303 var installableAttribute bazel.BoolAttribute
3304 if module.properties.Installable != nil {
3305 installableAttribute.Value = module.properties.Installable
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003306 }
3307
3308 attrs := &bazelApexBundleAttributes{
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -04003309 Manifest: manifestLabelAttribute,
3310 Android_manifest: androidManifestLabelAttribute,
3311 File_contexts: fileContextsLabelAttribute,
3312 Min_sdk_version: minSdkVersion,
3313 Key: keyLabelAttribute,
3314 Certificate: certificateLabelAttribute,
3315 Updatable: updatableAttribute,
3316 Installable: installableAttribute,
3317 Native_shared_libs: nativeSharedLibsLabelListAttribute,
3318 Binaries: binariesStringListAttribute,
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003319 }
3320
3321 props := bazel.BazelTargetModuleProperties{
3322 Rule_class: "apex",
3323 Bzl_load_location: "//build/bazel/rules:apex.bzl",
3324 }
3325
3326 ctx.CreateBazelTargetModule(BazelApexBundleFactory, module.Name(), props, attrs)
3327}
3328
3329func (m *bazelApexBundle) Name() string {
3330 return m.BaseModuleName()
3331}
3332
3333func (m *bazelApexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {}