2018-10-10 07:01:00 +02:00
|
|
|
// Copyright (C) 2018 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// package apex implements build rules for creating the APEX files which are container for
|
|
|
|
// lower-level system components. See https://source.android.com/devices/tech/ota/apex
|
2018-10-10 07:01:00 +02:00
|
|
|
package apex
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-09-07 09:00:04 +02:00
|
|
|
"log"
|
2018-10-10 07:01:00 +02:00
|
|
|
"path/filepath"
|
2022-05-05 15:52:25 +02:00
|
|
|
"regexp"
|
2018-10-10 07:05:29 +02:00
|
|
|
"sort"
|
2018-10-10 07:01:00 +02:00
|
|
|
"strings"
|
|
|
|
|
2023-11-17 02:05:47 +01:00
|
|
|
"android/soong/aconfig"
|
2022-10-14 21:20:20 +02:00
|
|
|
"android/soong/bazel/cquery"
|
|
|
|
|
2020-06-01 19:45:49 +02:00
|
|
|
"github.com/google/blueprint"
|
|
|
|
"github.com/google/blueprint/proptools"
|
|
|
|
|
2018-10-10 07:01:00 +02:00
|
|
|
"android/soong/android"
|
2021-07-02 13:17:16 +02:00
|
|
|
"android/soong/bazel"
|
2020-09-02 10:23:38 +02:00
|
|
|
"android/soong/bpf"
|
2018-10-10 07:01:00 +02:00
|
|
|
"android/soong/cc"
|
2020-06-01 19:45:49 +02:00
|
|
|
prebuilt_etc "android/soong/etc"
|
2021-01-07 07:31:24 +01:00
|
|
|
"android/soong/filesystem"
|
2018-10-10 07:01:00 +02:00
|
|
|
"android/soong/java"
|
2022-04-27 03:30:34 +02:00
|
|
|
"android/soong/multitree"
|
2020-11-17 14:21:02 +01:00
|
|
|
"android/soong/rust"
|
2020-06-01 19:45:49 +02:00
|
|
|
"android/soong/sh"
|
2018-10-10 07:01:00 +02:00
|
|
|
)
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func init() {
|
2021-03-09 23:34:13 +01:00
|
|
|
registerApexBuildComponents(android.InitRegistrationContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
func registerApexBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("apex", BundleFactory)
|
2022-10-14 21:20:20 +02:00
|
|
|
ctx.RegisterModuleType("apex_test", TestApexBundleFactory)
|
2021-03-09 23:34:13 +01:00
|
|
|
ctx.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
|
2023-03-08 21:29:50 +01:00
|
|
|
ctx.RegisterModuleType("apex_defaults", DefaultsFactory)
|
2021-03-09 23:34:13 +01:00
|
|
|
ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
|
2022-05-10 08:59:14 +02:00
|
|
|
ctx.RegisterModuleType("override_apex", OverrideApexFactory)
|
2021-03-09 23:34:13 +01:00
|
|
|
ctx.RegisterModuleType("apex_set", apexSetFactory)
|
2019-10-23 09:46:38 +02:00
|
|
|
|
2021-05-05 15:13:27 +02:00
|
|
|
ctx.PreArchMutators(registerPreArchMutators)
|
2021-03-09 23:34:13 +01:00
|
|
|
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
|
|
|
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
2020-06-12 14:46:59 +02:00
|
|
|
|
2021-05-05 15:13:27 +02:00
|
|
|
func registerPreArchMutators(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.TopDown("prebuilt_apex_module_creator", prebuiltApexModuleCreatorMutator).Parallel()
|
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
|
|
|
|
ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
|
2020-12-08 11:34:30 +01:00
|
|
|
ctx.TopDown("apex_info", apexInfoMutator).Parallel()
|
2020-11-19 06:37:47 +01:00
|
|
|
ctx.BottomUp("apex_unique", apexUniqueVariationsMutator).Parallel()
|
|
|
|
ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator).Parallel()
|
|
|
|
ctx.BottomUp("apex_test_for", apexTestForMutator).Parallel()
|
2021-05-12 17:41:35 +02:00
|
|
|
// Run mark_platform_availability before the apexMutator as the apexMutator needs to know whether
|
|
|
|
// it should create a platform variant.
|
|
|
|
ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel()
|
2020-11-19 06:37:47 +01:00
|
|
|
ctx.BottomUp("apex", apexMutator).Parallel()
|
|
|
|
ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel()
|
2023-01-11 15:15:43 +01:00
|
|
|
ctx.BottomUp("apex_dcla_deps", apexDCLADepsMutator).Parallel()
|
2022-01-15 01:23:18 +01:00
|
|
|
// Register after apex_info mutator so that it can use ApexVariationName
|
|
|
|
ctx.TopDown("apex_strict_updatability_lint", apexStrictUpdatibilityLintMutator).Parallel()
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-30 18:49:53 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
type apexBundleProperties struct {
|
2020-11-19 15:00:52 +01:00
|
|
|
// Json manifest file describing meta info of this APEX bundle. Refer to
|
|
|
|
// system/apex/proto/apex_manifest.proto for the schema. Default: "apex_manifest.json"
|
2020-11-19 06:37:47 +01:00
|
|
|
Manifest *string `android:"path"`
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// AndroidManifest.xml file used for the zip container of this APEX bundle. If unspecified,
|
|
|
|
// a default one is automatically generated.
|
2020-11-19 06:37:47 +01:00
|
|
|
AndroidManifest *string `android:"path"`
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Determines the file contexts file for setting the security contexts to files in this APEX
|
|
|
|
// bundle. For platform APEXes, this should points to a file under /system/sepolicy Default:
|
|
|
|
// /system/sepolicy/apex/<module_name>_file_contexts.
|
2020-11-19 06:37:47 +01:00
|
|
|
File_contexts *string `android:"path"`
|
|
|
|
|
2023-02-28 06:13:38 +01:00
|
|
|
// By default, file_contexts is amended by force-labelling / and /apex_manifest.pb as system_file
|
|
|
|
// to avoid mistakes. When set as true, no force-labelling.
|
|
|
|
Use_file_contexts_as_is *bool
|
|
|
|
|
2023-03-28 13:30:50 +02:00
|
|
|
// Path to the canned fs config file for customizing file's
|
|
|
|
// uid/gid/mod/capabilities. The content of this file is appended to the
|
|
|
|
// default config, so that the custom entries are preferred. The format is
|
|
|
|
// /<path_or_glob> <uid> <gid> <mode> [capabilities=0x<cap>], where
|
|
|
|
// path_or_glob is a path or glob pattern for a file or set of files,
|
|
|
|
// uid/gid are numerial values of user ID and group ID, mode is octal value
|
|
|
|
// for the file mode, and cap is hexadecimal value for the capability.
|
2021-12-13 15:56:35 +01:00
|
|
|
Canned_fs_config *string `android:"path"`
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
ApexNativeDependencies
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
Multilib apexMultilibProperties
|
|
|
|
|
2023-02-24 12:12:31 +01:00
|
|
|
// List of runtime resource overlays (RROs) that are embedded inside this APEX.
|
|
|
|
Rros []string
|
|
|
|
|
2023-02-24 12:06:07 +01:00
|
|
|
// List of bootclasspath fragments that are embedded inside this APEX bundle.
|
|
|
|
Bootclasspath_fragments []string
|
|
|
|
|
|
|
|
// List of systemserverclasspath fragments that are embedded inside this APEX bundle.
|
|
|
|
Systemserverclasspath_fragments []string
|
|
|
|
|
|
|
|
// List of java libraries that are embedded inside this APEX bundle.
|
|
|
|
Java_libs []string
|
|
|
|
|
2021-11-23 01:57:19 +01:00
|
|
|
// List of sh binaries that are embedded inside this APEX bundle.
|
|
|
|
Sh_binaries []string
|
|
|
|
|
2021-03-15 20:32:23 +01:00
|
|
|
// List of platform_compat_config files that are embedded inside this APEX bundle.
|
|
|
|
Compat_configs []string
|
|
|
|
|
2021-01-07 07:31:24 +01:00
|
|
|
// List of filesystem images that are embedded inside this APEX bundle.
|
|
|
|
Filesystems []string
|
|
|
|
|
2023-11-02 03:56:48 +01:00
|
|
|
// List of module names which we don't want to add as transitive deps. This can be used as
|
|
|
|
// a workaround when the current implementation collects more than necessary. For example,
|
|
|
|
// Rust binaries with prefer_rlib:true add unnecessary dependencies.
|
|
|
|
Unwanted_transitive_deps []string
|
|
|
|
|
2023-05-11 17:58:13 +02:00
|
|
|
// The minimum SDK version that this APEX must support at minimum. This is usually set to
|
|
|
|
// the SDK version that the APEX was first introduced.
|
|
|
|
Min_sdk_version *string
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Whether this APEX is considered updatable or not. When set to true, this will enforce
|
|
|
|
// additional rules for making sure that the APEX is truly updatable. To be updatable,
|
|
|
|
// min_sdk_version should be set as well. This will also disable the size optimizations like
|
2021-02-16 12:40:16 +01:00
|
|
|
// symlinking to the system libs. Default is true.
|
2020-11-19 15:00:52 +01:00
|
|
|
Updatable *bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2021-11-29 04:37:10 +01:00
|
|
|
// Marks that this APEX is designed to be updatable in the future, although it's not
|
|
|
|
// updatable yet. This is used to mimic some of the build behaviors that are applied only to
|
|
|
|
// updatable APEXes. Currently, this disables the size optimization, so that the size of
|
|
|
|
// APEX will not increase when the APEX is actually marked as truly updatable. Default is
|
|
|
|
// false.
|
|
|
|
Future_updatable *bool
|
|
|
|
|
2021-06-22 13:23:05 +02:00
|
|
|
// Whether this APEX can use platform APIs or not. Can be set to true only when `updatable:
|
|
|
|
// false`. Default is false.
|
|
|
|
Platform_apis *bool
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Whether this APEX is installable to one of the partitions like system, vendor, etc.
|
|
|
|
// Default: true.
|
|
|
|
Installable *bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// If set true, VNDK libs are considered as stable libs and are not included in this APEX.
|
|
|
|
// Should be only used in non-system apexes (e.g. vendor: true). Default is false.
|
|
|
|
Use_vndk_as_stable *bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2023-08-23 04:11:43 +02:00
|
|
|
// The type of filesystem to use. Either 'ext4', 'f2fs' or 'erofs'. Default 'ext4'.
|
2020-11-19 15:00:52 +01:00
|
|
|
Payload_fs_type *string
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// For telling the APEX to ignore special handling for system libraries such as bionic.
|
|
|
|
// Default is false.
|
|
|
|
Ignore_system_library_special_case *bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2021-06-09 20:43:46 +02:00
|
|
|
// Whenever apex_payload.img of the APEX should include dm-verity hashtree.
|
2021-06-16 19:15:03 +02:00
|
|
|
// Default value is true.
|
2021-06-09 20:43:46 +02:00
|
|
|
Generate_hashtree *bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Whenever apex_payload.img of the APEX should not be dm-verity signed. Should be only
|
|
|
|
// used in tests.
|
2020-11-19 06:37:47 +01:00
|
|
|
Test_only_unsigned_payload *bool
|
|
|
|
|
2020-12-22 11:47:50 +01:00
|
|
|
// Whenever apex should be compressed, regardless of product flag used. Should be only
|
|
|
|
// used in tests.
|
|
|
|
Test_only_force_compression *bool
|
|
|
|
|
2021-10-26 20:45:31 +02:00
|
|
|
// Put extra tags (signer=<value>) to apexkeys.txt, so that release tools can sign this apex
|
|
|
|
// with the tool to sign payload contents.
|
|
|
|
Custom_sign_tool *string
|
|
|
|
|
2022-08-03 18:46:43 +02:00
|
|
|
// Whether this is a dynamic common lib apex, if so the native shared libs will be placed
|
|
|
|
// in a special way that include the digest of the lib file under /lib(64)?
|
|
|
|
Dynamic_common_lib_apex *bool
|
|
|
|
|
2021-06-24 15:37:13 +02:00
|
|
|
// Canonical name of this APEX bundle. Used to determine the path to the
|
|
|
|
// activated APEX on device (i.e. /apex/<apexVariationName>), and used for the
|
|
|
|
// apex mutator variations. For override_apex modules, this is the name of the
|
|
|
|
// overridden base module.
|
|
|
|
ApexVariationName string `blueprint:"mutated"`
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
IsCoverageVariant bool `blueprint:"mutated"`
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// List of sanitizer names that this APEX is enabled for
|
|
|
|
SanitizerNames []string `blueprint:"mutated"`
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
PreventInstall bool `blueprint:"mutated"`
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
HideFromMake bool `blueprint:"mutated"`
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2023-06-02 20:09:50 +02:00
|
|
|
// Name that dependencies can specify in their apex_available properties to refer to this module.
|
2023-06-06 18:14:23 +02:00
|
|
|
// If not specified, this defaults to Soong module name. This must be the name of a Soong module.
|
2023-06-02 20:09:50 +02:00
|
|
|
Apex_available_name *string
|
2023-06-05 21:55:57 +02:00
|
|
|
|
|
|
|
// Variant version of the mainline module. Must be an integer between 0-9
|
|
|
|
Variant_version *string
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
type ApexNativeDependencies struct {
|
2020-11-19 15:00:52 +01:00
|
|
|
// List of native libraries that are embedded inside this APEX.
|
2020-11-19 06:37:47 +01:00
|
|
|
Native_shared_libs []string
|
2020-03-06 13:30:13 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// List of JNI libraries that are embedded inside this APEX.
|
2020-11-19 06:37:47 +01:00
|
|
|
Jni_libs []string
|
2020-06-11 20:32:11 +02:00
|
|
|
|
2022-11-02 21:14:20 +01:00
|
|
|
// List of rust dyn libraries that are embedded inside this APEX.
|
2020-11-17 14:21:02 +01:00
|
|
|
Rust_dyn_libs []string
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// List of native executables that are embedded inside this APEX.
|
2020-11-19 06:37:47 +01:00
|
|
|
Binaries []string
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// List of native tests that are embedded inside this APEX.
|
2020-11-19 06:37:47 +01:00
|
|
|
Tests []string
|
2021-02-15 09:54:43 +01:00
|
|
|
|
|
|
|
// List of filesystem images that are embedded inside this APEX bundle.
|
|
|
|
Filesystems []string
|
2022-11-02 21:14:20 +01:00
|
|
|
|
|
|
|
// List of native libraries to exclude from this APEX.
|
|
|
|
Exclude_native_shared_libs []string
|
|
|
|
|
|
|
|
// List of JNI libraries to exclude from this APEX.
|
|
|
|
Exclude_jni_libs []string
|
|
|
|
|
|
|
|
// List of rust dyn libraries to exclude from this APEX.
|
|
|
|
Exclude_rust_dyn_libs []string
|
|
|
|
|
|
|
|
// List of native executables to exclude from this APEX.
|
|
|
|
Exclude_binaries []string
|
|
|
|
|
|
|
|
// List of native tests to exclude from this APEX.
|
|
|
|
Exclude_tests []string
|
|
|
|
|
|
|
|
// List of filesystem images to exclude from this APEX bundle.
|
|
|
|
Exclude_filesystems []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Merge combines another ApexNativeDependencies into this one
|
|
|
|
func (a *ApexNativeDependencies) Merge(b ApexNativeDependencies) {
|
|
|
|
a.Native_shared_libs = append(a.Native_shared_libs, b.Native_shared_libs...)
|
|
|
|
a.Jni_libs = append(a.Jni_libs, b.Jni_libs...)
|
|
|
|
a.Rust_dyn_libs = append(a.Rust_dyn_libs, b.Rust_dyn_libs...)
|
|
|
|
a.Binaries = append(a.Binaries, b.Binaries...)
|
|
|
|
a.Tests = append(a.Tests, b.Tests...)
|
|
|
|
a.Filesystems = append(a.Filesystems, b.Filesystems...)
|
|
|
|
|
|
|
|
a.Exclude_native_shared_libs = append(a.Exclude_native_shared_libs, b.Exclude_native_shared_libs...)
|
|
|
|
a.Exclude_jni_libs = append(a.Exclude_jni_libs, b.Exclude_jni_libs...)
|
|
|
|
a.Exclude_rust_dyn_libs = append(a.Exclude_rust_dyn_libs, b.Exclude_rust_dyn_libs...)
|
|
|
|
a.Exclude_binaries = append(a.Exclude_binaries, b.Exclude_binaries...)
|
|
|
|
a.Exclude_tests = append(a.Exclude_tests, b.Exclude_tests...)
|
|
|
|
a.Exclude_filesystems = append(a.Exclude_filesystems, b.Exclude_filesystems...)
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type apexMultilibProperties struct {
|
|
|
|
// Native dependencies whose compile_multilib is "first"
|
|
|
|
First ApexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "both"
|
|
|
|
Both ApexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "prefer32"
|
|
|
|
Prefer32 ApexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "32"
|
|
|
|
Lib32 ApexNativeDependencies
|
|
|
|
|
|
|
|
// Native dependencies whose compile_multilib is "64"
|
|
|
|
Lib64 ApexNativeDependencies
|
|
|
|
}
|
|
|
|
|
|
|
|
type apexTargetBundleProperties struct {
|
|
|
|
Target struct {
|
|
|
|
// Multilib properties only for android.
|
|
|
|
Android struct {
|
|
|
|
Multilib apexMultilibProperties
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multilib properties only for host.
|
|
|
|
Host struct {
|
|
|
|
Multilib apexMultilibProperties
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multilib properties only for host linux_bionic.
|
|
|
|
Linux_bionic struct {
|
|
|
|
Multilib apexMultilibProperties
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multilib properties only for host linux_glibc.
|
|
|
|
Linux_glibc struct {
|
|
|
|
Multilib apexMultilibProperties
|
2020-03-06 13:30:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-14 10:44:04 +01:00
|
|
|
type apexArchBundleProperties struct {
|
|
|
|
Arch struct {
|
|
|
|
Arm struct {
|
|
|
|
ApexNativeDependencies
|
|
|
|
}
|
|
|
|
Arm64 struct {
|
|
|
|
ApexNativeDependencies
|
|
|
|
}
|
2022-10-03 21:41:50 +02:00
|
|
|
Riscv64 struct {
|
|
|
|
ApexNativeDependencies
|
|
|
|
}
|
2020-12-14 10:44:04 +01:00
|
|
|
X86 struct {
|
|
|
|
ApexNativeDependencies
|
|
|
|
}
|
|
|
|
X86_64 struct {
|
|
|
|
ApexNativeDependencies
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// These properties can be used in override_apex to override the corresponding properties in the
|
|
|
|
// base apex.
|
2020-11-19 06:37:47 +01:00
|
|
|
type overridableProperties struct {
|
2020-11-19 15:00:52 +01:00
|
|
|
// List of APKs that are embedded inside this APEX.
|
2020-11-19 06:37:47 +01:00
|
|
|
Apps []string
|
|
|
|
|
2021-08-27 00:44:43 +02:00
|
|
|
// List of prebuilt files that are embedded inside this APEX bundle.
|
|
|
|
Prebuilts []string
|
|
|
|
|
2021-08-26 16:10:06 +02:00
|
|
|
// List of BPF programs inside this APEX bundle.
|
|
|
|
Bpfs []string
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Names of modules to be overridden. Listed modules can only be other binaries (in Make or
|
|
|
|
// Soong). This does not completely prevent installation of the overridden binaries, but if
|
|
|
|
// both binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will
|
|
|
|
// be removed from PRODUCT_PACKAGES.
|
2020-11-19 06:37:47 +01:00
|
|
|
Overrides []string
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Logging parent value.
|
2020-11-19 06:37:47 +01:00
|
|
|
Logging_parent string
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Apex Container package name. Override value for attribute package:name in
|
|
|
|
// AndroidManifest.xml
|
2020-11-19 06:37:47 +01:00
|
|
|
Package_name string
|
|
|
|
|
|
|
|
// A txt file containing list of files that are allowed to be included in this APEX.
|
|
|
|
Allowed_files *string `android:"path"`
|
2021-04-21 01:21:24 +02:00
|
|
|
|
|
|
|
// Name of the apex_key module that provides the private key to sign this APEX bundle.
|
|
|
|
Key *string
|
|
|
|
|
|
|
|
// Specifies the certificate and the private key to sign the zip container of this APEX. If
|
|
|
|
// this is "foo", foo.x509.pem and foo.pk8 under PRODUCT_DEFAULT_DEV_CERTIFICATE are used
|
|
|
|
// as the certificate and the private key, respectively. If this is ":module", then the
|
|
|
|
// certificate and the private key are provided from the android_app_certificate module
|
|
|
|
// named "module".
|
|
|
|
Certificate *string
|
2021-10-14 21:33:41 +02:00
|
|
|
|
|
|
|
// Whether this APEX can be compressed or not. Setting this property to false means this
|
|
|
|
// APEX will never be compressed. When set to true, APEX will be compressed if other
|
|
|
|
// conditions, e.g., target device needs to support APEX compression, are also fulfilled.
|
|
|
|
// Default: false.
|
|
|
|
Compressible *bool
|
2023-01-11 15:15:43 +01:00
|
|
|
|
|
|
|
// Trim against a specific Dynamic Common Lib APEX
|
|
|
|
Trim_against *string
|
2020-03-06 13:30:13 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
type apexBundle struct {
|
2020-11-19 15:00:52 +01:00
|
|
|
// Inherited structs
|
2020-11-19 06:37:47 +01:00
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultableModuleBase
|
|
|
|
android.OverridableModuleBase
|
2021-07-02 13:17:16 +02:00
|
|
|
android.BazelModuleBase
|
2022-04-27 03:30:34 +02:00
|
|
|
multitree.ExportableModuleBase
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Properties
|
2020-11-19 06:37:47 +01:00
|
|
|
properties apexBundleProperties
|
|
|
|
targetProperties apexTargetBundleProperties
|
2020-12-14 10:44:04 +01:00
|
|
|
archProperties apexArchBundleProperties
|
2020-11-19 06:37:47 +01:00
|
|
|
overridableProperties overridableProperties
|
2020-11-19 15:00:52 +01:00
|
|
|
vndkProperties apexVndkProperties // only for apex_vndk modules
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Inputs
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2023-05-15 11:46:38 +02:00
|
|
|
// Keys for apex_payload.img
|
2020-12-21 18:11:10 +01:00
|
|
|
publicKeyFile android.Path
|
|
|
|
privateKeyFile android.Path
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Cert/priv-key for the zip container
|
2020-12-21 18:11:10 +01:00
|
|
|
containerCertificateFile android.Path
|
|
|
|
containerPrivateKeyFile android.Path
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Flags for special variants of APEX
|
|
|
|
testApex bool
|
|
|
|
vndkApex bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// File system type of apex_payload.img
|
|
|
|
payloadFsType fsType
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Whether to create symlink to the system file instead of having a file inside the apex or
|
|
|
|
// not
|
|
|
|
linkToSystemLib bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// List of files to be included in this APEX. This is filled in the first part of
|
|
|
|
// GenerateAndroidBuildActions.
|
|
|
|
filesInfo []apexFile
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2023-01-25 18:49:46 +01:00
|
|
|
// List of other module names that should be installed when this APEX gets installed (LOCAL_REQUIRED_MODULES).
|
|
|
|
makeModulesToInstall []string
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Outputs (final and intermediates)
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Processed apex manifest in JSONson format (for Q)
|
|
|
|
manifestJsonOut android.WritablePath
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Processed apex manifest in PB format (for R+)
|
|
|
|
manifestPbOut android.WritablePath
|
|
|
|
|
|
|
|
// Processed file_contexts files
|
|
|
|
fileContexts android.WritablePath
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// The built APEX file. This is the main product.
|
2022-02-24 05:58:07 +01:00
|
|
|
// Could be .apex or .capex
|
2020-11-19 15:00:52 +01:00
|
|
|
outputFile android.WritablePath
|
|
|
|
|
2022-02-24 05:58:07 +01:00
|
|
|
// The built uncompressed .apex file.
|
|
|
|
outputApexFile android.WritablePath
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// The built APEX file in app bundle format. This file is not directly installed to the
|
|
|
|
// device. For an APEX, multiple app bundles are created each of which is for a specific ABI
|
|
|
|
// like arm, arm64, x86, etc. Then they are processed again (outside of the Android build
|
|
|
|
// system) to be merged into a single app bundle file that Play accepts. See
|
|
|
|
// vendor/google/build/build_unbundled_mainline_module.sh for more detail.
|
|
|
|
bundleModuleFile android.WritablePath
|
|
|
|
|
2021-11-04 20:01:18 +01:00
|
|
|
// Target directory to install this APEX. Usually out/target/product/<device>/<partition>/apex.
|
2020-11-19 15:00:52 +01:00
|
|
|
installDir android.InstallPath
|
|
|
|
|
2021-11-04 20:01:18 +01:00
|
|
|
// Path where this APEX was installed.
|
|
|
|
installedFile android.InstallPath
|
|
|
|
|
2023-10-30 08:17:56 +01:00
|
|
|
// fragment for this apex for apexkeys.txt
|
|
|
|
apexKeysPath android.WritablePath
|
|
|
|
|
2021-11-04 20:01:18 +01:00
|
|
|
// Installed locations of symlinks for backward compatibility.
|
|
|
|
compatSymlinks android.InstallPaths
|
2020-11-19 15:00:52 +01:00
|
|
|
|
|
|
|
// Text file having the list of individual files that are included in this APEX. Used for
|
|
|
|
// debugging purpose.
|
|
|
|
installedFilesFile android.WritablePath
|
|
|
|
|
|
|
|
// List of module names that this APEX is including (to be shown via *-deps-info target).
|
|
|
|
// Used for debugging purpose.
|
|
|
|
android.ApexBundleDepsInfo
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
// Optional list of lint report zip files for apexes that contain java or app modules
|
|
|
|
lintReports android.Paths
|
|
|
|
|
2020-11-26 14:32:26 +01:00
|
|
|
isCompressed bool
|
|
|
|
|
2020-11-12 17:39:19 +01:00
|
|
|
// Path of API coverage generate file
|
2021-11-03 01:58:02 +01:00
|
|
|
nativeApisUsedByModuleFile android.ModuleOutPath
|
|
|
|
nativeApisBackedByModuleFile android.ModuleOutPath
|
|
|
|
javaApisUsedByModuleFile android.ModuleOutPath
|
2023-11-17 02:05:47 +01:00
|
|
|
|
|
|
|
aconfigFiles []android.Path
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexFileClass represents a type of file that can be included in APEX.
|
2020-11-19 06:37:47 +01:00
|
|
|
type apexFileClass int
|
|
|
|
|
|
|
|
const (
|
2020-11-19 15:00:52 +01:00
|
|
|
app apexFileClass = iota
|
|
|
|
appSet
|
|
|
|
etc
|
2020-11-19 06:37:47 +01:00
|
|
|
javaSharedLib
|
2020-11-19 15:00:52 +01:00
|
|
|
nativeExecutable
|
|
|
|
nativeSharedLib
|
2020-11-19 06:37:47 +01:00
|
|
|
nativeTest
|
2020-11-19 15:00:52 +01:00
|
|
|
shBinary
|
2020-11-19 06:37:47 +01:00
|
|
|
)
|
|
|
|
|
2023-03-14 17:11:38 +01:00
|
|
|
var (
|
|
|
|
classes = map[string]apexFileClass{
|
|
|
|
"app": app,
|
|
|
|
"appSet": appSet,
|
|
|
|
"etc": etc,
|
|
|
|
"javaSharedLib": javaSharedLib,
|
|
|
|
"nativeExecutable": nativeExecutable,
|
|
|
|
"nativeSharedLib": nativeSharedLib,
|
|
|
|
"nativeTest": nativeTest,
|
|
|
|
"shBinary": shBinary,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexFile represents a file in an APEX bundle. This is created during the first half of
|
|
|
|
// GenerateAndroidBuildActions by traversing the dependencies of the APEX. Then in the second half
|
|
|
|
// of the function, this is used to create commands that copies the files into a staging directory,
|
2023-06-20 09:25:59 +02:00
|
|
|
// where they are packaged into the APEX file.
|
2020-11-19 06:37:47 +01:00
|
|
|
type apexFile struct {
|
2020-11-19 15:00:52 +01:00
|
|
|
// buildFile is put in the installDir inside the APEX.
|
2022-04-01 20:00:00 +02:00
|
|
|
builtFile android.Path
|
|
|
|
installDir string
|
2023-02-17 10:22:25 +01:00
|
|
|
partition string
|
2022-04-01 20:00:00 +02:00
|
|
|
customStem string
|
|
|
|
symlinks []string // additional symlinks
|
2020-11-19 15:00:52 +01:00
|
|
|
|
|
|
|
// Info for Android.mk Module name of `module` in AndroidMk. Note the generated AndroidMk
|
|
|
|
// module for apexFile is named something like <AndroidMk module name>.<apex name>[<apex
|
|
|
|
// suffix>]
|
|
|
|
androidMkModuleName string // becomes LOCAL_MODULE
|
|
|
|
class apexFileClass // becomes LOCAL_MODULE_CLASS
|
|
|
|
moduleDir string // becomes LOCAL_PATH
|
|
|
|
requiredModuleNames []string // becomes LOCAL_REQUIRED_MODULES
|
|
|
|
targetRequiredModuleNames []string // becomes LOCAL_TARGET_REQUIRED_MODULES
|
|
|
|
hostRequiredModuleNames []string // becomes LOCAL_HOST_REQUIRED_MODULES
|
|
|
|
dataPaths []android.DataPath // becomes LOCAL_TEST_DATA
|
2020-11-19 06:37:47 +01:00
|
|
|
|
|
|
|
jacocoReportClassesFile android.Path // only for javalibs and apps
|
|
|
|
lintDepSets java.LintDepSets // only for javalibs and apps
|
|
|
|
certificate java.Certificate // only for apps
|
|
|
|
overriddenPackageName string // only for apps
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
transitiveDep bool
|
|
|
|
isJniLib bool
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2021-01-20 12:33:11 +01:00
|
|
|
multilib string
|
|
|
|
|
2023-03-14 17:11:38 +01:00
|
|
|
isBazelPrebuilt bool
|
|
|
|
unstrippedBuiltFile android.Path
|
|
|
|
arch string
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// TODO(jiyong): remove this
|
|
|
|
module android.Module
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// TODO(jiyong): shorten the arglist using an option struct
|
2020-11-19 06:37:47 +01:00
|
|
|
func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile {
|
|
|
|
ret := apexFile{
|
|
|
|
builtFile: builtFile,
|
|
|
|
installDir: installDir,
|
2020-11-19 15:00:52 +01:00
|
|
|
androidMkModuleName: androidMkModuleName,
|
2020-11-19 06:37:47 +01:00
|
|
|
class: class,
|
|
|
|
module: module,
|
2020-05-19 08:47:01 +02:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
if module != nil {
|
|
|
|
ret.moduleDir = ctx.OtherModuleDir(module)
|
2023-02-17 10:22:25 +01:00
|
|
|
ret.partition = module.PartitionTag(ctx.DeviceConfig())
|
2020-11-19 06:37:47 +01:00
|
|
|
ret.requiredModuleNames = module.RequiredModuleNames()
|
|
|
|
ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
|
|
|
|
ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
|
2021-01-20 12:33:11 +01:00
|
|
|
ret.multilib = module.Target().Arch.ArchType.Multilib
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-30 18:49:53 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
func (af *apexFile) ok() bool {
|
2020-11-19 06:37:47 +01:00
|
|
|
return af.builtFile != nil && af.builtFile.String() != ""
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexRelativePath returns the relative path of the given path from the install directory of this
|
|
|
|
// apexFile.
|
|
|
|
// TODO(jiyong): rename this
|
2020-11-19 06:37:47 +01:00
|
|
|
func (af *apexFile) apexRelativePath(path string) string {
|
|
|
|
return filepath.Join(af.installDir, path)
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// path returns path of this apex file relative to the APEX root
|
|
|
|
func (af *apexFile) path() string {
|
|
|
|
return af.apexRelativePath(af.stem())
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// stem returns the base filename of this apex file
|
|
|
|
func (af *apexFile) stem() string {
|
|
|
|
if af.customStem != "" {
|
|
|
|
return af.customStem
|
2020-01-10 16:12:39 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return af.builtFile.Base()
|
|
|
|
}
|
2020-05-20 02:06:00 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// symlinkPaths returns paths of the symlinks (if any) relative to the APEX root
|
|
|
|
func (af *apexFile) symlinkPaths() []string {
|
2020-11-19 06:37:47 +01:00
|
|
|
var ret []string
|
|
|
|
for _, symlink := range af.symlinks {
|
|
|
|
ret = append(ret, af.apexRelativePath(symlink))
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-30 18:49:53 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return ret
|
2020-01-10 16:12:39 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// availableToPlatform tests whether this apexFile is from a module that can be installed to the
|
|
|
|
// platform.
|
|
|
|
func (af *apexFile) availableToPlatform() bool {
|
2020-11-19 06:37:47 +01:00
|
|
|
if af.module == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if am, ok := af.module.(android.ApexModule); ok {
|
|
|
|
return am.AvailableFor(android.AvailableToPlatform)
|
2020-06-05 22:14:03 +02:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return false
|
2020-06-05 22:14:03 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Mutators
|
|
|
|
//
|
|
|
|
// Brief description about mutators for APEX. The following three mutators are the most important
|
|
|
|
// ones.
|
|
|
|
//
|
|
|
|
// 1) DepsMutator: from the properties like native_shared_libs, java_libs, etc., modules are added
|
|
|
|
// to the (direct) dependencies of this APEX bundle.
|
|
|
|
//
|
2020-12-08 11:34:30 +01:00
|
|
|
// 2) apexInfoMutator: this is a post-deps mutator, so runs after DepsMutator. Its goal is to
|
2020-11-19 15:00:52 +01:00
|
|
|
// collect modules that are direct and transitive dependencies of each APEX bundle. The collected
|
|
|
|
// modules are marked as being included in the APEX via BuildForApex().
|
|
|
|
//
|
2020-12-08 11:34:30 +01:00
|
|
|
// 3) apexMutator: this is a post-deps mutator that runs after apexInfoMutator. For each module that
|
|
|
|
// are marked by the apexInfoMutator, apex variations are created using CreateApexVariations().
|
2020-11-19 15:00:52 +01:00
|
|
|
|
|
|
|
type dependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
name string
|
|
|
|
|
|
|
|
// Determines if the dependent will be part of the APEX payload. Can be false for the
|
|
|
|
// dependencies to the signing key module, etc.
|
|
|
|
payload bool
|
2021-03-17 15:51:03 +01:00
|
|
|
|
|
|
|
// True if the dependent can only be a source module, false if a prebuilt module is a suitable
|
|
|
|
// replacement. This is needed because some prebuilt modules do not provide all the information
|
|
|
|
// needed by the apex.
|
|
|
|
sourceOnly bool
|
2022-05-13 15:12:19 +02:00
|
|
|
|
|
|
|
// If not-nil and an APEX is a member of an SDK then dependencies of that APEX with this tag will
|
|
|
|
// also be added as exported members of that SDK.
|
|
|
|
memberType android.SdkMemberType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dependencyTag) SdkMemberType(_ android.Module) android.SdkMemberType {
|
|
|
|
return d.memberType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dependencyTag) ExportMember() bool {
|
|
|
|
return true
|
2021-03-17 15:51:03 +01:00
|
|
|
}
|
|
|
|
|
2022-05-13 15:01:59 +02:00
|
|
|
func (d *dependencyTag) String() string {
|
|
|
|
return fmt.Sprintf("apex.dependencyTag{%q}", d.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *dependencyTag) ReplaceSourceWithPrebuilt() bool {
|
2021-03-17 15:51:03 +01:00
|
|
|
return !d.sourceOnly
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
2021-03-17 15:51:03 +01:00
|
|
|
var _ android.ReplaceSourceWithPrebuilt = &dependencyTag{}
|
2022-05-13 15:12:19 +02:00
|
|
|
var _ android.SdkMemberDependencyTag = &dependencyTag{}
|
2021-03-17 15:51:03 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
var (
|
2022-05-13 15:01:59 +02:00
|
|
|
androidAppTag = &dependencyTag{name: "androidApp", payload: true}
|
|
|
|
bpfTag = &dependencyTag{name: "bpf", payload: true}
|
|
|
|
certificateTag = &dependencyTag{name: "certificate"}
|
2023-01-11 15:15:43 +01:00
|
|
|
dclaTag = &dependencyTag{name: "dcla"}
|
2022-05-13 15:01:59 +02:00
|
|
|
executableTag = &dependencyTag{name: "executable", payload: true}
|
|
|
|
fsTag = &dependencyTag{name: "filesystem", payload: true}
|
2022-05-13 15:12:19 +02:00
|
|
|
bcpfTag = &dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true, memberType: java.BootclasspathFragmentSdkMemberType}
|
|
|
|
sscpfTag = &dependencyTag{name: "systemserverclasspathFragment", payload: true, sourceOnly: true, memberType: java.SystemServerClasspathFragmentSdkMemberType}
|
2022-07-20 16:18:24 +02:00
|
|
|
compatConfigTag = &dependencyTag{name: "compatConfig", payload: true, sourceOnly: true, memberType: java.CompatConfigSdkMemberType}
|
2022-05-13 15:01:59 +02:00
|
|
|
javaLibTag = &dependencyTag{name: "javaLib", payload: true}
|
|
|
|
jniLibTag = &dependencyTag{name: "jniLib", payload: true}
|
|
|
|
keyTag = &dependencyTag{name: "key"}
|
|
|
|
prebuiltTag = &dependencyTag{name: "prebuilt", payload: true}
|
|
|
|
rroTag = &dependencyTag{name: "rro", payload: true}
|
|
|
|
sharedLibTag = &dependencyTag{name: "sharedLib", payload: true}
|
|
|
|
testForTag = &dependencyTag{name: "test for"}
|
|
|
|
testTag = &dependencyTag{name: "test", payload: true}
|
|
|
|
shBinaryTag = &dependencyTag{name: "shBinary", payload: true}
|
2020-11-19 15:00:52 +01:00
|
|
|
)
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// TODO(jiyong): shorten this function signature
|
|
|
|
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeModules ApexNativeDependencies, target android.Target, imageVariation string) {
|
2020-11-19 06:37:47 +01:00
|
|
|
binVariations := target.Variations()
|
2020-11-19 15:00:52 +01:00
|
|
|
libVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
|
2020-11-17 14:21:02 +01:00
|
|
|
rustLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "rust_libraries", Variation: "dylib"})
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2023-08-23 06:54:08 +02:00
|
|
|
// Append "image" variation
|
|
|
|
binVariations = append(binVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation})
|
|
|
|
libVariations = append(libVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation})
|
|
|
|
rustLibVariations = append(rustLibVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation})
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Use *FarVariation* to be able to depend on modules having conflicting variations with
|
|
|
|
// this module. This is required since arch variant of an APEX bundle is 'common' but it is
|
|
|
|
// 'arm' or 'arm64' for native shared libs.
|
2022-11-02 21:14:20 +01:00
|
|
|
ctx.AddFarVariationDependencies(binVariations, executableTag,
|
|
|
|
android.RemoveListFromList(nativeModules.Binaries, nativeModules.Exclude_binaries)...)
|
|
|
|
ctx.AddFarVariationDependencies(binVariations, testTag,
|
|
|
|
android.RemoveListFromList(nativeModules.Tests, nativeModules.Exclude_tests)...)
|
|
|
|
ctx.AddFarVariationDependencies(libVariations, jniLibTag,
|
|
|
|
android.RemoveListFromList(nativeModules.Jni_libs, nativeModules.Exclude_jni_libs)...)
|
|
|
|
ctx.AddFarVariationDependencies(libVariations, sharedLibTag,
|
|
|
|
android.RemoveListFromList(nativeModules.Native_shared_libs, nativeModules.Exclude_native_shared_libs)...)
|
|
|
|
ctx.AddFarVariationDependencies(rustLibVariations, sharedLibTag,
|
|
|
|
android.RemoveListFromList(nativeModules.Rust_dyn_libs, nativeModules.Exclude_rust_dyn_libs)...)
|
|
|
|
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
|
|
|
|
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
|
2020-06-05 22:14:03 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
|
2023-08-23 06:54:08 +02:00
|
|
|
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2022-12-06 07:23:57 +01:00
|
|
|
// getImageVariationPair returns a pair for the image variation name as its
|
|
|
|
// prefix and suffix. The prefix indicates whether it's core/vendor/product and the
|
|
|
|
// suffix indicates the vndk version when it's vendor or product.
|
|
|
|
// getImageVariation can simply join the result of this function to get the
|
|
|
|
// image variation name.
|
|
|
|
func (a *apexBundle) getImageVariationPair(deviceConfig android.DeviceConfig) (string, string) {
|
2020-11-19 15:00:52 +01:00
|
|
|
if a.vndkApex {
|
2022-12-06 07:23:57 +01:00
|
|
|
return cc.VendorVariationPrefix, a.vndkVersion(deviceConfig)
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
2019-10-08 14:59:58 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
var prefix string
|
|
|
|
var vndkVersion string
|
|
|
|
if deviceConfig.VndkVersion() != "" {
|
2021-04-27 04:08:49 +02:00
|
|
|
if a.SocSpecific() || a.DeviceSpecific() {
|
2020-11-19 15:00:52 +01:00
|
|
|
prefix = cc.VendorVariationPrefix
|
|
|
|
vndkVersion = deviceConfig.VndkVersion()
|
|
|
|
} else if a.ProductSpecific() {
|
|
|
|
prefix = cc.ProductVariationPrefix
|
2023-09-27 09:22:10 +02:00
|
|
|
vndkVersion = deviceConfig.PlatformVndkVersion()
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if vndkVersion == "current" {
|
|
|
|
vndkVersion = deviceConfig.PlatformVndkVersion()
|
|
|
|
}
|
|
|
|
if vndkVersion != "" {
|
2022-12-06 07:23:57 +01:00
|
|
|
return prefix, vndkVersion
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
2020-06-05 22:14:03 +02:00
|
|
|
|
2022-12-06 07:23:57 +01:00
|
|
|
return android.CoreVariation, "" // The usual case
|
|
|
|
}
|
|
|
|
|
|
|
|
// getImageVariation returns the image variant name for this apexBundle. In most cases, it's simply
|
|
|
|
// android.CoreVariation, but gets complicated for the vendor APEXes and the VNDK APEX.
|
|
|
|
func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) string {
|
|
|
|
prefix, vndkVersion := a.getImageVariationPair(ctx.DeviceConfig())
|
|
|
|
return prefix + vndkVersion
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
|
|
|
|
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexBundle is a multi-arch targets module. Arch variant of apexBundle is set to 'common'.
|
|
|
|
// arch-specific targets are enabled by the compile_multilib setting of the apex bundle. For
|
|
|
|
// each target os/architectures, appropriate dependencies are selected by their
|
|
|
|
// target.<os>.multilib.<type> groups and are added as (direct) dependencies.
|
2020-11-19 06:37:47 +01:00
|
|
|
targets := ctx.MultiTargets()
|
|
|
|
imageVariation := a.getImageVariation(ctx)
|
|
|
|
|
|
|
|
a.combineProperties(ctx)
|
|
|
|
|
|
|
|
has32BitTarget := false
|
|
|
|
for _, target := range targets {
|
|
|
|
if target.Arch.ArchType.Multilib == "lib32" {
|
|
|
|
has32BitTarget = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for i, target := range targets {
|
2022-11-02 21:14:20 +01:00
|
|
|
var deps ApexNativeDependencies
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Add native modules targeting both ABIs. When multilib.* is omitted for
|
|
|
|
// native_shared_libs/jni_libs/tests, it implies multilib.both
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.properties.Multilib.Both)
|
|
|
|
deps.Merge(ApexNativeDependencies{
|
2020-11-19 15:00:52 +01:00
|
|
|
Native_shared_libs: a.properties.Native_shared_libs,
|
|
|
|
Tests: a.properties.Tests,
|
|
|
|
Jni_libs: a.properties.Jni_libs,
|
|
|
|
Binaries: nil,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Add native modules targeting the first ABI When multilib.* is omitted for
|
|
|
|
// binaries, it implies multilib.first
|
2020-11-19 06:37:47 +01:00
|
|
|
isPrimaryAbi := i == 0
|
|
|
|
if isPrimaryAbi {
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.properties.Multilib.First)
|
|
|
|
deps.Merge(ApexNativeDependencies{
|
2020-11-19 15:00:52 +01:00
|
|
|
Native_shared_libs: nil,
|
|
|
|
Tests: nil,
|
|
|
|
Jni_libs: nil,
|
|
|
|
Binaries: a.properties.Binaries,
|
|
|
|
})
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Add native modules targeting either 32-bit or 64-bit ABI
|
2020-11-19 06:37:47 +01:00
|
|
|
switch target.Arch.ArchType.Multilib {
|
|
|
|
case "lib32":
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.properties.Multilib.Lib32)
|
|
|
|
deps.Merge(a.properties.Multilib.Prefer32)
|
2020-11-19 06:37:47 +01:00
|
|
|
case "lib64":
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.properties.Multilib.Lib64)
|
2020-11-19 06:37:47 +01:00
|
|
|
if !has32BitTarget {
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.properties.Multilib.Prefer32)
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
|
2020-12-14 10:44:04 +01:00
|
|
|
// Add native modules targeting a specific arch variant
|
|
|
|
switch target.Arch.ArchType {
|
|
|
|
case android.Arm:
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.archProperties.Arch.Arm.ApexNativeDependencies)
|
2020-12-14 10:44:04 +01:00
|
|
|
case android.Arm64:
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.archProperties.Arch.Arm64.ApexNativeDependencies)
|
2022-10-03 21:41:50 +02:00
|
|
|
case android.Riscv64:
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.archProperties.Arch.Riscv64.ApexNativeDependencies)
|
2020-12-14 10:44:04 +01:00
|
|
|
case android.X86:
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.archProperties.Arch.X86.ApexNativeDependencies)
|
2020-12-14 10:44:04 +01:00
|
|
|
case android.X86_64:
|
2022-11-02 21:14:20 +01:00
|
|
|
deps.Merge(a.archProperties.Arch.X86_64.ApexNativeDependencies)
|
2020-12-14 10:44:04 +01:00
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unsupported arch %v\n", ctx.Arch().ArchType))
|
|
|
|
}
|
|
|
|
|
2022-11-02 21:14:20 +01:00
|
|
|
addDependenciesForNativeModules(ctx, deps, target, imageVariation)
|
2021-11-23 01:57:19 +01:00
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "os", Variation: target.OsVariation()},
|
|
|
|
{Mutator: "arch", Variation: target.ArchVariation()},
|
|
|
|
}, shBinaryTag, a.properties.Sh_binaries...)
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Common-arch dependencies come next
|
|
|
|
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
|
2023-02-24 12:12:31 +01:00
|
|
|
ctx.AddFarVariationDependencies(commonVariation, rroTag, a.properties.Rros...)
|
2023-02-24 12:06:07 +01:00
|
|
|
ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...)
|
|
|
|
ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments...)
|
|
|
|
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...)
|
2021-01-07 07:31:24 +01:00
|
|
|
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
|
2021-03-17 16:02:19 +01:00
|
|
|
ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...)
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// DepsMutator for the overridden properties.
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
if a.overridableProperties.Allowed_files != nil {
|
|
|
|
android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files)
|
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
|
|
|
|
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
|
|
|
|
ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...)
|
2021-08-26 16:10:06 +02:00
|
|
|
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.overridableProperties.Bpfs...)
|
2021-08-27 00:44:43 +02:00
|
|
|
if prebuilts := a.overridableProperties.Prebuilts; len(prebuilts) > 0 {
|
|
|
|
// For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device)
|
|
|
|
// regardless of the TARGET_PREFER_* setting. See b/144532908
|
|
|
|
arches := ctx.DeviceConfig().Arches()
|
|
|
|
if len(arches) != 0 {
|
|
|
|
archForPrebuiltEtc := arches[0]
|
|
|
|
for _, arch := range arches {
|
|
|
|
// Prefer 64-bit arch if there is any
|
|
|
|
if arch.ArchType.Multilib == "lib64" {
|
|
|
|
archForPrebuiltEtc = arch
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "os", Variation: ctx.Os().String()},
|
|
|
|
{Mutator: "arch", Variation: archForPrebuiltEtc.String()},
|
|
|
|
}, prebuiltTag, prebuilts...)
|
|
|
|
}
|
|
|
|
}
|
2021-04-21 01:21:24 +02:00
|
|
|
|
|
|
|
// Dependencies for signing
|
|
|
|
if String(a.overridableProperties.Key) == "" {
|
|
|
|
ctx.PropertyErrorf("key", "missing")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ctx.AddDependency(ctx.Module(), keyTag, String(a.overridableProperties.Key))
|
|
|
|
|
|
|
|
cert := android.SrcIsModule(a.getCertString(ctx))
|
|
|
|
if cert != "" {
|
|
|
|
ctx.AddDependency(ctx.Module(), certificateTag, cert)
|
|
|
|
// empty cert is not an error. Cert and private keys will be directly found under
|
|
|
|
// PRODUCT_DEFAULT_DEV_CERTIFICATE
|
|
|
|
}
|
2019-10-18 09:26:59 +02:00
|
|
|
}
|
|
|
|
|
2023-01-11 15:15:43 +01:00
|
|
|
func apexDCLADepsMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if !mctx.Config().ApexTrimEnabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if a, ok := mctx.Module().(*apexBundle); ok && a.overridableProperties.Trim_against != nil {
|
|
|
|
commonVariation := mctx.Config().AndroidCommonTarget.Variations()
|
|
|
|
mctx.AddFarVariationDependencies(commonVariation, dclaTag, String(a.overridableProperties.Trim_against))
|
|
|
|
} else if o, ok := mctx.Module().(*OverrideApex); ok {
|
|
|
|
for _, p := range o.GetProperties() {
|
|
|
|
properties, ok := p.(*overridableProperties)
|
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if properties.Trim_against != nil {
|
|
|
|
commonVariation := mctx.Config().AndroidCommonTarget.Variations()
|
|
|
|
mctx.AddFarVariationDependencies(commonVariation, dclaTag, String(properties.Trim_against))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type DCLAInfo struct {
|
|
|
|
ProvidedLibs []string
|
|
|
|
}
|
|
|
|
|
|
|
|
var DCLAInfoProvider = blueprint.NewMutatorProvider(DCLAInfo{}, "apex_info")
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
type ApexBundleInfo struct {
|
|
|
|
Contents *android.ApexContents
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
2020-12-08 11:34:30 +01:00
|
|
|
var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_info")
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-12-07 18:39:59 +01:00
|
|
|
var _ ApexInfoMutator = (*apexBundle)(nil)
|
|
|
|
|
2021-06-24 15:37:13 +02:00
|
|
|
func (a *apexBundle) ApexVariationName() string {
|
|
|
|
return a.properties.ApexVariationName
|
|
|
|
}
|
|
|
|
|
2020-12-07 18:39:59 +01:00
|
|
|
// ApexInfoMutator is responsible for collecting modules that need to have apex variants. They are
|
2020-11-19 15:00:52 +01:00
|
|
|
// identified by doing a graph walk starting from an apexBundle. Basically, all the (direct and
|
|
|
|
// indirect) dependencies are collected. But a few types of modules that shouldn't be included in
|
|
|
|
// the apexBundle (e.g. stub libraries) are not collected. Note that a single module can be depended
|
|
|
|
// on by multiple apexBundles. In that case, the module is collected for all of the apexBundles.
|
2020-12-08 11:34:30 +01:00
|
|
|
//
|
|
|
|
// For each dependency between an apex and an ApexModule an ApexInfo object describing the apex
|
|
|
|
// is passed to that module's BuildForApex(ApexInfo) method which collates them all in a list.
|
|
|
|
// The apexMutator uses that list to create module variants for the apexes to which it belongs.
|
|
|
|
// The relationship between module variants and apexes is not one-to-one as variants will be
|
|
|
|
// shared between compatible apexes.
|
2020-12-07 18:39:59 +01:00
|
|
|
func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
|
2020-11-19 15:00:52 +01:00
|
|
|
|
|
|
|
// The VNDK APEX is special. For the APEX, the membership is described in a very different
|
|
|
|
// way. There is no dependency from the VNDK APEX to the VNDK libraries. Instead, VNDK
|
|
|
|
// libraries are self-identified by their vndk.enabled properties. There is no need to run
|
|
|
|
// this mutator for the APEX as nothing will be collected. So, let's return fast.
|
|
|
|
if a.vndkApex {
|
apexDepsMutator is a top-down mutator
apex { name: ["myapex"], native_shared_libs: ["libX", "libY"] }
cc_library { name: "libX", shared_libs: ["libY"] }
cc_library { name: "libY", shared_libs: ["libZ"], stubs: {...} }
apexDepsMutator was a bottom up mutator and it uses WalkDeps to traverse
the dependency tree rooted at myapex in a depth-first order. While
traversing the tree, if calls BuildForApex for a module that will be
part of the APEX.
libY is visited twice. Once via libX and once via myapex. If the visit
from libX was before the visit from myapex (since this is a depth-first
traversing), BuildForApex is not called for libY and its dependency
libZ, because libY provides a stub. And then when libY is again visited
via myapex, BuildForApex is correctly called for the module, but not for
its dependencies libZ because the paths from libY to libZ was already
visited.
As a result, the apex variant of libY has a dependency to the non-apex
variant of libZ.
Fixing the problem by changing the mutator a top-down one.
Bug: 148645937
Test: m
Change-Id: Ib2cb28852087c63a568b3fd036504e9261cf0782
2020-02-11 23:53:12 +01:00
|
|
|
return
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
2020-07-22 08:54:47 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Special casing for APEXes on non-system (e.g., vendor, odm, etc.) partitions. They are
|
|
|
|
// provided with a property named use_vndk_as_stable, which when set to true doesn't collect
|
|
|
|
// VNDK libraries as transitive dependencies. This option is useful for reducing the size of
|
|
|
|
// the non-system APEXes because the VNDK libraries won't be included (and duped) in the
|
|
|
|
// APEX, but shared across APEXes via the VNDK APEX.
|
2020-07-22 08:54:47 +02:00
|
|
|
useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface())
|
2023-07-26 05:39:19 +02:00
|
|
|
excludeVndkLibs := useVndk && a.useVndkAsStable(mctx)
|
2022-02-04 03:54:50 +01:00
|
|
|
if proptools.Bool(a.properties.Use_vndk_as_stable) {
|
|
|
|
if !useVndk {
|
|
|
|
mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes")
|
|
|
|
}
|
2023-03-22 09:41:03 +01:00
|
|
|
if a.minSdkVersionValue(mctx) != "" {
|
|
|
|
mctx.PropertyErrorf("use_vndk_as_stable", "not supported when min_sdk_version is set")
|
|
|
|
}
|
2022-02-04 03:54:50 +01:00
|
|
|
mctx.VisitDirectDepsWithTag(sharedLibTag, func(dep android.Module) {
|
|
|
|
if c, ok := dep.(*cc.Module); ok && c.IsVndk() {
|
|
|
|
mctx.PropertyErrorf("use_vndk_as_stable", "Trying to include a VNDK library(%s) while use_vndk_as_stable is true.", dep.Name())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if mctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2020-07-22 08:54:47 +02:00
|
|
|
}
|
|
|
|
|
2020-09-16 03:30:11 +02:00
|
|
|
continueApexDepsWalk := func(child, parent android.Module) bool {
|
2020-07-22 08:17:19 +02:00
|
|
|
am, ok := child.(android.ApexModule)
|
|
|
|
if !ok || !am.CanHaveApexVariants() {
|
|
|
|
return false
|
|
|
|
}
|
2021-03-17 14:25:29 +01:00
|
|
|
depTag := mctx.OtherModuleDependencyTag(child)
|
|
|
|
|
|
|
|
// Check to see if the tag always requires that the child module has an apex variant for every
|
|
|
|
// apex variant of the parent module. If it does not then it is still possible for something
|
|
|
|
// else, e.g. the DepIsInSameApex(...) method to decide that a variant is required.
|
|
|
|
if required, ok := depTag.(android.AlwaysRequireApexVariantTag); ok && required.AlwaysRequireApexVariant() {
|
|
|
|
return true
|
|
|
|
}
|
2021-03-18 16:41:29 +01:00
|
|
|
if !android.IsDepInSameApex(mctx, parent, child) {
|
2020-07-22 08:17:19 +02:00
|
|
|
return false
|
|
|
|
}
|
2020-07-22 08:54:47 +02:00
|
|
|
if excludeVndkLibs {
|
|
|
|
if c, ok := child.(*cc.Module); ok && c.IsVndk() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2023-09-07 09:00:04 +02:00
|
|
|
|
|
|
|
//TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
|
|
|
|
if useVndk && mctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
|
|
|
|
log.Print("Libbinder is linked from Vendor APEX ", a.Name(), " with module ", parent.Name())
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// By default, all the transitive dependencies are collected, unless filtered out
|
|
|
|
// above.
|
2020-09-16 03:30:11 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Records whether a certain module is included in this apexBundle via direct dependency or
|
|
|
|
// inndirect dependency.
|
|
|
|
contents := make(map[string]android.ApexMembership)
|
2020-09-16 03:30:11 +02:00
|
|
|
mctx.WalkDeps(func(child, parent android.Module) bool {
|
|
|
|
if !continueApexDepsWalk(child, parent) {
|
|
|
|
return false
|
|
|
|
}
|
2020-07-22 08:17:19 +02:00
|
|
|
// If the parent is apexBundle, this child is directly depended.
|
|
|
|
_, directDep := parent.(*apexBundle)
|
2020-11-19 15:00:52 +01:00
|
|
|
depName := mctx.OtherModuleName(child)
|
2020-09-16 03:30:11 +02:00
|
|
|
contents[depName] = contents[depName].Add(directDep)
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// The membership information is saved for later access
|
2020-11-17 17:34:22 +01:00
|
|
|
apexContents := android.NewApexContents(contents)
|
2020-09-16 03:30:11 +02:00
|
|
|
mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{
|
|
|
|
Contents: apexContents,
|
|
|
|
})
|
|
|
|
|
2021-01-26 03:43:46 +01:00
|
|
|
minSdkVersion := a.minSdkVersion(mctx)
|
|
|
|
// When min_sdk_version is not set, the apex is built against FutureApiLevel.
|
|
|
|
if minSdkVersion.IsNone() {
|
|
|
|
minSdkVersion = android.FutureApiLevel
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// This is the main part of this mutator. Mark the collected dependencies that they need to
|
|
|
|
// be built for this apexBundle.
|
Record the actual APEXes that a module is part of.
Consider this case:
apex {
name: "com.android.foo",
native_libs: ["foo"],
}
override_apex {
name: "com.mycompany.android.foo",
base: "com.android.foo",
}
cc_library {
name: "foo",
}
There are two APEXes defined: "com.android.foo" and
"com.mycompany.android.foo" which is a copy of "com.android.foo" with
some properties overridden (e.g. signing keys).
The module "foo" is mutated into two variants by the apex mutator: the
platform variant and the apex variant. The former has the variation name
"" and the later has "apex<min_api_ver>" which usually is "apex10000".
Internally, the apex variant has an alias "com.android.foo".
ApexInfo.InApexVariants() returns only "com.android.foo" when called for
the module "foo".
We can see that the information that "foo" is also part of
"com.mycompany.android.foo" is completely lost. This is causing problem
when we compare the apex membership by their "soong module name", not
the "apex name". In the example above, the two modules have different
soone module names, but have the same apex name: "com.android.foo".
To fix that, this CL introduces a new field `InApexes` to the `ApexInfo`
struct. It has the actual name of the APEXes that the module is part of.
With the example above, `InApexes` is ["com.android.foo",
"com.mycompany.android.foo"].
Bug: 180325915
Test: m nothing
Test: m nothing on non-AOSP targets with ag/13740887 applied.
Change-Id: I4e7a7ac5495d2e622ba92a4358ed967e066c6c2e
2021-05-12 10:13:56 +02:00
|
|
|
|
2023-02-09 01:11:27 +01:00
|
|
|
apexVariationName := mctx.ModuleName() // could be com.android.foo
|
2021-06-24 15:37:13 +02:00
|
|
|
a.properties.ApexVariationName = apexVariationName
|
2023-04-12 19:14:11 +02:00
|
|
|
testApexes := []string{}
|
|
|
|
if a.testApex {
|
|
|
|
testApexes = []string{apexVariationName}
|
|
|
|
}
|
2020-09-16 03:30:11 +02:00
|
|
|
apexInfo := android.ApexInfo{
|
2021-06-24 15:37:13 +02:00
|
|
|
ApexVariationName: apexVariationName,
|
2021-04-15 08:17:54 +02:00
|
|
|
MinSdkVersion: minSdkVersion,
|
2020-09-16 03:30:11 +02:00
|
|
|
Updatable: a.Updatable(),
|
2021-06-22 13:23:05 +02:00
|
|
|
UsePlatformApis: a.UsePlatformApis(),
|
2021-06-24 15:37:13 +02:00
|
|
|
InApexVariants: []string{apexVariationName},
|
|
|
|
InApexModules: []string{a.Name()}, // could be com.mycompany.android.foo
|
2020-09-16 03:30:11 +02:00
|
|
|
ApexContents: []*android.ApexContents{apexContents},
|
2023-04-12 19:14:11 +02:00
|
|
|
TestApexes: testApexes,
|
2020-09-16 03:30:11 +02:00
|
|
|
}
|
|
|
|
mctx.WalkDeps(func(child, parent android.Module) bool {
|
|
|
|
if !continueApexDepsWalk(child, parent) {
|
|
|
|
return false
|
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
child.(android.ApexModule).BuildForApex(apexInfo) // leave a mark!
|
2020-07-22 08:17:19 +02:00
|
|
|
return true
|
apexDepsMutator is a top-down mutator
apex { name: ["myapex"], native_shared_libs: ["libX", "libY"] }
cc_library { name: "libX", shared_libs: ["libY"] }
cc_library { name: "libY", shared_libs: ["libZ"], stubs: {...} }
apexDepsMutator was a bottom up mutator and it uses WalkDeps to traverse
the dependency tree rooted at myapex in a depth-first order. While
traversing the tree, if calls BuildForApex for a module that will be
part of the APEX.
libY is visited twice. Once via libX and once via myapex. If the visit
from libX was before the visit from myapex (since this is a depth-first
traversing), BuildForApex is not called for libY and its dependency
libZ, because libY provides a stub. And then when libY is again visited
via myapex, BuildForApex is correctly called for the module, but not for
its dependencies libZ because the paths from libY to libZ was already
visited.
As a result, the apex variant of libY has a dependency to the non-apex
variant of libZ.
Fixing the problem by changing the mutator a top-down one.
Bug: 148645937
Test: m
Change-Id: Ib2cb28852087c63a568b3fd036504e9261cf0782
2020-02-11 23:53:12 +01:00
|
|
|
})
|
2023-01-11 15:15:43 +01:00
|
|
|
|
|
|
|
if a.dynamic_common_lib_apex() {
|
|
|
|
mctx.SetProvider(DCLAInfoProvider, DCLAInfo{
|
|
|
|
ProvidedLibs: a.properties.Native_shared_libs,
|
|
|
|
})
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
|
2020-12-07 18:39:59 +01:00
|
|
|
type ApexInfoMutator interface {
|
2021-06-24 15:37:13 +02:00
|
|
|
// ApexVariationName returns the name of the APEX variation to use in the apex
|
|
|
|
// mutator etc. It is the same name as ApexInfo.ApexVariationName.
|
|
|
|
ApexVariationName() string
|
|
|
|
|
2020-12-07 18:39:59 +01:00
|
|
|
// ApexInfoMutator implementations must call BuildForApex(ApexInfo) on any modules that are
|
|
|
|
// depended upon by an apex and which require an apex specific variant.
|
|
|
|
ApexInfoMutator(android.TopDownMutatorContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
// apexInfoMutator delegates the work of identifying which modules need an ApexInfo and apex
|
|
|
|
// specific variant to modules that support the ApexInfoMutator.
|
2022-05-07 00:12:55 +02:00
|
|
|
// It also propagates updatable=true to apps of updatable apexes
|
2020-12-07 18:39:59 +01:00
|
|
|
func apexInfoMutator(mctx android.TopDownMutatorContext) {
|
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if a, ok := mctx.Module().(ApexInfoMutator); ok {
|
|
|
|
a.ApexInfoMutator(mctx)
|
|
|
|
}
|
2022-05-07 00:12:55 +02:00
|
|
|
enforceAppUpdatability(mctx)
|
2020-12-07 18:39:59 +01:00
|
|
|
}
|
|
|
|
|
2022-01-15 01:23:18 +01:00
|
|
|
// apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module
|
|
|
|
// This check is enforced for updatable modules
|
|
|
|
func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
|
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
2022-01-21 23:07:26 +01:00
|
|
|
if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() {
|
2022-01-15 01:23:18 +01:00
|
|
|
mctx.WalkDeps(func(child, parent android.Module) bool {
|
2022-02-10 03:34:13 +01:00
|
|
|
// b/208656169 Do not propagate strict updatability linting to libcore/
|
|
|
|
// These libs are available on the classpath during compilation
|
|
|
|
// These libs are transitive deps of the sdk. See java/sdk.go:decodeSdkDep
|
|
|
|
// Only skip libraries defined in libcore root, not subdirectories
|
|
|
|
if mctx.OtherModuleDir(child) == "libcore" {
|
|
|
|
// Do not traverse transitive deps of libcore/ libs
|
|
|
|
return false
|
|
|
|
}
|
2022-03-24 21:19:35 +01:00
|
|
|
if android.InList(child.Name(), skipLintJavalibAllowlist) {
|
|
|
|
return false
|
|
|
|
}
|
2022-01-15 01:23:18 +01:00
|
|
|
if lintable, ok := child.(java.LintDepSetsIntf); ok {
|
|
|
|
lintable.SetStrictUpdatabilityLinting(true)
|
|
|
|
}
|
|
|
|
// visit transitive deps
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 00:12:55 +02:00
|
|
|
// enforceAppUpdatability propagates updatable=true to apps of updatable apexes
|
|
|
|
func enforceAppUpdatability(mctx android.TopDownMutatorContext) {
|
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if apex, ok := mctx.Module().(*apexBundle); ok && apex.Updatable() {
|
|
|
|
// checking direct deps is sufficient since apex->apk is a direct edge, even when inherited via apex_defaults
|
|
|
|
mctx.VisitDirectDeps(func(module android.Module) {
|
|
|
|
// ignore android_test_app
|
|
|
|
if app, ok := module.(*java.AndroidApp); ok {
|
|
|
|
app.SetUpdatable(true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-21 23:07:26 +01:00
|
|
|
// TODO: b/215736885 Whittle the denylist
|
|
|
|
// Transitive deps of certain mainline modules baseline NewApi errors
|
|
|
|
// Skip these mainline modules for now
|
|
|
|
var (
|
|
|
|
skipStrictUpdatabilityLintAllowlist = []string{
|
|
|
|
"com.android.art",
|
|
|
|
"com.android.art.debug",
|
|
|
|
"com.android.conscrypt",
|
|
|
|
"com.android.media",
|
|
|
|
// test apexes
|
|
|
|
"test_com.android.art",
|
|
|
|
"test_com.android.conscrypt",
|
|
|
|
"test_com.android.media",
|
|
|
|
"test_jitzygote_com.android.art",
|
|
|
|
}
|
2022-03-24 21:19:35 +01:00
|
|
|
|
|
|
|
// TODO: b/215736885 Remove this list
|
|
|
|
skipLintJavalibAllowlist = []string{
|
|
|
|
"conscrypt.module.platform.api.stubs",
|
|
|
|
"conscrypt.module.public.api.stubs",
|
|
|
|
"conscrypt.module.public.api.stubs.system",
|
|
|
|
"conscrypt.module.public.api.stubs.module_lib",
|
|
|
|
"framework-media.stubs",
|
|
|
|
"framework-media.stubs.system",
|
|
|
|
"framework-media.stubs.module_lib",
|
|
|
|
}
|
2022-01-21 23:07:26 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (a *apexBundle) checkStrictUpdatabilityLinting() bool {
|
|
|
|
return a.Updatable() && !android.InList(a.ApexVariationName(), skipStrictUpdatabilityLintAllowlist)
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexUniqueVariationsMutator checks if any dependencies use unique apex variations. If so, use
|
|
|
|
// unique apex variations for this module. See android/apex.go for more about unique apex variant.
|
|
|
|
// TODO(jiyong): move this to android/apex.go?
|
Reland: Deduplicate APEX variants that would build identically
APEX variants that share the same SDK version and updatability
almost always use identical command line arguments to build but
with different intermediates directories. This causes unnecessary
build time and disk space for duplicated work.
Deduplicate APEX variants that would build identically. Create
aliases from the per-APEX variations to the new shared variations
so that the APEX modules can continue to depend on them via the
APEX name as the variation.
This has one significant change in behavior. Before this change,
if an APEX had two libraries in its direct dependencies and one
of those libraries depended on the other, and the second library
had stubs, then the first library would depend on the implementation
of the second library and not the stubs. After this change, if
the first library is also present in a second APEX but the second
library is not, then the common variant shared between the two
APEXes would use the stubs, not the implementation.
In a correctly configured set of build rules this change will
be irrelevant, because if the compilation worked for the second
APEX using stubs then it will work for the common variant using
stubs. However, if an incorrect change to the build rules is
made this could lead to confusing errors, as a previously-working
common variant could suddenly stop building when a module is added
to a new APEX without its dependencies that require implementation
APIs to compile.
This change reduces the number of modules in an AOSP arm64-userdebug
build by 3% (52242 to 50586), reduces the number of variants of the
libcutils module from 74 to 53, and reduces the number of variants
of the massive libart[d] modules from 44 to 32.
This relands I0529837476a253c32b3dfb98dcccf107427c742c with a fix
to always mark permissions XML files of java_sdk_library modules as
unique per apex since they contain the APEX filename, and a fix
to UpdateUniqueApexVariationsForDeps to check ApexInfo.InApexes
instead of DepIsInSameApex to check if two modules are in the same
apex to account for a module that depends on another in a way that
doesn't normally include the dependency in the APEX (e.g. a libs
property), but the dependency is directly included in the APEX.
Bug: 164216768
Test: go test ./build/soong/apex/...
Change-Id: I2ae170601f764e5b88d0be2e0e6adc84e3a4d9cc
2020-08-11 21:17:01 +02:00
|
|
|
func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if am, ok := mctx.Module().(android.ApexModule); ok {
|
2020-09-16 03:30:11 +02:00
|
|
|
android.UpdateUniqueApexVariationsForDeps(mctx, am)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexTestForDepsMutator checks if this module is a test for an apex. If so, add a dependency on
|
|
|
|
// the apex in order to retrieve its contents later.
|
|
|
|
// TODO(jiyong): move this to android/apex.go?
|
2020-09-16 03:30:11 +02:00
|
|
|
func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if am, ok := mctx.Module().(android.ApexModule); ok {
|
|
|
|
if testFor := am.TestFor(); len(testFor) > 0 {
|
|
|
|
mctx.AddFarVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "os", Variation: am.Target().OsVariation()},
|
|
|
|
{"arch", "common"},
|
|
|
|
}, testForTag, testFor...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// TODO(jiyong): move this to android/apex.go?
|
2020-09-16 03:30:11 +02:00
|
|
|
func apexTestForMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if _, ok := mctx.Module().(android.ApexModule); ok {
|
|
|
|
var contents []*android.ApexContents
|
|
|
|
for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) {
|
|
|
|
abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo)
|
|
|
|
contents = append(contents, abInfo.Contents)
|
|
|
|
}
|
|
|
|
mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{
|
|
|
|
ApexContents: contents,
|
|
|
|
})
|
Reland: Deduplicate APEX variants that would build identically
APEX variants that share the same SDK version and updatability
almost always use identical command line arguments to build but
with different intermediates directories. This causes unnecessary
build time and disk space for duplicated work.
Deduplicate APEX variants that would build identically. Create
aliases from the per-APEX variations to the new shared variations
so that the APEX modules can continue to depend on them via the
APEX name as the variation.
This has one significant change in behavior. Before this change,
if an APEX had two libraries in its direct dependencies and one
of those libraries depended on the other, and the second library
had stubs, then the first library would depend on the implementation
of the second library and not the stubs. After this change, if
the first library is also present in a second APEX but the second
library is not, then the common variant shared between the two
APEXes would use the stubs, not the implementation.
In a correctly configured set of build rules this change will
be irrelevant, because if the compilation worked for the second
APEX using stubs then it will work for the common variant using
stubs. However, if an incorrect change to the build rules is
made this could lead to confusing errors, as a previously-working
common variant could suddenly stop building when a module is added
to a new APEX without its dependencies that require implementation
APIs to compile.
This change reduces the number of modules in an AOSP arm64-userdebug
build by 3% (52242 to 50586), reduces the number of variants of the
libcutils module from 74 to 53, and reduces the number of variants
of the massive libart[d] modules from 44 to 32.
This relands I0529837476a253c32b3dfb98dcccf107427c742c with a fix
to always mark permissions XML files of java_sdk_library modules as
unique per apex since they contain the APEX filename, and a fix
to UpdateUniqueApexVariationsForDeps to check ApexInfo.InApexes
instead of DepIsInSameApex to check if two modules are in the same
apex to account for a module that depends on another in a way that
doesn't normally include the dependency in the APEX (e.g. a libs
property), but the dependency is directly included in the APEX.
Bug: 164216768
Test: go test ./build/soong/apex/...
Change-Id: I2ae170601f764e5b88d0be2e0e6adc84e3a4d9cc
2020-08-11 21:17:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// markPlatformAvailability marks whether or not a module can be available to platform. A module
|
|
|
|
// cannot be available to platform if 1) it is explicitly marked as not available (i.e.
|
|
|
|
// "//apex_available:platform" is absent) or 2) it depends on another module that isn't (or can't
|
|
|
|
// be) available to platform
|
|
|
|
// TODO(jiyong): move this to android/apex.go?
|
mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.
In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.
The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.
cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}
Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.
Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,
cc_library_shared { name: "mylib", static_libs: ["libfoo"] }
can exist and it might be installed to the device, in which case
we really should trigger an error.
Since Make has the knowledge of what's installed and what's not,
the check should be done there.
Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-07 09:37:39 +02:00
|
|
|
func markPlatformAvailability(mctx android.BottomUpMutatorContext) {
|
2023-08-23 06:54:08 +02:00
|
|
|
// Recovery is not considered as platform
|
|
|
|
if mctx.Module().InstallInRecovery() {
|
mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.
In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.
The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.
cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}
Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.
Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,
cc_library_shared { name: "mylib", static_libs: ["libfoo"] }
can exist and it might be installed to the device, in which case
we really should trigger an error.
Since Make has the knowledge of what's installed and what's not,
the check should be done there.
Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-07 09:37:39 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
am, ok := mctx.Module().(android.ApexModule)
|
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.
In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.
The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.
cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}
Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.
Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,
cc_library_shared { name: "mylib", static_libs: ["libfoo"] }
can exist and it might be installed to the device, in which case
we really should trigger an error.
Since Make has the knowledge of what's installed and what's not,
the check should be done there.
Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-07 09:37:39 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
availableToPlatform := am.AvailableFor(android.AvailableToPlatform)
|
mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.
In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.
The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.
cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}
Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.
Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,
cc_library_shared { name: "mylib", static_libs: ["libfoo"] }
can exist and it might be installed to the device, in which case
we really should trigger an error.
Since Make has the knowledge of what's installed and what's not,
the check should be done there.
Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-07 09:37:39 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// If any of the dep is not available to platform, this module is also considered as being
|
|
|
|
// not available to platform even if it has "//apex_available:platform"
|
|
|
|
mctx.VisitDirectDeps(func(child android.Module) {
|
2021-03-18 16:41:29 +01:00
|
|
|
if !android.IsDepInSameApex(mctx, am, child) {
|
2020-11-19 15:00:52 +01:00
|
|
|
// if the dependency crosses apex boundary, don't consider it
|
|
|
|
return
|
mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.
In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.
The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.
cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}
Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.
Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,
cc_library_shared { name: "mylib", static_libs: ["libfoo"] }
can exist and it might be installed to the device, in which case
we really should trigger an error.
Since Make has the knowledge of what's installed and what's not,
the check should be done there.
Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-07 09:37:39 +02:00
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() {
|
|
|
|
availableToPlatform = false
|
|
|
|
// TODO(b/154889534) trigger an error when 'am' has
|
|
|
|
// "//apex_available:platform"
|
mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.
In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.
The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.
cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}
Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.
Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,
cc_library_shared { name: "mylib", static_libs: ["libfoo"] }
can exist and it might be installed to the device, in which case
we really should trigger an error.
Since Make has the knowledge of what's installed and what's not,
the check should be done there.
Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-07 09:37:39 +02:00
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
})
|
|
|
|
|
2021-05-12 17:16:51 +02:00
|
|
|
// Exception 1: check to see if the module always requires it.
|
|
|
|
if am.AlwaysRequiresPlatformApexVariant() {
|
2020-11-19 15:00:52 +01:00
|
|
|
availableToPlatform = true
|
mark platform un-availability
A module is marked unavailable for platform when 1) it does not have
"//apex_available:platform" in its apex_available property, or 2)
it depends on another module that is unavailable for platform.
In that case, LOCAL_NOT_AVAILABLE_FOR_PLATFORM is set to true for the
module in the Make world. Later, that flag is used to ensure that there
is no module with the flag is installed to the device.
The reason why this isn't entirely done in Soong is because Soong
doesn't know if a module will be installed to the device or not. To
explain this, let's have an example.
cc_test { name: "mytest", static_libs: ["libfoo"]}
cc_library_static { name: "libfoo", static_libs: ["libbar"]}
cc_library { name: "libbar", apex_available: ["com.android.xxx"]}
Here, libbar is not available for platform, but is used by libfoo which
is available for platform (apex_available defaults to
"//apex_available:platform"). libfoo is again depended on by mytest
which again is available for platform. The use of libbar should be
allowed in the context of test; we don't want to make libbar available
to platform just for the dependency from test because it will allow
non-test uses of the library as well.
Soong by itself can't tell whether libfoo and libbar are used only in the
context of a test. There could be another module depending them, e.g.,
cc_library_shared { name: "mylib", static_libs: ["libfoo"] }
can exist and it might be installed to the device, in which case
we really should trigger an error.
Since Make has the knowledge of what's installed and what's not,
the check should be done there.
Bug: 153073816
Test: m
Test: remove "//apex_available:platform" from libmdnssd (it is currently
installed to /system/lib), and check that `m system_image` fails
Change-Id: Ia304cc5f41f173229e8a154e90cea4dce46dcebe
2020-04-07 09:37:39 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Exception 2: bootstrap bionic libraries are also always available to platform
|
|
|
|
if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) {
|
|
|
|
availableToPlatform = true
|
2020-03-31 16:23:40 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
if !availableToPlatform {
|
|
|
|
am.SetNotAvailableForPlatform()
|
|
|
|
}
|
2020-03-31 16:23:40 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexMutator visits each module and creates apex variations if the module was marked in the
|
2020-12-08 11:34:30 +01:00
|
|
|
// previous run of apexInfoMutator.
|
2018-10-10 07:01:00 +02:00
|
|
|
func apexMutator(mctx android.BottomUpMutatorContext) {
|
2020-04-17 06:43:10 +02:00
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
2020-09-16 03:30:11 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// This is the usual path.
|
2018-10-10 07:01:00 +02:00
|
|
|
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
|
2020-09-16 03:30:11 +02:00
|
|
|
android.CreateApexVariations(mctx, am)
|
2020-11-19 15:00:52 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// apexBundle itself is mutated so that it and its dependencies have the same apex variant.
|
2021-06-24 15:37:13 +02:00
|
|
|
if ai, ok := mctx.Module().(ApexInfoMutator); ok && apexModuleTypeRequiresVariant(ai) {
|
|
|
|
apexBundleName := ai.ApexVariationName()
|
2018-10-10 07:01:00 +02:00
|
|
|
mctx.CreateVariations(apexBundleName)
|
2021-03-27 16:18:31 +01:00
|
|
|
if strings.HasPrefix(apexBundleName, "com.android.art") {
|
|
|
|
// Create an alias from the platform variant. This is done to make
|
|
|
|
// test_for dependencies work for modules that are split by the APEX
|
|
|
|
// mutator, since test_for dependencies always go to the platform variant.
|
|
|
|
// This doesn't happen for normal APEXes that are disjunct, so only do
|
|
|
|
// this for the overlapping ART APEXes.
|
|
|
|
// TODO(b/183882457): Remove this if the test_for functionality is
|
|
|
|
// refactored to depend on the proper APEX variants instead of platform.
|
|
|
|
mctx.CreateAliasVariation("", apexBundleName)
|
|
|
|
}
|
2019-11-15 10:40:32 +01:00
|
|
|
} else if o, ok := mctx.Module().(*OverrideApex); ok {
|
|
|
|
apexBundleName := o.GetOverriddenModuleName()
|
|
|
|
if apexBundleName == "" {
|
|
|
|
mctx.ModuleErrorf("base property is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
mctx.CreateVariations(apexBundleName)
|
2021-03-27 16:18:31 +01:00
|
|
|
if strings.HasPrefix(apexBundleName, "com.android.art") {
|
|
|
|
// TODO(b/183882457): See note for CreateAliasVariation above.
|
|
|
|
mctx.CreateAliasVariation("", apexBundleName)
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-06 10:37:42 +02:00
|
|
|
|
2021-06-15 20:09:41 +02:00
|
|
|
// apexModuleTypeRequiresVariant determines whether the module supplied requires an apex specific
|
|
|
|
// variant.
|
2021-06-24 15:37:13 +02:00
|
|
|
func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool {
|
2021-06-15 20:09:41 +02:00
|
|
|
if a, ok := module.(*apexBundle); ok {
|
2021-06-24 15:37:13 +02:00
|
|
|
// TODO(jiyong): document the reason why the VNDK APEX is an exception here.
|
2021-06-15 20:09:41 +02:00
|
|
|
return !a.vndkApex
|
|
|
|
}
|
|
|
|
|
2021-06-24 15:37:13 +02:00
|
|
|
return true
|
2021-06-15 20:09:41 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// See android.UpdateDirectlyInAnyApex
|
|
|
|
// TODO(jiyong): move this to android/apex.go?
|
2020-09-16 03:30:11 +02:00
|
|
|
func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if !mctx.Module().Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if am, ok := mctx.Module().(android.ApexModule); ok {
|
|
|
|
android.UpdateDirectlyInAnyApex(mctx, am)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
const (
|
2020-11-19 15:00:52 +01:00
|
|
|
// File extensions of an APEX for different packaging methods
|
2021-09-08 18:48:28 +02:00
|
|
|
imageApexSuffix = ".apex"
|
|
|
|
imageCapexSuffix = ".capex"
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// variant names each of which is for a packaging method
|
2023-06-20 09:25:59 +02:00
|
|
|
imageApexType = "image"
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2021-10-17 03:36:13 +02:00
|
|
|
ext4FsType = "ext4"
|
|
|
|
f2fsFsType = "f2fs"
|
2021-08-02 09:02:17 +02:00
|
|
|
erofsFsType = "erofs"
|
2020-11-19 06:37:47 +01:00
|
|
|
)
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
var _ android.DepIsInSameApex = (*apexBundle)(nil)
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Implements android.DepInInSameApex
|
2022-06-29 07:43:04 +02:00
|
|
|
func (a *apexBundle) DepIsInSameApex(_ android.BaseModuleContext, _ android.Module) bool {
|
2020-11-19 06:37:47 +01:00
|
|
|
// direct deps of an APEX bundle are all part of the APEX bundle
|
2020-11-19 15:00:52 +01:00
|
|
|
// TODO(jiyong): shouldn't we look into the payload field of the dependencyTag?
|
2020-11-19 06:37:47 +01:00
|
|
|
return true
|
2019-01-30 03:07:33 +01:00
|
|
|
}
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
var _ android.OutputFileProducer = (*apexBundle)(nil)
|
2019-01-30 03:07:33 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Implements android.OutputFileProducer
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
|
|
|
|
switch tag {
|
2020-11-25 17:37:46 +01:00
|
|
|
case "", android.DefaultDistTag:
|
|
|
|
// This is the default dist path.
|
2020-11-19 06:37:47 +01:00
|
|
|
return android.Paths{a.outputFile}, nil
|
2022-02-24 05:58:07 +01:00
|
|
|
case imageApexSuffix:
|
|
|
|
// uncompressed one
|
|
|
|
if a.outputApexFile != nil {
|
|
|
|
return android.Paths{a.outputApexFile}, nil
|
|
|
|
}
|
|
|
|
fallthrough
|
2020-11-19 06:37:47 +01:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
|
|
|
}
|
|
|
|
}
|
2019-01-30 03:07:33 +01:00
|
|
|
|
2022-04-27 03:30:34 +02:00
|
|
|
var _ multitree.Exportable = (*apexBundle)(nil)
|
|
|
|
|
|
|
|
func (a *apexBundle) Exportable() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) TaggedOutputs() map[string]android.Paths {
|
|
|
|
ret := make(map[string]android.Paths)
|
|
|
|
ret["apex"] = android.Paths{a.outputFile}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
var _ cc.Coverage = (*apexBundle)(nil)
|
|
|
|
|
|
|
|
// Implements cc.Coverage
|
|
|
|
func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
|
2023-08-23 06:54:08 +02:00
|
|
|
return ctx.DeviceConfig().NativeCoverageEnabled()
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Implements cc.Coverage
|
2021-04-01 15:49:36 +02:00
|
|
|
func (a *apexBundle) SetPreventInstall() {
|
2020-11-19 15:00:52 +01:00
|
|
|
a.properties.PreventInstall = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements cc.Coverage
|
|
|
|
func (a *apexBundle) HideFromMake() {
|
|
|
|
a.properties.HideFromMake = true
|
2020-12-18 03:22:34 +01:00
|
|
|
// This HideFromMake is shadowing the ModuleBase one, call through to it for now.
|
|
|
|
// TODO(ccross): untangle these
|
|
|
|
a.ModuleBase.HideFromMake()
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Implements cc.Coverage
|
|
|
|
func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
|
|
|
|
a.properties.IsCoverageVariant = coverage
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implements cc.Coverage
|
|
|
|
func (a *apexBundle) EnableCoverageIfNeeded() {}
|
|
|
|
|
|
|
|
var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil)
|
|
|
|
|
2021-10-14 21:33:41 +02:00
|
|
|
// Implements android.ApexBundleDepsInfoIntf
|
2020-11-19 15:00:52 +01:00
|
|
|
func (a *apexBundle) Updatable() bool {
|
2021-02-16 12:40:16 +01:00
|
|
|
return proptools.BoolDefault(a.properties.Updatable, true)
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-29 04:37:10 +01:00
|
|
|
func (a *apexBundle) FutureUpdatable() bool {
|
|
|
|
return proptools.BoolDefault(a.properties.Future_updatable, false)
|
|
|
|
}
|
|
|
|
|
2021-06-22 13:23:05 +02:00
|
|
|
func (a *apexBundle) UsePlatformApis() bool {
|
|
|
|
return proptools.BoolDefault(a.properties.Platform_apis, false)
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// getCertString returns the name of the cert that should be used to sign this APEX. This is
|
|
|
|
// basically from the "certificate" property, but could be overridden by the device config.
|
|
|
|
func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
|
|
|
|
moduleName := ctx.ModuleName()
|
|
|
|
// VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the
|
|
|
|
// OVERRIDE_* list, we check with the pseudo module name to see if its certificate is
|
|
|
|
// overridden.
|
|
|
|
if a.vndkApex {
|
|
|
|
moduleName = vndkApexName
|
|
|
|
}
|
|
|
|
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
|
|
|
|
if overridden {
|
|
|
|
return ":" + certificate
|
|
|
|
}
|
2021-04-21 01:21:24 +02:00
|
|
|
return String(a.overridableProperties.Certificate)
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// See the installable property
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) installable() bool {
|
|
|
|
return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
|
|
|
|
}
|
2019-01-30 03:07:33 +01:00
|
|
|
|
2021-06-09 20:43:46 +02:00
|
|
|
// See the generate_hashtree property
|
|
|
|
func (a *apexBundle) shouldGenerateHashtree() bool {
|
2021-06-16 19:15:03 +02:00
|
|
|
return proptools.BoolDefault(a.properties.Generate_hashtree, true)
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
2019-01-30 03:07:33 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// See the test_only_unsigned_payload property
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool {
|
|
|
|
return proptools.Bool(a.properties.Test_only_unsigned_payload)
|
2019-01-30 03:07:33 +01:00
|
|
|
}
|
|
|
|
|
2020-12-22 11:47:50 +01:00
|
|
|
// See the test_only_force_compression property
|
|
|
|
func (a *apexBundle) testOnlyShouldForceCompression() bool {
|
|
|
|
return proptools.Bool(a.properties.Test_only_force_compression)
|
|
|
|
}
|
|
|
|
|
2022-08-03 18:46:43 +02:00
|
|
|
// See the dynamic_common_lib_apex property
|
|
|
|
func (a *apexBundle) dynamic_common_lib_apex() bool {
|
|
|
|
return proptools.BoolDefault(a.properties.Dynamic_common_lib_apex, false)
|
|
|
|
}
|
|
|
|
|
2023-01-11 15:15:43 +01:00
|
|
|
// See the list of libs to trim
|
|
|
|
func (a *apexBundle) libs_to_trim(ctx android.ModuleContext) []string {
|
|
|
|
dclaModules := ctx.GetDirectDepsWithTag(dclaTag)
|
|
|
|
if len(dclaModules) > 1 {
|
|
|
|
panic(fmt.Errorf("expected exactly at most one dcla dependency, got %d", len(dclaModules)))
|
|
|
|
}
|
|
|
|
if len(dclaModules) > 0 {
|
|
|
|
DCLAInfo := ctx.OtherModuleProvider(dclaModules[0], DCLAInfoProvider).(DCLAInfo)
|
|
|
|
return DCLAInfo.ProvidedLibs
|
|
|
|
}
|
|
|
|
return []string{}
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its
|
|
|
|
// members) can be sanitized, either forcibly, or by the global configuration. For some of the
|
|
|
|
// sanitizers, extra dependencies can be forcibly added as well.
|
2019-02-07 18:53:06 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) EnableSanitizer(sanitizerName string) {
|
|
|
|
if !android.InList(sanitizerName, a.properties.SanitizerNames) {
|
|
|
|
a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
|
|
|
|
}
|
|
|
|
}
|
2019-03-18 06:26:32 +01:00
|
|
|
|
2022-06-17 08:59:37 +02:00
|
|
|
func (a *apexBundle) IsSanitizerEnabled(config android.Config, sanitizerName string) bool {
|
2020-11-19 06:37:47 +01:00
|
|
|
if android.InList(sanitizerName, a.properties.SanitizerNames) {
|
|
|
|
return true
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
// Then follow the global setting
|
2022-06-29 07:43:04 +02:00
|
|
|
var globalSanitizerNames []string
|
2023-08-23 06:54:08 +02:00
|
|
|
arches := config.SanitizeDeviceArch()
|
|
|
|
if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
|
|
|
|
globalSanitizerNames = config.SanitizeDevice()
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
|
|
|
return android.InList(sanitizerName, globalSanitizerNames)
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) {
|
2020-11-19 15:00:52 +01:00
|
|
|
// TODO(jiyong): move this info (the sanitizer name, the lib name, etc.) to cc/sanitize.go
|
|
|
|
// Keep only the mechanism here.
|
2023-08-23 06:54:08 +02:00
|
|
|
if sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") {
|
2020-11-19 15:00:52 +01:00
|
|
|
imageVariation := a.getImageVariation(ctx)
|
2020-11-19 06:37:47 +01:00
|
|
|
for _, target := range ctx.MultiTargets() {
|
|
|
|
if target.Arch.ArchType.Multilib == "lib64" {
|
2020-11-19 15:00:52 +01:00
|
|
|
addDependenciesForNativeModules(ctx, ApexNativeDependencies{
|
2022-02-10 20:41:18 +01:00
|
|
|
Native_shared_libs: []string{"libclang_rt.hwasan"},
|
2020-11-19 15:00:52 +01:00
|
|
|
Tests: nil,
|
|
|
|
Jni_libs: nil,
|
|
|
|
Binaries: nil,
|
|
|
|
}, target, imageVariation)
|
2020-11-19 06:37:47 +01:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-10 07:01:00 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apexFileFor<Type> functions below create an apexFile struct for a given Soong module. The
|
|
|
|
// returned apexFile saves information about the Soong module that will be used for creating the
|
|
|
|
// build rules.
|
2020-11-19 06:37:47 +01:00
|
|
|
func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
|
2020-11-19 15:00:52 +01:00
|
|
|
// Decide the APEX-local directory by the multilib of the library In the future, we may
|
|
|
|
// query this to the module.
|
|
|
|
// TODO(jiyong): use the new PackagingSpec
|
2020-11-19 06:37:47 +01:00
|
|
|
var dirInApex string
|
|
|
|
switch ccMod.Arch().ArchType.Multilib {
|
|
|
|
case "lib32":
|
|
|
|
dirInApex = "lib"
|
|
|
|
case "lib64":
|
|
|
|
dirInApex = "lib64"
|
|
|
|
}
|
|
|
|
if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
|
|
|
|
}
|
|
|
|
if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
|
2020-11-19 15:00:52 +01:00
|
|
|
// Special case for Bionic libs and other libs installed with them. This is to
|
|
|
|
// prevent those libs from being included in the search path
|
|
|
|
// /apex/com.android.runtime/${LIB}. This exclusion is required because those libs
|
|
|
|
// in the Runtime APEX are available via the legacy paths in /system/lib/. By the
|
|
|
|
// init process, the libs in the APEX are bind-mounted to the legacy paths and thus
|
|
|
|
// will be loaded into the default linker namespace (aka "platform" namespace). If
|
|
|
|
// the libs are directly in /apex/com.android.runtime/${LIB} then the same libs will
|
|
|
|
// be loaded again into the runtime linker namespace, which will result in double
|
|
|
|
// loading of them, which isn't supported.
|
2020-11-19 06:37:47 +01:00
|
|
|
dirInApex = filepath.Join(dirInApex, "bionic")
|
|
|
|
}
|
2023-03-24 01:48:07 +01:00
|
|
|
// This needs to go after the runtime APEX handling because otherwise we would get
|
|
|
|
// weird paths like lib64/rel_install_path/bionic rather than
|
|
|
|
// lib64/bionic/rel_install_path.
|
|
|
|
dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
|
2018-12-19 09:12:36 +01:00
|
|
|
|
2022-10-04 04:14:46 +02:00
|
|
|
fileToCopy := android.OutputFileForModule(ctx, ccMod, "")
|
2020-11-19 06:37:47 +01:00
|
|
|
androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName
|
|
|
|
return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod)
|
|
|
|
}
|
2019-01-30 03:31:59 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
|
|
|
|
dirInApex := "bin"
|
|
|
|
if cc.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
|
|
|
|
}
|
|
|
|
dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
|
2022-10-04 04:14:46 +02:00
|
|
|
fileToCopy := android.OutputFileForModule(ctx, cc, "")
|
2020-11-19 06:37:47 +01:00
|
|
|
androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName
|
|
|
|
af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc)
|
|
|
|
af.symlinks = cc.Symlinks()
|
|
|
|
af.dataPaths = cc.DataPaths()
|
|
|
|
return af
|
|
|
|
}
|
2019-02-09 03:50:56 +01:00
|
|
|
|
2020-11-17 14:21:02 +01:00
|
|
|
func apexFileForRustExecutable(ctx android.BaseModuleContext, rustm *rust.Module) apexFile {
|
|
|
|
dirInApex := "bin"
|
|
|
|
if rustm.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath)
|
|
|
|
}
|
2023-08-11 09:30:04 +02:00
|
|
|
dirInApex = filepath.Join(dirInApex, rustm.RelativeInstallPath())
|
2022-10-04 04:14:46 +02:00
|
|
|
fileToCopy := android.OutputFileForModule(ctx, rustm, "")
|
2020-11-17 14:21:02 +01:00
|
|
|
androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName
|
|
|
|
af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, rustm)
|
|
|
|
return af
|
|
|
|
}
|
|
|
|
|
|
|
|
func apexFileForRustLibrary(ctx android.BaseModuleContext, rustm *rust.Module) apexFile {
|
|
|
|
// Decide the APEX-local directory by the multilib of the library
|
|
|
|
// In the future, we may query this to the module.
|
|
|
|
var dirInApex string
|
|
|
|
switch rustm.Arch().ArchType.Multilib {
|
|
|
|
case "lib32":
|
|
|
|
dirInApex = "lib"
|
|
|
|
case "lib64":
|
|
|
|
dirInApex = "lib64"
|
|
|
|
}
|
|
|
|
if rustm.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath)
|
|
|
|
}
|
2023-08-11 09:30:04 +02:00
|
|
|
dirInApex = filepath.Join(dirInApex, rustm.RelativeInstallPath())
|
2022-10-04 04:14:46 +02:00
|
|
|
fileToCopy := android.OutputFileForModule(ctx, rustm, "")
|
2020-11-17 14:21:02 +01:00
|
|
|
androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName
|
|
|
|
return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, rustm)
|
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
|
|
|
|
dirInApex := filepath.Join("bin", sh.SubDir())
|
2021-11-23 01:57:19 +01:00
|
|
|
if sh.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
dirInApex = filepath.Join(dirInApex, sh.Target().NativeBridgeRelativePath)
|
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
fileToCopy := sh.OutputFile()
|
|
|
|
af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh)
|
|
|
|
af.symlinks = sh.Symlinks()
|
|
|
|
return af
|
|
|
|
}
|
2019-08-09 07:44:36 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
|
|
|
|
dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir())
|
|
|
|
fileToCopy := prebuilt.OutputFile()
|
|
|
|
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
|
|
|
|
}
|
|
|
|
|
|
|
|
func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
|
|
|
|
dirInApex := filepath.Join("etc", config.SubDir())
|
|
|
|
fileToCopy := config.CompatConfig()
|
|
|
|
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
|
|
|
|
}
|
|
|
|
|
|
|
|
// javaModule is an interface to handle all Java modules (java_library, dex_import, etc) in the same
|
|
|
|
// way.
|
2020-11-19 06:37:47 +01:00
|
|
|
type javaModule interface {
|
|
|
|
android.Module
|
|
|
|
BaseModuleName() string
|
2021-09-15 04:34:04 +02:00
|
|
|
DexJarBuildPath() java.OptionalDexJarPath
|
2020-11-19 06:37:47 +01:00
|
|
|
JacocoReportClassesFile() android.Path
|
|
|
|
LintDepSets() java.LintDepSets
|
|
|
|
Stem() string
|
|
|
|
}
|
2019-09-17 06:50:45 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
var _ javaModule = (*java.Library)(nil)
|
2021-01-11 19:58:54 +01:00
|
|
|
var _ javaModule = (*java.Import)(nil)
|
2020-11-19 06:37:47 +01:00
|
|
|
var _ javaModule = (*java.SdkLibrary)(nil)
|
|
|
|
var _ javaModule = (*java.DexImport)(nil)
|
|
|
|
var _ javaModule = (*java.SdkLibraryImport)(nil)
|
2019-11-15 10:40:32 +01:00
|
|
|
|
2021-04-26 11:33:59 +02:00
|
|
|
// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
|
2020-11-19 15:00:52 +01:00
|
|
|
func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile {
|
2021-09-15 04:34:04 +02:00
|
|
|
return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath().PathOrNil())
|
2021-04-26 11:33:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
|
|
|
|
func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
|
2020-11-19 06:37:47 +01:00
|
|
|
dirInApex := "javalib"
|
2021-04-26 11:33:59 +02:00
|
|
|
af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
|
2020-11-19 06:37:47 +01:00
|
|
|
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
|
|
|
|
af.lintDepSets = module.LintDepSets()
|
2020-11-19 15:00:52 +01:00
|
|
|
af.customStem = module.Stem() + ".jar"
|
2021-09-16 08:15:39 +02:00
|
|
|
if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
|
|
|
|
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
|
|
|
|
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
|
|
|
|
}
|
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return af
|
|
|
|
}
|
2019-11-12 05:03:50 +01:00
|
|
|
|
2023-02-07 18:19:19 +01:00
|
|
|
func apexFileForJavaModuleProfile(ctx android.BaseModuleContext, module javaModule) *apexFile {
|
|
|
|
if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
|
2023-02-08 14:56:07 +01:00
|
|
|
if profilePathOnHost := dexpreopter.OutputProfilePathOnHost(); profilePathOnHost != nil {
|
2023-02-07 18:19:19 +01:00
|
|
|
dirInApex := "javalib"
|
|
|
|
af := newApexFile(ctx, profilePathOnHost, module.BaseModuleName()+"-profile", dirInApex, etc, nil)
|
|
|
|
af.customStem = module.Stem() + ".jar.prof"
|
|
|
|
return &af
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in
|
|
|
|
// the same way.
|
|
|
|
type androidApp interface {
|
2020-11-19 06:37:47 +01:00
|
|
|
android.Module
|
|
|
|
Privileged() bool
|
|
|
|
InstallApkName() string
|
|
|
|
OutputFile() android.Path
|
|
|
|
JacocoReportClassesFile() android.Path
|
|
|
|
Certificate() java.Certificate
|
|
|
|
BaseModuleName() string
|
2021-08-11 04:24:07 +02:00
|
|
|
LintDepSets() java.LintDepSets
|
2022-08-17 18:53:46 +02:00
|
|
|
PrivAppAllowlist() android.OptionalPath
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ androidApp = (*java.AndroidApp)(nil)
|
|
|
|
var _ androidApp = (*java.AndroidAppImport)(nil)
|
|
|
|
|
2022-05-05 15:52:25 +02:00
|
|
|
func sanitizedBuildIdForPath(ctx android.BaseModuleContext) string {
|
|
|
|
buildId := ctx.Config().BuildId()
|
|
|
|
|
|
|
|
// The build ID is used as a suffix for a filename, so ensure that
|
|
|
|
// the set of characters being used are sanitized.
|
|
|
|
// - any word character: [a-zA-Z0-9_]
|
|
|
|
// - dots: .
|
|
|
|
// - dashes: -
|
|
|
|
validRegex := regexp.MustCompile(`^[\w\.\-\_]+$`)
|
|
|
|
if !validRegex.MatchString(buildId) {
|
|
|
|
ctx.ModuleErrorf("Unable to use build id %s as filename suffix, valid characters are [a-z A-Z 0-9 _ . -].", buildId)
|
|
|
|
}
|
|
|
|
return buildId
|
|
|
|
}
|
2022-04-19 15:57:01 +02:00
|
|
|
|
2022-08-17 18:53:46 +02:00
|
|
|
func apexFilesForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) []apexFile {
|
2020-11-19 06:37:47 +01:00
|
|
|
appDir := "app"
|
|
|
|
if aapp.Privileged() {
|
|
|
|
appDir = "priv-app"
|
|
|
|
}
|
2022-04-19 15:57:01 +02:00
|
|
|
|
|
|
|
// TODO(b/224589412, b/226559955): Ensure that the subdirname is suffixed
|
|
|
|
// so that PackageManager correctly invalidates the existing installed apk
|
|
|
|
// in favour of the new APK-in-APEX. See bugs for more information.
|
2022-05-05 15:52:25 +02:00
|
|
|
dirInApex := filepath.Join(appDir, aapp.InstallApkName()+"@"+sanitizedBuildIdForPath(ctx))
|
2020-11-19 06:37:47 +01:00
|
|
|
fileToCopy := aapp.OutputFile()
|
2022-04-19 15:57:01 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp)
|
|
|
|
af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
|
2021-08-11 04:24:07 +02:00
|
|
|
af.lintDepSets = aapp.LintDepSets()
|
2020-11-19 06:37:47 +01:00
|
|
|
af.certificate = aapp.Certificate()
|
2020-02-20 05:41:10 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
if app, ok := aapp.(interface {
|
|
|
|
OverriddenManifestPackageName() string
|
|
|
|
}); ok {
|
|
|
|
af.overriddenPackageName = app.OverriddenManifestPackageName()
|
|
|
|
}
|
2023-05-25 20:45:30 +02:00
|
|
|
|
|
|
|
apexFiles := []apexFile{}
|
2022-08-17 18:53:46 +02:00
|
|
|
|
|
|
|
if allowlist := aapp.PrivAppAllowlist(); allowlist.Valid() {
|
|
|
|
dirInApex := filepath.Join("etc", "permissions")
|
2023-05-25 20:45:30 +02:00
|
|
|
privAppAllowlist := newApexFile(ctx, allowlist.Path(), aapp.BaseModuleName()+"_privapp", dirInApex, etc, aapp)
|
2022-08-17 18:53:46 +02:00
|
|
|
apexFiles = append(apexFiles, privAppAllowlist)
|
|
|
|
}
|
|
|
|
|
2023-05-25 20:45:30 +02:00
|
|
|
apexFiles = append(apexFiles, af)
|
|
|
|
|
2022-08-17 18:53:46 +02:00
|
|
|
return apexFiles
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
2020-07-22 08:54:47 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile {
|
|
|
|
rroDir := "overlay"
|
|
|
|
dirInApex := filepath.Join(rroDir, rro.Theme())
|
|
|
|
fileToCopy := rro.OutputFile()
|
|
|
|
af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro)
|
|
|
|
af.certificate = rro.Certificate()
|
2020-06-12 14:46:59 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
if a, ok := rro.(interface {
|
|
|
|
OverriddenManifestPackageName() string
|
|
|
|
}); ok {
|
|
|
|
af.overriddenPackageName = a.OverriddenManifestPackageName()
|
|
|
|
}
|
|
|
|
return af
|
2019-01-30 03:07:33 +01:00
|
|
|
}
|
|
|
|
|
2021-11-10 15:02:57 +01:00
|
|
|
func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, apex_sub_dir string, bpfProgram bpf.BpfModule) apexFile {
|
|
|
|
dirInApex := filepath.Join("etc", "bpf", apex_sub_dir)
|
2020-11-19 06:37:47 +01:00
|
|
|
return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram)
|
2020-09-16 03:30:11 +02:00
|
|
|
}
|
|
|
|
|
2021-01-07 07:31:24 +01:00
|
|
|
func apexFileForFilesystem(ctx android.BaseModuleContext, buildFile android.Path, fs filesystem.Filesystem) apexFile {
|
|
|
|
dirInApex := filepath.Join("etc", "fs")
|
|
|
|
return newApexFile(ctx, buildFile, buildFile.Base(), dirInApex, etc, fs)
|
|
|
|
}
|
|
|
|
|
2020-11-02 18:32:38 +01:00
|
|
|
// WalkPayloadDeps visits dependencies that contributes to the payload of this APEX. For each of the
|
2020-11-19 15:00:52 +01:00
|
|
|
// visited module, the `do` callback is executed. Returning true in the callback continues the visit
|
|
|
|
// to the child modules. Returning false makes the visit to continue in the sibling or the parent
|
|
|
|
// modules. This is used in check* functions below.
|
2020-11-19 06:37:47 +01:00
|
|
|
func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) {
|
|
|
|
ctx.WalkDeps(func(child, parent android.Module) bool {
|
|
|
|
am, ok := child.(android.ApexModule)
|
|
|
|
if !ok || !am.CanHaveApexVariants() {
|
|
|
|
return false
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
2019-08-23 04:17:39 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Filter-out unwanted depedendencies
|
|
|
|
depTag := ctx.OtherModuleDependencyTag(child)
|
|
|
|
if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
|
2020-11-19 06:37:47 +01:00
|
|
|
return false
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
2022-05-13 15:01:59 +02:00
|
|
|
if dt, ok := depTag.(*dependencyTag); ok && !dt.payload {
|
2020-11-19 06:37:47 +01:00
|
|
|
return false
|
|
|
|
}
|
2019-11-15 10:40:32 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
|
2021-05-12 10:13:56 +02:00
|
|
|
externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants)
|
2018-11-30 02:12:15 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Visit actually
|
|
|
|
return do(ctx, parent, am, externalDep)
|
2020-11-19 06:37:47 +01:00
|
|
|
})
|
2018-11-30 02:12:15 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// filesystem type of the apex_payload.img inside the APEX. Currently, ext4 and f2fs are supported.
|
|
|
|
type fsType int
|
2020-11-19 06:37:47 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
const (
|
|
|
|
ext4 fsType = iota
|
|
|
|
f2fs
|
2021-08-02 09:02:17 +02:00
|
|
|
erofs
|
2020-11-19 15:00:52 +01:00
|
|
|
)
|
2018-11-30 02:12:15 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
func (f fsType) string() string {
|
|
|
|
switch f {
|
|
|
|
case ext4:
|
|
|
|
return ext4FsType
|
|
|
|
case f2fs:
|
|
|
|
return f2fsFsType
|
2021-08-02 09:02:17 +02:00
|
|
|
case erofs:
|
|
|
|
return erofsFsType
|
2020-11-19 15:00:52 +01:00
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown APEX payload type %d", f))
|
2020-11-19 06:37:47 +01:00
|
|
|
}
|
2018-11-07 18:50:25 +01:00
|
|
|
}
|
|
|
|
|
2022-07-27 23:51:45 +02:00
|
|
|
var _ android.MixedBuildBuildable = (*apexBundle)(nil)
|
|
|
|
|
|
|
|
func (a *apexBundle) IsMixedBuildSupported(ctx android.BaseModuleContext) bool {
|
2023-08-23 04:11:43 +02:00
|
|
|
return true
|
2022-07-27 23:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) QueueBazelCall(ctx android.BaseModuleContext) {
|
|
|
|
bazelCtx := ctx.Config().BazelContext
|
|
|
|
bazelCtx.QueueBazelRequest(a.GetBazelLabel(ctx, a), cquery.GetApexInfo, android.GetConfigKey(ctx))
|
|
|
|
}
|
|
|
|
|
2022-12-16 09:16:01 +01:00
|
|
|
// GetBazelLabel returns the bazel label of this apexBundle, or the label of the
|
|
|
|
// override_apex module overriding this apexBundle. An apexBundle can be
|
|
|
|
// overridden by different override_apex modules (e.g. Google or Go variants),
|
|
|
|
// which is handled by the overrides mutators.
|
|
|
|
func (a *apexBundle) GetBazelLabel(ctx android.BazelConversionPathContext, module blueprint.Module) string {
|
|
|
|
return a.BazelModuleBase.GetBazelLabel(ctx, a)
|
|
|
|
}
|
|
|
|
|
2022-07-27 23:51:45 +02:00
|
|
|
func (a *apexBundle) ProcessBazelQueryResponse(ctx android.ModuleContext) {
|
|
|
|
if !a.commonBuildActions(ctx) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
a.setPayloadFsType(ctx)
|
|
|
|
a.setSystemLibLink(ctx)
|
2023-08-23 04:11:43 +02:00
|
|
|
a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
|
2022-07-27 23:51:45 +02:00
|
|
|
|
|
|
|
bazelCtx := ctx.Config().BazelContext
|
|
|
|
outputs, err := bazelCtx.GetApexInfo(a.GetBazelLabel(ctx, a), android.GetConfigKey(ctx))
|
|
|
|
if err != nil {
|
|
|
|
ctx.ModuleErrorf(err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
2023-01-10 15:50:42 +01:00
|
|
|
|
|
|
|
// Set the output file to .apex or .capex depending on the compression configuration.
|
2022-07-27 23:51:45 +02:00
|
|
|
a.setCompression(ctx)
|
2023-01-10 15:50:42 +01:00
|
|
|
if a.isCompressed {
|
2023-04-03 23:28:36 +02:00
|
|
|
a.outputApexFile = android.PathForBazelOutRelative(ctx, ctx.ModuleDir(), outputs.SignedCompressedOutput)
|
2023-01-10 15:50:42 +01:00
|
|
|
} else {
|
2023-04-03 23:28:36 +02:00
|
|
|
a.outputApexFile = android.PathForBazelOutRelative(ctx, ctx.ModuleDir(), outputs.SignedOutput)
|
2023-01-10 15:50:42 +01:00
|
|
|
}
|
|
|
|
a.outputFile = a.outputApexFile
|
2022-07-27 23:51:45 +02:00
|
|
|
|
2023-02-04 00:12:15 +01:00
|
|
|
if len(outputs.TidyFiles) > 0 {
|
|
|
|
tidyFiles := android.PathsForBazelOut(ctx, outputs.TidyFiles)
|
|
|
|
a.outputFile = android.AttachValidationActions(ctx, a.outputFile, tidyFiles)
|
|
|
|
}
|
|
|
|
|
2022-11-04 21:07:04 +01:00
|
|
|
// TODO(b/257829940): These are used by the apex_keys_text singleton; would probably be a clearer
|
|
|
|
// interface if these were set in a provider rather than the module itself
|
2022-10-27 07:30:48 +02:00
|
|
|
a.publicKeyFile = android.PathForBazelOut(ctx, outputs.BundleKeyInfo[0])
|
|
|
|
a.privateKeyFile = android.PathForBazelOut(ctx, outputs.BundleKeyInfo[1])
|
|
|
|
a.containerCertificateFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[0])
|
|
|
|
a.containerPrivateKeyFile = android.PathForBazelOut(ctx, outputs.ContainerKeyInfo[1])
|
2022-11-04 21:07:04 +01:00
|
|
|
|
2023-01-25 18:49:46 +01:00
|
|
|
// Ensure ApexMkInfo.install_to_system make module names are installed as
|
|
|
|
// part of a bundled build.
|
|
|
|
a.makeModulesToInstall = append(a.makeModulesToInstall, outputs.MakeModulesToInstall...)
|
2022-12-14 17:34:54 +01:00
|
|
|
|
2023-08-23 04:11:43 +02:00
|
|
|
a.bundleModuleFile = android.PathForBazelOut(ctx, outputs.BundleFile)
|
|
|
|
a.nativeApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.SymbolsUsedByApex))
|
|
|
|
a.nativeApisBackedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.BackingLibs))
|
|
|
|
// TODO(b/239084755): Generate the java api using.xml file from Bazel.
|
|
|
|
a.javaApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.JavaSymbolsUsedByApex))
|
|
|
|
a.installedFilesFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.InstalledFiles))
|
|
|
|
installSuffix := imageApexSuffix
|
|
|
|
if a.isCompressed {
|
|
|
|
installSuffix = imageCapexSuffix
|
2022-07-27 23:51:45 +02:00
|
|
|
}
|
2023-08-23 04:11:43 +02:00
|
|
|
a.installedFile = ctx.InstallFile(a.installDir, a.Name()+installSuffix, a.outputFile,
|
2023-11-15 21:29:33 +01:00
|
|
|
a.compatSymlinks...)
|
2022-07-27 23:51:45 +02:00
|
|
|
|
2023-03-14 17:11:38 +01:00
|
|
|
// filesInfo in mixed mode must retrieve all information about the apex's
|
|
|
|
// contents completely from the Starlark providers. It should never rely on
|
|
|
|
// Android.bp information, as they might not exist for fully migrated
|
|
|
|
// dependencies.
|
2023-02-03 11:31:08 +01:00
|
|
|
//
|
|
|
|
// Prevent accidental writes to filesInfo in the earlier parts Soong by
|
|
|
|
// asserting it to be nil.
|
|
|
|
if a.filesInfo != nil {
|
2023-03-14 17:11:38 +01:00
|
|
|
panic(
|
|
|
|
fmt.Errorf("internal error: filesInfo must be nil for an apex handled by Bazel. " +
|
|
|
|
"Did something else set filesInfo before this line of code?"))
|
|
|
|
}
|
|
|
|
for _, f := range outputs.PayloadFilesInfo {
|
|
|
|
fileInfo := apexFile{
|
|
|
|
isBazelPrebuilt: true,
|
|
|
|
|
|
|
|
builtFile: android.PathForBazelOut(ctx, f["built_file"]),
|
|
|
|
unstrippedBuiltFile: android.PathForBazelOut(ctx, f["unstripped_built_file"]),
|
|
|
|
androidMkModuleName: f["make_module_name"],
|
|
|
|
installDir: f["install_dir"],
|
|
|
|
class: classes[f["class"]],
|
|
|
|
customStem: f["basename"],
|
|
|
|
moduleDir: f["package"],
|
|
|
|
}
|
|
|
|
|
|
|
|
arch := f["arch"]
|
|
|
|
fileInfo.arch = arch
|
|
|
|
if len(arch) > 0 {
|
|
|
|
fileInfo.multilib = "lib32"
|
|
|
|
if strings.HasSuffix(arch, "64") {
|
|
|
|
fileInfo.multilib = "lib64"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
a.filesInfo = append(a.filesInfo, fileInfo)
|
2023-02-03 11:31:08 +01:00
|
|
|
}
|
2023-10-30 08:17:56 +01:00
|
|
|
a.apexKeysPath = writeApexKeys(ctx, a)
|
2022-07-27 23:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) setCompression(ctx android.ModuleContext) {
|
2023-08-23 04:11:43 +02:00
|
|
|
if a.testOnlyShouldForceCompression() {
|
2022-07-27 23:51:45 +02:00
|
|
|
a.isCompressed = true
|
|
|
|
} else {
|
|
|
|
a.isCompressed = ctx.Config().ApexCompressionEnabled() && a.isCompressable()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) setSystemLibLink(ctx android.ModuleContext) {
|
|
|
|
// Optimization. If we are building bundled APEX, for the files that are gathered due to the
|
|
|
|
// transitive dependencies, don't place them inside the APEX, but place a symlink pointing
|
|
|
|
// the same library in the system partition, thus effectively sharing the same libraries
|
|
|
|
// across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
|
|
|
|
// in the APEX.
|
|
|
|
a.linkToSystemLib = !ctx.Config().UnbundledBuild() && a.installable()
|
|
|
|
|
|
|
|
// APEXes targeting other than system/system_ext partitions use vendor/product variants.
|
|
|
|
// So we can't link them to /system/lib libs which are core variants.
|
|
|
|
if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
|
|
|
|
a.linkToSystemLib = false
|
|
|
|
}
|
|
|
|
|
|
|
|
forced := ctx.Config().ForceApexSymlinkOptimization()
|
|
|
|
updatable := a.Updatable() || a.FutureUpdatable()
|
|
|
|
|
|
|
|
// We don't need the optimization for updatable APEXes, as it might give false signal
|
|
|
|
// to the system health when the APEXes are still bundled (b/149805758).
|
2023-08-23 04:11:43 +02:00
|
|
|
if !forced && updatable {
|
2022-07-27 23:51:45 +02:00
|
|
|
a.linkToSystemLib = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) setPayloadFsType(ctx android.ModuleContext) {
|
|
|
|
switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) {
|
|
|
|
case ext4FsType:
|
|
|
|
a.payloadFsType = ext4
|
|
|
|
case f2fsFsType:
|
|
|
|
a.payloadFsType = f2fs
|
|
|
|
case erofsFsType:
|
|
|
|
a.payloadFsType = erofs
|
|
|
|
default:
|
|
|
|
ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs, erofs]", *a.properties.Payload_fs_type)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-20 09:25:59 +02:00
|
|
|
func (a *apexBundle) isCompressable() bool {
|
2022-07-27 23:51:45 +02:00
|
|
|
return proptools.BoolDefault(a.overridableProperties.Compressible, false) && !a.testApex
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) commonBuildActions(ctx android.ModuleContext) bool {
|
|
|
|
a.checkApexAvailability(ctx)
|
|
|
|
a.checkUpdatable(ctx)
|
|
|
|
a.CheckMinSdkVersion(ctx)
|
|
|
|
a.checkStaticLinkingToStubLibraries(ctx)
|
|
|
|
a.checkStaticExecutables(ctx)
|
|
|
|
if len(a.properties.Tests) > 0 && !a.testApex {
|
|
|
|
ctx.PropertyErrorf("tests", "property allowed only in apex_test module type")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-06-29 07:43:04 +02:00
|
|
|
type visitorContext struct {
|
|
|
|
// all the files that will be included in this APEX
|
|
|
|
filesInfo []apexFile
|
|
|
|
|
|
|
|
// native lib dependencies
|
|
|
|
provideNativeLibs []string
|
|
|
|
requireNativeLibs []string
|
|
|
|
|
|
|
|
handleSpecialLibs bool
|
2022-12-21 02:15:37 +01:00
|
|
|
|
|
|
|
// if true, raise error on duplicate apexFile
|
|
|
|
checkDuplicate bool
|
2023-11-02 03:56:48 +01:00
|
|
|
|
|
|
|
// visitor skips these from this list of module names
|
|
|
|
unwantedTransitiveDeps []string
|
2023-11-17 02:05:47 +01:00
|
|
|
|
|
|
|
aconfigFiles []android.Path
|
2022-06-29 07:43:04 +02:00
|
|
|
}
|
|
|
|
|
2022-12-21 02:15:37 +01:00
|
|
|
func (vctx *visitorContext) normalizeFileInfo(mctx android.ModuleContext) {
|
2022-06-29 07:43:04 +02:00
|
|
|
encountered := make(map[string]apexFile)
|
|
|
|
for _, f := range vctx.filesInfo {
|
2023-11-02 03:56:48 +01:00
|
|
|
// Skips unwanted transitive deps. This happens, for example, with Rust binaries with prefer_rlib:true.
|
|
|
|
// TODO(b/295593640)
|
|
|
|
// Needs additional verification for the resulting APEX to ensure that skipped artifacts don't make problems.
|
|
|
|
// For example, DT_NEEDED modules should be found within the APEX unless they are marked in `requiredNativeLibs`.
|
|
|
|
if f.transitiveDep && f.module != nil && android.InList(mctx.OtherModuleName(f.module), vctx.unwantedTransitiveDeps) {
|
|
|
|
continue
|
|
|
|
}
|
2022-06-29 07:43:04 +02:00
|
|
|
dest := filepath.Join(f.installDir, f.builtFile.Base())
|
|
|
|
if e, ok := encountered[dest]; !ok {
|
|
|
|
encountered[dest] = f
|
|
|
|
} else {
|
2022-12-21 02:15:37 +01:00
|
|
|
if vctx.checkDuplicate && f.builtFile.String() != e.builtFile.String() {
|
|
|
|
mctx.ModuleErrorf("apex file %v is provided by two different files %v and %v",
|
|
|
|
dest, e.builtFile, f.builtFile)
|
|
|
|
return
|
|
|
|
}
|
2022-06-29 07:43:04 +02:00
|
|
|
// If a module is directly included and also transitively depended on
|
|
|
|
// consider it as directly included.
|
|
|
|
e.transitiveDep = e.transitiveDep && f.transitiveDep
|
2023-09-05 16:19:21 +02:00
|
|
|
// If a module is added as both a JNI library and a regular shared library, consider it as a
|
|
|
|
// JNI library.
|
|
|
|
e.isJniLib = e.isJniLib || f.isJniLib
|
2022-06-29 07:43:04 +02:00
|
|
|
encountered[dest] = e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vctx.filesInfo = vctx.filesInfo[:0]
|
|
|
|
for _, v := range encountered {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, v)
|
|
|
|
}
|
|
|
|
sort.Slice(vctx.filesInfo, func(i, j int) bool {
|
|
|
|
// Sort by destination path so as to ensure consistent ordering even if the source of the files
|
|
|
|
// changes.
|
|
|
|
return vctx.filesInfo[i].path() < vctx.filesInfo[j].path()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, child, parent blueprint.Module) bool {
|
|
|
|
depTag := ctx.OtherModuleDependencyTag(child)
|
|
|
|
if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if mod, ok := child.(android.Module); ok && !mod.Enabled() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
depName := ctx.OtherModuleName(child)
|
|
|
|
if _, isDirectDep := parent.(*apexBundle); isDirectDep {
|
|
|
|
switch depTag {
|
|
|
|
case sharedLibTag, jniLibTag:
|
|
|
|
isJniLib := depTag == jniLibTag
|
2023-12-05 07:23:56 +01:00
|
|
|
propertyName := "native_shared_libs"
|
|
|
|
if isJniLib {
|
|
|
|
propertyName = "jni_libs"
|
|
|
|
}
|
2022-06-29 07:43:04 +02:00
|
|
|
switch ch := child.(type) {
|
|
|
|
case *cc.Module:
|
2023-12-05 07:23:56 +01:00
|
|
|
if ch.IsStubs() {
|
|
|
|
ctx.PropertyErrorf(propertyName, "%q is a stub. Remove it from the list.", depName)
|
|
|
|
}
|
2022-06-29 07:43:04 +02:00
|
|
|
fi := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
|
|
|
|
fi.isJniLib = isJniLib
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, fi)
|
2023-11-17 02:05:47 +01:00
|
|
|
addAconfigFiles(vctx, ctx, child)
|
2022-06-29 07:43:04 +02:00
|
|
|
// Collect the list of stub-providing libs except:
|
|
|
|
// - VNDK libs are only for vendors
|
|
|
|
// - bootstrap bionic libs are treated as provided by system
|
|
|
|
if ch.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(ch.BaseModuleName(), ctx.Config()) {
|
|
|
|
vctx.provideNativeLibs = append(vctx.provideNativeLibs, fi.stem())
|
|
|
|
}
|
|
|
|
return true // track transitive dependencies
|
|
|
|
case *rust.Module:
|
|
|
|
fi := apexFileForRustLibrary(ctx, ch)
|
|
|
|
fi.isJniLib = isJniLib
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, fi)
|
|
|
|
return true // track transitive dependencies
|
|
|
|
default:
|
|
|
|
ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
|
|
|
|
}
|
|
|
|
case executableTag:
|
|
|
|
switch ch := child.(type) {
|
|
|
|
case *cc.Module:
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, ch))
|
2023-11-17 02:05:47 +01:00
|
|
|
addAconfigFiles(vctx, ctx, child)
|
2022-06-29 07:43:04 +02:00
|
|
|
return true // track transitive dependencies
|
|
|
|
case *rust.Module:
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, ch))
|
|
|
|
return true // track transitive dependencies
|
|
|
|
default:
|
|
|
|
ctx.PropertyErrorf("binaries",
|
|
|
|
"%q is neither cc_binary, rust_binary, (embedded) py_binary, (host) blueprint_go_binary, nor (host) bootstrap_go_binary", depName)
|
|
|
|
}
|
|
|
|
case shBinaryTag:
|
|
|
|
if csh, ok := child.(*sh.ShBinary); ok {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForShBinary(ctx, csh))
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName)
|
|
|
|
}
|
|
|
|
case bcpfTag:
|
2023-05-10 17:40:18 +02:00
|
|
|
_, ok := child.(*java.BootclasspathFragmentModule)
|
2022-06-29 07:43:04 +02:00
|
|
|
if !ok {
|
|
|
|
ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a bootclasspath_fragment module", depName)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexBootclasspathFragmentFiles(ctx, child)...)
|
|
|
|
return true
|
|
|
|
case sscpfTag:
|
|
|
|
if _, ok := child.(*java.SystemServerClasspathModule); !ok {
|
|
|
|
ctx.PropertyErrorf("systemserverclasspath_fragments",
|
|
|
|
"%q is not a systemserverclasspath_fragment module", depName)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if af := apexClasspathFragmentProtoFile(ctx, child); af != nil {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, *af)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
case javaLibTag:
|
|
|
|
switch child.(type) {
|
|
|
|
case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport, *java.Import:
|
|
|
|
af := apexFileForJavaModule(ctx, child.(javaModule))
|
|
|
|
if !af.ok() {
|
|
|
|
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
2023-11-17 02:05:47 +01:00
|
|
|
addAconfigFiles(vctx, ctx, child)
|
2022-06-29 07:43:04 +02:00
|
|
|
return true // track transitive dependencies
|
|
|
|
default:
|
|
|
|
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
|
|
|
}
|
|
|
|
case androidAppTag:
|
|
|
|
switch ap := child.(type) {
|
|
|
|
case *java.AndroidApp:
|
2022-08-17 18:53:46 +02:00
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...)
|
2023-11-17 02:05:47 +01:00
|
|
|
addAconfigFiles(vctx, ctx, child)
|
2022-06-29 07:43:04 +02:00
|
|
|
return true // track transitive dependencies
|
|
|
|
case *java.AndroidAppImport:
|
2022-08-17 18:53:46 +02:00
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...)
|
2022-06-29 07:43:04 +02:00
|
|
|
case *java.AndroidTestHelperApp:
|
2022-08-17 18:53:46 +02:00
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...)
|
2022-06-29 07:43:04 +02:00
|
|
|
case *java.AndroidAppSet:
|
|
|
|
appDir := "app"
|
|
|
|
if ap.Privileged() {
|
|
|
|
appDir = "priv-app"
|
|
|
|
}
|
|
|
|
// TODO(b/224589412, b/226559955): Ensure that the dirname is
|
|
|
|
// suffixed so that PackageManager correctly invalidates the
|
|
|
|
// existing installed apk in favour of the new APK-in-APEX.
|
|
|
|
// See bugs for more information.
|
|
|
|
appDirName := filepath.Join(appDir, ap.BaseModuleName()+"@"+sanitizedBuildIdForPath(ctx))
|
|
|
|
af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap)
|
|
|
|
af.certificate = java.PresignedCertificate
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
|
|
|
default:
|
|
|
|
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
|
|
|
|
}
|
|
|
|
case rroTag:
|
|
|
|
if rro, ok := child.(java.RuntimeResourceOverlayModule); ok {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro))
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
|
|
|
|
}
|
|
|
|
case bpfTag:
|
|
|
|
if bpfProgram, ok := child.(bpf.BpfModule); ok {
|
|
|
|
filesToCopy, _ := bpfProgram.OutputFiles("")
|
|
|
|
apex_sub_dir := bpfProgram.SubDir()
|
|
|
|
for _, bpfFile := range filesToCopy {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForBpfProgram(ctx, bpfFile, apex_sub_dir, bpfProgram))
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName)
|
|
|
|
}
|
|
|
|
case fsTag:
|
|
|
|
if fs, ok := child.(filesystem.Filesystem); ok {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForFilesystem(ctx, fs.OutputPath(), fs))
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("filesystems", "%q is not a filesystem module", depName)
|
|
|
|
}
|
|
|
|
case prebuiltTag:
|
|
|
|
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
|
|
|
|
}
|
|
|
|
case compatConfigTag:
|
|
|
|
if compatConfig, ok := child.(java.PlatformCompatConfigIntf); ok {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForCompatConfig(ctx, compatConfig, depName))
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("compat_configs", "%q is not a platform_compat_config module", depName)
|
|
|
|
}
|
|
|
|
case testTag:
|
|
|
|
if ccTest, ok := child.(*cc.Module); ok {
|
|
|
|
if ccTest.IsTestPerSrcAllTestsVariation() {
|
|
|
|
// Multiple-output test module (where `test_per_src: true`).
|
|
|
|
//
|
|
|
|
// `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
|
|
|
|
// We do not add this variation to `filesInfo`, as it has no output;
|
|
|
|
// however, we do add the other variations of this module as indirect
|
|
|
|
// dependencies (see below).
|
|
|
|
} else {
|
|
|
|
// Single-output test module (where `test_per_src: false`).
|
|
|
|
af := apexFileForExecutable(ctx, ccTest)
|
|
|
|
af.class = nativeTest
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
|
|
|
}
|
|
|
|
return true // track transitive dependencies
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
|
|
|
|
}
|
|
|
|
case keyTag:
|
|
|
|
if key, ok := child.(*apexKey); ok {
|
|
|
|
a.privateKeyFile = key.privateKeyFile
|
|
|
|
a.publicKeyFile = key.publicKeyFile
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
|
|
|
|
}
|
|
|
|
case certificateTag:
|
|
|
|
if dep, ok := child.(*java.AndroidAppCertificate); ok {
|
|
|
|
a.containerCertificateFile = dep.Certificate.Pem
|
|
|
|
a.containerPrivateKeyFile = dep.Certificate.Key
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.vndkApex {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// indirect dependencies
|
|
|
|
am, ok := child.(android.ApexModule)
|
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
// We cannot use a switch statement on `depTag` here as the checked
|
|
|
|
// tags used below are private (e.g. `cc.sharedDepTag`).
|
|
|
|
if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
|
|
|
|
if ch, ok := child.(*cc.Module); ok {
|
2023-07-26 05:39:19 +02:00
|
|
|
if ch.UseVndk() && a.useVndkAsStable(ctx) && ch.IsVndk() {
|
2022-06-29 07:43:04 +02:00
|
|
|
vctx.requireNativeLibs = append(vctx.requireNativeLibs, ":vndk")
|
|
|
|
return false
|
|
|
|
}
|
2023-09-07 09:00:04 +02:00
|
|
|
|
|
|
|
//TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
|
|
|
|
if ch.UseVndk() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
|
|
|
|
return false
|
|
|
|
}
|
2022-06-29 07:43:04 +02:00
|
|
|
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
|
|
|
|
af.transitiveDep = true
|
|
|
|
|
|
|
|
abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
|
|
|
|
if !abInfo.Contents.DirectlyInApex(depName) && (ch.IsStubs() || ch.HasStubsVariants()) {
|
|
|
|
// If the dependency is a stubs lib, don't include it in this APEX,
|
|
|
|
// but make sure that the lib is installed on the device.
|
|
|
|
// In case no APEX is having the lib, the lib is installed to the system
|
|
|
|
// partition.
|
|
|
|
//
|
|
|
|
// Always include if we are a host-apex however since those won't have any
|
|
|
|
// system libraries.
|
2023-01-27 00:39:15 +01:00
|
|
|
//
|
|
|
|
// Skip the dependency in unbundled builds where the device image is not
|
|
|
|
// being built.
|
|
|
|
if ch.IsStubsImplementationRequired() && !am.DirectlyInAnyApex() && !ctx.Config().UnbundledBuild() {
|
2022-06-29 07:43:04 +02:00
|
|
|
// we need a module name for Make
|
|
|
|
name := ch.ImplementationModuleNameForMake(ctx) + ch.Properties.SubName
|
2023-01-25 18:49:46 +01:00
|
|
|
if !android.InList(name, a.makeModulesToInstall) {
|
|
|
|
a.makeModulesToInstall = append(a.makeModulesToInstall, name)
|
2022-06-29 07:43:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
vctx.requireNativeLibs = append(vctx.requireNativeLibs, af.stem())
|
|
|
|
// Don't track further
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the dep is not considered to be in the same
|
|
|
|
// apex, don't add it to filesInfo so that it is not
|
|
|
|
// included in this APEX.
|
|
|
|
// TODO(jiyong): move this to at the top of the
|
|
|
|
// else-if clause for the indirect dependencies.
|
|
|
|
// Currently, that's impossible because we would
|
|
|
|
// like to record requiredNativeLibs even when
|
|
|
|
// DepIsInSameAPex is false. We also shouldn't do
|
|
|
|
// this for host.
|
|
|
|
//
|
|
|
|
// TODO(jiyong): explain why the same module is passed in twice.
|
|
|
|
// Switching the first am to parent breaks lots of tests.
|
|
|
|
if !android.IsDepInSameApex(ctx, am, am) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
2023-11-17 02:05:47 +01:00
|
|
|
addAconfigFiles(vctx, ctx, child)
|
2022-06-29 07:43:04 +02:00
|
|
|
return true // track transitive dependencies
|
|
|
|
} else if rm, ok := child.(*rust.Module); ok {
|
|
|
|
af := apexFileForRustLibrary(ctx, rm)
|
|
|
|
af.transitiveDep = true
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
|
|
|
return true // track transitive dependencies
|
|
|
|
}
|
|
|
|
} else if cc.IsTestPerSrcDepTag(depTag) {
|
|
|
|
if ch, ok := child.(*cc.Module); ok {
|
|
|
|
af := apexFileForExecutable(ctx, ch)
|
|
|
|
// Handle modules created as `test_per_src` variations of a single test module:
|
|
|
|
// use the name of the generated test binary (`fileToCopy`) instead of the name
|
|
|
|
// of the original test module (`depName`, shared by all `test_per_src`
|
|
|
|
// variations of that module).
|
|
|
|
af.androidMkModuleName = filepath.Base(af.builtFile.String())
|
|
|
|
// these are not considered transitive dep
|
|
|
|
af.transitiveDep = false
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
|
|
|
return true // track transitive dependencies
|
|
|
|
}
|
|
|
|
} else if cc.IsHeaderDepTag(depTag) {
|
|
|
|
// nothing
|
|
|
|
} else if java.IsJniDepTag(depTag) {
|
|
|
|
// Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
|
|
|
|
} else if java.IsXmlPermissionsFileDepTag(depTag) {
|
|
|
|
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
|
|
|
|
}
|
|
|
|
} else if rust.IsDylibDepTag(depTag) {
|
|
|
|
if rustm, ok := child.(*rust.Module); ok && rustm.IsInstallableToApex() {
|
|
|
|
af := apexFileForRustLibrary(ctx, rustm)
|
|
|
|
af.transitiveDep = true
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
|
|
|
return true // track transitive dependencies
|
|
|
|
}
|
|
|
|
} else if rust.IsRlibDepTag(depTag) {
|
|
|
|
// Rlib is statically linked, but it might have shared lib
|
|
|
|
// dependencies. Track them.
|
|
|
|
return true
|
|
|
|
} else if java.IsBootclasspathFragmentContentDepTag(depTag) {
|
|
|
|
// Add the contents of the bootclasspath fragment to the apex.
|
|
|
|
switch child.(type) {
|
|
|
|
case *java.Library, *java.SdkLibrary:
|
|
|
|
javaModule := child.(javaModule)
|
|
|
|
af := apexFileForBootclasspathFragmentContentModule(ctx, parent, javaModule)
|
|
|
|
if !af.ok() {
|
|
|
|
ctx.PropertyErrorf("bootclasspath_fragments",
|
|
|
|
"bootclasspath_fragment content %q is not configured to be compiled into dex", depName)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
|
|
|
return true // track transitive dependencies
|
|
|
|
default:
|
|
|
|
ctx.PropertyErrorf("bootclasspath_fragments",
|
|
|
|
"bootclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
|
|
|
}
|
|
|
|
} else if java.IsSystemServerClasspathFragmentContentDepTag(depTag) {
|
|
|
|
// Add the contents of the systemserverclasspath fragment to the apex.
|
|
|
|
switch child.(type) {
|
|
|
|
case *java.Library, *java.SdkLibrary:
|
|
|
|
af := apexFileForJavaModule(ctx, child.(javaModule))
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
2023-02-07 18:19:19 +01:00
|
|
|
if profileAf := apexFileForJavaModuleProfile(ctx, child.(javaModule)); profileAf != nil {
|
|
|
|
vctx.filesInfo = append(vctx.filesInfo, *profileAf)
|
|
|
|
}
|
2022-06-29 07:43:04 +02:00
|
|
|
return true // track transitive dependencies
|
|
|
|
default:
|
|
|
|
ctx.PropertyErrorf("systemserverclasspath_fragments",
|
|
|
|
"systemserverclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
|
|
|
}
|
|
|
|
} else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok {
|
|
|
|
// nothing
|
|
|
|
} else if depTag == android.DarwinUniversalVariantTag {
|
|
|
|
// nothing
|
|
|
|
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
|
|
|
|
ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2023-11-17 02:05:47 +01:00
|
|
|
func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) {
|
|
|
|
dep := ctx.OtherModuleProvider(module, aconfig.TransitiveDeclarationsInfoProvider).(aconfig.TransitiveDeclarationsInfo)
|
|
|
|
if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil {
|
|
|
|
vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()].ToList()...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-21 02:15:37 +01:00
|
|
|
func (a *apexBundle) shouldCheckDuplicate(ctx android.ModuleContext) bool {
|
|
|
|
// TODO(b/263308293) remove this
|
|
|
|
if a.properties.IsCoverageVariant {
|
|
|
|
return false
|
|
|
|
}
|
2023-08-23 06:54:08 +02:00
|
|
|
if ctx.DeviceConfig().DeviceArch() == "" {
|
2022-12-21 02:15:37 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// Creates build rules for an APEX. It consists of the following major steps:
|
|
|
|
//
|
|
|
|
// 1) do some validity checks such as apex_available, min_sdk_version, etc.
|
|
|
|
// 2) traverse the dependency tree to collect apexFile structs from them.
|
|
|
|
// 3) some fields in apexBundle struct are configured
|
|
|
|
// 4) generate the build rules to create the APEX. This is mostly done in builder.go.
|
|
|
|
func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 1) do some validity checks such as apex_available, min_sdk_version, etc.
|
2022-07-27 23:51:45 +02:00
|
|
|
if !a.commonBuildActions(ctx) {
|
2020-11-19 06:37:47 +01:00
|
|
|
return
|
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 2) traverse the dependency tree to collect apexFile structs from them.
|
2021-06-07 16:49:13 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// TODO(jiyong): do this using WalkPayloadDeps
|
|
|
|
// TODO(jiyong): make this clean!!!
|
2022-12-21 02:15:37 +01:00
|
|
|
vctx := visitorContext{
|
2023-11-02 03:56:48 +01:00
|
|
|
handleSpecialLibs: !android.Bool(a.properties.Ignore_system_library_special_case),
|
|
|
|
checkDuplicate: a.shouldCheckDuplicate(ctx),
|
|
|
|
unwantedTransitiveDeps: a.properties.Unwanted_transitive_deps,
|
2022-12-21 02:15:37 +01:00
|
|
|
}
|
2022-06-29 07:43:04 +02:00
|
|
|
ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { return a.depVisitor(&vctx, ctx, child, parent) })
|
2022-12-21 02:15:37 +01:00
|
|
|
vctx.normalizeFileInfo(ctx)
|
2020-12-21 18:11:10 +01:00
|
|
|
if a.privateKeyFile == nil {
|
2023-05-15 11:46:38 +02:00
|
|
|
if ctx.Config().AllowMissingDependencies() {
|
|
|
|
// TODO(b/266099037): a better approach for slim manifests.
|
|
|
|
ctx.AddMissingDependencies([]string{String(a.overridableProperties.Key)})
|
|
|
|
// Create placeholder paths for later stages that expect to see those paths,
|
|
|
|
// though they won't be used.
|
|
|
|
var unusedPath = android.PathForModuleOut(ctx, "nonexistentprivatekey")
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.ErrorRule,
|
|
|
|
Output: unusedPath,
|
|
|
|
Args: map[string]string{
|
|
|
|
"error": "Private key not available",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
a.privateKeyFile = unusedPath
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.overridableProperties.Key))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.publicKeyFile == nil {
|
|
|
|
if ctx.Config().AllowMissingDependencies() {
|
|
|
|
// TODO(b/266099037): a better approach for slim manifests.
|
|
|
|
ctx.AddMissingDependencies([]string{String(a.overridableProperties.Key)})
|
|
|
|
// Create placeholder paths for later stages that expect to see those paths,
|
|
|
|
// though they won't be used.
|
|
|
|
var unusedPath = android.PathForModuleOut(ctx, "nonexistentpublickey")
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.ErrorRule,
|
|
|
|
Output: unusedPath,
|
|
|
|
Args: map[string]string{
|
|
|
|
"error": "Public key not available",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
a.publicKeyFile = unusedPath
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("key", "public_key for %q could not be found", String(a.overridableProperties.Key))
|
|
|
|
return
|
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
2019-11-19 18:26:02 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 3) some fields in apexBundle struct are configured
|
2020-11-19 06:37:47 +01:00
|
|
|
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
2022-06-29 07:43:04 +02:00
|
|
|
a.filesInfo = vctx.filesInfo
|
2023-11-17 02:05:47 +01:00
|
|
|
a.aconfigFiles = android.FirstUniquePaths(vctx.aconfigFiles)
|
2020-01-14 01:22:18 +01:00
|
|
|
|
2022-07-27 23:51:45 +02:00
|
|
|
a.setPayloadFsType(ctx)
|
|
|
|
a.setSystemLibLink(ctx)
|
2023-08-23 04:11:43 +02:00
|
|
|
a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
|
2020-08-22 01:15:23 +02:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 4) generate the build rules to create the APEX. This is done in builder.go.
|
2022-06-29 07:43:04 +02:00
|
|
|
a.buildManifest(ctx, vctx.provideNativeLibs, vctx.requireNativeLibs)
|
2023-06-20 09:25:59 +02:00
|
|
|
a.buildApex(ctx)
|
2020-11-19 06:37:47 +01:00
|
|
|
a.buildApexDependencyInfo(ctx)
|
|
|
|
a.buildLintReports(ctx)
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 00:14:55 +02:00
|
|
|
// apexBootclasspathFragmentFiles returns the list of apexFile structures defining the files that
|
|
|
|
// the bootclasspath_fragment contributes to the apex.
|
|
|
|
func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint.Module) []apexFile {
|
|
|
|
bootclasspathFragmentInfo := ctx.OtherModuleProvider(module, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
|
|
|
|
var filesToAdd []apexFile
|
|
|
|
|
2021-05-07 00:59:58 +02:00
|
|
|
// Add classpaths.proto config.
|
2021-06-15 17:49:50 +02:00
|
|
|
if af := apexClasspathFragmentProtoFile(ctx, module); af != nil {
|
|
|
|
filesToAdd = append(filesToAdd, *af)
|
|
|
|
}
|
2021-05-07 00:59:58 +02:00
|
|
|
|
2022-11-16 15:52:41 +01:00
|
|
|
pathInApex := bootclasspathFragmentInfo.ProfileInstallPathInApex()
|
2023-05-08 18:28:38 +02:00
|
|
|
if pathInApex != "" {
|
2021-11-26 19:09:27 +01:00
|
|
|
pathOnHost := bootclasspathFragmentInfo.ProfilePathOnHost()
|
|
|
|
tempPath := android.PathForModuleOut(ctx, "boot_image_profile", pathInApex)
|
|
|
|
|
|
|
|
if pathOnHost != nil {
|
|
|
|
// We need to copy the profile to a temporary path with the right filename because the apexer
|
|
|
|
// will take the filename as is.
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Input: pathOnHost,
|
|
|
|
Output: tempPath,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
// At this point, the boot image profile cannot be generated. It is probably because the boot
|
|
|
|
// image profile source file does not exist on the branch, or it is not available for the
|
|
|
|
// current build target.
|
|
|
|
// However, we cannot enforce the boot image profile to be generated because some build
|
|
|
|
// targets (such as module SDK) do not need it. It is only needed when the APEX is being
|
|
|
|
// built. Therefore, we create an error rule so that an error will occur at the ninja phase
|
|
|
|
// only if the APEX is being built.
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.ErrorRule,
|
|
|
|
Output: tempPath,
|
|
|
|
Args: map[string]string{
|
|
|
|
"error": "Boot image profile cannot be generated",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
androidMkModuleName := filepath.Base(pathInApex)
|
|
|
|
af := newApexFile(ctx, tempPath, androidMkModuleName, filepath.Dir(pathInApex), etc, nil)
|
|
|
|
filesToAdd = append(filesToAdd, af)
|
|
|
|
}
|
|
|
|
|
2021-04-26 00:14:55 +02:00
|
|
|
return filesToAdd
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:49:50 +02:00
|
|
|
// apexClasspathFragmentProtoFile returns *apexFile structure defining the classpath.proto config that
|
|
|
|
// the module contributes to the apex; or nil if the proto config was not generated.
|
|
|
|
func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) *apexFile {
|
|
|
|
info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
|
|
|
|
if !info.ClasspathFragmentProtoGenerated {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
classpathProtoOutput := info.ClasspathFragmentProtoOutput
|
|
|
|
af := newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), info.ClasspathFragmentProtoInstallDir.Rel(), etc, nil)
|
|
|
|
return &af
|
2021-05-17 22:03:07 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 00:14:55 +02:00
|
|
|
// apexFileForBootclasspathFragmentContentModule creates an apexFile for a bootclasspath_fragment
|
|
|
|
// content module, i.e. a library that is part of the bootclasspath.
|
2021-04-26 11:33:59 +02:00
|
|
|
func apexFileForBootclasspathFragmentContentModule(ctx android.ModuleContext, fragmentModule blueprint.Module, javaModule javaModule) apexFile {
|
|
|
|
bootclasspathFragmentInfo := ctx.OtherModuleProvider(fragmentModule, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)
|
|
|
|
|
|
|
|
// Get the dexBootJar from the bootclasspath_fragment as that is responsible for performing the
|
|
|
|
// hidden API encpding.
|
2021-05-15 13:39:23 +02:00
|
|
|
dexBootJar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(javaModule)
|
|
|
|
if err != nil {
|
|
|
|
ctx.ModuleErrorf("%s", err)
|
|
|
|
}
|
2021-04-26 11:33:59 +02:00
|
|
|
|
|
|
|
// Create an apexFile as for a normal java module but with the dex boot jar provided by the
|
|
|
|
// bootclasspath_fragment.
|
|
|
|
af := apexFileForJavaModuleWithFile(ctx, javaModule, dexBootJar)
|
|
|
|
return af
|
2021-04-26 00:14:55 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Factory functions
|
|
|
|
//
|
2019-06-26 13:48:34 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func newApexBundle() *apexBundle {
|
|
|
|
module := &apexBundle{}
|
2020-11-19 15:00:52 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
module.AddProperties(&module.targetProperties)
|
2020-12-14 10:44:04 +01:00
|
|
|
module.AddProperties(&module.archProperties)
|
2020-11-19 06:37:47 +01:00
|
|
|
module.AddProperties(&module.overridableProperties)
|
2020-11-19 15:00:52 +01:00
|
|
|
|
2023-08-23 06:54:08 +02:00
|
|
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
2020-11-19 06:37:47 +01:00
|
|
|
android.InitDefaultableModule(module)
|
|
|
|
android.InitOverridableModule(module, &module.overridableProperties.Overrides)
|
2021-07-16 11:28:53 +02:00
|
|
|
android.InitBazelModule(module)
|
2022-04-27 03:30:34 +02:00
|
|
|
multitree.InitExportableModule(module)
|
2020-11-19 06:37:47 +01:00
|
|
|
return module
|
|
|
|
}
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
2021-10-18 18:49:39 +02:00
|
|
|
func ApexBundleFactory(testApex bool) android.Module {
|
2020-11-19 06:37:47 +01:00
|
|
|
bundle := newApexBundle()
|
|
|
|
bundle.testApex = testApex
|
|
|
|
return bundle
|
|
|
|
}
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
|
|
|
|
// certain compatibility checks such as apex_available are not done for apex_test.
|
2022-10-14 21:20:20 +02:00
|
|
|
func TestApexBundleFactory() android.Module {
|
2020-11-19 06:37:47 +01:00
|
|
|
bundle := newApexBundle()
|
|
|
|
bundle.testApex = true
|
|
|
|
return bundle
|
|
|
|
}
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
// apex packages other modules into an APEX file which is a packaging format for system-level
|
|
|
|
// components like binaries, shared libraries, etc.
|
|
|
|
func BundleFactory() android.Module {
|
|
|
|
return newApexBundle()
|
|
|
|
}
|
binaries and native_shared_libraires are multilib-aware props
The properties 'binaries' and 'native_shared_libraries' can be
multilib-aware, i.e, can be under multilib.type where type can be either
first, both, lib32, lib64, or prefer32.
Native modules listed in multilib.first are installed only for the first
ABI of the device. Similarily, multilib.both are for both of the ABIs,
while multilib.lib32 and multilib.lib64 are 32 and 64-bit ABI only,
respectively. multilib.prefer32 is for 32-bit only when 32-bit ABI is
available.
Another change is that the binaries property, when not within multilib,
targets only the first ABI.
Test: m apex.test on ...
1) aosp_arm64 without TARGET_PREFER_32_BIT_EXECUTABLES=true
2) aosp_arm64 with TARGET_PREFER_32_BIT_EXECUTABLES=true
3) aosp_arm
in all cases, vold, surfaceflinger and drmserver are all intalled under
./bin directory of the APEX. And native libraries are installed under
both ./lib and ./lib64 directories in the case of 1) and 2).
Change-Id: Idd7f8526a61bceca89d43c0c69ccedb471b67d31
2018-10-24 14:09:55 +02:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
type Defaults struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultsModuleBase
|
2019-11-15 10:40:32 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// apex_defaults provides defaultable properties to other apex modules.
|
2023-03-08 21:29:50 +01:00
|
|
|
func DefaultsFactory() android.Module {
|
2020-11-19 06:37:47 +01:00
|
|
|
module := &Defaults{}
|
2019-02-11 03:38:15 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
module.AddProperties(
|
|
|
|
&apexBundleProperties{},
|
|
|
|
&apexTargetBundleProperties{},
|
2022-10-24 18:24:38 +02:00
|
|
|
&apexArchBundleProperties{},
|
2020-11-19 06:37:47 +01:00
|
|
|
&overridableProperties{},
|
|
|
|
)
|
2018-11-27 13:27:08 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
android.InitDefaultsModule(module)
|
|
|
|
return module
|
2018-12-13 15:14:57 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
type OverrideApex struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.OverrideModuleBase
|
2022-05-10 08:59:14 +02:00
|
|
|
android.BazelModuleBase
|
2019-12-07 18:30:22 +01:00
|
|
|
}
|
|
|
|
|
2022-06-29 07:43:04 +02:00
|
|
|
func (o *OverrideApex) GenerateAndroidBuildActions(_ android.ModuleContext) {
|
2020-11-19 06:37:47 +01:00
|
|
|
// All the overrides happen in the base module.
|
2020-04-27 19:21:11 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// override_apex is used to create an apex module based on another apex module by overriding some of
|
|
|
|
// its properties.
|
2022-05-10 08:59:14 +02:00
|
|
|
func OverrideApexFactory() android.Module {
|
2020-11-19 06:37:47 +01:00
|
|
|
m := &OverrideApex{}
|
2020-11-19 15:00:52 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
m.AddProperties(&overridableProperties{})
|
2018-12-19 09:12:36 +01:00
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
|
|
|
android.InitOverrideModule(m)
|
2022-05-10 08:59:14 +02:00
|
|
|
android.InitBazelModule(m)
|
2020-11-19 06:37:47 +01:00
|
|
|
return m
|
2019-02-13 12:28:58 +01:00
|
|
|
}
|
|
|
|
|
2023-09-19 22:09:00 +02:00
|
|
|
func (o *OverrideApex) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
2022-05-10 08:59:14 +02:00
|
|
|
if ctx.ModuleType() != "override_apex" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
baseApexModuleName := o.OverrideModuleBase.GetOverriddenModuleName()
|
|
|
|
baseModule, baseApexExists := ctx.ModuleFromName(baseApexModuleName)
|
|
|
|
if !baseApexExists {
|
|
|
|
panic(fmt.Errorf("Base apex module doesn't exist: %s", baseApexModuleName))
|
|
|
|
}
|
|
|
|
|
|
|
|
a, baseModuleIsApex := baseModule.(*apexBundle)
|
|
|
|
if !baseModuleIsApex {
|
|
|
|
panic(fmt.Errorf("Base module is not apex module: %s", baseApexModuleName))
|
|
|
|
}
|
2023-03-28 17:39:50 +02:00
|
|
|
attrs, props, commonAttrs := convertWithBp2build(a, ctx)
|
2022-05-10 08:59:14 +02:00
|
|
|
|
2022-11-29 13:07:45 +01:00
|
|
|
// We just want the name, not module reference.
|
|
|
|
baseApexName := strings.TrimPrefix(baseApexModuleName, ":")
|
|
|
|
attrs.Base_apex_name = &baseApexName
|
|
|
|
|
2022-05-10 08:59:14 +02:00
|
|
|
for _, p := range o.GetProperties() {
|
|
|
|
overridableProperties, ok := p.(*overridableProperties)
|
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
}
|
2022-05-21 07:08:11 +02:00
|
|
|
|
|
|
|
// Manifest is either empty or a file in the directory of base APEX and is not overridable.
|
|
|
|
// After it is converted in convertWithBp2build(baseApex, ctx),
|
|
|
|
// the attrs.Manifest.Value.Label is the file path relative to the directory
|
|
|
|
// of base apex. So the following code converts it to a label that looks like
|
|
|
|
// <package of base apex>:<path of manifest file> if base apex and override
|
|
|
|
// apex are not in the same package.
|
|
|
|
baseApexPackage := ctx.OtherModuleDir(a)
|
|
|
|
overrideApexPackage := ctx.ModuleDir()
|
|
|
|
if baseApexPackage != overrideApexPackage {
|
|
|
|
attrs.Manifest.Value.Label = "//" + baseApexPackage + ":" + attrs.Manifest.Value.Label
|
|
|
|
}
|
|
|
|
|
2022-05-10 08:59:14 +02:00
|
|
|
// Key
|
|
|
|
if overridableProperties.Key != nil {
|
|
|
|
attrs.Key = bazel.LabelAttribute{}
|
|
|
|
attrs.Key.SetValue(android.BazelLabelForModuleDepSingle(ctx, *overridableProperties.Key))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Certificate
|
2022-09-29 18:56:02 +02:00
|
|
|
if overridableProperties.Certificate == nil {
|
2022-10-14 11:56:07 +02:00
|
|
|
// If overridableProperties.Certificate is nil, clear this out as
|
|
|
|
// well with zeroed structs, so the override_apex does not use the
|
|
|
|
// base apex's certificate.
|
|
|
|
attrs.Certificate = bazel.LabelAttribute{}
|
|
|
|
attrs.Certificate_name = bazel.StringAttribute{}
|
2022-09-29 18:56:02 +02:00
|
|
|
} else {
|
2022-10-14 11:56:07 +02:00
|
|
|
attrs.Certificate, attrs.Certificate_name = android.BazelStringOrLabelFromProp(ctx, overridableProperties.Certificate)
|
2022-05-10 08:59:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Prebuilts
|
2022-06-08 18:00:39 +02:00
|
|
|
if overridableProperties.Prebuilts != nil {
|
|
|
|
prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, overridableProperties.Prebuilts)
|
|
|
|
attrs.Prebuilts = bazel.MakeLabelListAttribute(prebuiltsLabelList)
|
|
|
|
}
|
2022-05-10 08:59:14 +02:00
|
|
|
|
|
|
|
// Compressible
|
|
|
|
if overridableProperties.Compressible != nil {
|
|
|
|
attrs.Compressible = bazel.BoolAttribute{Value: overridableProperties.Compressible}
|
|
|
|
}
|
2022-06-03 11:11:20 +02:00
|
|
|
|
|
|
|
// Package name
|
|
|
|
//
|
|
|
|
// e.g. com.android.adbd's package name is com.android.adbd, but
|
|
|
|
// com.google.android.adbd overrides the package name to com.google.android.adbd
|
|
|
|
//
|
|
|
|
// TODO: this can be overridden from the product configuration, see
|
|
|
|
// getOverrideManifestPackageName and
|
|
|
|
// PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES.
|
|
|
|
//
|
|
|
|
// Instead of generating the BUILD files differently based on the product config
|
|
|
|
// at the point of conversion, this should be handled by the BUILD file loading
|
|
|
|
// from the soong_injection's product_vars, so product config is decoupled from bp2build.
|
|
|
|
if overridableProperties.Package_name != "" {
|
|
|
|
attrs.Package_name = &overridableProperties.Package_name
|
|
|
|
}
|
2022-06-10 10:14:19 +02:00
|
|
|
|
|
|
|
// Logging parent
|
|
|
|
if overridableProperties.Logging_parent != "" {
|
|
|
|
attrs.Logging_parent = &overridableProperties.Logging_parent
|
|
|
|
}
|
2022-05-10 08:59:14 +02:00
|
|
|
}
|
|
|
|
|
2023-03-28 17:39:50 +02:00
|
|
|
commonAttrs.Name = o.Name()
|
|
|
|
|
|
|
|
ctx.CreateBazelTargetModule(props, commonAttrs, &attrs)
|
2022-05-10 08:59:14 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Vality check routines
|
|
|
|
//
|
|
|
|
// These are called in at the very beginning of GenerateAndroidBuildActions to flag an error when
|
|
|
|
// certain conditions are not met.
|
|
|
|
//
|
|
|
|
// TODO(jiyong): move these checks to a separate go file.
|
|
|
|
|
2021-12-03 19:58:32 +01:00
|
|
|
var _ android.ModuleWithMinSdkVersionCheck = (*apexBundle)(nil)
|
|
|
|
|
2022-08-05 04:35:52 +02:00
|
|
|
// Ensures that min_sdk_version of the included modules are equal or less than the min_sdk_version
|
2020-11-19 15:00:52 +01:00
|
|
|
// of this apexBundle.
|
2021-12-02 14:59:35 +01:00
|
|
|
func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) {
|
2020-11-19 15:00:52 +01:00
|
|
|
if a.testApex || a.vndkApex {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// apexBundle::minSdkVersion reports its own errors.
|
|
|
|
minSdkVersion := a.minSdkVersion(ctx)
|
2021-12-02 14:59:35 +01:00
|
|
|
android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps)
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 21:11:16 +01:00
|
|
|
// Returns apex's min_sdk_version string value, honoring overrides
|
|
|
|
func (a *apexBundle) minSdkVersionValue(ctx android.EarlyModuleContext) string {
|
|
|
|
// Only override the minSdkVersion value on Apexes which already specify
|
|
|
|
// a min_sdk_version (it's optional for non-updatable apexes), and that its
|
|
|
|
// min_sdk_version value is lower than the one to override with.
|
2023-08-19 00:43:28 +02:00
|
|
|
minApiLevel := android.MinSdkVersionFromValue(ctx, proptools.String(a.properties.Min_sdk_version))
|
2022-10-04 18:58:58 +02:00
|
|
|
if minApiLevel.IsNone() {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2022-03-21 21:11:16 +01:00
|
|
|
overrideMinSdkValue := ctx.DeviceConfig().ApexGlobalMinSdkVersionOverride()
|
2023-08-19 00:43:28 +02:00
|
|
|
overrideApiLevel := android.MinSdkVersionFromValue(ctx, overrideMinSdkValue)
|
2022-10-04 18:58:58 +02:00
|
|
|
if !overrideApiLevel.IsNone() && overrideApiLevel.CompareTo(minApiLevel) > 0 {
|
|
|
|
minApiLevel = overrideApiLevel
|
2022-03-21 21:11:16 +01:00
|
|
|
}
|
|
|
|
|
2022-10-04 18:58:58 +02:00
|
|
|
return minApiLevel.String()
|
2022-03-21 21:11:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns apex's min_sdk_version SdkSpec, honoring overrides
|
2023-03-03 22:20:36 +01:00
|
|
|
func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
|
|
|
return a.minSdkVersion(ctx)
|
2021-12-03 19:58:32 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 21:11:16 +01:00
|
|
|
// Returns apex's min_sdk_version ApiLevel, honoring overrides
|
2021-12-03 19:58:32 +01:00
|
|
|
func (a *apexBundle) minSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
2023-08-19 00:43:28 +02:00
|
|
|
return android.MinSdkVersionFromValue(ctx, a.minSdkVersionValue(ctx))
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ensures that a lib providing stub isn't statically linked
|
|
|
|
func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) {
|
|
|
|
// Practically, we only care about regular APEXes on the device.
|
2023-08-23 06:54:08 +02:00
|
|
|
if a.testApex || a.vndkApex {
|
2020-11-19 15:00:52 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
|
|
|
|
|
|
|
|
a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
|
|
|
|
if ccm, ok := to.(*cc.Module); ok {
|
|
|
|
apexName := ctx.ModuleName()
|
|
|
|
fromName := ctx.OtherModuleName(from)
|
|
|
|
toName := ctx.OtherModuleName(to)
|
|
|
|
|
|
|
|
// If `to` is not actually in the same APEX as `from` then it does not need
|
|
|
|
// apex_available and neither do any of its dependencies.
|
2021-03-18 16:41:29 +01:00
|
|
|
//
|
|
|
|
// It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps().
|
2020-11-19 15:00:52 +01:00
|
|
|
if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
|
|
|
|
// As soon as the dependency graph crosses the APEX boundary, don't go further.
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// The dynamic linker and crash_dump tool in the runtime APEX is the only
|
|
|
|
// exception to this rule. It can't make the static dependencies dynamic
|
|
|
|
// because it can't do the dynamic linking for itself.
|
2020-11-30 06:42:14 +01:00
|
|
|
// Same rule should be applied to linkerconfig, because it should be executed
|
|
|
|
// only with static linked libraries before linker is available with ld.config.txt
|
|
|
|
if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump" || fromName == "linkerconfig") {
|
2020-11-19 15:00:52 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName)
|
|
|
|
if isStubLibraryFromOtherApex && !externalDep {
|
|
|
|
ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
|
|
|
|
"It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:49:50 +02:00
|
|
|
// checkUpdatable enforces APEX and its transitive dep properties to have desired values for updatable APEXes.
|
2020-11-19 15:00:52 +01:00
|
|
|
func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
|
|
|
|
if a.Updatable() {
|
2022-03-21 21:11:16 +01:00
|
|
|
if a.minSdkVersionValue(ctx) == "" {
|
2020-11-19 15:00:52 +01:00
|
|
|
ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
|
|
|
|
}
|
2021-06-22 13:23:05 +02:00
|
|
|
if a.UsePlatformApis() {
|
|
|
|
ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs")
|
|
|
|
}
|
2023-03-20 10:19:07 +01:00
|
|
|
if proptools.Bool(a.properties.Use_vndk_as_stable) {
|
|
|
|
ctx.PropertyErrorf("use_vndk_as_stable", "updatable APEXes can't use external VNDK libs")
|
2021-12-02 21:52:42 +01:00
|
|
|
}
|
2021-11-29 04:37:10 +01:00
|
|
|
if a.FutureUpdatable() {
|
|
|
|
ctx.PropertyErrorf("future_updatable", "Already updatable. Remove `future_updatable: true:`")
|
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
a.checkJavaStableSdkVersion(ctx)
|
2021-06-15 17:49:50 +02:00
|
|
|
a.checkClasspathFragments(ctx)
|
2020-11-19 15:00:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:49:50 +02:00
|
|
|
// checkClasspathFragments enforces that all classpath fragments in deps generate classpaths.proto config.
|
|
|
|
func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) {
|
|
|
|
ctx.VisitDirectDeps(func(module android.Module) {
|
|
|
|
if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag {
|
|
|
|
info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo)
|
|
|
|
if !info.ClasspathFragmentProtoGenerated {
|
|
|
|
ctx.OtherModuleErrorf(module, "is included in updatable apex %v, it must not set generate_classpaths_proto to false", ctx.ModuleName())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// checkJavaStableSdkVersion enforces that all Java deps are using stable SDKs to compile.
|
2020-11-19 15:00:52 +01:00
|
|
|
func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
|
|
|
|
// Visit direct deps only. As long as we guarantee top-level deps are using stable SDKs,
|
|
|
|
// java's checkLinkType guarantees correct usage for transitive deps
|
|
|
|
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
|
|
|
tag := ctx.OtherModuleDependencyTag(module)
|
|
|
|
switch tag {
|
|
|
|
case javaLibTag, androidAppTag:
|
2021-04-02 01:45:46 +02:00
|
|
|
if m, ok := module.(interface {
|
|
|
|
CheckStableSdkVersion(ctx android.BaseModuleContext) error
|
|
|
|
}); ok {
|
|
|
|
if err := m.CheckStableSdkVersion(ctx); err != nil {
|
2020-11-19 15:00:52 +01:00
|
|
|
ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:49:50 +02:00
|
|
|
// checkApexAvailability ensures that the all the dependencies are marked as available for this APEX.
|
2020-11-19 15:00:52 +01:00
|
|
|
func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
|
|
|
|
// Let's be practical. Availability for test, host, and the VNDK apex isn't important
|
2023-08-23 06:54:08 +02:00
|
|
|
if a.testApex || a.vndkApex {
|
2020-11-19 15:00:52 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Because APEXes targeting other than system/system_ext partitions can't set
|
|
|
|
// apex_available, we skip checks for these APEXes
|
|
|
|
if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Coverage build adds additional dependencies for the coverage-only runtime libraries.
|
|
|
|
// Requiring them and their transitive depencies with apex_available is not right
|
|
|
|
// because they just add noise.
|
|
|
|
if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
|
|
|
|
// As soon as the dependency graph crosses the APEX boundary, don't go further.
|
|
|
|
if externalDep {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
apexName := ctx.ModuleName()
|
2023-06-02 20:09:50 +02:00
|
|
|
for _, props := range ctx.Module().GetProperties() {
|
|
|
|
if apexProps, ok := props.(*apexBundleProperties); ok {
|
|
|
|
if apexProps.Apex_available_name != nil {
|
|
|
|
apexName = *apexProps.Apex_available_name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-19 15:00:52 +01:00
|
|
|
fromName := ctx.OtherModuleName(from)
|
|
|
|
toName := ctx.OtherModuleName(to)
|
|
|
|
|
|
|
|
// If `to` is not actually in the same APEX as `from` then it does not need
|
|
|
|
// apex_available and neither do any of its dependencies.
|
2021-03-18 16:41:29 +01:00
|
|
|
//
|
|
|
|
// It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps().
|
2020-11-19 15:00:52 +01:00
|
|
|
if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
|
|
|
|
// As soon as the dependency graph crosses the APEX boundary, don't go
|
|
|
|
// further.
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
|
|
|
|
return true
|
|
|
|
}
|
Friendly error message on apex_available and min_sdk_version checks
1) suggest a fix at the end of the message
2) add new lines around the dependency path so that they are visually
separated from rest of the error message
Bug: N/A
Test: m with an intentional break
error: bionic/apex/Android.bp:32:1: module "com.android.runtime" variant "android_common_com.android.runtime_image": "libutils_headers" requires "libsystem_headers" that doesn't list the APEX under 'apex_available'.
Dependency path:
via tag apex.dependencyTag: { name:executable payload:true}
-> crash_dump{os:android,image:,arch:arm_armv8-a,sdk:,apex:apex10000}
via tag cc.libraryDependencyTag: { Kind:staticLibraryDependency Order:normalLibraryDependency wholeStatic:false reexportFlags:false explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
-> libtombstoned_client_static{os:android,image:,arch:arm_armv8-a,sdk:,link:static,apex:apex10000}
via tag cc.libraryDependencyTag: { Kind:staticLibraryDependency Order:normalLibraryDependency wholeStatic:true reexportFlags:true explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
-> libcutils{os:android,image:,arch:arm_armv8-a,sdk:,link:static,asan:,apex:apex10000}
via tag cc.libraryDependencyTag: { Kind:headerLibraryDependency Order:normalLibraryDependency wholeStatic:false reexportFlags:false explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
-> libutils_headers{os:android,image:,arch:arm_armv8-a,sdk:,asan:,apex:apex10000}
via tag cc.libraryDependencyTag: { Kind:headerLibraryDependency Order:normalLibraryDependency wholeStatic:false reexportFlags:true explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
-> libsystem_headers{os:android,image:,arch:arm_armv8-a,sdk:,asan:,apex:apex10000}
Consider adding "com.android.runtime" to 'apex_available' property of "libsystem_headers"
Change-Id: I09f92c3086ea433780133a33ba0ad73baee6dc41
2021-03-04 05:03:10 +01:00
|
|
|
ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'."+
|
|
|
|
"\n\nDependency path:%s\n\n"+
|
|
|
|
"Consider adding %q to 'apex_available' property of %q",
|
|
|
|
fromName, toName, ctx.GetPathString(true), apexName, toName)
|
2020-11-19 15:00:52 +01:00
|
|
|
// Visit this module's dependencies to check and report any issues with their availability.
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-08-03 09:52:17 +02:00
|
|
|
// checkStaticExecutable ensures that executables in an APEX are not static.
|
|
|
|
func (a *apexBundle) checkStaticExecutables(ctx android.ModuleContext) {
|
|
|
|
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
|
|
|
if ctx.OtherModuleDependencyTag(module) != executableTag {
|
|
|
|
return
|
|
|
|
}
|
2021-08-03 06:36:09 +02:00
|
|
|
|
|
|
|
if l, ok := module.(cc.LinkableInterface); ok && l.StaticExecutable() {
|
2021-08-03 09:52:17 +02:00
|
|
|
apex := a.ApexVariationName()
|
|
|
|
exec := ctx.OtherModuleName(module)
|
|
|
|
if isStaticExecutableAllowed(apex, exec) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ctx.ModuleErrorf("executable %s is static", ctx.OtherModuleName(module))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// A small list of exceptions where static executables are allowed in APEXes.
|
|
|
|
func isStaticExecutableAllowed(apex string, exec string) bool {
|
|
|
|
m := map[string][]string{
|
2022-05-21 07:08:11 +02:00
|
|
|
"com.android.runtime": {
|
2021-08-03 09:52:17 +02:00
|
|
|
"linker",
|
|
|
|
"linkerconfig",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
execNames, ok := m[apex]
|
|
|
|
return ok && android.InList(exec, execNames)
|
|
|
|
}
|
|
|
|
|
2021-06-07 16:49:13 +02:00
|
|
|
// Collect information for opening IDE project files in java/jdeps.go.
|
|
|
|
func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
|
2023-02-24 12:06:07 +01:00
|
|
|
dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
|
|
|
|
dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...)
|
|
|
|
dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments...)
|
2021-06-07 16:49:13 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
var (
|
|
|
|
apexAvailBaseline = makeApexAvailableBaseline()
|
|
|
|
inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline)
|
|
|
|
)
|
2018-12-18 18:47:14 +01:00
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
func baselineApexAvailable(apex, moduleName string) bool {
|
|
|
|
key := apex
|
|
|
|
moduleName = normalizeModuleName(moduleName)
|
|
|
|
|
|
|
|
if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
key = android.AvailableToAnyApex
|
|
|
|
if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func normalizeModuleName(moduleName string) string {
|
|
|
|
// Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
|
|
|
|
// system. Trim the prefix for the check since they are confusing
|
2020-12-11 19:13:08 +01:00
|
|
|
moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName)
|
2020-11-19 15:00:52 +01:00
|
|
|
if strings.HasPrefix(moduleName, "libclang_rt.") {
|
|
|
|
// This module has many arch variants that depend on the product being built.
|
|
|
|
// We don't want to list them all
|
|
|
|
moduleName = "libclang_rt"
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(moduleName, "androidx.") {
|
|
|
|
// TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries
|
|
|
|
moduleName = "androidx"
|
|
|
|
}
|
|
|
|
return moduleName
|
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
// Transform the map of apex -> modules to module -> apexes.
|
|
|
|
func invertApexBaseline(m map[string][]string) map[string][]string {
|
|
|
|
r := make(map[string][]string)
|
|
|
|
for apex, modules := range m {
|
|
|
|
for _, module := range modules {
|
|
|
|
r[module] = append(r[module], apex)
|
2020-05-15 12:05:05 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return r
|
2020-05-15 12:05:05 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
// Retrieve the baseline of apexes to which the supplied module belongs.
|
|
|
|
func BaselineApexAvailable(moduleName string) []string {
|
|
|
|
return inverseApexAvailBaseline[normalizeModuleName(moduleName)]
|
2020-01-09 04:32:06 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// This is a map from apex to modules, which overrides the apex_available setting for that
|
|
|
|
// particular module to make it available for the apex regardless of its setting.
|
2020-11-19 06:37:47 +01:00
|
|
|
// TODO(b/147364041): remove this
|
|
|
|
func makeApexAvailableBaseline() map[string][]string {
|
|
|
|
// The "Module separator"s below are employed to minimize merge conflicts.
|
|
|
|
m := make(map[string][]string)
|
|
|
|
//
|
|
|
|
// Module separator
|
|
|
|
//
|
|
|
|
m["com.android.mediaprovider"] = []string{
|
|
|
|
"MediaProvider",
|
|
|
|
"MediaProviderGoogle",
|
|
|
|
"fmtlib_ndk",
|
|
|
|
"libbase_ndk",
|
|
|
|
"libfuse",
|
|
|
|
"libfuse_jni",
|
2018-11-08 21:52:26 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
//
|
|
|
|
// Module separator
|
|
|
|
//
|
|
|
|
m["com.android.runtime"] = []string{
|
|
|
|
"libdebuggerd",
|
|
|
|
"libdebuggerd_common_headers",
|
|
|
|
"libdebuggerd_handler_core",
|
|
|
|
"libdl_static",
|
|
|
|
"libjemalloc5",
|
|
|
|
"liblinker_main",
|
|
|
|
"liblinker_malloc",
|
|
|
|
"liblzma",
|
|
|
|
"libprocinfo",
|
|
|
|
"libpropertyinfoparser",
|
|
|
|
"libscudo",
|
|
|
|
"libsystemproperties",
|
|
|
|
"libtombstoned_client_static",
|
|
|
|
"libunwindstack",
|
|
|
|
"libz",
|
|
|
|
"libziparchive",
|
2020-06-12 14:46:59 +02:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
//
|
|
|
|
// Module separator
|
|
|
|
//
|
|
|
|
m["com.android.tethering"] = []string{
|
|
|
|
"android.hardware.tetheroffload.config-V1.0-java",
|
|
|
|
"android.hardware.tetheroffload.control-V1.0-java",
|
|
|
|
"net-utils-framework-common",
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Module separator
|
|
|
|
//
|
|
|
|
m["com.android.wifi"] = []string{
|
|
|
|
"PlatformProperties",
|
|
|
|
"android.hardware.wifi-V1.0-java",
|
|
|
|
"android.hardware.wifi-V1.0-java-constants",
|
|
|
|
"android.hardware.wifi-V1.1-java",
|
|
|
|
"android.hardware.wifi-V1.2-java",
|
|
|
|
"android.hardware.wifi-V1.3-java",
|
|
|
|
"android.hardware.wifi-V1.4-java",
|
|
|
|
"android.hardware.wifi.hostapd-V1.0-java",
|
|
|
|
"android.hardware.wifi.hostapd-V1.1-java",
|
|
|
|
"android.hardware.wifi.hostapd-V1.2-java",
|
|
|
|
"android.hardware.wifi.supplicant-V1.0-java",
|
|
|
|
"android.hardware.wifi.supplicant-V1.1-java",
|
|
|
|
"android.hardware.wifi.supplicant-V1.2-java",
|
|
|
|
"android.hardware.wifi.supplicant-V1.3-java",
|
|
|
|
"bouncycastle-unbundled",
|
|
|
|
"framework-wifi-util-lib",
|
|
|
|
"ksoap2",
|
|
|
|
"libnanohttpd",
|
|
|
|
"wifi-lite-protos",
|
|
|
|
"wifi-nano-protos",
|
|
|
|
"wifi-service-pre-jarjar",
|
2020-02-26 10:27:19 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
//
|
|
|
|
// Module separator
|
|
|
|
//
|
|
|
|
m[android.AvailableToAnyApex] = []string{
|
|
|
|
"libprofile-clang-extras",
|
|
|
|
"libprofile-clang-extras_ndk",
|
|
|
|
"libprofile-extras",
|
|
|
|
"libprofile-extras_ndk",
|
2019-11-01 18:52:25 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return m
|
2019-11-01 18:52:25 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 06:37:47 +01:00
|
|
|
func init() {
|
2021-11-12 01:01:37 +01:00
|
|
|
android.AddNeverAllowRules(createBcpPermittedPackagesRules(qBcpPackages())...)
|
|
|
|
android.AddNeverAllowRules(createBcpPermittedPackagesRules(rBcpPackages())...)
|
2020-04-15 18:29:42 +02:00
|
|
|
}
|
|
|
|
|
2021-11-12 01:01:37 +01:00
|
|
|
func createBcpPermittedPackagesRules(bcpPermittedPackages map[string][]string) []android.Rule {
|
|
|
|
rules := make([]android.Rule, 0, len(bcpPermittedPackages))
|
|
|
|
for jar, permittedPackages := range bcpPermittedPackages {
|
2020-12-21 18:11:10 +01:00
|
|
|
permittedPackagesRule := android.NeverAllow().
|
2021-11-12 01:01:37 +01:00
|
|
|
With("name", jar).
|
|
|
|
WithMatcher("permitted_packages", android.NotInList(permittedPackages)).
|
|
|
|
Because(jar +
|
|
|
|
" bootjar may only use these package prefixes: " + strings.Join(permittedPackages, ",") +
|
2021-12-23 16:05:38 +01:00
|
|
|
". Please consider the following alternatives:\n" +
|
2022-01-19 16:36:40 +01:00
|
|
|
" 1. If the offending code is from a statically linked library, consider " +
|
|
|
|
"removing that dependency and using an alternative already in the " +
|
|
|
|
"bootclasspath, or perhaps a shared library." +
|
|
|
|
" 2. Move the offending code into an allowed package.\n" +
|
|
|
|
" 3. Jarjar the offending code. Please be mindful of the potential system " +
|
|
|
|
"health implications of bundling that code, particularly if the offending jar " +
|
|
|
|
"is part of the bootclasspath.")
|
2021-11-12 01:01:37 +01:00
|
|
|
|
2020-12-21 18:11:10 +01:00
|
|
|
rules = append(rules, permittedPackagesRule)
|
2020-01-10 16:12:39 +01:00
|
|
|
}
|
2020-11-19 06:37:47 +01:00
|
|
|
return rules
|
2020-01-10 16:12:39 +01:00
|
|
|
}
|
|
|
|
|
2021-12-23 16:05:38 +01:00
|
|
|
// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
|
2020-11-19 06:37:47 +01:00
|
|
|
// Adding code to the bootclasspath in new packages will cause issues on module update.
|
2021-11-12 01:01:37 +01:00
|
|
|
func qBcpPackages() map[string][]string {
|
2020-11-19 06:37:47 +01:00
|
|
|
return map[string][]string{
|
2022-05-21 07:08:11 +02:00
|
|
|
"conscrypt": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"android.net.ssl",
|
|
|
|
"com.android.org.conscrypt",
|
|
|
|
},
|
2022-05-21 07:08:11 +02:00
|
|
|
"updatable-media": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"android.media",
|
|
|
|
},
|
2020-05-20 02:06:00 +02:00
|
|
|
}
|
2019-11-15 10:40:32 +01:00
|
|
|
}
|
|
|
|
|
2021-12-23 16:05:38 +01:00
|
|
|
// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
|
2020-11-19 06:37:47 +01:00
|
|
|
// Adding code to the bootclasspath in new packages will cause issues on module update.
|
2021-11-12 01:01:37 +01:00
|
|
|
func rBcpPackages() map[string][]string {
|
2020-11-19 06:37:47 +01:00
|
|
|
return map[string][]string{
|
2022-05-21 07:08:11 +02:00
|
|
|
"framework-mediaprovider": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"android.provider",
|
|
|
|
},
|
2022-05-21 07:08:11 +02:00
|
|
|
"framework-permission": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"android.permission",
|
|
|
|
"android.app.role",
|
|
|
|
"com.android.permission",
|
|
|
|
"com.android.role",
|
|
|
|
},
|
2022-05-21 07:08:11 +02:00
|
|
|
"framework-sdkextensions": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"android.os.ext",
|
|
|
|
},
|
2022-05-21 07:08:11 +02:00
|
|
|
"framework-statsd": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"android.app",
|
|
|
|
"android.os",
|
|
|
|
"android.util",
|
|
|
|
"com.android.internal.statsd",
|
|
|
|
"com.android.server.stats",
|
|
|
|
},
|
2022-05-21 07:08:11 +02:00
|
|
|
"framework-wifi": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"com.android.server.wifi",
|
|
|
|
"com.android.wifi.x",
|
|
|
|
"android.hardware.wifi",
|
|
|
|
"android.net.wifi",
|
|
|
|
},
|
2022-05-21 07:08:11 +02:00
|
|
|
"framework-tethering": {
|
2020-11-19 06:37:47 +01:00
|
|
|
"android.net",
|
|
|
|
},
|
|
|
|
}
|
2019-11-15 10:40:32 +01:00
|
|
|
}
|
2021-07-02 13:17:16 +02:00
|
|
|
|
|
|
|
// For Bazel / bp2build
|
|
|
|
|
|
|
|
type bazelApexBundleAttributes struct {
|
2022-01-06 02:17:23 +01:00
|
|
|
Manifest bazel.LabelAttribute
|
|
|
|
Android_manifest bazel.LabelAttribute
|
|
|
|
File_contexts bazel.LabelAttribute
|
2023-03-28 15:05:02 +02:00
|
|
|
Canned_fs_config bazel.LabelAttribute
|
2022-01-06 02:17:23 +01:00
|
|
|
Key bazel.LabelAttribute
|
2022-10-14 11:56:07 +02:00
|
|
|
Certificate bazel.LabelAttribute // used when the certificate prop is a module
|
|
|
|
Certificate_name bazel.StringAttribute // used when the certificate prop is a string
|
2022-12-21 20:53:41 +01:00
|
|
|
Min_sdk_version bazel.StringAttribute
|
2022-01-06 02:17:23 +01:00
|
|
|
Updatable bazel.BoolAttribute
|
|
|
|
Installable bazel.BoolAttribute
|
|
|
|
Binaries bazel.LabelListAttribute
|
|
|
|
Prebuilts bazel.LabelListAttribute
|
|
|
|
Native_shared_libs_32 bazel.LabelListAttribute
|
|
|
|
Native_shared_libs_64 bazel.LabelListAttribute
|
2022-01-20 00:54:31 +01:00
|
|
|
Compressible bazel.BoolAttribute
|
2022-06-03 11:11:20 +02:00
|
|
|
Package_name *string
|
2022-06-10 10:14:19 +02:00
|
|
|
Logging_parent *string
|
2022-10-14 21:20:20 +02:00
|
|
|
Tests bazel.LabelListAttribute
|
2022-11-29 13:07:45 +01:00
|
|
|
Base_apex_name *string
|
2023-06-06 17:30:31 +02:00
|
|
|
Apex_available_name *string
|
2023-06-06 18:06:53 +02:00
|
|
|
Variant_version *string
|
2022-01-06 02:17:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type convertedNativeSharedLibs struct {
|
|
|
|
Native_shared_libs_32 bazel.LabelListAttribute
|
|
|
|
Native_shared_libs_64 bazel.LabelListAttribute
|
2021-07-02 13:17:16 +02:00
|
|
|
}
|
|
|
|
|
2022-12-21 20:53:41 +01:00
|
|
|
const (
|
|
|
|
minSdkVersionPropName = "Min_sdk_version"
|
|
|
|
)
|
|
|
|
|
2021-11-01 20:32:43 +01:00
|
|
|
// ConvertWithBp2build performs bp2build conversion of an apex
|
2023-09-19 22:09:00 +02:00
|
|
|
func (a *apexBundle) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
2022-10-14 21:20:20 +02:00
|
|
|
// We only convert apex and apex_test modules at this time
|
|
|
|
if ctx.ModuleType() != "apex" && ctx.ModuleType() != "apex_test" {
|
2021-07-02 13:17:16 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-28 17:39:50 +02:00
|
|
|
attrs, props, commonAttrs := convertWithBp2build(a, ctx)
|
|
|
|
commonAttrs.Name = a.Name()
|
2022-10-14 21:20:20 +02:00
|
|
|
ctx.CreateBazelTargetModule(props, commonAttrs, &attrs)
|
2022-05-10 08:59:14 +02:00
|
|
|
}
|
|
|
|
|
2023-09-19 22:09:00 +02:00
|
|
|
func convertWithBp2build(a *apexBundle, ctx android.Bp2buildMutatorContext) (bazelApexBundleAttributes, bazel.BazelTargetModuleProperties, android.CommonAttributes) {
|
2021-07-02 13:17:16 +02:00
|
|
|
var manifestLabelAttribute bazel.LabelAttribute
|
2022-05-21 07:08:11 +02:00
|
|
|
manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json")))
|
2021-07-27 07:34:59 +02:00
|
|
|
|
|
|
|
var androidManifestLabelAttribute bazel.LabelAttribute
|
2021-11-01 20:32:43 +01:00
|
|
|
if a.properties.AndroidManifest != nil {
|
|
|
|
androidManifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.AndroidManifest))
|
2021-07-27 07:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var fileContextsLabelAttribute bazel.LabelAttribute
|
2022-05-10 08:59:14 +02:00
|
|
|
if a.properties.File_contexts == nil {
|
|
|
|
// See buildFileContexts(), if file_contexts is not specified the default one is used, which is //system/sepolicy/apex:<module name>-file_contexts
|
|
|
|
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, a.Name()+"-file_contexts"))
|
|
|
|
} else if strings.HasPrefix(*a.properties.File_contexts, ":") {
|
|
|
|
// File_contexts is a module
|
2021-11-01 20:32:43 +01:00
|
|
|
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.properties.File_contexts))
|
2022-05-10 08:59:14 +02:00
|
|
|
} else {
|
|
|
|
// File_contexts is a file
|
|
|
|
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.File_contexts))
|
2021-07-27 07:34:59 +02:00
|
|
|
}
|
|
|
|
|
2023-03-28 15:05:02 +02:00
|
|
|
var cannedFsConfigAttribute bazel.LabelAttribute
|
|
|
|
if a.properties.Canned_fs_config != nil {
|
|
|
|
cannedFsConfigAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.Canned_fs_config))
|
|
|
|
}
|
|
|
|
|
2023-09-19 14:41:14 +02:00
|
|
|
productVariableProps, errs := android.ProductVariableProperties(ctx, a)
|
|
|
|
for _, err := range errs {
|
|
|
|
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
|
|
|
}
|
2022-03-21 21:11:16 +01:00
|
|
|
// TODO(b/219503907) this would need to be set to a.MinSdkVersionValue(ctx) but
|
|
|
|
// given it's coming via config, we probably don't want to put it in here.
|
2022-12-21 20:53:41 +01:00
|
|
|
var minSdkVersion bazel.StringAttribute
|
2023-05-11 17:58:13 +02:00
|
|
|
if a.properties.Min_sdk_version != nil {
|
|
|
|
minSdkVersion.SetValue(*a.properties.Min_sdk_version)
|
2022-12-21 20:53:41 +01:00
|
|
|
}
|
|
|
|
if props, ok := productVariableProps[minSdkVersionPropName]; ok {
|
|
|
|
for c, p := range props {
|
|
|
|
if val, ok := p.(*string); ok {
|
|
|
|
minSdkVersion.SetSelectValue(c.ConfigurationAxis(), c.SelectKey(), val)
|
|
|
|
}
|
|
|
|
}
|
2021-07-27 07:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var keyLabelAttribute bazel.LabelAttribute
|
2021-11-01 20:32:43 +01:00
|
|
|
if a.overridableProperties.Key != nil {
|
|
|
|
keyLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.overridableProperties.Key))
|
2021-07-27 07:34:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-14 11:56:07 +02:00
|
|
|
// Certificate
|
|
|
|
certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableProperties.Certificate)
|
2021-07-27 07:34:59 +02:00
|
|
|
|
2022-01-06 02:17:23 +01:00
|
|
|
nativeSharedLibs := &convertedNativeSharedLibs{
|
|
|
|
Native_shared_libs_32: bazel.LabelListAttribute{},
|
|
|
|
Native_shared_libs_64: bazel.LabelListAttribute{},
|
|
|
|
}
|
2022-10-08 00:16:47 +02:00
|
|
|
|
|
|
|
// https://cs.android.com/android/platform/superproject/+/master:build/soong/android/arch.go;l=698;drc=f05b0d35d2fbe51be9961ce8ce8031f840295c68
|
|
|
|
// https://cs.android.com/android/platform/superproject/+/master:build/soong/apex/apex.go;l=2549;drc=ec731a83e3e2d80a1254e32fd4ad7ef85e262669
|
|
|
|
// In Soong, decodeMultilib, used to get multilib, return "first" if defaultMultilib is set to "common".
|
|
|
|
// Since apex sets defaultMultilib to be "common", equivalent compileMultilib in bp2build for apex should be "first"
|
|
|
|
compileMultilib := "first"
|
2022-01-06 02:17:23 +01:00
|
|
|
if a.CompileMultilib() != nil {
|
|
|
|
compileMultilib = *a.CompileMultilib()
|
|
|
|
}
|
|
|
|
|
|
|
|
// properties.Native_shared_libs is treated as "both"
|
|
|
|
convertBothLibs(ctx, compileMultilib, a.properties.Native_shared_libs, nativeSharedLibs)
|
|
|
|
convertBothLibs(ctx, compileMultilib, a.properties.Multilib.Both.Native_shared_libs, nativeSharedLibs)
|
|
|
|
convert32Libs(ctx, compileMultilib, a.properties.Multilib.Lib32.Native_shared_libs, nativeSharedLibs)
|
|
|
|
convert64Libs(ctx, compileMultilib, a.properties.Multilib.Lib64.Native_shared_libs, nativeSharedLibs)
|
|
|
|
convertFirstLibs(ctx, compileMultilib, a.properties.Multilib.First.Native_shared_libs, nativeSharedLibs)
|
2021-07-27 07:34:59 +02:00
|
|
|
|
2021-11-01 20:32:43 +01:00
|
|
|
prebuilts := a.overridableProperties.Prebuilts
|
2021-07-28 11:53:42 +02:00
|
|
|
prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts)
|
|
|
|
prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList)
|
|
|
|
|
2021-11-01 20:32:43 +01:00
|
|
|
binaries := android.BazelLabelForModuleDeps(ctx, a.properties.ApexNativeDependencies.Binaries)
|
2021-12-08 11:05:45 +01:00
|
|
|
binariesLabelListAttribute := bazel.MakeLabelListAttribute(binaries)
|
2021-07-27 07:34:59 +02:00
|
|
|
|
2022-10-14 21:20:20 +02:00
|
|
|
var testsAttrs bazel.LabelListAttribute
|
|
|
|
if a.testApex && len(a.properties.ApexNativeDependencies.Tests) > 0 {
|
|
|
|
tests := android.BazelLabelForModuleDeps(ctx, a.properties.ApexNativeDependencies.Tests)
|
|
|
|
testsAttrs = bazel.MakeLabelListAttribute(tests)
|
|
|
|
}
|
|
|
|
|
2021-07-27 07:34:59 +02:00
|
|
|
var updatableAttribute bazel.BoolAttribute
|
2021-11-01 20:32:43 +01:00
|
|
|
if a.properties.Updatable != nil {
|
|
|
|
updatableAttribute.Value = a.properties.Updatable
|
2021-07-27 07:34:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var installableAttribute bazel.BoolAttribute
|
2021-11-01 20:32:43 +01:00
|
|
|
if a.properties.Installable != nil {
|
|
|
|
installableAttribute.Value = a.properties.Installable
|
2021-07-02 13:17:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-20 00:54:31 +01:00
|
|
|
var compressibleAttribute bazel.BoolAttribute
|
|
|
|
if a.overridableProperties.Compressible != nil {
|
|
|
|
compressibleAttribute.Value = a.overridableProperties.Compressible
|
|
|
|
}
|
|
|
|
|
2022-06-03 11:11:20 +02:00
|
|
|
var packageName *string
|
|
|
|
if a.overridableProperties.Package_name != "" {
|
|
|
|
packageName = &a.overridableProperties.Package_name
|
|
|
|
}
|
|
|
|
|
2022-06-10 10:14:19 +02:00
|
|
|
var loggingParent *string
|
|
|
|
if a.overridableProperties.Logging_parent != "" {
|
|
|
|
loggingParent = &a.overridableProperties.Logging_parent
|
|
|
|
}
|
|
|
|
|
2022-05-10 08:59:14 +02:00
|
|
|
attrs := bazelApexBundleAttributes{
|
2022-01-06 02:17:23 +01:00
|
|
|
Manifest: manifestLabelAttribute,
|
|
|
|
Android_manifest: androidManifestLabelAttribute,
|
|
|
|
File_contexts: fileContextsLabelAttribute,
|
2023-03-28 15:05:02 +02:00
|
|
|
Canned_fs_config: cannedFsConfigAttribute,
|
2022-01-06 02:17:23 +01:00
|
|
|
Min_sdk_version: minSdkVersion,
|
|
|
|
Key: keyLabelAttribute,
|
2022-09-29 18:56:02 +02:00
|
|
|
Certificate: certificate,
|
|
|
|
Certificate_name: certificateName,
|
2022-01-06 02:17:23 +01:00
|
|
|
Updatable: updatableAttribute,
|
|
|
|
Installable: installableAttribute,
|
|
|
|
Native_shared_libs_32: nativeSharedLibs.Native_shared_libs_32,
|
|
|
|
Native_shared_libs_64: nativeSharedLibs.Native_shared_libs_64,
|
|
|
|
Binaries: binariesLabelListAttribute,
|
|
|
|
Prebuilts: prebuiltsLabelListAttribute,
|
2022-01-20 00:54:31 +01:00
|
|
|
Compressible: compressibleAttribute,
|
2022-06-03 11:11:20 +02:00
|
|
|
Package_name: packageName,
|
2022-06-10 10:14:19 +02:00
|
|
|
Logging_parent: loggingParent,
|
2022-10-14 21:20:20 +02:00
|
|
|
Tests: testsAttrs,
|
2023-06-06 17:30:31 +02:00
|
|
|
Apex_available_name: a.properties.Apex_available_name,
|
2023-06-06 18:06:53 +02:00
|
|
|
Variant_version: a.properties.Variant_version,
|
2021-07-02 13:17:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
props := bazel.BazelTargetModuleProperties{
|
|
|
|
Rule_class: "apex",
|
2022-04-29 22:37:43 +02:00
|
|
|
Bzl_load_location: "//build/bazel/rules/apex:apex.bzl",
|
2021-07-02 13:17:16 +02:00
|
|
|
}
|
|
|
|
|
2023-03-28 17:39:50 +02:00
|
|
|
commonAttrs := android.CommonAttributes{}
|
|
|
|
if a.testApex {
|
|
|
|
commonAttrs.Testonly = proptools.BoolPtr(true)
|
2023-05-08 20:33:16 +02:00
|
|
|
// Set the api_domain of the test apex
|
|
|
|
attrs.Base_apex_name = proptools.StringPtr(cc.GetApiDomain(a.Name()))
|
2023-03-28 17:39:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return attrs, props, commonAttrs
|
2021-07-02 13:17:16 +02:00
|
|
|
}
|
2022-01-06 02:17:23 +01:00
|
|
|
|
|
|
|
// The following conversions are based on this table where the rows are the compile_multilib
|
|
|
|
// values and the columns are the properties.Multilib.*.Native_shared_libs. Each cell
|
|
|
|
// represents how the libs should be compiled for a 64-bit/32-bit device: 32 means it
|
|
|
|
// should be compiled as 32-bit, 64 means it should be compiled as 64-bit, none means it
|
|
|
|
// should not be compiled.
|
|
|
|
// multib/compile_multilib, 32, 64, both, first
|
|
|
|
// 32, 32/32, none/none, 32/32, none/32
|
|
|
|
// 64, none/none, 64/none, 64/none, 64/none
|
|
|
|
// both, 32/32, 64/none, 32&64/32, 64/32
|
|
|
|
// first, 32/32, 64/none, 64/32, 64/32
|
|
|
|
|
2023-09-19 22:09:00 +02:00
|
|
|
func convert32Libs(ctx android.Bp2buildMutatorContext, compileMultilb string,
|
2022-01-06 02:17:23 +01:00
|
|
|
libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
|
|
|
|
switch compileMultilb {
|
|
|
|
case "both", "32":
|
|
|
|
makeNoConfig32SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "first":
|
|
|
|
make32SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "64":
|
|
|
|
// Incompatible, ignore
|
|
|
|
default:
|
|
|
|
invalidCompileMultilib(ctx, compileMultilb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-19 22:09:00 +02:00
|
|
|
func convert64Libs(ctx android.Bp2buildMutatorContext, compileMultilb string,
|
2022-01-06 02:17:23 +01:00
|
|
|
libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
|
|
|
|
switch compileMultilb {
|
|
|
|
case "both", "64", "first":
|
|
|
|
make64SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "32":
|
|
|
|
// Incompatible, ignore
|
|
|
|
default:
|
|
|
|
invalidCompileMultilib(ctx, compileMultilb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-19 22:09:00 +02:00
|
|
|
func convertBothLibs(ctx android.Bp2buildMutatorContext, compileMultilb string,
|
2022-01-06 02:17:23 +01:00
|
|
|
libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
|
|
|
|
switch compileMultilb {
|
|
|
|
case "both":
|
|
|
|
makeNoConfig32SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
make64SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "first":
|
|
|
|
makeFirstSharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "32":
|
|
|
|
makeNoConfig32SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "64":
|
|
|
|
make64SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
default:
|
|
|
|
invalidCompileMultilib(ctx, compileMultilb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-19 22:09:00 +02:00
|
|
|
func convertFirstLibs(ctx android.Bp2buildMutatorContext, compileMultilb string,
|
2022-01-06 02:17:23 +01:00
|
|
|
libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
|
|
|
|
switch compileMultilb {
|
|
|
|
case "both", "first":
|
|
|
|
makeFirstSharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "32":
|
|
|
|
make32SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
case "64":
|
|
|
|
make64SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
default:
|
|
|
|
invalidCompileMultilib(ctx, compileMultilb)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeFirstSharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
make32SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
make64SharedLibsAttributes(libsLabelList, nativeSharedLibs)
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeNoConfig32SharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
list := bazel.LabelListAttribute{}
|
|
|
|
list.SetSelectValue(bazel.NoConfigAxis, "", libsLabelList)
|
|
|
|
nativeSharedLibs.Native_shared_libs_32.Append(list)
|
|
|
|
}
|
|
|
|
|
|
|
|
func make32SharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
makeSharedLibsAttributes("x86", libsLabelList, &nativeSharedLibs.Native_shared_libs_32)
|
|
|
|
makeSharedLibsAttributes("arm", libsLabelList, &nativeSharedLibs.Native_shared_libs_32)
|
|
|
|
}
|
|
|
|
|
|
|
|
func make64SharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) {
|
|
|
|
makeSharedLibsAttributes("x86_64", libsLabelList, &nativeSharedLibs.Native_shared_libs_64)
|
|
|
|
makeSharedLibsAttributes("arm64", libsLabelList, &nativeSharedLibs.Native_shared_libs_64)
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeSharedLibsAttributes(config string, libsLabelList bazel.LabelList,
|
|
|
|
labelListAttr *bazel.LabelListAttribute) {
|
|
|
|
list := bazel.LabelListAttribute{}
|
|
|
|
list.SetSelectValue(bazel.ArchConfigurationAxis, config, libsLabelList)
|
|
|
|
labelListAttr.Append(list)
|
|
|
|
}
|
|
|
|
|
2023-09-19 22:09:00 +02:00
|
|
|
func invalidCompileMultilib(ctx android.Bp2buildMutatorContext, value string) {
|
2022-01-06 02:17:23 +01:00
|
|
|
ctx.PropertyErrorf("compile_multilib", "Invalid value: %s", value)
|
|
|
|
}
|
2023-04-12 21:05:49 +02:00
|
|
|
|
|
|
|
func (a *apexBundle) IsTestApex() bool {
|
|
|
|
return a.testApex
|
|
|
|
}
|
2023-07-26 05:39:19 +02:00
|
|
|
|
|
|
|
func (a *apexBundle) useVndkAsStable(ctx android.BaseModuleContext) bool {
|
|
|
|
// VNDK cannot be linked if it is deprecated
|
|
|
|
if ctx.Config().IsVndkDeprecated() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return proptools.Bool(a.properties.Use_vndk_as_stable)
|
|
|
|
}
|