blob: 6bafcae52db1b67b4037d9830ae78b97164bc0e0 [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 Park12a719c2021-01-07 15:31:24 +0900120 // List of filesystem images that are embedded inside this APEX bundle.
121 Filesystems []string
122
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900123 // The minimum SDK version that this APEX must support at minimum. This is usually set to
124 // the SDK version that the APEX was first introduced.
125 Min_sdk_version *string
126
127 // Whether this APEX is considered updatable or not. When set to true, this will enforce
128 // additional rules for making sure that the APEX is truly updatable. To be updatable,
129 // min_sdk_version should be set as well. This will also disable the size optimizations like
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +0000130 // symlinking to the system libs. Default is true.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900131 Updatable *bool
132
Jiyong Park9477c262021-06-22 20:23:05 +0900133 // Whether this APEX can use platform APIs or not. Can be set to true only when `updatable:
134 // false`. Default is false.
135 Platform_apis *bool
136
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900137 // Whether this APEX is installable to one of the partitions like system, vendor, etc.
138 // Default: true.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900139 Installable *bool
140
Mohammad Samiul Islam3cd005d2020-11-26 13:32:26 +0000141 // Whether this APEX can be compressed or not. Setting this property to false means this
142 // APEX will never be compressed. When set to true, APEX will be compressed if other
143 // conditions, e.g, target device needs to support APEX compression, are also fulfilled.
144 // Default: true.
145 Compressible *bool
146
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900147 // For native libraries and binaries, use the vendor variant instead of the core (platform)
148 // variant. Default is false. DO NOT use this for APEXes that are installed to the system or
149 // system_ext partition.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900150 Use_vendor *bool
151
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900152 // If set true, VNDK libs are considered as stable libs and are not included in this APEX.
153 // Should be only used in non-system apexes (e.g. vendor: true). Default is false.
154 Use_vndk_as_stable *bool
155
156 // List of SDKs that are used to build this APEX. A reference to an SDK should be either
157 // `name#version` or `name` which is an alias for `name#current`. If left empty,
158 // `platform#current` is implied. This value affects all modules included in this APEX. In
159 // other words, they are also built with the SDKs specified here.
160 Uses_sdks []string
161
162 // The type of APEX to build. Controls what the APEX payload is. Either 'image', 'zip' or
163 // 'both'. When set to image, contents are stored in a filesystem image inside a zip
164 // container. When set to zip, contents are stored in a zip container directly. This type is
165 // mostly for host-side debugging. When set to both, the two types are both built. Default
166 // is 'image'.
167 Payload_type *string
168
169 // The type of filesystem to use when the payload_type is 'image'. Either 'ext4' or 'f2fs'.
170 // Default 'ext4'.
171 Payload_fs_type *string
172
173 // For telling the APEX to ignore special handling for system libraries such as bionic.
174 // Default is false.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900175 Ignore_system_library_special_case *bool
176
Nikita Ioffe9d9960f2021-06-09 19:43:46 +0100177 // Whenever apex_payload.img of the APEX should include dm-verity hashtree.
Nikita Ioffee261ae62021-06-16 18:15:03 +0100178 // Default value is true.
Nikita Ioffe9d9960f2021-06-09 19:43:46 +0100179 Generate_hashtree *bool
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900180
181 // Whenever apex_payload.img of the APEX should not be dm-verity signed. Should be only
182 // used in tests.
183 Test_only_unsigned_payload *bool
184
Mohammad Samiul Islama8008f92020-12-22 10:47:50 +0000185 // Whenever apex should be compressed, regardless of product flag used. Should be only
186 // used in tests.
187 Test_only_force_compression *bool
188
Martin Stjernholmbfffae72021-06-24 14:37:13 +0100189 // Canonical name of this APEX bundle. Used to determine the path to the
190 // activated APEX on device (i.e. /apex/<apexVariationName>), and used for the
191 // apex mutator variations. For override_apex modules, this is the name of the
192 // overridden base module.
193 ApexVariationName string `blueprint:"mutated"`
194
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900195 IsCoverageVariant bool `blueprint:"mutated"`
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900196
197 // List of sanitizer names that this APEX is enabled for
198 SanitizerNames []string `blueprint:"mutated"`
199
200 PreventInstall bool `blueprint:"mutated"`
201
202 HideFromMake bool `blueprint:"mutated"`
203
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900204 // Internal package method for this APEX. When payload_type is image, this can be either
205 // imageApex or flattenedApex depending on Config.FlattenApex(). When payload_type is zip,
206 // this becomes zipApex.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900207 ApexType apexPackaging `blueprint:"mutated"`
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900208}
209
210type ApexNativeDependencies struct {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900211 // List of native libraries that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900212 Native_shared_libs []string
213
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900214 // List of JNI libraries that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900215 Jni_libs []string
216
Jiyong Park99644e92020-11-17 22:21:02 +0900217 // List of rust dyn libraries
218 Rust_dyn_libs []string
219
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900220 // List of native executables that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900221 Binaries []string
222
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900223 // List of native tests that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900224 Tests []string
Jiyong Park06711462021-02-15 17:54:43 +0900225
226 // List of filesystem images that are embedded inside this APEX bundle.
227 Filesystems []string
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900228}
229
230type apexMultilibProperties struct {
231 // Native dependencies whose compile_multilib is "first"
232 First ApexNativeDependencies
233
234 // Native dependencies whose compile_multilib is "both"
235 Both ApexNativeDependencies
236
237 // Native dependencies whose compile_multilib is "prefer32"
238 Prefer32 ApexNativeDependencies
239
240 // Native dependencies whose compile_multilib is "32"
241 Lib32 ApexNativeDependencies
242
243 // Native dependencies whose compile_multilib is "64"
244 Lib64 ApexNativeDependencies
245}
246
247type apexTargetBundleProperties struct {
248 Target struct {
249 // Multilib properties only for android.
250 Android struct {
251 Multilib apexMultilibProperties
252 }
253
254 // Multilib properties only for host.
255 Host struct {
256 Multilib apexMultilibProperties
257 }
258
259 // Multilib properties only for host linux_bionic.
260 Linux_bionic struct {
261 Multilib apexMultilibProperties
262 }
263
264 // Multilib properties only for host linux_glibc.
265 Linux_glibc struct {
266 Multilib apexMultilibProperties
267 }
268 }
269}
270
Jiyong Park59140302020-12-14 18:44:04 +0900271type apexArchBundleProperties struct {
272 Arch struct {
273 Arm struct {
274 ApexNativeDependencies
275 }
276 Arm64 struct {
277 ApexNativeDependencies
278 }
279 X86 struct {
280 ApexNativeDependencies
281 }
282 X86_64 struct {
283 ApexNativeDependencies
284 }
285 }
286}
287
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900288// These properties can be used in override_apex to override the corresponding properties in the
289// base apex.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900290type overridableProperties struct {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900291 // List of APKs that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900292 Apps []string
293
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900294 // List of runtime resource overlays (RROs) that are embedded inside this APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900295 Rros []string
296
markchien7c803b82021-08-26 22:10:06 +0800297 // List of BPF programs inside this APEX bundle.
298 Bpfs []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...)
Jiyong Park12a719c2021-01-07 15:31:24 +0900783 ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
Paul Duffin0b817782021-03-17 15:02:19 +0000784 ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...)
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900785
Ulya Trafimovicha4a1c4e2021-01-15 18:40:04 +0000786 if a.artApex {
787 // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
788 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
789 ctx.AddFarVariationDependencies(commonVariation, javaLibTag, "jacocoagent")
790 }
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900791 }
792
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900793 // Marks that this APEX (in fact all the modules in it) has to be built with the given SDKs.
794 // This field currently isn't used.
795 // TODO(jiyong): consider dropping this feature
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900796 // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
797 if len(a.properties.Uses_sdks) > 0 {
798 sdkRefs := []android.SdkRef{}
799 for _, str := range a.properties.Uses_sdks {
800 parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
801 sdkRefs = append(sdkRefs, parsed)
802 }
803 a.BuildWithSdks(sdkRefs)
Andrei Onea115e7e72020-06-05 21:14:03 +0100804 }
805}
806
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900807// DepsMutator for the overridden properties.
Jiyong Park8e6d52f2020-11-19 14:37:47 +0900808func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
809 if a.overridableProperties.Allowed_files != nil {
810 android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files)
Andrei Onea115e7e72020-06-05 21:14:03 +0100811 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900812
813 commonVariation := ctx.Config().AndroidCommonTarget.Variations()
814 ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...)
markchien7c803b82021-08-26 22:10:06 +0800815 ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.overridableProperties.Bpfs...)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +0900816 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 }
1103 mctx.CreateVariations(apexBundleName)
Martin Stjernholmec009002021-03-27 15:18:31 +00001104 if strings.HasPrefix(apexBundleName, "com.android.art") {
1105 // TODO(b/183882457): See note for CreateAliasVariation above.
1106 mctx.CreateAliasVariation("", apexBundleName)
1107 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001108 }
1109}
Sundong Ahne9b55722019-09-06 17:37:42 +09001110
Paul Duffin6717d882021-06-15 19:09:41 +01001111// apexModuleTypeRequiresVariant determines whether the module supplied requires an apex specific
1112// variant.
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001113func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool {
Paul Duffin6717d882021-06-15 19:09:41 +01001114 if a, ok := module.(*apexBundle); ok {
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001115 // TODO(jiyong): document the reason why the VNDK APEX is an exception here.
Paul Duffin6717d882021-06-15 19:09:41 +01001116 return !a.vndkApex
1117 }
1118
Martin Stjernholmbfffae72021-06-24 14:37:13 +01001119 return true
Paul Duffin6717d882021-06-15 19:09:41 +01001120}
1121
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001122// See android.UpdateDirectlyInAnyApex
1123// TODO(jiyong): move this to android/apex.go?
Colin Cross56a83212020-09-15 18:30:11 -07001124func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {
1125 if !mctx.Module().Enabled() {
1126 return
1127 }
1128 if am, ok := mctx.Module().(android.ApexModule); ok {
1129 android.UpdateDirectlyInAnyApex(mctx, am)
1130 }
1131}
1132
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001133// apexPackaging represents a specific packaging method for an APEX.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001134type apexPackaging int
1135
1136const (
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001137 // imageApex is a packaging method where contents are included in a filesystem image which
1138 // is then included in a zip container. This is the most typical way of packaging.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001139 imageApex apexPackaging = iota
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001140
1141 // zipApex is a packaging method where contents are directly included in the zip container.
1142 // This is used for host-side testing - because the contents are easily accessible by
1143 // unzipping the container.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001144 zipApex
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001145
1146 // flattendApex is a packaging method where contents are not included in the APEX file, but
1147 // installed to /apex/<apexname> directory on the device. This packaging method is used for
1148 // old devices where the filesystem-based APEX file can't be supported.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001149 flattenedApex
1150)
1151
1152const (
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001153 // File extensions of an APEX for different packaging methods
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001154 imageApexSuffix = ".apex"
1155 zipApexSuffix = ".zipapex"
1156 flattenedSuffix = ".flattened"
1157
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001158 // variant names each of which is for a packaging method
Jiyong Park8e6d52f2020-11-19 14:37:47 +09001159 imageApexType = "image"
1160 zipApexType = "zip"
1161 flattenedApexType = "flattened"
1162
1163 ext4FsType = "ext4"
1164 f2fsFsType = "f2fs"
1165)
1166
1167// The suffix for the output "file", not the module
1168func (a apexPackaging) suffix() string {
1169 switch a {
1170 case imageApex:
1171 return imageApexSuffix
1172 case zipApex:
1173 return zipApexSuffix
1174 default:
1175 panic(fmt.Errorf("unknown APEX type %d", a))
1176 }
1177}
1178
1179func (a apexPackaging) name() string {
1180 switch a {
1181 case imageApex:
1182 return imageApexType
1183 case zipApex:
1184 return zipApexType
1185 default:
1186 panic(fmt.Errorf("unknown APEX type %d", a))
1187 }
1188}
1189
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001190// apexFlattenedMutator creates one or more variations each of which is for a packaging method.
1191// TODO(jiyong): give a better name to this mutator
Sundong Ahne9b55722019-09-06 17:37:42 +09001192func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
Jooyung Han49f67012020-04-17 13:43:10 +09001193 if !mctx.Module().Enabled() {
1194 return
1195 }
Sundong Ahne8fb7242019-09-17 13:50:45 +09001196 if ab, ok := mctx.Module().(*apexBundle); ok {
Sundong Ahnabb64432019-10-22 13:58:29 +09001197 var variants []string
1198 switch proptools.StringDefault(ab.properties.Payload_type, "image") {
1199 case "image":
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001200 // This is the normal case. Note that both image and flattend APEXes are
1201 // created. The image type is installed to the system partition, while the
1202 // flattened APEX is (optionally) installed to the system_ext partition.
1203 // This is mostly for GSI which has to support wide range of devices. If GSI
1204 // is installed on a newer (APEX-capable) device, the image APEX in the
1205 // system will be used. However, if the same GSI is installed on an old
1206 // device which can't support image APEX, the flattened APEX in the
1207 // system_ext partion (which still is part of GSI) is used instead.
Sundong Ahnabb64432019-10-22 13:58:29 +09001208 variants = append(variants, imageApexType, flattenedApexType)
1209 case "zip":
1210 variants = append(variants, zipApexType)
1211 case "both":
1212 variants = append(variants, imageApexType, zipApexType, flattenedApexType)
1213 default:
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001214 mctx.PropertyErrorf("payload_type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
Sundong Ahnabb64432019-10-22 13:58:29 +09001215 return
1216 }
1217
1218 modules := mctx.CreateLocalVariations(variants...)
1219
1220 for i, v := range variants {
1221 switch v {
1222 case imageApexType:
1223 modules[i].(*apexBundle).properties.ApexType = imageApex
1224 case zipApexType:
1225 modules[i].(*apexBundle).properties.ApexType = zipApex
1226 case flattenedApexType:
1227 modules[i].(*apexBundle).properties.ApexType = flattenedApex
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001228 // See the comment above for why system_ext.
Jooyung Han91df2082019-11-20 01:49:42 +09001229 if !mctx.Config().FlattenApex() && ab.Platform() {
Sundong Ahnd95aa2d2019-10-08 19:34:03 +09001230 modules[i].(*apexBundle).MakeAsSystemExt()
1231 }
Sundong Ahnabb64432019-10-22 13:58:29 +09001232 }
Sundong Ahne9b55722019-09-06 17:37:42 +09001233 }
Jiyong Park5d790c32019-11-15 18:40:32 +09001234 } else if _, ok := mctx.Module().(*OverrideApex); ok {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001235 // payload_type is forcibly overridden to "image"
1236 // TODO(jiyong): is this the right decision?
Jiyong Park5d790c32019-11-15 18:40:32 +09001237 mctx.CreateVariations(imageApexType, flattenedApexType)
Sundong Ahne9b55722019-09-06 17:37:42 +09001238 }
1239}
1240
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001241// checkUseVendorProperty checks if the use of `use_vendor` property is allowed for the given APEX.
1242// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
1243// which may cause compatibility issues. (e.g. libbinder) Even though libbinder restricts its
1244// availability via 'apex_available' property and relies on yet another macro
1245// __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules to avoid
1246// similar problems.
1247func checkUseVendorProperty(ctx android.BottomUpMutatorContext, a *apexBundle) {
1248 if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) {
1249 ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
1250 }
1251}
1252
Jooyung Handc782442019-11-01 03:14:38 +09001253var (
Colin Cross440e0d02020-06-11 11:32:11 -07001254 useVendorAllowListKey = android.NewOnceKey("useVendorAllowList")
Jooyung Handc782442019-11-01 03:14:38 +09001255)
1256
Colin Cross440e0d02020-06-11 11:32:11 -07001257func useVendorAllowList(config android.Config) []string {
1258 return config.Once(useVendorAllowListKey, func() interface{} {
Jooyung Handc782442019-11-01 03:14:38 +09001259 return []string{
1260 // swcodec uses "vendor" variants for smaller size
1261 "com.android.media.swcodec",
1262 "test_com.android.media.swcodec",
1263 }
1264 }).([]string)
1265}
1266
Paul Duffin0a49fdc2021-03-08 11:28:25 +00001267// setUseVendorAllowListForTest returns a FixturePreparer that overrides useVendorAllowList and
1268// must be called before the first call to useVendorAllowList()
1269func setUseVendorAllowListForTest(allowList []string) android.FixturePreparer {
1270 return android.FixtureModifyConfig(func(config android.Config) {
1271 config.Once(useVendorAllowListKey, func() interface{} {
1272 return allowList
1273 })
Jooyung Handc782442019-11-01 03:14:38 +09001274 })
1275}
1276
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001277var _ android.DepIsInSameApex = (*apexBundle)(nil)
Theotime Combes4ba38c12020-06-12 12:46:59 +00001278
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001279// Implements android.DepInInSameApex
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001280func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1281 // direct deps of an APEX bundle are all part of the APEX bundle
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001282 // TODO(jiyong): shouldn't we look into the payload field of the dependencyTag?
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09001283 return true
1284}
1285
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001286var _ android.OutputFileProducer = (*apexBundle)(nil)
1287
1288// Implements android.OutputFileProducer
1289func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
1290 switch tag {
Paul Duffin74f05592020-11-25 16:37:46 +00001291 case "", android.DefaultDistTag:
1292 // This is the default dist path.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001293 return android.Paths{a.outputFile}, nil
1294 default:
1295 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
1296 }
1297}
1298
1299var _ cc.Coverage = (*apexBundle)(nil)
1300
1301// Implements cc.Coverage
1302func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
1303 return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
1304}
1305
1306// Implements cc.Coverage
Ivan Lozanod7586b62021-04-01 09:49:36 -04001307func (a *apexBundle) SetPreventInstall() {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001308 a.properties.PreventInstall = true
1309}
1310
1311// Implements cc.Coverage
1312func (a *apexBundle) HideFromMake() {
1313 a.properties.HideFromMake = true
Colin Crosse6a83e62020-12-17 18:22:34 -08001314 // This HideFromMake is shadowing the ModuleBase one, call through to it for now.
1315 // TODO(ccross): untangle these
1316 a.ModuleBase.HideFromMake()
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001317}
1318
1319// Implements cc.Coverage
1320func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
1321 a.properties.IsCoverageVariant = coverage
1322}
1323
1324// Implements cc.Coverage
1325func (a *apexBundle) EnableCoverageIfNeeded() {}
1326
1327var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil)
1328
1329// Implements android.ApexBudleDepsInfoIntf
1330func (a *apexBundle) Updatable() bool {
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +00001331 return proptools.BoolDefault(a.properties.Updatable, true)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001332}
1333
Jiyong Park9477c262021-06-22 20:23:05 +09001334func (a *apexBundle) UsePlatformApis() bool {
1335 return proptools.BoolDefault(a.properties.Platform_apis, false)
1336}
1337
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001338// getCertString returns the name of the cert that should be used to sign this APEX. This is
1339// basically from the "certificate" property, but could be overridden by the device config.
Colin Cross0ea8ba82019-06-06 14:33:29 -07001340func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
Jooyung Han27151d92019-12-16 17:45:32 +09001341 moduleName := ctx.ModuleName()
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001342 // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the
1343 // OVERRIDE_* list, we check with the pseudo module name to see if its certificate is
1344 // overridden.
Jooyung Han27151d92019-12-16 17:45:32 +09001345 if a.vndkApex {
1346 moduleName = vndkApexName
1347 }
1348 certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001349 if overridden {
Jaewoong Jungacb6db32019-02-28 16:22:30 +00001350 return ":" + certificate
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001351 }
Jaewoong Jung4cfdf7d2021-04-20 16:21:24 -07001352 return String(a.overridableProperties.Certificate)
Jiyong Parkb2742fd2019-02-11 11:38:15 +09001353}
1354
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001355// See the installable property
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001356func (a *apexBundle) installable() bool {
Jiyong Parkee9a98d2019-08-09 14:44:36 +09001357 return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
Jiyong Park92c0f9c2018-12-13 23:14:57 +09001358}
1359
Nikita Ioffe9d9960f2021-06-09 19:43:46 +01001360// See the generate_hashtree property
1361func (a *apexBundle) shouldGenerateHashtree() bool {
Nikita Ioffee261ae62021-06-16 18:15:03 +01001362 return proptools.BoolDefault(a.properties.Generate_hashtree, true)
Nikita Ioffec72b5dd2019-12-07 17:30:22 +00001363}
1364
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001365// See the test_only_unsigned_payload property
Dario Frenica913392020-04-27 18:21:11 +01001366func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool {
1367 return proptools.Bool(a.properties.Test_only_unsigned_payload)
1368}
1369
Mohammad Samiul Islama8008f92020-12-22 10:47:50 +00001370// See the test_only_force_compression property
1371func (a *apexBundle) testOnlyShouldForceCompression() bool {
1372 return proptools.Bool(a.properties.Test_only_force_compression)
1373}
1374
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001375// These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its
1376// members) can be sanitized, either forcibly, or by the global configuration. For some of the
1377// sanitizers, extra dependencies can be forcibly added as well.
Jiyong Parkda6eb592018-12-19 17:12:36 +09001378
Jiyong Parkf97782b2019-02-13 20:28:58 +09001379func (a *apexBundle) EnableSanitizer(sanitizerName string) {
1380 if !android.InList(sanitizerName, a.properties.SanitizerNames) {
1381 a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
1382 }
1383}
1384
Jiyong Park388ef3f2019-01-28 19:47:32 +09001385func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
Jiyong Parkf97782b2019-02-13 20:28:58 +09001386 if android.InList(sanitizerName, a.properties.SanitizerNames) {
1387 return true
Jiyong Park235e67c2019-02-09 11:50:56 +09001388 }
1389
1390 // Then follow the global setting
Jiyong Park388ef3f2019-01-28 19:47:32 +09001391 globalSanitizerNames := []string{}
1392 if a.Host() {
1393 globalSanitizerNames = ctx.Config().SanitizeHost()
1394 } else {
1395 arches := ctx.Config().SanitizeDeviceArch()
1396 if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
1397 globalSanitizerNames = ctx.Config().SanitizeDevice()
1398 }
1399 }
1400 return android.InList(sanitizerName, globalSanitizerNames)
Jiyong Park379de2f2018-12-19 02:47:14 +09001401}
1402
Jooyung Han8ce8db92020-05-15 19:05:05 +09001403func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001404 // TODO(jiyong): move this info (the sanitizer name, the lib name, etc.) to cc/sanitize.go
1405 // Keep only the mechanism here.
Jooyung Han8ce8db92020-05-15 19:05:05 +09001406 if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001407 imageVariation := a.getImageVariation(ctx)
Jooyung Han8ce8db92020-05-15 19:05:05 +09001408 for _, target := range ctx.MultiTargets() {
1409 if target.Arch.ArchType.Multilib == "lib64" {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001410 addDependenciesForNativeModules(ctx, ApexNativeDependencies{
1411 Native_shared_libs: []string{"libclang_rt.hwasan-aarch64-android"},
1412 Tests: nil,
1413 Jni_libs: nil,
1414 Binaries: nil,
1415 }, target, imageVariation)
Jooyung Han8ce8db92020-05-15 19:05:05 +09001416 break
1417 }
1418 }
1419 }
1420}
1421
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001422// apexFileFor<Type> functions below create an apexFile struct for a given Soong module. The
1423// returned apexFile saves information about the Soong module that will be used for creating the
1424// build rules.
Jiyong Park1833cef2019-12-13 13:28:36 +09001425func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001426 // Decide the APEX-local directory by the multilib of the library In the future, we may
1427 // query this to the module.
1428 // TODO(jiyong): use the new PackagingSpec
Jiyong Parkf653b052019-11-18 15:39:01 +09001429 var dirInApex string
Martin Stjernholm279de572019-09-10 23:18:20 +01001430 switch ccMod.Arch().ArchType.Multilib {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001431 case "lib32":
1432 dirInApex = "lib"
1433 case "lib64":
1434 dirInApex = "lib64"
1435 }
Colin Cross3b19f5d2019-09-17 14:45:31 -07001436 if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
Martin Stjernholm279de572019-09-10 23:18:20 +01001437 dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001438 }
Jooyung Han35155c42020-02-06 17:33:20 +09001439 dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
Jiyong Park1833cef2019-12-13 13:28:36 +09001440 if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001441 // Special case for Bionic libs and other libs installed with them. This is to
1442 // prevent those libs from being included in the search path
1443 // /apex/com.android.runtime/${LIB}. This exclusion is required because those libs
1444 // in the Runtime APEX are available via the legacy paths in /system/lib/. By the
1445 // init process, the libs in the APEX are bind-mounted to the legacy paths and thus
1446 // will be loaded into the default linker namespace (aka "platform" namespace). If
1447 // the libs are directly in /apex/com.android.runtime/${LIB} then the same libs will
1448 // be loaded again into the runtime linker namespace, which will result in double
1449 // loading of them, which isn't supported.
Martin Stjernholm279de572019-09-10 23:18:20 +01001450 dirInApex = filepath.Join(dirInApex, "bionic")
Jiyong Parkb0788572018-12-20 22:10:17 +09001451 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001452
Jiyong Parkf653b052019-11-18 15:39:01 +09001453 fileToCopy := ccMod.OutputFile().Path()
Yo Chiange8128052020-07-23 20:09:18 +08001454 androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName
1455 return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001456}
1457
Jiyong Park1833cef2019-12-13 13:28:36 +09001458func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
Jooyung Han35155c42020-02-06 17:33:20 +09001459 dirInApex := "bin"
Colin Cross3b19f5d2019-09-17 14:45:31 -07001460 if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dimitry8d6dde82019-07-11 10:23:53 +02001461 dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
Jiyong Parkacbf6c72019-07-09 16:19:16 +09001462 }
Jooyung Han35155c42020-02-06 17:33:20 +09001463 dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001464 fileToCopy := cc.OutputFile().Path()
Yo Chiange8128052020-07-23 20:09:18 +08001465 androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName
1466 af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc)
Jiyong Parkf653b052019-11-18 15:39:01 +09001467 af.symlinks = cc.Symlinks()
Liz Kammer1c14a212020-05-12 15:26:55 -07001468 af.dataPaths = cc.DataPaths()
Jiyong Parkf653b052019-11-18 15:39:01 +09001469 return af
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001470}
1471
Jiyong Park99644e92020-11-17 22:21:02 +09001472func apexFileForRustExecutable(ctx android.BaseModuleContext, rustm *rust.Module) apexFile {
1473 dirInApex := "bin"
1474 if rustm.Target().NativeBridge == android.NativeBridgeEnabled {
1475 dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath)
1476 }
1477 fileToCopy := rustm.OutputFile().Path()
1478 androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName
1479 af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, rustm)
1480 return af
1481}
1482
1483func apexFileForRustLibrary(ctx android.BaseModuleContext, rustm *rust.Module) apexFile {
1484 // Decide the APEX-local directory by the multilib of the library
1485 // In the future, we may query this to the module.
1486 var dirInApex string
1487 switch rustm.Arch().ArchType.Multilib {
1488 case "lib32":
1489 dirInApex = "lib"
1490 case "lib64":
1491 dirInApex = "lib64"
1492 }
1493 if rustm.Target().NativeBridge == android.NativeBridgeEnabled {
1494 dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath)
1495 }
1496 fileToCopy := rustm.OutputFile().Path()
1497 androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName
1498 return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, rustm)
1499}
1500
Jiyong Park1833cef2019-12-13 13:28:36 +09001501func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001502 dirInApex := "bin"
1503 fileToCopy := py.HostToolPath().Path()
Yo Chiange8128052020-07-23 20:09:18 +08001504 return newApexFile(ctx, fileToCopy, py.BaseModuleName(), dirInApex, pyBinary, py)
Alex Light778127a2019-02-27 14:19:50 -08001505}
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001506
Jiyong Park1833cef2019-12-13 13:28:36 +09001507func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001508 dirInApex := "bin"
Alex Light778127a2019-02-27 14:19:50 -08001509 s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
1510 if err != nil {
1511 ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
Jiyong Parkf653b052019-11-18 15:39:01 +09001512 return apexFile{}
Alex Light778127a2019-02-27 14:19:50 -08001513 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001514 fileToCopy := android.PathForOutput(ctx, s)
1515 // NB: Since go binaries are static we don't need the module for anything here, which is
1516 // good since the go tool is a blueprint.Module not an android.Module like we would
1517 // normally use.
Jiyong Park1833cef2019-12-13 13:28:36 +09001518 return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
Alex Light778127a2019-02-27 14:19:50 -08001519}
1520
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001521func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
Jiyong Parkf653b052019-11-18 15:39:01 +09001522 dirInApex := filepath.Join("bin", sh.SubDir())
1523 fileToCopy := sh.OutputFile()
Yo Chiange8128052020-07-23 20:09:18 +08001524 af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh)
Jiyong Parkf653b052019-11-18 15:39:01 +09001525 af.symlinks = sh.Symlinks()
1526 return af
Jiyong Park04480cf2019-02-06 00:16:29 +09001527}
1528
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001529func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
Jooyung Han0703fd82020-08-26 22:11:53 +09001530 dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir())
Jiyong Parkf653b052019-11-18 15:39:01 +09001531 fileToCopy := prebuilt.OutputFile()
Jiyong Park1833cef2019-12-13 13:28:36 +09001532 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001533}
1534
atrost6e126252020-01-27 17:01:16 +00001535func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
1536 dirInApex := filepath.Join("etc", config.SubDir())
1537 fileToCopy := config.CompatConfig()
1538 return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
1539}
1540
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001541// javaModule is an interface to handle all Java modules (java_library, dex_import, etc) in the same
1542// way.
1543type javaModule interface {
1544 android.Module
1545 BaseModuleName() string
1546 DexJarBuildPath() android.Path
1547 JacocoReportClassesFile() android.Path
1548 LintDepSets() java.LintDepSets
1549 Stem() string
1550}
1551
1552var _ javaModule = (*java.Library)(nil)
Bill Peckhama41a6962021-01-11 10:58:54 -08001553var _ javaModule = (*java.Import)(nil)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001554var _ javaModule = (*java.SdkLibrary)(nil)
1555var _ javaModule = (*java.DexImport)(nil)
1556var _ javaModule = (*java.SdkLibraryImport)(nil)
1557
Paul Duffin190fdef2021-04-26 10:33:59 +01001558// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001559func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile {
Paul Duffin190fdef2021-04-26 10:33:59 +01001560 return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath())
1561}
1562
1563// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
1564func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001565 dirInApex := "javalib"
Paul Duffin190fdef2021-04-26 10:33:59 +01001566 af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001567 af.jacocoReportClassesFile = module.JacocoReportClassesFile()
1568 af.lintDepSets = module.LintDepSets()
1569 af.customStem = module.Stem() + ".jar"
1570 return af
1571}
1572
1573// androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in
1574// the same way.
1575type androidApp interface {
Jiyong Parkf653b052019-11-18 15:39:01 +09001576 android.Module
1577 Privileged() bool
Jooyung Han39ee1192020-03-23 20:21:11 +09001578 InstallApkName() string
Jiyong Parkf653b052019-11-18 15:39:01 +09001579 OutputFile() android.Path
Jiyong Park618922e2020-01-08 13:35:43 +09001580 JacocoReportClassesFile() android.Path
Colin Cross503c1d02020-01-28 14:00:53 -08001581 Certificate() java.Certificate
Yo Chiange8128052020-07-23 20:09:18 +08001582 BaseModuleName() string
Colin Cross8355c152021-08-10 19:24:07 -07001583 LintDepSets() java.LintDepSets
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001584}
1585
1586var _ androidApp = (*java.AndroidApp)(nil)
1587var _ androidApp = (*java.AndroidAppImport)(nil)
1588
1589func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexFile {
Jiyong Parkf7487312019-10-17 12:54:30 +09001590 appDir := "app"
Jiyong Parkf653b052019-11-18 15:39:01 +09001591 if aapp.Privileged() {
Jiyong Parkf7487312019-10-17 12:54:30 +09001592 appDir = "priv-app"
1593 }
Jooyung Han39ee1192020-03-23 20:21:11 +09001594 dirInApex := filepath.Join(appDir, aapp.InstallApkName())
Jiyong Parkf653b052019-11-18 15:39:01 +09001595 fileToCopy := aapp.OutputFile()
Yo Chiange8128052020-07-23 20:09:18 +08001596 af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp)
Jiyong Park618922e2020-01-08 13:35:43 +09001597 af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
Colin Cross8355c152021-08-10 19:24:07 -07001598 af.lintDepSets = aapp.LintDepSets()
Colin Cross503c1d02020-01-28 14:00:53 -08001599 af.certificate = aapp.Certificate()
Jiyong Parkcfaa1642020-02-28 16:51:07 +09001600
1601 if app, ok := aapp.(interface {
1602 OverriddenManifestPackageName() string
1603 }); ok {
1604 af.overriddenPackageName = app.OverriddenManifestPackageName()
1605 }
Jiyong Park618922e2020-01-08 13:35:43 +09001606 return af
Dario Frenicde2a032019-10-27 00:29:22 +01001607}
1608
Jiyong Park69aeba92020-04-24 21:16:36 +09001609func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile {
1610 rroDir := "overlay"
1611 dirInApex := filepath.Join(rroDir, rro.Theme())
1612 fileToCopy := rro.OutputFile()
1613 af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro)
1614 af.certificate = rro.Certificate()
1615
1616 if a, ok := rro.(interface {
1617 OverriddenManifestPackageName() string
1618 }); ok {
1619 af.overriddenPackageName = a.OverriddenManifestPackageName()
1620 }
1621 return af
1622}
1623
markchien2f59ec92020-09-02 16:23:38 +08001624func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile {
1625 dirInApex := filepath.Join("etc", "bpf")
1626 return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram)
1627}
1628
Jiyong Park12a719c2021-01-07 15:31:24 +09001629func apexFileForFilesystem(ctx android.BaseModuleContext, buildFile android.Path, fs filesystem.Filesystem) apexFile {
1630 dirInApex := filepath.Join("etc", "fs")
1631 return newApexFile(ctx, buildFile, buildFile.Base(), dirInApex, etc, fs)
1632}
1633
Paul Duffin064b70c2020-11-02 17:32:38 +00001634// WalkPayloadDeps visits dependencies that contributes to the payload of this APEX. For each of the
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001635// visited module, the `do` callback is executed. Returning true in the callback continues the visit
1636// to the child modules. Returning false makes the visit to continue in the sibling or the parent
1637// modules. This is used in check* functions below.
Jooyung Han749dc692020-04-15 11:03:39 +09001638func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) {
Paul Duffindf915ff2020-03-30 17:58:21 +01001639 ctx.WalkDeps(func(child, parent android.Module) bool {
Jiyong Park0f80c182020-01-31 02:49:53 +09001640 am, ok := child.(android.ApexModule)
1641 if !ok || !am.CanHaveApexVariants() {
1642 return false
1643 }
1644
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001645 // Filter-out unwanted depedendencies
1646 depTag := ctx.OtherModuleDependencyTag(child)
1647 if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
1648 return false
1649 }
1650 if dt, ok := depTag.(dependencyTag); ok && !dt.payload {
Martin Stjernholm58c33f02020-07-06 22:56:01 +01001651 return false
1652 }
1653
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001654 ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
Jiyong Parkab50b072021-05-12 17:13:56 +09001655 externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants)
Jiyong Park0f80c182020-01-31 02:49:53 +09001656
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001657 // Visit actually
1658 return do(ctx, parent, am, externalDep)
Jiyong Park0f80c182020-01-31 02:49:53 +09001659 })
1660}
1661
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001662// filesystem type of the apex_payload.img inside the APEX. Currently, ext4 and f2fs are supported.
1663type fsType int
Jooyung Han03b51852020-02-26 22:45:42 +09001664
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001665const (
1666 ext4 fsType = iota
1667 f2fs
1668)
Artur Satayev849f8442020-04-28 14:57:42 +01001669
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001670func (f fsType) string() string {
1671 switch f {
1672 case ext4:
1673 return ext4FsType
1674 case f2fs:
1675 return f2fsFsType
1676 default:
1677 panic(fmt.Errorf("unknown APEX payload type %d", f))
Jooyung Han548640b2020-04-27 12:10:30 +09001678 }
1679}
1680
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001681// Creates build rules for an APEX. It consists of the following major steps:
1682//
1683// 1) do some validity checks such as apex_available, min_sdk_version, etc.
1684// 2) traverse the dependency tree to collect apexFile structs from them.
1685// 3) some fields in apexBundle struct are configured
1686// 4) generate the build rules to create the APEX. This is mostly done in builder.go.
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001687func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001688 ////////////////////////////////////////////////////////////////////////////////////////////
1689 // 1) do some validity checks such as apex_available, min_sdk_version, etc.
Jiyong Park0f80c182020-01-31 02:49:53 +09001690 a.checkApexAvailability(ctx)
Jooyung Han548640b2020-04-27 12:10:30 +09001691 a.checkUpdatable(ctx)
Jooyung Han749dc692020-04-15 11:03:39 +09001692 a.checkMinSdkVersion(ctx)
Jiyong Park7d95a512020-05-10 15:16:24 +09001693 a.checkStaticLinkingToStubLibraries(ctx)
Jiyong Park192600a2021-08-03 07:52:17 +00001694 a.checkStaticExecutables(ctx)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001695 if len(a.properties.Tests) > 0 && !a.testApex {
1696 ctx.PropertyErrorf("tests", "property allowed only in apex_test module type")
1697 return
1698 }
Jiyong Park678c8812020-02-07 17:25:49 +09001699
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001700 ////////////////////////////////////////////////////////////////////////////////////////////
1701 // 2) traverse the dependency tree to collect apexFile structs from them.
1702
1703 // all the files that will be included in this APEX
1704 var filesInfo []apexFile
Alex Lightfc0bd7c2019-01-29 18:31:59 -08001705
Jooyung Hane1633032019-08-01 17:41:43 +09001706 // native lib dependencies
1707 var provideNativeLibs []string
1708 var requireNativeLibs []string
1709
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001710 handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
1711
braleeb0c1f0c2021-06-07 22:49:13 +08001712 // Collect the module directory for IDE info in java/jdeps.go.
1713 a.modulePaths = append(a.modulePaths, ctx.ModuleDir())
1714
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001715 // TODO(jiyong): do this using WalkPayloadDeps
1716 // TODO(jiyong): make this clean!!!
Alex Light778127a2019-02-27 14:19:50 -08001717 ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
Roland Levillainf89cd092019-07-29 16:22:59 +01001718 depTag := ctx.OtherModuleDependencyTag(child)
Paul Duffindddd5462020-04-07 15:25:44 +01001719 if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
1720 return false
1721 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001722 depName := ctx.OtherModuleName(child)
Jiyong Parkf653b052019-11-18 15:39:01 +09001723 if _, isDirectDep := parent.(*apexBundle); isDirectDep {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001724 switch depTag {
Jooyung Han643adc42020-02-27 13:50:06 +09001725 case sharedLibTag, jniLibTag:
1726 isJniLib := depTag == jniLibTag
Jooyung Hanfaa2d5f2020-02-06 17:42:40 +09001727 if c, ok := child.(*cc.Module); ok {
Jooyung Han643adc42020-02-27 13:50:06 +09001728 fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
1729 fi.isJniLib = isJniLib
1730 filesInfo = append(filesInfo, fi)
Jooyung Han45a96772020-06-15 14:59:42 +09001731 // Collect the list of stub-providing libs except:
1732 // - VNDK libs are only for vendors
1733 // - bootstrap bionic libs are treated as provided by system
1734 if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001735 provideNativeLibs = append(provideNativeLibs, fi.stem())
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001736 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001737 return true // track transitive dependencies
Jiyong Parkf2cc1b72020-12-09 00:20:45 +09001738 } else if r, ok := child.(*rust.Module); ok {
1739 fi := apexFileForRustLibrary(ctx, r)
1740 filesInfo = append(filesInfo, fi)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001741 } else {
Jooyung Han643adc42020-02-27 13:50:06 +09001742 propertyName := "native_shared_libs"
1743 if isJniLib {
1744 propertyName = "jni_libs"
1745 }
1746 ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001747 }
1748 case executableTag:
1749 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001750 filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
Jiyong Parkf653b052019-11-18 15:39:01 +09001751 return true // track transitive dependencies
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001752 } else if sh, ok := child.(*sh.ShBinary); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001753 filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
Alex Light778127a2019-02-27 14:19:50 -08001754 } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
Jiyong Park1833cef2019-12-13 13:28:36 +09001755 filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Alex Light778127a2019-02-27 14:19:50 -08001756 } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
Jiyong Parkf653b052019-11-18 15:39:01 +09001757 filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
Jiyong Park99644e92020-11-17 22:21:02 +09001758 } else if rust, ok := child.(*rust.Module); ok {
1759 filesInfo = append(filesInfo, apexFileForRustExecutable(ctx, rust))
1760 return true // track transitive dependencies
Jiyong Parkff1458f2018-10-12 21:49:38 +09001761 } else {
Jiyong Park99644e92020-11-17 22:21:02 +09001762 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 +09001763 }
Paul Duffin94f19632021-04-20 12:40:07 +01001764 case bcpfTag:
Paul Duffina1d60252021-01-21 18:13:43 +00001765 {
Paul Duffin7771eba2021-04-23 14:25:28 +01001766 if _, ok := child.(*java.BootclasspathFragmentModule); !ok {
Paul Duffincc33ec82021-04-25 23:14:55 +01001767 ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a bootclasspath_fragment module", depName)
Paul Duffina1d60252021-01-21 18:13:43 +00001768 return false
1769 }
Paul Duffin4d101b62021-03-24 15:42:20 +00001770
Paul Duffincc33ec82021-04-25 23:14:55 +01001771 filesToAdd := apexBootclasspathFragmentFiles(ctx, child)
1772 filesInfo = append(filesInfo, filesToAdd...)
Paul Duffin4d101b62021-03-24 15:42:20 +00001773 return true
Paul Duffina1d60252021-01-21 18:13:43 +00001774 }
satayev333a1732021-05-17 21:35:26 +01001775 case sscpfTag:
1776 {
1777 if _, ok := child.(*java.SystemServerClasspathModule); !ok {
1778 ctx.PropertyErrorf("systemserverclasspath_fragments", "%q is not a systemserverclasspath_fragment module", depName)
1779 return false
1780 }
satayevb98371c2021-06-15 16:49:50 +01001781 if af := apexClasspathFragmentProtoFile(ctx, child); af != nil {
1782 filesInfo = append(filesInfo, *af)
1783 }
satayev333a1732021-05-17 21:35:26 +01001784 return true
1785 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001786 case javaLibTag:
Jiyong Park77acec62020-06-01 21:39:15 +09001787 switch child.(type) {
Bill Peckhama41a6962021-01-11 10:58:54 -08001788 case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport, *java.Import:
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001789 af := apexFileForJavaModule(ctx, child.(javaModule))
1790 if !af.ok() {
Jooyung Han58f26ab2019-12-18 15:34:32 +09001791 ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
1792 return false
1793 }
1794 filesInfo = append(filesInfo, af)
Jooyung Han58f26ab2019-12-18 15:34:32 +09001795 return true // track transitive dependencies
Jiyong Park77acec62020-06-01 21:39:15 +09001796 default:
Jiyong Park9e6c2422019-08-09 20:39:45 +09001797 ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001798 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001799 case androidAppTag:
Jiyong Parkf653b052019-11-18 15:39:01 +09001800 if ap, ok := child.(*java.AndroidApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001801 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Jiyong Parkf653b052019-11-18 15:39:01 +09001802 return true // track transitive dependencies
1803 } else if ap, ok := child.(*java.AndroidAppImport); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001804 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Dario Freni6f3937c2019-12-20 22:58:03 +00001805 } else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
Jooyung Han39ee1192020-03-23 20:21:11 +09001806 filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001807 } else if ap, ok := child.(*java.AndroidAppSet); ok {
1808 appDir := "app"
1809 if ap.Privileged() {
1810 appDir = "priv-app"
1811 }
Yo Chiange8128052020-07-23 20:09:18 +08001812 af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(),
Sasha Smundak18d98bc2020-05-27 16:36:07 -07001813 filepath.Join(appDir, ap.BaseModuleName()), appSet, ap)
1814 af.certificate = java.PresignedCertificate
1815 filesInfo = append(filesInfo, af)
Jiyong Parkf653b052019-11-18 15:39:01 +09001816 } else {
1817 ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
1818 }
Jiyong Park69aeba92020-04-24 21:16:36 +09001819 case rroTag:
1820 if rro, ok := child.(java.RuntimeResourceOverlayModule); ok {
1821 filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro))
1822 } else {
1823 ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
1824 }
markchien2f59ec92020-09-02 16:23:38 +08001825 case bpfTag:
1826 if bpfProgram, ok := child.(bpf.BpfModule); ok {
1827 filesToCopy, _ := bpfProgram.OutputFiles("")
1828 for _, bpfFile := range filesToCopy {
1829 filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram))
1830 }
1831 } else {
1832 ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName)
1833 }
Jiyong Park12a719c2021-01-07 15:31:24 +09001834 case fsTag:
1835 if fs, ok := child.(filesystem.Filesystem); ok {
1836 filesInfo = append(filesInfo, apexFileForFilesystem(ctx, fs.OutputPath(), fs))
1837 } else {
1838 ctx.PropertyErrorf("filesystems", "%q is not a filesystem module", depName)
1839 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001840 case prebuiltTag:
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001841 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001842 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
Jiyong Parkff1458f2018-10-12 21:49:38 +09001843 } else {
Paul Duffin1bc21dc2021-03-15 19:43:17 +00001844 ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
Jiyong Parkff1458f2018-10-12 21:49:38 +09001845 }
Paul Duffin0b817782021-03-17 15:02:19 +00001846 case compatConfigTag:
Paul Duffin3abc1742021-03-15 19:32:23 +00001847 if compatConfig, ok := child.(java.PlatformCompatConfigIntf); ok {
1848 filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, compatConfig, depName))
1849 } else {
1850 ctx.PropertyErrorf("compat_configs", "%q is not a platform_compat_config module", depName)
1851 }
Roland Levillain630846d2019-06-26 12:48:34 +01001852 case testTag:
Roland Levillainf89cd092019-07-29 16:22:59 +01001853 if ccTest, ok := child.(*cc.Module); ok {
1854 if ccTest.IsTestPerSrcAllTestsVariation() {
1855 // Multiple-output test module (where `test_per_src: true`).
1856 //
1857 // `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
1858 // We do not add this variation to `filesInfo`, as it has no output;
1859 // however, we do add the other variations of this module as indirect
1860 // dependencies (see below).
Roland Levillain9b5fde92019-06-28 15:41:19 +01001861 } else {
Roland Levillainf89cd092019-07-29 16:22:59 +01001862 // Single-output test module (where `test_per_src: false`).
Jiyong Park1833cef2019-12-13 13:28:36 +09001863 af := apexFileForExecutable(ctx, ccTest)
Jiyong Parkf653b052019-11-18 15:39:01 +09001864 af.class = nativeTest
1865 filesInfo = append(filesInfo, af)
Roland Levillain9b5fde92019-06-28 15:41:19 +01001866 }
Jiyong Parkaf9539f2020-05-04 10:31:32 +09001867 return true // track transitive dependencies
Roland Levillain630846d2019-06-26 12:48:34 +01001868 } else {
1869 ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
1870 }
Jiyong Parkff1458f2018-10-12 21:49:38 +09001871 case keyTag:
1872 if key, ok := child.(*apexKey); ok {
Jaewoong Jung18aefc12020-12-21 09:11:10 -08001873 a.privateKeyFile = key.privateKeyFile
1874 a.publicKeyFile = key.publicKeyFile
Jiyong Parkff1458f2018-10-12 21:49:38 +09001875 } else {
1876 ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001877 }
Jiyong Parkf653b052019-11-18 15:39:01 +09001878 return false
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001879 case certificateTag:
1880 if dep, ok := child.(*java.AndroidAppCertificate); ok {
Jaewoong Jung18aefc12020-12-21 09:11:10 -08001881 a.containerCertificateFile = dep.Certificate.Pem
1882 a.containerPrivateKeyFile = dep.Certificate.Key
Jiyong Parkc00cbd92018-10-30 21:20:05 +09001883 } else {
1884 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
1885 }
Jiyong Park03b68dd2019-07-26 23:20:40 +09001886 case android.PrebuiltDepTag:
1887 // If the prebuilt is force disabled, remember to delete the prebuilt file
1888 // that might have been installed in the previous builds
Jiyong Park10e926b2020-07-16 21:38:56 +09001889 if prebuilt, ok := child.(prebuilt); ok && prebuilt.isForceDisabled() {
Jiyong Park03b68dd2019-07-26 23:20:40 +09001890 a.prebuiltFileToDelete = prebuilt.InstallFilename()
1891 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001892 }
Jooyung Han8aee2042019-10-29 05:08:31 +09001893 } else if !a.vndkApex {
Jiyong Park48ca7dc2018-10-10 14:01:00 +09001894 // indirect dependencies
Jooyung Han9c80bae2019-08-20 17:30:57 +09001895 if am, ok := child.(android.ApexModule); ok {
Roland Levillainf89cd092019-07-29 16:22:59 +01001896 // We cannot use a switch statement on `depTag` here as the checked
1897 // tags used below are private (e.g. `cc.sharedDepTag`).
Jiyong Park52cd06f2019-11-11 10:14:32 +09001898 if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001899 if cc, ok := child.(*cc.Module); ok {
Jooyung Handf78e212020-07-22 15:54:47 +09001900 if cc.UseVndk() && proptools.Bool(a.properties.Use_vndk_as_stable) && cc.IsVndk() {
Jooyung Han6c4cc9c2020-07-29 16:00:54 +09001901 requireNativeLibs = append(requireNativeLibs, ":vndk")
Jooyung Handf78e212020-07-22 15:54:47 +09001902 return false
1903 }
Jiyong Parkf1493cc2020-05-29 21:29:20 +09001904 af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
1905 af.transitiveDep = true
Martin Stjernholmf2635ec2020-12-16 01:01:59 +00001906
1907 // Always track transitive dependencies for host.
1908 if a.Host() {
1909 filesInfo = append(filesInfo, af)
1910 return true
1911 }
1912
Colin Cross56a83212020-09-15 18:30:11 -07001913 abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
Martin Stjernholmf2635ec2020-12-16 01:01:59 +00001914 if !abInfo.Contents.DirectlyInApex(depName) && (cc.IsStubs() || cc.HasStubsVariants()) {
Roland Levillainf89cd092019-07-29 16:22:59 +01001915 // If the dependency is a stubs lib, don't include it in this APEX,
1916 // but make sure that the lib is installed on the device.
1917 // In case no APEX is having the lib, the lib is installed to the system
1918 // partition.
1919 //
1920 // Always include if we are a host-apex however since those won't have any
1921 // system libraries.
Colin Cross56a83212020-09-15 18:30:11 -07001922 if !am.DirectlyInAnyApex() {
Jooyung Hanefb184e2020-06-25 17:14:25 +09001923 // we need a module name for Make
Martin Stjernholm2856c662020-12-02 15:03:42 +00001924 name := cc.ImplementationModuleNameForMake(ctx)
Colin Cross0477b422020-10-13 18:43:54 -07001925
1926 if !proptools.Bool(a.properties.Use_vendor) {
Jooyung Hanefb184e2020-06-25 17:14:25 +09001927 // we don't use subName(.vendor) for a "use_vendor: true" apex
1928 // which is supposed to be installed in /system
Colin Cross0477b422020-10-13 18:43:54 -07001929 name += cc.Properties.SubName
Jooyung Hanefb184e2020-06-25 17:14:25 +09001930 }
1931 if !android.InList(name, a.requiredDeps) {
1932 a.requiredDeps = append(a.requiredDeps, name)
1933 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001934 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09001935 requireNativeLibs = append(requireNativeLibs, af.stem())
Roland Levillainf89cd092019-07-29 16:22:59 +01001936 // Don't track further
1937 return false
1938 }
Jiyong Parke3867542020-12-03 17:28:25 +09001939
1940 // If the dep is not considered to be in the same
1941 // apex, don't add it to filesInfo so that it is not
1942 // included in this APEX.
1943 // TODO(jiyong): move this to at the top of the
1944 // else-if clause for the indirect dependencies.
1945 // Currently, that's impossible because we would
1946 // like to record requiredNativeLibs even when
Martin Stjernholmf2635ec2020-12-16 01:01:59 +00001947 // DepIsInSameAPex is false. We also shouldn't do
1948 // this for host.
Paul Duffin4c3e8e22021-03-18 15:41:29 +00001949 //
1950 // TODO(jiyong): explain why the same module is passed in twice.
1951 // Switching the first am to parent breaks lots of tests.
1952 if !android.IsDepInSameApex(ctx, am, am) {
Jiyong Parke3867542020-12-03 17:28:25 +09001953 return false
1954 }
1955
Jiyong Parkf653b052019-11-18 15:39:01 +09001956 filesInfo = append(filesInfo, af)
1957 return true // track transitive dependencies
Jiyong Parkf2cc1b72020-12-09 00:20:45 +09001958 } else if rm, ok := child.(*rust.Module); ok {
1959 af := apexFileForRustLibrary(ctx, rm)
1960 af.transitiveDep = true
1961 filesInfo = append(filesInfo, af)
1962 return true // track transitive dependencies
Jiyong Park25fc6a92018-11-18 18:02:45 +09001963 }
Roland Levillainf89cd092019-07-29 16:22:59 +01001964 } else if cc.IsTestPerSrcDepTag(depTag) {
1965 if cc, ok := child.(*cc.Module); ok {
Jiyong Park1833cef2019-12-13 13:28:36 +09001966 af := apexFileForExecutable(ctx, cc)
Roland Levillainf89cd092019-07-29 16:22:59 +01001967 // Handle modules created as `test_per_src` variations of a single test module:
1968 // use the name of the generated test binary (`fileToCopy`) instead of the name
1969 // of the original test module (`depName`, shared by all `test_per_src`
1970 // variations of that module).
Yo Chiange8128052020-07-23 20:09:18 +08001971 af.androidMkModuleName = filepath.Base(af.builtFile.String())
Jiyong Park7cd10e32020-01-14 09:22:18 +09001972 // these are not considered transitive dep
1973 af.transitiveDep = false
Jiyong Parkf653b052019-11-18 15:39:01 +09001974 filesInfo = append(filesInfo, af)
1975 return true // track transitive dependencies
Roland Levillainf89cd092019-07-29 16:22:59 +01001976 }
Jiyong Park1ad8e162020-12-01 23:40:09 +09001977 } else if cc.IsHeaderDepTag(depTag) {
1978 // nothing
Jiyong Park52cd06f2019-11-11 10:14:32 +09001979 } else if java.IsJniDepTag(depTag) {
Jooyung Hanb7bebe22020-02-25 16:59:29 +09001980 // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
1981 return false
Jiyong Parke3833882020-02-17 17:28:10 +09001982 } else if java.IsXmlPermissionsFileDepTag(depTag) {
Jaewoong Jung4b79e982020-06-01 10:45:49 -07001983 if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
Jiyong Parke3833882020-02-17 17:28:10 +09001984 filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
1985 }
Jiyong Park99644e92020-11-17 22:21:02 +09001986 } else if rust.IsDylibDepTag(depTag) {
1987 if rustm, ok := child.(*rust.Module); ok && rustm.IsInstallableToApex() {
1988 af := apexFileForRustLibrary(ctx, rustm)
1989 af.transitiveDep = true
1990 filesInfo = append(filesInfo, af)
1991 return true // track transitive dependencies
1992 }
Jiyong Park94e22fd2021-04-08 18:19:15 +09001993 } else if rust.IsRlibDepTag(depTag) {
1994 // Rlib is statically linked, but it might have shared lib
1995 // dependencies. Track them.
1996 return true
Paul Duffin65898052021-04-20 22:47:03 +01001997 } else if java.IsBootclasspathFragmentContentDepTag(depTag) {
Paul Duffin94f19632021-04-20 12:40:07 +01001998 // Add the contents of the bootclasspath fragment to the apex.
Paul Duffin4d101b62021-03-24 15:42:20 +00001999 switch child.(type) {
2000 case *java.Library, *java.SdkLibrary:
Paul Duffincc33ec82021-04-25 23:14:55 +01002001 javaModule := child.(javaModule)
Paul Duffin190fdef2021-04-26 10:33:59 +01002002 af := apexFileForBootclasspathFragmentContentModule(ctx, parent, javaModule)
Paul Duffin4d101b62021-03-24 15:42:20 +00002003 if !af.ok() {
Paul Duffin94f19632021-04-20 12:40:07 +01002004 ctx.PropertyErrorf("bootclasspath_fragments", "bootclasspath_fragment content %q is not configured to be compiled into dex", depName)
Paul Duffin4d101b62021-03-24 15:42:20 +00002005 return false
2006 }
2007 filesInfo = append(filesInfo, af)
2008 return true // track transitive dependencies
2009 default:
Paul Duffin94f19632021-04-20 12:40:07 +01002010 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 +00002011 }
satayev333a1732021-05-17 21:35:26 +01002012 } else if java.IsSystemServerClasspathFragmentContentDepTag(depTag) {
2013 // Add the contents of the systemserverclasspath fragment to the apex.
2014 switch child.(type) {
2015 case *java.Library, *java.SdkLibrary:
2016 af := apexFileForJavaModule(ctx, child.(javaModule))
2017 filesInfo = append(filesInfo, af)
2018 return true // track transitive dependencies
2019 default:
2020 ctx.PropertyErrorf("systemserverclasspath_fragments", "systemserverclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
2021 }
Colin Cross56a83212020-09-15 18:30:11 -07002022 } else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok {
2023 // nothing
Jooyung Han9c80bae2019-08-20 17:30:57 +09002024 } else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Jiyong Park1c7e9622020-05-07 16:12:13 +09002025 ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002026 }
2027 }
2028 }
2029 return false
2030 })
Jaewoong Jung18aefc12020-12-21 09:11:10 -08002031 if a.privateKeyFile == nil {
Jaewoong Jung4cfdf7d2021-04-20 16:21:24 -07002032 ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.overridableProperties.Key))
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002033 return
2034 }
Jiyong Park48ca7dc2018-10-10 14:01:00 +09002035
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002036 // Remove duplicates in filesInfo
Jiyong Park8fd61922018-11-08 02:50:25 +09002037 removeDup := func(filesInfo []apexFile) []apexFile {
Jiyong Park7cd10e32020-01-14 09:22:18 +09002038 encountered := make(map[string]apexFile)
Jiyong Park8fd61922018-11-08 02:50:25 +09002039 for _, f := range filesInfo {
Jooyung Han344d5432019-08-23 11:17:39 +09002040 dest := filepath.Join(f.installDir, f.builtFile.Base())
Jiyong Park7cd10e32020-01-14 09:22:18 +09002041 if e, ok := encountered[dest]; !ok {
2042 encountered[dest] = f
2043 } else {
2044 // If a module is directly included and also transitively depended on
2045 // consider it as directly included.
2046 e.transitiveDep = e.transitiveDep && f.transitiveDep
2047 encountered[dest] = e
Jiyong Park8fd61922018-11-08 02:50:25 +09002048 }
2049 }
Jiyong Park7cd10e32020-01-14 09:22:18 +09002050 var result []apexFile
2051 for _, v := range encountered {
2052 result = append(result, v)
2053 }
Jiyong Park8fd61922018-11-08 02:50:25 +09002054 return result
2055 }
2056 filesInfo = removeDup(filesInfo)
2057
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002058 // Sort to have consistent build rules
Jiyong Park8fd61922018-11-08 02:50:25 +09002059 sort.Slice(filesInfo, func(i, j int) bool {
Paul Duffin56060292021-05-15 19:34:05 +01002060 // Sort by destination path so as to ensure consistent ordering even if the source of the files
2061 // changes.
2062 return filesInfo[i].path() < filesInfo[j].path()
Jiyong Park8fd61922018-11-08 02:50:25 +09002063 })
2064
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002065 ////////////////////////////////////////////////////////////////////////////////////////////
2066 // 3) some fields in apexBundle struct are configured
Jiyong Park8fd61922018-11-08 02:50:25 +09002067 a.installDir = android.PathForModuleInstall(ctx, "apex")
2068 a.filesInfo = filesInfo
Alex Light5098a612018-11-29 17:12:15 -08002069
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002070 // Set suffix and primaryApexType depending on the ApexType
Martin Stjernholmcb3ff1e2021-05-25 00:28:27 +01002071 buildFlattenedAsDefault := ctx.Config().FlattenApex()
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002072 switch a.properties.ApexType {
2073 case imageApex:
2074 if buildFlattenedAsDefault {
2075 a.suffix = imageApexSuffix
2076 } else {
2077 a.suffix = ""
2078 a.primaryApexType = true
2079
2080 if ctx.Config().InstallExtraFlattenedApexes() {
2081 a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
2082 }
2083 }
2084 case zipApex:
2085 if proptools.String(a.properties.Payload_type) == "zip" {
2086 a.suffix = ""
2087 a.primaryApexType = true
2088 } else {
2089 a.suffix = zipApexSuffix
2090 }
2091 case flattenedApex:
2092 if buildFlattenedAsDefault {
2093 a.suffix = ""
2094 a.primaryApexType = true
2095 } else {
2096 a.suffix = flattenedSuffix
2097 }
2098 }
2099
Theotime Combes4ba38c12020-06-12 12:46:59 +00002100 switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) {
2101 case ext4FsType:
2102 a.payloadFsType = ext4
2103 case f2fsFsType:
2104 a.payloadFsType = f2fs
2105 default:
2106 ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs]", *a.properties.Payload_fs_type)
2107 }
2108
Jiyong Park7cd10e32020-01-14 09:22:18 +09002109 // Optimization. If we are building bundled APEX, for the files that are gathered due to the
2110 // transitive dependencies, don't place them inside the APEX, but place a symlink pointing
2111 // the same library in the system partition, thus effectively sharing the same libraries
2112 // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
2113 // in the APEX.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002114 a.linkToSystemLib = !ctx.Config().UnbundledBuild() && a.installable() && !proptools.Bool(a.properties.Use_vendor)
Jooyung Han54aca7b2019-11-20 02:26:02 +09002115
Jooyung Han85d61762020-06-24 23:50:26 +09002116 // APEXes targeting other than system/system_ext partitions use vendor/product variants.
2117 // So we can't link them to /system/lib libs which are core variants.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002118 if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
Jooyung Han85d61762020-06-24 23:50:26 +09002119 a.linkToSystemLib = false
2120 }
2121
Jiyong Park4da07972021-01-05 21:01:11 +09002122 forced := ctx.Config().ForceApexSymlinkOptimization()
2123
Jiyong Park9d677202020-02-19 16:29:35 +09002124 // We don't need the optimization for updatable APEXes, as it might give false signal
Jiyong Park4da07972021-01-05 21:01:11 +09002125 // to the system health when the APEXes are still bundled (b/149805758).
2126 if !forced && a.Updatable() && a.properties.ApexType == imageApex {
Jiyong Park9d677202020-02-19 16:29:35 +09002127 a.linkToSystemLib = false
2128 }
2129
Jiyong Park638d30e2020-02-26 18:27:19 +09002130 // We also don't want the optimization for host APEXes, because it doesn't make sense.
2131 if ctx.Host() {
2132 a.linkToSystemLib = false
2133 }
2134
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002135 a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
2136
2137 ////////////////////////////////////////////////////////////////////////////////////////////
2138 // 4) generate the build rules to create the APEX. This is done in builder.go.
2139 a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
Jooyung Han01a3ee22019-11-02 02:52:25 +09002140 if a.properties.ApexType == flattenedApex {
2141 a.buildFlattenedApex(ctx)
2142 } else {
2143 a.buildUnflattenedApex(ctx)
2144 }
Jiyong Park956305c2020-01-09 12:32:06 +09002145 a.buildApexDependencyInfo(ctx)
Colin Cross08dca382020-07-21 20:31:17 -07002146 a.buildLintReports(ctx)
Jiyong Parkb81b9902020-11-24 19:51:18 +09002147
2148 // Append meta-files to the filesInfo list so that they are reflected in Android.mk as well.
2149 if a.installable() {
2150 // For flattened APEX, make sure that APEX manifest and apex_pubkey are also copied
2151 // along with other ordinary files. (Note that this is done by apexer for
2152 // non-flattened APEXes)
2153 a.filesInfo = append(a.filesInfo, newApexFile(ctx, a.manifestPbOut, "apex_manifest.pb", ".", etc, nil))
2154
2155 // Place the public key as apex_pubkey. This is also done by apexer for
2156 // non-flattened APEXes case.
2157 // TODO(jiyong): Why do we need this CP rule?
2158 copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
2159 ctx.Build(pctx, android.BuildParams{
2160 Rule: android.Cp,
Jaewoong Jung18aefc12020-12-21 09:11:10 -08002161 Input: a.publicKeyFile,
Jiyong Parkb81b9902020-11-24 19:51:18 +09002162 Output: copiedPubkey,
2163 })
2164 a.filesInfo = append(a.filesInfo, newApexFile(ctx, copiedPubkey, "apex_pubkey", ".", etc, nil))
2165 }
Jooyung Han01a3ee22019-11-02 02:52:25 +09002166}
2167
Paul Duffincc33ec82021-04-25 23:14:55 +01002168// apexBootclasspathFragmentFiles returns the list of apexFile structures defining the files that
2169// the bootclasspath_fragment contributes to the apex.
2170func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint.Module) []apexFile {
2171 bootclasspathFragmentInfo := ctx.OtherModuleProvider(module, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
2172 var filesToAdd []apexFile
2173
2174 // Add the boot image files, e.g. .art, .oat and .vdex files.
2175 for arch, files := range bootclasspathFragmentInfo.AndroidBootImageFilesByArchType() {
2176 dirInApex := filepath.Join("javalib", arch.String())
2177 for _, f := range files {
2178 androidMkModuleName := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
2179 // TODO(b/177892522) - consider passing in the bootclasspath fragment module here instead of nil
2180 af := newApexFile(ctx, f, androidMkModuleName, dirInApex, etc, nil)
2181 filesToAdd = append(filesToAdd, af)
2182 }
2183 }
2184
satayev3db35472021-05-06 23:59:58 +01002185 // Add classpaths.proto config.
satayevb98371c2021-06-15 16:49:50 +01002186 if af := apexClasspathFragmentProtoFile(ctx, module); af != nil {
2187 filesToAdd = append(filesToAdd, *af)
2188 }
satayev3db35472021-05-06 23:59:58 +01002189
Paul Duffincc33ec82021-04-25 23:14:55 +01002190 return filesToAdd
2191}
2192
satayevb98371c2021-06-15 16:49:50 +01002193// apexClasspathFragmentProtoFile returns *apexFile structure defining the classpath.proto config that
2194// the module contributes to the apex; or nil if the proto config was not generated.
2195func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) *apexFile {
2196 info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
2197 if !info.ClasspathFragmentProtoGenerated {
2198 return nil
2199 }
2200 classpathProtoOutput := info.ClasspathFragmentProtoOutput
2201 af := newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), info.ClasspathFragmentProtoInstallDir.Rel(), etc, nil)
2202 return &af
satayev14e49132021-05-17 21:03:07 +01002203}
2204
Paul Duffincc33ec82021-04-25 23:14:55 +01002205// apexFileForBootclasspathFragmentContentModule creates an apexFile for a bootclasspath_fragment
2206// content module, i.e. a library that is part of the bootclasspath.
Paul Duffin190fdef2021-04-26 10:33:59 +01002207func apexFileForBootclasspathFragmentContentModule(ctx android.ModuleContext, fragmentModule blueprint.Module, javaModule javaModule) apexFile {
2208 bootclasspathFragmentInfo := ctx.OtherModuleProvider(fragmentModule, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
2209
2210 // Get the dexBootJar from the bootclasspath_fragment as that is responsible for performing the
2211 // hidden API encpding.
Paul Duffin1a8010a2021-05-15 12:39:23 +01002212 dexBootJar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(javaModule)
2213 if err != nil {
2214 ctx.ModuleErrorf("%s", err)
2215 }
Paul Duffin190fdef2021-04-26 10:33:59 +01002216
2217 // Create an apexFile as for a normal java module but with the dex boot jar provided by the
2218 // bootclasspath_fragment.
2219 af := apexFileForJavaModuleWithFile(ctx, javaModule, dexBootJar)
2220 return af
Paul Duffincc33ec82021-04-25 23:14:55 +01002221}
2222
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002223///////////////////////////////////////////////////////////////////////////////////////////////////
2224// Factory functions
2225//
2226
2227func newApexBundle() *apexBundle {
2228 module := &apexBundle{}
2229
2230 module.AddProperties(&module.properties)
2231 module.AddProperties(&module.targetProperties)
Jiyong Park59140302020-12-14 18:44:04 +09002232 module.AddProperties(&module.archProperties)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002233 module.AddProperties(&module.overridableProperties)
2234
2235 android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
2236 android.InitDefaultableModule(module)
2237 android.InitSdkAwareModule(module)
2238 android.InitOverridableModule(module, &module.overridableProperties.Overrides)
Jingwen Chenf59a8e12021-07-16 09:28:53 +00002239 android.InitBazelModule(module)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002240 return module
2241}
2242
2243func ApexBundleFactory(testApex bool, artApex bool) android.Module {
2244 bundle := newApexBundle()
2245 bundle.testApex = testApex
2246 bundle.artApex = artApex
2247 return bundle
2248}
2249
2250// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
2251// certain compatibility checks such as apex_available are not done for apex_test.
2252func testApexBundleFactory() android.Module {
2253 bundle := newApexBundle()
2254 bundle.testApex = true
2255 return bundle
2256}
2257
2258// apex packages other modules into an APEX file which is a packaging format for system-level
2259// components like binaries, shared libraries, etc.
2260func BundleFactory() android.Module {
2261 return newApexBundle()
2262}
2263
2264type Defaults struct {
2265 android.ModuleBase
2266 android.DefaultsModuleBase
2267}
2268
2269// apex_defaults provides defaultable properties to other apex modules.
2270func defaultsFactory() android.Module {
2271 return DefaultsFactory()
2272}
2273
2274func DefaultsFactory(props ...interface{}) android.Module {
2275 module := &Defaults{}
2276
2277 module.AddProperties(props...)
2278 module.AddProperties(
2279 &apexBundleProperties{},
2280 &apexTargetBundleProperties{},
2281 &overridableProperties{},
2282 )
2283
2284 android.InitDefaultsModule(module)
2285 return module
2286}
2287
2288type OverrideApex struct {
2289 android.ModuleBase
2290 android.OverrideModuleBase
2291}
2292
2293func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
2294 // All the overrides happen in the base module.
2295}
2296
2297// override_apex is used to create an apex module based on another apex module by overriding some of
2298// its properties.
2299func overrideApexFactory() android.Module {
2300 m := &OverrideApex{}
2301
2302 m.AddProperties(&overridableProperties{})
2303
2304 android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
2305 android.InitOverrideModule(m)
2306 return m
2307}
2308
2309///////////////////////////////////////////////////////////////////////////////////////////////////
2310// Vality check routines
2311//
2312// These are called in at the very beginning of GenerateAndroidBuildActions to flag an error when
2313// certain conditions are not met.
2314//
2315// TODO(jiyong): move these checks to a separate go file.
2316
2317// Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version
2318// of this apexBundle.
2319func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) {
2320 if a.testApex || a.vndkApex {
2321 return
2322 }
2323 // Meaningless to check min_sdk_version when building use_vendor modules against non-Trebleized targets
2324 if proptools.Bool(a.properties.Use_vendor) && ctx.DeviceConfig().VndkVersion() == "" {
2325 return
2326 }
2327 // apexBundle::minSdkVersion reports its own errors.
2328 minSdkVersion := a.minSdkVersion(ctx)
2329 android.CheckMinSdkVersion(a, ctx, minSdkVersion)
2330}
2331
2332func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel {
2333 ver := proptools.String(a.properties.Min_sdk_version)
2334 if ver == "" {
Jooyung Haned124c32021-01-26 11:43:46 +09002335 return android.NoneApiLevel
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002336 }
2337 apiLevel, err := android.ApiLevelFromUser(ctx, ver)
2338 if err != nil {
2339 ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
2340 return android.NoneApiLevel
2341 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002342 return apiLevel
2343}
2344
2345// Ensures that a lib providing stub isn't statically linked
2346func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) {
2347 // Practically, we only care about regular APEXes on the device.
2348 if ctx.Host() || a.testApex || a.vndkApex {
2349 return
2350 }
2351
2352 abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
2353
2354 a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
2355 if ccm, ok := to.(*cc.Module); ok {
2356 apexName := ctx.ModuleName()
2357 fromName := ctx.OtherModuleName(from)
2358 toName := ctx.OtherModuleName(to)
2359
2360 // If `to` is not actually in the same APEX as `from` then it does not need
2361 // apex_available and neither do any of its dependencies.
Paul Duffin4c3e8e22021-03-18 15:41:29 +00002362 //
2363 // It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps().
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002364 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
2365 // As soon as the dependency graph crosses the APEX boundary, don't go further.
2366 return false
2367 }
2368
2369 // The dynamic linker and crash_dump tool in the runtime APEX is the only
2370 // exception to this rule. It can't make the static dependencies dynamic
2371 // because it can't do the dynamic linking for itself.
Kiyoung Kim4098c7e2020-11-30 14:42:14 +09002372 // Same rule should be applied to linkerconfig, because it should be executed
2373 // only with static linked libraries before linker is available with ld.config.txt
2374 if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump" || fromName == "linkerconfig") {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002375 return false
2376 }
2377
2378 isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName)
2379 if isStubLibraryFromOtherApex && !externalDep {
2380 ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
2381 "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))
2382 }
2383
2384 }
2385 return true
2386 })
2387}
2388
satayevb98371c2021-06-15 16:49:50 +01002389// checkUpdatable enforces APEX and its transitive dep properties to have desired values for updatable APEXes.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002390func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
2391 if a.Updatable() {
2392 if String(a.properties.Min_sdk_version) == "" {
2393 ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
2394 }
Jiyong Park9477c262021-06-22 20:23:05 +09002395 if a.UsePlatformApis() {
2396 ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs")
2397 }
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002398 a.checkJavaStableSdkVersion(ctx)
satayevb98371c2021-06-15 16:49:50 +01002399 a.checkClasspathFragments(ctx)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002400 }
2401}
2402
satayevb98371c2021-06-15 16:49:50 +01002403// checkClasspathFragments enforces that all classpath fragments in deps generate classpaths.proto config.
2404func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) {
2405 ctx.VisitDirectDeps(func(module android.Module) {
2406 if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag {
2407 info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
2408 if !info.ClasspathFragmentProtoGenerated {
2409 ctx.OtherModuleErrorf(module, "is included in updatable apex %v, it must not set generate_classpaths_proto to false", ctx.ModuleName())
2410 }
2411 }
2412 })
2413}
2414
2415// checkJavaStableSdkVersion enforces that all Java deps are using stable SDKs to compile.
Artur Satayev8cf899a2020-04-15 17:29:42 +01002416func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002417 // Visit direct deps only. As long as we guarantee top-level deps are using stable SDKs,
2418 // java's checkLinkType guarantees correct usage for transitive deps
Artur Satayev8cf899a2020-04-15 17:29:42 +01002419 ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
2420 tag := ctx.OtherModuleDependencyTag(module)
2421 switch tag {
2422 case javaLibTag, androidAppTag:
Jiyong Park92315372021-04-02 08:45:46 +09002423 if m, ok := module.(interface {
2424 CheckStableSdkVersion(ctx android.BaseModuleContext) error
2425 }); ok {
2426 if err := m.CheckStableSdkVersion(ctx); err != nil {
Artur Satayev8cf899a2020-04-15 17:29:42 +01002427 ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err)
2428 }
2429 }
2430 }
2431 })
2432}
2433
satayevb98371c2021-06-15 16:49:50 +01002434// checkApexAvailability ensures that the all the dependencies are marked as available for this APEX.
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002435func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
2436 // Let's be practical. Availability for test, host, and the VNDK apex isn't important
2437 if ctx.Host() || a.testApex || a.vndkApex {
2438 return
2439 }
2440
2441 // Because APEXes targeting other than system/system_ext partitions can't set
2442 // apex_available, we skip checks for these APEXes
2443 if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
2444 return
2445 }
2446
2447 // Coverage build adds additional dependencies for the coverage-only runtime libraries.
2448 // Requiring them and their transitive depencies with apex_available is not right
2449 // because they just add noise.
2450 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) {
2451 return
2452 }
2453
2454 a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
2455 // As soon as the dependency graph crosses the APEX boundary, don't go further.
2456 if externalDep {
2457 return false
2458 }
2459
2460 apexName := ctx.ModuleName()
2461 fromName := ctx.OtherModuleName(from)
2462 toName := ctx.OtherModuleName(to)
2463
2464 // If `to` is not actually in the same APEX as `from` then it does not need
2465 // apex_available and neither do any of its dependencies.
Paul Duffin4c3e8e22021-03-18 15:41:29 +00002466 //
2467 // It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps().
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002468 if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
2469 // As soon as the dependency graph crosses the APEX boundary, don't go
2470 // further.
2471 return false
2472 }
2473
2474 if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
2475 return true
2476 }
Jiyong Park767dbd92021-03-04 13:03:10 +09002477 ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'."+
2478 "\n\nDependency path:%s\n\n"+
2479 "Consider adding %q to 'apex_available' property of %q",
2480 fromName, toName, ctx.GetPathString(true), apexName, toName)
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002481 // Visit this module's dependencies to check and report any issues with their availability.
2482 return true
2483 })
2484}
2485
Jiyong Park192600a2021-08-03 07:52:17 +00002486// checkStaticExecutable ensures that executables in an APEX are not static.
2487func (a *apexBundle) checkStaticExecutables(ctx android.ModuleContext) {
Jiyong Parkd12979d2021-08-03 13:36:09 +09002488 // No need to run this for host APEXes
2489 if ctx.Host() {
2490 return
2491 }
2492
Jiyong Park192600a2021-08-03 07:52:17 +00002493 ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
2494 if ctx.OtherModuleDependencyTag(module) != executableTag {
2495 return
2496 }
Jiyong Parkd12979d2021-08-03 13:36:09 +09002497
2498 if l, ok := module.(cc.LinkableInterface); ok && l.StaticExecutable() {
Jiyong Park192600a2021-08-03 07:52:17 +00002499 apex := a.ApexVariationName()
2500 exec := ctx.OtherModuleName(module)
2501 if isStaticExecutableAllowed(apex, exec) {
2502 return
2503 }
2504 ctx.ModuleErrorf("executable %s is static", ctx.OtherModuleName(module))
2505 }
2506 })
2507}
2508
2509// A small list of exceptions where static executables are allowed in APEXes.
2510func isStaticExecutableAllowed(apex string, exec string) bool {
2511 m := map[string][]string{
2512 "com.android.runtime": []string{
2513 "linker",
2514 "linkerconfig",
2515 },
2516 }
2517 execNames, ok := m[apex]
2518 return ok && android.InList(exec, execNames)
2519}
2520
braleeb0c1f0c2021-06-07 22:49:13 +08002521// Collect information for opening IDE project files in java/jdeps.go.
2522func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
2523 dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
2524 dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...)
2525 dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments...)
2526 dpInfo.Paths = append(dpInfo.Paths, a.modulePaths...)
2527}
2528
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002529var (
2530 apexAvailBaseline = makeApexAvailableBaseline()
2531 inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline)
2532)
2533
Colin Cross440e0d02020-06-11 11:32:11 -07002534func baselineApexAvailable(apex, moduleName string) bool {
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002535 key := apex
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002536 moduleName = normalizeModuleName(moduleName)
2537
Colin Cross440e0d02020-06-11 11:32:11 -07002538 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002539 return true
2540 }
2541
2542 key = android.AvailableToAnyApex
Colin Cross440e0d02020-06-11 11:32:11 -07002543 if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002544 return true
2545 }
2546
2547 return false
2548}
2549
2550func normalizeModuleName(moduleName string) string {
Jiyong Park0f80c182020-01-31 02:49:53 +09002551 // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
2552 // system. Trim the prefix for the check since they are confusing
Paul Duffind23c7262020-12-11 18:13:08 +00002553 moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName)
Jiyong Park0f80c182020-01-31 02:49:53 +09002554 if strings.HasPrefix(moduleName, "libclang_rt.") {
2555 // This module has many arch variants that depend on the product being built.
2556 // We don't want to list them all
2557 moduleName = "libclang_rt"
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002558 }
Jooyung Hanacc7bbe2020-05-20 09:06:00 +09002559 if strings.HasPrefix(moduleName, "androidx.") {
2560 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries
2561 moduleName = "androidx"
2562 }
Paul Duffin7d74e7b2020-03-06 12:30:13 +00002563 return moduleName
Anton Hanssoneec79eb2020-01-10 15:12:39 +00002564}
2565
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002566// Transform the map of apex -> modules to module -> apexes.
2567func invertApexBaseline(m map[string][]string) map[string][]string {
2568 r := make(map[string][]string)
2569 for apex, modules := range m {
2570 for _, module := range modules {
2571 r[module] = append(r[module], apex)
2572 }
2573 }
2574 return r
2575}
2576
2577// Retrieve the baseline of apexes to which the supplied module belongs.
2578func BaselineApexAvailable(moduleName string) []string {
2579 return inverseApexAvailBaseline[normalizeModuleName(moduleName)]
2580}
2581
Jiyong Parkc0ec6f92020-11-19 23:00:52 +09002582// This is a map from apex to modules, which overrides the apex_available setting for that
2583// particular module to make it available for the apex regardless of its setting.
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002584// TODO(b/147364041): remove this
2585func makeApexAvailableBaseline() map[string][]string {
2586 // The "Module separator"s below are employed to minimize merge conflicts.
2587 m := make(map[string][]string)
2588 //
2589 // Module separator
2590 //
2591 m["com.android.appsearch"] = []string{
2592 "icing-java-proto-lite",
2593 "libprotobuf-java-lite",
2594 }
2595 //
2596 // Module separator
2597 //
2598 m["com.android.bluetooth.updatable"] = []string{
2599 "android.hardware.audio.common@5.0",
2600 "android.hardware.bluetooth.a2dp@1.0",
2601 "android.hardware.bluetooth.audio@2.0",
2602 "android.hardware.bluetooth@1.0",
2603 "android.hardware.bluetooth@1.1",
2604 "android.hardware.graphics.bufferqueue@1.0",
2605 "android.hardware.graphics.bufferqueue@2.0",
2606 "android.hardware.graphics.common@1.0",
2607 "android.hardware.graphics.common@1.1",
2608 "android.hardware.graphics.common@1.2",
2609 "android.hardware.media@1.0",
2610 "android.hidl.safe_union@1.0",
2611 "android.hidl.token@1.0",
2612 "android.hidl.token@1.0-utils",
2613 "avrcp-target-service",
2614 "avrcp_headers",
2615 "bluetooth-protos-lite",
2616 "bluetooth.mapsapi",
2617 "com.android.vcard",
2618 "dnsresolver_aidl_interface-V2-java",
2619 "ipmemorystore-aidl-interfaces-V5-java",
2620 "ipmemorystore-aidl-interfaces-java",
2621 "internal_include_headers",
2622 "lib-bt-packets",
2623 "lib-bt-packets-avrcp",
2624 "lib-bt-packets-base",
2625 "libFraunhoferAAC",
2626 "libaudio-a2dp-hw-utils",
2627 "libaudio-hearing-aid-hw-utils",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002628 "libbluetooth",
2629 "libbluetooth-types",
2630 "libbluetooth-types-header",
2631 "libbluetooth_gd",
2632 "libbluetooth_headers",
2633 "libbluetooth_jni",
2634 "libbt-audio-hal-interface",
2635 "libbt-bta",
2636 "libbt-common",
2637 "libbt-hci",
2638 "libbt-platform-protos-lite",
2639 "libbt-protos-lite",
2640 "libbt-sbc-decoder",
2641 "libbt-sbc-encoder",
2642 "libbt-stack",
2643 "libbt-utils",
2644 "libbtcore",
2645 "libbtdevice",
2646 "libbte",
2647 "libbtif",
2648 "libchrome",
2649 "libevent",
2650 "libfmq",
2651 "libg722codec",
2652 "libgui_headers",
2653 "libmedia_headers",
2654 "libmodpb64",
2655 "libosi",
2656 "libstagefright_foundation_headers",
2657 "libstagefright_headers",
2658 "libstatslog",
2659 "libstatssocket",
2660 "libtinyxml2",
2661 "libudrv-uipc",
2662 "libz",
2663 "media_plugin_headers",
2664 "net-utils-services-common",
2665 "netd_aidl_interface-unstable-java",
2666 "netd_event_listener_interface-java",
2667 "netlink-client",
2668 "networkstack-client",
2669 "sap-api-java-static",
2670 "services.net",
2671 }
2672 //
2673 // Module separator
2674 //
2675 m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
2676 //
2677 // Module separator
2678 //
2679 m["com.android.extservices"] = []string{
2680 "error_prone_annotations",
2681 "ExtServices-core",
2682 "ExtServices",
2683 "libtextclassifier-java",
2684 "libz_current",
2685 "textclassifier-statsd",
2686 "TextClassifierNotificationLibNoManifest",
2687 "TextClassifierServiceLibNoManifest",
2688 }
2689 //
2690 // Module separator
2691 //
2692 m["com.android.neuralnetworks"] = []string{
2693 "android.hardware.neuralnetworks@1.0",
2694 "android.hardware.neuralnetworks@1.1",
2695 "android.hardware.neuralnetworks@1.2",
2696 "android.hardware.neuralnetworks@1.3",
2697 "android.hidl.allocator@1.0",
2698 "android.hidl.memory.token@1.0",
2699 "android.hidl.memory@1.0",
2700 "android.hidl.safe_union@1.0",
2701 "libarect",
2702 "libbuildversion",
2703 "libmath",
2704 "libprocpartition",
2705 "libsync",
2706 }
2707 //
2708 // Module separator
2709 //
2710 m["com.android.media"] = []string{
2711 "android.frameworks.bufferhub@1.0",
2712 "android.hardware.cas.native@1.0",
2713 "android.hardware.cas@1.0",
2714 "android.hardware.configstore-utils",
2715 "android.hardware.configstore@1.0",
2716 "android.hardware.configstore@1.1",
2717 "android.hardware.graphics.allocator@2.0",
2718 "android.hardware.graphics.allocator@3.0",
2719 "android.hardware.graphics.bufferqueue@1.0",
2720 "android.hardware.graphics.bufferqueue@2.0",
2721 "android.hardware.graphics.common@1.0",
2722 "android.hardware.graphics.common@1.1",
2723 "android.hardware.graphics.common@1.2",
2724 "android.hardware.graphics.mapper@2.0",
2725 "android.hardware.graphics.mapper@2.1",
2726 "android.hardware.graphics.mapper@3.0",
2727 "android.hardware.media.omx@1.0",
2728 "android.hardware.media@1.0",
2729 "android.hidl.allocator@1.0",
2730 "android.hidl.memory.token@1.0",
2731 "android.hidl.memory@1.0",
2732 "android.hidl.token@1.0",
2733 "android.hidl.token@1.0-utils",
2734 "bionic_libc_platform_headers",
2735 "exoplayer2-extractor",
2736 "exoplayer2-extractor-annotation-stubs",
2737 "gl_headers",
2738 "jsr305",
2739 "libEGL",
2740 "libEGL_blobCache",
2741 "libEGL_getProcAddress",
2742 "libFLAC",
2743 "libFLAC-config",
2744 "libFLAC-headers",
2745 "libGLESv2",
2746 "libaacextractor",
2747 "libamrextractor",
2748 "libarect",
2749 "libaudio_system_headers",
2750 "libaudioclient",
2751 "libaudioclient_headers",
2752 "libaudiofoundation",
2753 "libaudiofoundation_headers",
2754 "libaudiomanager",
2755 "libaudiopolicy",
2756 "libaudioutils",
2757 "libaudioutils_fixedfft",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002758 "libbluetooth-types-header",
2759 "libbufferhub",
2760 "libbufferhub_headers",
2761 "libbufferhubqueue",
2762 "libc_malloc_debug_backtrace",
2763 "libcamera_client",
2764 "libcamera_metadata",
2765 "libdvr_headers",
2766 "libexpat",
2767 "libfifo",
2768 "libflacextractor",
2769 "libgrallocusage",
2770 "libgraphicsenv",
2771 "libgui",
2772 "libgui_headers",
2773 "libhardware_headers",
2774 "libinput",
2775 "liblzma",
2776 "libmath",
2777 "libmedia",
2778 "libmedia_codeclist",
2779 "libmedia_headers",
2780 "libmedia_helper",
2781 "libmedia_helper_headers",
2782 "libmedia_midiiowrapper",
2783 "libmedia_omx",
2784 "libmediautils",
2785 "libmidiextractor",
2786 "libmkvextractor",
2787 "libmp3extractor",
2788 "libmp4extractor",
2789 "libmpeg2extractor",
2790 "libnativebase_headers",
2791 "libnativewindow_headers",
2792 "libnblog",
2793 "liboggextractor",
2794 "libpackagelistparser",
2795 "libpdx",
2796 "libpdx_default_transport",
2797 "libpdx_headers",
2798 "libpdx_uds",
2799 "libprocinfo",
2800 "libspeexresampler",
2801 "libspeexresampler",
2802 "libstagefright_esds",
2803 "libstagefright_flacdec",
2804 "libstagefright_flacdec",
2805 "libstagefright_foundation",
2806 "libstagefright_foundation_headers",
2807 "libstagefright_foundation_without_imemory",
2808 "libstagefright_headers",
2809 "libstagefright_id3",
2810 "libstagefright_metadatautils",
2811 "libstagefright_mpeg2extractor",
2812 "libstagefright_mpeg2support",
2813 "libsync",
2814 "libui",
2815 "libui_headers",
2816 "libunwindstack",
2817 "libvibrator",
2818 "libvorbisidec",
2819 "libwavextractor",
2820 "libwebm",
2821 "media_ndk_headers",
2822 "media_plugin_headers",
2823 "updatable-media",
2824 }
2825 //
2826 // Module separator
2827 //
2828 m["com.android.media.swcodec"] = []string{
2829 "android.frameworks.bufferhub@1.0",
2830 "android.hardware.common-ndk_platform",
2831 "android.hardware.configstore-utils",
2832 "android.hardware.configstore@1.0",
2833 "android.hardware.configstore@1.1",
2834 "android.hardware.graphics.allocator@2.0",
2835 "android.hardware.graphics.allocator@3.0",
2836 "android.hardware.graphics.allocator@4.0",
2837 "android.hardware.graphics.bufferqueue@1.0",
2838 "android.hardware.graphics.bufferqueue@2.0",
2839 "android.hardware.graphics.common-ndk_platform",
2840 "android.hardware.graphics.common@1.0",
2841 "android.hardware.graphics.common@1.1",
2842 "android.hardware.graphics.common@1.2",
2843 "android.hardware.graphics.mapper@2.0",
2844 "android.hardware.graphics.mapper@2.1",
2845 "android.hardware.graphics.mapper@3.0",
2846 "android.hardware.graphics.mapper@4.0",
2847 "android.hardware.media.bufferpool@2.0",
2848 "android.hardware.media.c2@1.0",
2849 "android.hardware.media.c2@1.1",
2850 "android.hardware.media.omx@1.0",
2851 "android.hardware.media@1.0",
2852 "android.hardware.media@1.0",
2853 "android.hidl.memory.token@1.0",
2854 "android.hidl.memory@1.0",
2855 "android.hidl.safe_union@1.0",
2856 "android.hidl.token@1.0",
2857 "android.hidl.token@1.0-utils",
2858 "libEGL",
2859 "libFLAC",
2860 "libFLAC-config",
2861 "libFLAC-headers",
2862 "libFraunhoferAAC",
2863 "libLibGuiProperties",
2864 "libarect",
2865 "libaudio_system_headers",
2866 "libaudioutils",
2867 "libaudioutils",
2868 "libaudioutils_fixedfft",
2869 "libavcdec",
2870 "libavcenc",
2871 "libavservices_minijail",
2872 "libavservices_minijail",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09002873 "libbinderthreadstateutils",
2874 "libbluetooth-types-header",
2875 "libbufferhub_headers",
2876 "libcodec2",
2877 "libcodec2_headers",
2878 "libcodec2_hidl@1.0",
2879 "libcodec2_hidl@1.1",
2880 "libcodec2_internal",
2881 "libcodec2_soft_aacdec",
2882 "libcodec2_soft_aacenc",
2883 "libcodec2_soft_amrnbdec",
2884 "libcodec2_soft_amrnbenc",
2885 "libcodec2_soft_amrwbdec",
2886 "libcodec2_soft_amrwbenc",
2887 "libcodec2_soft_av1dec_gav1",
2888 "libcodec2_soft_avcdec",
2889 "libcodec2_soft_avcenc",
2890 "libcodec2_soft_common",
2891 "libcodec2_soft_flacdec",
2892 "libcodec2_soft_flacenc",
2893 "libcodec2_soft_g711alawdec",
2894 "libcodec2_soft_g711mlawdec",
2895 "libcodec2_soft_gsmdec",
2896 "libcodec2_soft_h263dec",
2897 "libcodec2_soft_h263enc",
2898 "libcodec2_soft_hevcdec",
2899 "libcodec2_soft_hevcenc",
2900 "libcodec2_soft_mp3dec",
2901 "libcodec2_soft_mpeg2dec",
2902 "libcodec2_soft_mpeg4dec",
2903 "libcodec2_soft_mpeg4enc",
2904 "libcodec2_soft_opusdec",
2905 "libcodec2_soft_opusenc",
2906 "libcodec2_soft_rawdec",
2907 "libcodec2_soft_vorbisdec",
2908 "libcodec2_soft_vp8dec",
2909 "libcodec2_soft_vp8enc",
2910 "libcodec2_soft_vp9dec",
2911 "libcodec2_soft_vp9enc",
2912 "libcodec2_vndk",
2913 "libdvr_headers",
2914 "libfmq",
2915 "libfmq",
2916 "libgav1",
2917 "libgralloctypes",
2918 "libgrallocusage",
2919 "libgraphicsenv",
2920 "libgsm",
2921 "libgui_bufferqueue_static",
2922 "libgui_headers",
2923 "libhardware",
2924 "libhardware_headers",
2925 "libhevcdec",
2926 "libhevcenc",
2927 "libion",
2928 "libjpeg",
2929 "liblzma",
2930 "libmath",
2931 "libmedia_codecserviceregistrant",
2932 "libmedia_headers",
2933 "libmpeg2dec",
2934 "libnativebase_headers",
2935 "libnativewindow_headers",
2936 "libpdx_headers",
2937 "libscudo_wrapper",
2938 "libsfplugin_ccodec_utils",
2939 "libspeexresampler",
2940 "libstagefright_amrnb_common",
2941 "libstagefright_amrnbdec",
2942 "libstagefright_amrnbenc",
2943 "libstagefright_amrwbdec",
2944 "libstagefright_amrwbenc",
2945 "libstagefright_bufferpool@2.0.1",
2946 "libstagefright_bufferqueue_helper",
2947 "libstagefright_enc_common",
2948 "libstagefright_flacdec",
2949 "libstagefright_foundation",
2950 "libstagefright_foundation_headers",
2951 "libstagefright_headers",
2952 "libstagefright_m4vh263dec",
2953 "libstagefright_m4vh263enc",
2954 "libstagefright_mp3dec",
2955 "libsync",
2956 "libui",
2957 "libui_headers",
2958 "libunwindstack",
2959 "libvorbisidec",
2960 "libvpx",
2961 "libyuv",
2962 "libyuv_static",
2963 "media_ndk_headers",
2964 "media_plugin_headers",
2965 "mediaswcodec",
2966 }
2967 //
2968 // Module separator
2969 //
2970 m["com.android.mediaprovider"] = []string{
2971 "MediaProvider",
2972 "MediaProviderGoogle",
2973 "fmtlib_ndk",
2974 "libbase_ndk",
2975 "libfuse",
2976 "libfuse_jni",
2977 }
2978 //
2979 // Module separator
2980 //
2981 m["com.android.permission"] = []string{
2982 "car-ui-lib",
2983 "iconloader",
2984 "kotlin-annotations",
2985 "kotlin-stdlib",
2986 "kotlin-stdlib-jdk7",
2987 "kotlin-stdlib-jdk8",
2988 "kotlinx-coroutines-android",
2989 "kotlinx-coroutines-android-nodeps",
2990 "kotlinx-coroutines-core",
2991 "kotlinx-coroutines-core-nodeps",
2992 "permissioncontroller-statsd",
2993 "GooglePermissionController",
2994 "PermissionController",
2995 "SettingsLibActionBarShadow",
2996 "SettingsLibAppPreference",
2997 "SettingsLibBarChartPreference",
2998 "SettingsLibLayoutPreference",
2999 "SettingsLibProgressBar",
3000 "SettingsLibSearchWidget",
3001 "SettingsLibSettingsTheme",
3002 "SettingsLibRestrictedLockUtils",
3003 "SettingsLibHelpUtils",
3004 }
3005 //
3006 // Module separator
3007 //
3008 m["com.android.runtime"] = []string{
3009 "bionic_libc_platform_headers",
3010 "libarm-optimized-routines-math",
3011 "libc_aeabi",
3012 "libc_bionic",
3013 "libc_bionic_ndk",
3014 "libc_bootstrap",
3015 "libc_common",
3016 "libc_common_shared",
3017 "libc_common_static",
3018 "libc_dns",
3019 "libc_dynamic_dispatch",
3020 "libc_fortify",
3021 "libc_freebsd",
3022 "libc_freebsd_large_stack",
3023 "libc_gdtoa",
3024 "libc_init_dynamic",
3025 "libc_init_static",
3026 "libc_jemalloc_wrapper",
3027 "libc_netbsd",
3028 "libc_nomalloc",
3029 "libc_nopthread",
3030 "libc_openbsd",
3031 "libc_openbsd_large_stack",
3032 "libc_openbsd_ndk",
3033 "libc_pthread",
3034 "libc_static_dispatch",
3035 "libc_syscalls",
3036 "libc_tzcode",
3037 "libc_unwind_static",
3038 "libdebuggerd",
3039 "libdebuggerd_common_headers",
3040 "libdebuggerd_handler_core",
3041 "libdebuggerd_handler_fallback",
3042 "libdl_static",
3043 "libjemalloc5",
3044 "liblinker_main",
3045 "liblinker_malloc",
3046 "liblz4",
3047 "liblzma",
3048 "libprocinfo",
3049 "libpropertyinfoparser",
3050 "libscudo",
3051 "libstdc++",
3052 "libsystemproperties",
3053 "libtombstoned_client_static",
3054 "libunwindstack",
3055 "libz",
3056 "libziparchive",
3057 }
3058 //
3059 // Module separator
3060 //
3061 m["com.android.tethering"] = []string{
3062 "android.hardware.tetheroffload.config-V1.0-java",
3063 "android.hardware.tetheroffload.control-V1.0-java",
3064 "android.hidl.base-V1.0-java",
3065 "libcgrouprc",
3066 "libcgrouprc_format",
3067 "libtetherutilsjni",
3068 "libvndksupport",
3069 "net-utils-framework-common",
3070 "netd_aidl_interface-V3-java",
3071 "netlink-client",
3072 "networkstack-aidl-interfaces-java",
3073 "tethering-aidl-interfaces-java",
3074 "TetheringApiCurrentLib",
3075 }
3076 //
3077 // Module separator
3078 //
3079 m["com.android.wifi"] = []string{
3080 "PlatformProperties",
3081 "android.hardware.wifi-V1.0-java",
3082 "android.hardware.wifi-V1.0-java-constants",
3083 "android.hardware.wifi-V1.1-java",
3084 "android.hardware.wifi-V1.2-java",
3085 "android.hardware.wifi-V1.3-java",
3086 "android.hardware.wifi-V1.4-java",
3087 "android.hardware.wifi.hostapd-V1.0-java",
3088 "android.hardware.wifi.hostapd-V1.1-java",
3089 "android.hardware.wifi.hostapd-V1.2-java",
3090 "android.hardware.wifi.supplicant-V1.0-java",
3091 "android.hardware.wifi.supplicant-V1.1-java",
3092 "android.hardware.wifi.supplicant-V1.2-java",
3093 "android.hardware.wifi.supplicant-V1.3-java",
3094 "android.hidl.base-V1.0-java",
3095 "android.hidl.manager-V1.0-java",
3096 "android.hidl.manager-V1.1-java",
3097 "android.hidl.manager-V1.2-java",
3098 "bouncycastle-unbundled",
3099 "dnsresolver_aidl_interface-V2-java",
3100 "error_prone_annotations",
3101 "framework-wifi-pre-jarjar",
3102 "framework-wifi-util-lib",
3103 "ipmemorystore-aidl-interfaces-V3-java",
3104 "ipmemorystore-aidl-interfaces-java",
3105 "ksoap2",
3106 "libnanohttpd",
3107 "libwifi-jni",
3108 "net-utils-services-common",
3109 "netd_aidl_interface-V2-java",
3110 "netd_aidl_interface-unstable-java",
3111 "netd_event_listener_interface-java",
3112 "netlink-client",
3113 "networkstack-client",
3114 "services.net",
3115 "wifi-lite-protos",
3116 "wifi-nano-protos",
3117 "wifi-service-pre-jarjar",
3118 "wifi-service-resources",
3119 }
3120 //
3121 // Module separator
3122 //
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003123 m["com.android.os.statsd"] = []string{
3124 "libstatssocket",
3125 }
3126 //
3127 // Module separator
3128 //
3129 m[android.AvailableToAnyApex] = []string{
3130 // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries
3131 "androidx",
3132 "androidx-constraintlayout_constraintlayout",
3133 "androidx-constraintlayout_constraintlayout-nodeps",
3134 "androidx-constraintlayout_constraintlayout-solver",
3135 "androidx-constraintlayout_constraintlayout-solver-nodeps",
3136 "com.google.android.material_material",
3137 "com.google.android.material_material-nodeps",
3138
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003139 "libclang_rt",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003140 "libprofile-clang-extras",
3141 "libprofile-clang-extras_ndk",
3142 "libprofile-extras",
3143 "libprofile-extras_ndk",
Ryan Prichardb35a85e2021-01-13 19:18:53 -08003144 "libunwind",
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003145 }
3146 return m
3147}
3148
3149func init() {
3150 android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...)
3151 android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...)
3152}
3153
3154func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule {
3155 rules := make([]android.Rule, 0, len(modules_packages))
3156 for module_name, module_packages := range modules_packages {
Jaewoong Jung18aefc12020-12-21 09:11:10 -08003157 permittedPackagesRule := android.NeverAllow().
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003158 BootclasspathJar().
3159 With("apex_available", module_name).
3160 WithMatcher("permitted_packages", android.NotInList(module_packages)).
3161 Because("jars that are part of the " + module_name +
3162 " module may only allow these packages: " + strings.Join(module_packages, ",") +
3163 ". Please jarjar or move code around.")
Jaewoong Jung18aefc12020-12-21 09:11:10 -08003164 rules = append(rules, permittedPackagesRule)
Jiyong Park8e6d52f2020-11-19 14:37:47 +09003165 }
3166 return rules
3167}
3168
3169// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
3170// Adding code to the bootclasspath in new packages will cause issues on module update.
3171func qModulesPackages() map[string][]string {
3172 return map[string][]string{
3173 "com.android.conscrypt": []string{
3174 "android.net.ssl",
3175 "com.android.org.conscrypt",
3176 },
3177 "com.android.media": []string{
3178 "android.media",
3179 },
3180 }
3181}
3182
3183// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
3184// Adding code to the bootclasspath in new packages will cause issues on module update.
3185func rModulesPackages() map[string][]string {
3186 return map[string][]string{
3187 "com.android.mediaprovider": []string{
3188 "android.provider",
3189 },
3190 "com.android.permission": []string{
3191 "android.permission",
3192 "android.app.role",
3193 "com.android.permission",
3194 "com.android.role",
3195 },
3196 "com.android.sdkext": []string{
3197 "android.os.ext",
3198 },
3199 "com.android.os.statsd": []string{
3200 "android.app",
3201 "android.os",
3202 "android.util",
3203 "com.android.internal.statsd",
3204 "com.android.server.stats",
3205 },
3206 "com.android.wifi": []string{
3207 "com.android.server.wifi",
3208 "com.android.wifi.x",
3209 "android.hardware.wifi",
3210 "android.net.wifi",
3211 },
3212 "com.android.tethering": []string{
3213 "android.net",
3214 },
3215 }
3216}
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003217
3218// For Bazel / bp2build
3219
3220type bazelApexBundleAttributes struct {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -04003221 Manifest bazel.LabelAttribute
3222 Android_manifest bazel.LabelAttribute
3223 File_contexts bazel.LabelAttribute
3224 Key bazel.LabelAttribute
3225 Certificate bazel.LabelAttribute
3226 Min_sdk_version string
3227 Updatable bazel.BoolAttribute
3228 Installable bazel.BoolAttribute
3229 Native_shared_libs bazel.LabelListAttribute
3230 Binaries bazel.StringListAttribute
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -04003231 Prebuilts bazel.LabelListAttribute
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003232}
3233
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003234func ApexBundleBp2Build(ctx android.TopDownMutatorContext) {
3235 module, ok := ctx.Module().(*apexBundle)
3236 if !ok {
3237 // Not an APEX bundle
3238 return
3239 }
3240 if !module.ConvertWithBp2build(ctx) {
3241 return
3242 }
3243 if ctx.ModuleType() != "apex" {
3244 return
3245 }
3246
3247 apexBundleBp2BuildInternal(ctx, module)
3248}
3249
3250func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexBundle) {
3251 var manifestLabelAttribute bazel.LabelAttribute
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003252 if module.properties.Manifest != nil {
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -04003253 manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.Manifest))
3254 }
3255
3256 var androidManifestLabelAttribute bazel.LabelAttribute
3257 if module.properties.AndroidManifest != nil {
3258 androidManifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.AndroidManifest))
3259 }
3260
3261 var fileContextsLabelAttribute bazel.LabelAttribute
3262 if module.properties.File_contexts != nil {
3263 fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.properties.File_contexts))
3264 }
3265
3266 var minSdkVersion string
3267 if module.properties.Min_sdk_version != nil {
3268 minSdkVersion = *module.properties.Min_sdk_version
3269 }
3270
3271 var keyLabelAttribute bazel.LabelAttribute
3272 if module.overridableProperties.Key != nil {
3273 keyLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.overridableProperties.Key))
3274 }
3275
3276 var certificateLabelAttribute bazel.LabelAttribute
3277 if module.overridableProperties.Certificate != nil {
3278 certificateLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.overridableProperties.Certificate))
3279 }
3280
3281 nativeSharedLibs := module.properties.ApexNativeDependencies.Native_shared_libs
3282 nativeSharedLibsLabelList := android.BazelLabelForModuleDeps(ctx, nativeSharedLibs)
3283 nativeSharedLibsLabelListAttribute := bazel.MakeLabelListAttribute(nativeSharedLibsLabelList)
3284
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -04003285 prebuilts := module.properties.Prebuilts
3286 prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts)
3287 prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList)
3288
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -04003289 binaries := module.properties.ApexNativeDependencies.Binaries
3290 binariesStringListAttribute := bazel.MakeStringListAttribute(binaries)
3291
3292 var updatableAttribute bazel.BoolAttribute
3293 if module.properties.Updatable != nil {
3294 updatableAttribute.Value = module.properties.Updatable
3295 }
3296
3297 var installableAttribute bazel.BoolAttribute
3298 if module.properties.Installable != nil {
3299 installableAttribute.Value = module.properties.Installable
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003300 }
3301
3302 attrs := &bazelApexBundleAttributes{
Rupert Shuttleworth6e4950a2021-07-27 01:34:59 -04003303 Manifest: manifestLabelAttribute,
3304 Android_manifest: androidManifestLabelAttribute,
3305 File_contexts: fileContextsLabelAttribute,
3306 Min_sdk_version: minSdkVersion,
3307 Key: keyLabelAttribute,
3308 Certificate: certificateLabelAttribute,
3309 Updatable: updatableAttribute,
3310 Installable: installableAttribute,
3311 Native_shared_libs: nativeSharedLibsLabelListAttribute,
3312 Binaries: binariesStringListAttribute,
Rupert Shuttleworth9447e1e2021-07-28 05:53:42 -04003313 Prebuilts: prebuiltsLabelListAttribute,
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003314 }
3315
3316 props := bazel.BazelTargetModuleProperties{
3317 Rule_class: "apex",
3318 Bzl_load_location: "//build/bazel/rules:apex.bzl",
3319 }
3320
Liz Kammer2ada09a2021-08-11 00:17:36 -04003321 ctx.CreateBazelTargetModule(module.Name(), props, attrs)
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04003322}