2015-03-18 21:28:46 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
2015-01-31 02:27:36 +01:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
package cc
|
|
|
|
|
|
|
|
// This file contains the module types for compiling C/C++ for Android, and converts the properties
|
|
|
|
// into the flags and filenames necessary to pass to the compiler. The final creation of the rules
|
|
|
|
// is handled in builder.go
|
|
|
|
|
|
|
|
import (
|
2019-05-29 23:40:35 +02:00
|
|
|
"fmt"
|
2019-04-10 07:33:58 +02:00
|
|
|
"io"
|
2016-08-03 23:12:14 +02:00
|
|
|
"strconv"
|
2015-01-31 02:27:36 +01:00
|
|
|
"strings"
|
|
|
|
|
2015-03-24 01:50:24 +01:00
|
|
|
"github.com/google/blueprint"
|
2015-10-29 01:23:31 +01:00
|
|
|
"github.com/google/blueprint/proptools"
|
2015-03-24 01:50:24 +01:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2016-07-29 22:44:28 +02:00
|
|
|
"android/soong/cc/config"
|
2021-07-22 21:05:08 +02:00
|
|
|
"android/soong/fuzz"
|
2015-03-18 21:28:46 +01:00
|
|
|
"android/soong/genrule"
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
"android/soong/multitree"
|
2021-08-10 22:42:03 +02:00
|
|
|
"android/soong/snapshot"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
2015-06-17 23:20:06 +02:00
|
|
|
func init() {
|
2019-12-19 20:16:28 +01:00
|
|
|
RegisterCCBuildComponents(android.InitRegistrationContext)
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2019-12-19 20:16:28 +01:00
|
|
|
pctx.Import("android/soong/cc/config")
|
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("cc_defaults", defaultsFactory)
|
|
|
|
|
|
|
|
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
2020-04-07 18:50:32 +02:00
|
|
|
ctx.BottomUp("sdk", sdkMutator).Parallel()
|
2019-08-26 09:52:35 +02:00
|
|
|
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
2018-10-03 07:25:58 +02:00
|
|
|
ctx.BottomUp("link", LinkageMutator).Parallel()
|
2019-06-28 16:41:19 +02:00
|
|
|
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
2020-08-19 03:35:15 +02:00
|
|
|
ctx.BottomUp("version", versionMutator).Parallel()
|
2018-10-03 07:25:58 +02:00
|
|
|
ctx.BottomUp("begin", BeginMutator).Parallel()
|
2019-12-09 10:15:47 +01:00
|
|
|
ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
|
2016-10-12 23:38:15 +02:00
|
|
|
})
|
2016-01-06 23:41:07 +01:00
|
|
|
|
2019-12-19 20:16:28 +01:00
|
|
|
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
2021-07-07 22:41:50 +02:00
|
|
|
for _, san := range Sanitizers {
|
|
|
|
san.registerMutators(ctx)
|
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
|
2019-06-20 08:00:20 +02:00
|
|
|
ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
|
2018-12-18 18:47:14 +01:00
|
|
|
ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
|
2018-02-22 00:49:20 +01:00
|
|
|
|
2022-06-07 22:12:06 +02:00
|
|
|
ctx.TopDown("fuzz_deps", fuzzMutatorDeps)
|
|
|
|
|
2018-12-11 00:12:40 +01:00
|
|
|
ctx.BottomUp("coverage", coverageMutator).Parallel()
|
2017-05-10 00:44:35 +02:00
|
|
|
|
2021-12-09 11:06:29 +01:00
|
|
|
ctx.TopDown("afdo_deps", afdoDepsMutator)
|
|
|
|
ctx.BottomUp("afdo", afdoMutator).Parallel()
|
|
|
|
|
2017-05-10 00:44:35 +02:00
|
|
|
ctx.TopDown("lto_deps", ltoDepsMutator)
|
|
|
|
ctx.BottomUp("lto", ltoMutator).Parallel()
|
2019-01-18 07:20:43 +01:00
|
|
|
|
2020-10-19 11:51:07 +02:00
|
|
|
ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel()
|
2019-01-18 07:20:43 +01:00
|
|
|
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
|
2016-10-12 23:38:15 +02:00
|
|
|
})
|
2016-07-29 22:44:28 +02:00
|
|
|
|
2020-11-19 09:30:49 +01:00
|
|
|
ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
|
|
|
// sabi mutator needs to be run after apex mutator finishes.
|
|
|
|
ctx.TopDown("sabi_deps", sabiDepsMutator)
|
|
|
|
})
|
|
|
|
|
2020-10-30 02:25:19 +01:00
|
|
|
ctx.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
|
2015-06-17 23:20:06 +02:00
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// Deps is a struct containing module names of dependencies, separated by the kind of dependency.
|
|
|
|
// Mutators should use `AddVariationDependencies` or its sibling methods to add actual dependency
|
|
|
|
// edges to these modules.
|
|
|
|
// This object is constructed in DepsMutator, by calling to various module delegates to set
|
|
|
|
// relevant fields. For example, `module.compiler.compilerDeps()` may append type-specific
|
|
|
|
// dependencies.
|
|
|
|
// This is then consumed by the same DepsMutator, which will call `ctx.AddVariationDependencies()`
|
|
|
|
// (or its sibling methods) to set real dependencies on the given modules.
|
2016-01-04 23:34:37 +01:00
|
|
|
type Deps struct {
|
|
|
|
SharedLibs, LateSharedLibs []string
|
|
|
|
StaticLibs, LateStaticLibs, WholeStaticLibs []string
|
2016-12-13 21:50:57 +01:00
|
|
|
HeaderLibs []string
|
2017-12-19 18:17:32 +01:00
|
|
|
RuntimeLibs []string
|
2015-09-24 00:26:20 +02:00
|
|
|
|
2022-06-18 00:17:05 +02:00
|
|
|
// UnexportedStaticLibs are static libraries that are also passed to -Wl,--exclude-libs= to
|
|
|
|
// prevent automatically exporting symbols.
|
|
|
|
UnexportedStaticLibs []string
|
|
|
|
|
2020-06-05 23:26:16 +02:00
|
|
|
// Used for data dependencies adjacent to tests
|
|
|
|
DataLibs []string
|
2021-09-25 01:50:14 +02:00
|
|
|
DataBins []string
|
2020-06-05 23:26:16 +02:00
|
|
|
|
2020-09-22 12:45:04 +02:00
|
|
|
// Used by DepsMutator to pass system_shared_libs information to check_elf_file.py.
|
|
|
|
SystemSharedLibs []string
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// If true, statically link the unwinder into native libraries/binaries.
|
2020-02-13 02:13:25 +01:00
|
|
|
StaticUnwinderIfLegacy bool
|
|
|
|
|
2016-12-13 21:50:57 +01:00
|
|
|
ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string
|
2016-06-07 03:22:19 +02:00
|
|
|
|
2016-04-11 23:37:39 +02:00
|
|
|
ObjFiles []string
|
2015-03-17 23:06:21 +01:00
|
|
|
|
2016-04-20 23:21:14 +02:00
|
|
|
GeneratedSources []string
|
|
|
|
GeneratedHeaders []string
|
2019-12-06 05:15:38 +01:00
|
|
|
GeneratedDeps []string
|
2016-04-20 23:21:14 +02:00
|
|
|
|
2016-09-29 02:34:58 +02:00
|
|
|
ReexportGeneratedHeaders []string
|
|
|
|
|
2021-06-12 03:00:04 +02:00
|
|
|
CrtBegin, CrtEnd []string
|
2018-10-12 09:24:23 +02:00
|
|
|
|
|
|
|
// Used for host bionic
|
2021-06-12 03:02:22 +02:00
|
|
|
DynamicLinker string
|
2020-12-03 09:28:25 +01:00
|
|
|
|
|
|
|
// List of libs that need to be excluded for APEX variant
|
|
|
|
ExcludeLibsForApex []string
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// PathDeps is a struct containing file paths to dependencies of a module.
|
|
|
|
// It's constructed in depsToPath() by traversing the direct dependencies of the current module.
|
|
|
|
// It's used to construct flags for various build statements (such as for compiling and linking).
|
|
|
|
// It is then passed to module decorator functions responsible for registering build statements
|
|
|
|
// (such as `module.compiler.compile()`).`
|
2016-01-04 23:34:37 +01:00
|
|
|
type PathDeps struct {
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to .so files
|
2019-01-18 06:37:08 +01:00
|
|
|
SharedLibs, EarlySharedLibs, LateSharedLibs android.Paths
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to the dependencies to use for .so files (.so.toc files)
|
2019-01-18 06:37:08 +01:00
|
|
|
SharedLibsDeps, EarlySharedLibsDeps, LateSharedLibsDeps android.Paths
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to .a files
|
2016-05-19 00:37:25 +02:00
|
|
|
StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
|
2015-09-24 00:26:20 +02:00
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
// Transitive static library dependencies of static libraries for use in ordering.
|
|
|
|
TranstiveStaticLibrariesForOrdering *android.DepSet
|
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to .o files
|
2020-04-17 18:34:31 +02:00
|
|
|
Objs Objects
|
|
|
|
// Paths to .o files in dependencies that provide them. Note that these lists
|
|
|
|
// aren't complete since prebuilt modules don't provide the .o files.
|
2017-02-10 01:16:31 +01:00
|
|
|
StaticLibObjs Objects
|
2016-09-27 02:33:01 +02:00
|
|
|
WholeStaticLibObjs Objects
|
2015-09-24 00:26:20 +02:00
|
|
|
|
2020-04-17 18:34:31 +02:00
|
|
|
// Paths to .a files in prebuilts. Complements WholeStaticLibObjs to contain
|
|
|
|
// the libs from all whole_static_lib dependencies.
|
|
|
|
WholeStaticLibsFromPrebuilts android.Paths
|
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to generated source files
|
2016-05-19 00:37:25 +02:00
|
|
|
GeneratedSources android.Paths
|
2019-12-06 05:15:38 +01:00
|
|
|
GeneratedDeps android.Paths
|
2016-04-20 23:21:14 +02:00
|
|
|
|
2019-12-06 05:15:38 +01:00
|
|
|
Flags []string
|
2022-06-18 00:17:05 +02:00
|
|
|
LdFlags []string
|
2019-12-06 05:15:38 +01:00
|
|
|
IncludeDirs android.Paths
|
|
|
|
SystemIncludeDirs android.Paths
|
|
|
|
ReexportedDirs android.Paths
|
|
|
|
ReexportedSystemDirs android.Paths
|
|
|
|
ReexportedFlags []string
|
|
|
|
ReexportedGeneratedHeaders android.Paths
|
|
|
|
ReexportedDeps android.Paths
|
2015-09-24 00:26:20 +02:00
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to crt*.o files
|
2021-06-12 03:00:04 +02:00
|
|
|
CrtBegin, CrtEnd android.Paths
|
2018-10-12 09:24:23 +02:00
|
|
|
|
|
|
|
// Path to the dynamic linker binary
|
|
|
|
DynamicLinker android.OptionalPath
|
2021-10-20 05:24:49 +02:00
|
|
|
|
|
|
|
// For Darwin builds, the path to the second architecture's output that should
|
|
|
|
// be combined with this architectures's output into a FAT MachO file.
|
|
|
|
DarwinSecondArchOutput android.OptionalPath
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2019-11-04 18:37:55 +01:00
|
|
|
// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
|
|
|
|
// tracked separately, in order to maintain the required ordering (most of the global flags need to go first on the
|
|
|
|
// command line so they can be overridden by the local module flags).
|
|
|
|
type LocalOrGlobalFlags struct {
|
|
|
|
CommonFlags []string // Flags that apply to C, C++, and assembly source files
|
2017-06-15 23:45:18 +02:00
|
|
|
AsFlags []string // Flags that apply to assembly source files
|
2019-11-04 18:37:55 +01:00
|
|
|
YasmFlags []string // Flags that apply to yasm assembly source files
|
2017-06-15 23:45:18 +02:00
|
|
|
CFlags []string // Flags that apply to C and C++ source files
|
|
|
|
ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools
|
|
|
|
ConlyFlags []string // Flags that apply to C source files
|
|
|
|
CppFlags []string // Flags that apply to C++ source files
|
|
|
|
ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
|
|
|
|
LdFlags []string // Flags that apply to linker command lines
|
2019-11-04 18:37:55 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// Flags contains various types of command line flags (and settings) for use in building build
|
|
|
|
// statements related to C++.
|
2019-11-04 18:37:55 +01:00
|
|
|
type Flags struct {
|
2020-12-02 00:26:21 +01:00
|
|
|
// Local flags (which individual modules are responsible for). These may override global flags.
|
|
|
|
Local LocalOrGlobalFlags
|
|
|
|
// Global flags (which build system or toolchain is responsible for).
|
2019-11-04 18:37:55 +01:00
|
|
|
Global LocalOrGlobalFlags
|
|
|
|
|
|
|
|
aidlFlags []string // Flags that apply to aidl source files
|
|
|
|
rsFlags []string // Flags that apply to renderscript source files
|
|
|
|
libFlags []string // Flags to add libraries early to the link order
|
|
|
|
extraLibFlags []string // Flags to add libraries late in the link order after LdFlags
|
|
|
|
TidyFlags []string // Flags that apply to clang-tidy
|
|
|
|
SAbiFlags []string // Flags that apply to header-abi-dumper
|
2015-04-22 22:07:53 +02:00
|
|
|
|
2017-03-31 00:03:04 +02:00
|
|
|
// Global include flags that apply to C, C++, and assembly source files
|
2019-11-04 18:37:55 +01:00
|
|
|
// These must be after any module include flags, which will be in CommonFlags.
|
2017-03-31 00:03:04 +02:00
|
|
|
SystemIncludeFlags []string
|
|
|
|
|
2022-01-09 04:56:09 +01:00
|
|
|
Toolchain config.Toolchain
|
|
|
|
Tidy bool // True if ninja .tidy rules should be generated.
|
|
|
|
NeedTidyFiles bool // True if module link should depend on .tidy files
|
|
|
|
GcovCoverage bool // True if coverage files should be generated.
|
|
|
|
SAbiDump bool // True if header abi dumps should be generated.
|
|
|
|
EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// The instruction set required for clang ("arm" or "thumb").
|
2016-01-04 23:34:37 +01:00
|
|
|
RequiredInstructionSet string
|
2020-12-02 00:26:21 +01:00
|
|
|
// The target-device system path to the dynamic linker.
|
|
|
|
DynamicLinker string
|
2016-01-06 23:41:07 +01:00
|
|
|
|
2017-09-01 08:38:27 +02:00
|
|
|
CFlagsDeps android.Paths // Files depended on by compiler flags
|
|
|
|
LdFlagsDeps android.Paths // Files depended on by linker flags
|
2016-12-01 23:45:23 +01:00
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// True if .s files should be processed with the c preprocessor.
|
2019-08-28 06:20:40 +02:00
|
|
|
AssemblerWithCpp bool
|
2018-11-17 06:05:32 +01:00
|
|
|
|
2019-03-28 22:45:07 +01:00
|
|
|
proto android.ProtoFlags
|
|
|
|
protoC bool // Whether to use C instead of C++
|
|
|
|
protoOptionsFile bool // Whether to look for a .options file next to the .proto
|
2019-04-11 07:59:54 +02:00
|
|
|
|
|
|
|
Yacc *YaccProperties
|
2020-07-15 10:58:56 +02:00
|
|
|
Lex *LexProperties
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
// Properties used to compile all C or C++ modules
|
|
|
|
type BaseProperties struct {
|
2018-07-24 02:19:36 +02:00
|
|
|
// Deprecated. true is the default, false is invalid.
|
2016-01-04 23:34:37 +01:00
|
|
|
Clang *bool `android:"arch_variant"`
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2020-08-10 08:59:36 +02:00
|
|
|
// The API level that this module is built against. The APIs of this API level will be
|
|
|
|
// visible at build time, but use of any APIs newer than min_sdk_version will render the
|
|
|
|
// module unloadable on older devices. In the future it will be possible to weakly-link new
|
|
|
|
// APIs, making the behavior match Java: such modules will load on older devices, but
|
|
|
|
// calling new APIs on devices that do not support them will result in a crash.
|
|
|
|
//
|
|
|
|
// This property has the same behavior as sdk_version does for Java modules. For those
|
|
|
|
// familiar with Android Gradle, the property behaves similarly to how compileSdkVersion
|
|
|
|
// does for Java code.
|
|
|
|
//
|
|
|
|
// In addition, setting this property causes two variants to be built, one for the platform
|
|
|
|
// and one for apps.
|
2017-11-07 19:57:05 +01:00
|
|
|
Sdk_version *string
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2020-08-10 08:59:36 +02:00
|
|
|
// Minimum OS API level supported by this C or C++ module. This property becomes the value
|
|
|
|
// of the __ANDROID_API__ macro. When the C or C++ module is included in an APEX or an APK,
|
|
|
|
// this property is also used to ensure that the min_sdk_version of the containing module is
|
|
|
|
// not older (i.e. less) than this module's min_sdk_version. When not set, this property
|
|
|
|
// defaults to the value of sdk_version. When this is set to "apex_inherit", this tracks
|
|
|
|
// min_sdk_version of the containing APEX. When the module
|
|
|
|
// is not built for an APEX, "apex_inherit" defaults to sdk_version.
|
2020-04-21 08:24:00 +02:00
|
|
|
Min_sdk_version *string
|
|
|
|
|
2020-04-07 18:50:32 +02:00
|
|
|
// If true, always create an sdk variant and don't create a platform variant.
|
|
|
|
Sdk_variant_only *bool
|
|
|
|
|
2018-12-07 15:08:36 +01:00
|
|
|
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
|
|
|
AndroidMkStaticLibs []string `blueprint:"mutated"`
|
|
|
|
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
|
|
|
|
AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
|
2020-04-22 02:23:37 +02:00
|
|
|
AndroidMkHeaderLibs []string `blueprint:"mutated"`
|
2018-12-07 15:08:36 +01:00
|
|
|
HideFromMake bool `blueprint:"mutated"`
|
|
|
|
PreventInstall bool `blueprint:"mutated"`
|
|
|
|
ApexesProvidingSharedLibs []string `blueprint:"mutated"`
|
2017-09-14 03:37:08 +02:00
|
|
|
|
2020-09-22 12:45:04 +02:00
|
|
|
// Set by DepsMutator.
|
|
|
|
AndroidMkSystemSharedLibs []string `blueprint:"mutated"`
|
|
|
|
|
2021-06-15 11:27:56 +02:00
|
|
|
// The name of the image this module is built for, suffixed with a '.'
|
2019-11-18 11:52:14 +01:00
|
|
|
ImageVariationPrefix string `blueprint:"mutated"`
|
2021-06-15 11:27:56 +02:00
|
|
|
|
|
|
|
// The VNDK version this module is built against. If empty, the module is not
|
|
|
|
// build against the VNDK.
|
|
|
|
VndkVersion string `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// Suffix for the name of Android.mk entries generated by this module
|
|
|
|
SubName string `blueprint:"mutated"`
|
2017-12-08 00:28:59 +01:00
|
|
|
|
|
|
|
// *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
|
|
|
|
// file
|
|
|
|
Logtags []string
|
2018-01-31 16:54:12 +01:00
|
|
|
|
2020-10-26 20:43:12 +01:00
|
|
|
// Make this module available when building for ramdisk.
|
|
|
|
// On device without a dedicated recovery partition, the module is only
|
|
|
|
// available after switching root into
|
|
|
|
// /first_stage_ramdisk. To expose the module before switching root, install
|
|
|
|
// the recovery variant instead.
|
2020-01-22 00:53:22 +01:00
|
|
|
Ramdisk_available *bool
|
|
|
|
|
2020-10-26 20:43:12 +01:00
|
|
|
// Make this module available when building for vendor ramdisk.
|
|
|
|
// On device without a dedicated recovery partition, the module is only
|
|
|
|
// available after switching root into
|
|
|
|
// /first_stage_ramdisk. To expose the module before switching root, install
|
|
|
|
// the recovery variant instead.
|
2020-10-22 00:17:56 +02:00
|
|
|
Vendor_ramdisk_available *bool
|
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
// Make this module available when building for recovery
|
|
|
|
Recovery_available *bool
|
|
|
|
|
2021-06-15 11:27:56 +02:00
|
|
|
// Used by imageMutator, set by ImageMutatorBegin()
|
|
|
|
CoreVariantNeeded bool `blueprint:"mutated"`
|
|
|
|
RamdiskVariantNeeded bool `blueprint:"mutated"`
|
|
|
|
VendorRamdiskVariantNeeded bool `blueprint:"mutated"`
|
|
|
|
RecoveryVariantNeeded bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// A list of variations for the "image" mutator of the form
|
|
|
|
//<image name> '.' <version char>, for example, 'vendor.S'
|
|
|
|
ExtraVersionedImageVariations []string `blueprint:"mutated"`
|
2018-12-20 14:10:17 +01:00
|
|
|
|
|
|
|
// Allows this module to use non-APEX version of libraries. Useful
|
|
|
|
// for building binaries that are started before APEXes are activated.
|
|
|
|
Bootstrap *bool
|
2019-10-22 12:32:18 +02:00
|
|
|
|
|
|
|
// Even if DeviceConfig().VndkUseCoreVariant() is set, this module must use vendor variant.
|
|
|
|
// see soong/cc/config/vndk.go
|
|
|
|
MustUseVendorVariant bool `blueprint:"mutated"`
|
2019-11-15 01:59:12 +01:00
|
|
|
|
|
|
|
// Used by vendor snapshot to record dependencies from snapshot modules.
|
|
|
|
SnapshotSharedLibs []string `blueprint:"mutated"`
|
2021-06-29 13:50:37 +02:00
|
|
|
SnapshotStaticLibs []string `blueprint:"mutated"`
|
2019-11-15 01:59:12 +01:00
|
|
|
SnapshotRuntimeLibs []string `blueprint:"mutated"`
|
2020-03-04 15:52:46 +01:00
|
|
|
|
2021-10-28 22:25:54 +02:00
|
|
|
Installable *bool `android:"arch_variant"`
|
2020-04-07 18:50:32 +02:00
|
|
|
|
|
|
|
// Set by factories of module types that can only be referenced from variants compiled against
|
|
|
|
// the SDK.
|
|
|
|
AlwaysSdk bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// Variant is an SDK variant created by sdkMutator
|
|
|
|
IsSdkVariant bool `blueprint:"mutated"`
|
|
|
|
// Set when both SDK and platform variants are exported to Make to trigger renaming the SDK
|
|
|
|
// variant to have a ".sdk" suffix.
|
|
|
|
SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"`
|
2020-09-01 01:07:58 +02:00
|
|
|
|
|
|
|
// Normally Soong uses the directory structure to decide which modules
|
|
|
|
// should be included (framework) or excluded (non-framework) from the
|
2020-12-11 22:36:29 +01:00
|
|
|
// different snapshots (vendor, recovery, etc.), but this property
|
|
|
|
// allows a partner to exclude a module normally thought of as a
|
|
|
|
// framework module from the vendor snapshot.
|
|
|
|
Exclude_from_vendor_snapshot *bool
|
|
|
|
|
|
|
|
// Normally Soong uses the directory structure to decide which modules
|
|
|
|
// should be included (framework) or excluded (non-framework) from the
|
|
|
|
// different snapshots (vendor, recovery, etc.), but this property
|
|
|
|
// allows a partner to exclude a module normally thought of as a
|
|
|
|
// framework module from the recovery snapshot.
|
2020-11-13 21:07:36 +01:00
|
|
|
Exclude_from_recovery_snapshot *bool
|
2020-12-04 10:02:13 +01:00
|
|
|
|
|
|
|
// List of APEXes that this module has private access to for testing purpose. The module
|
|
|
|
// can depend on libraries that are not exported by the APEXes and use private symbols
|
|
|
|
// from the exported libraries.
|
2021-03-25 03:33:14 +01:00
|
|
|
Test_for []string `android:"arch_variant"`
|
2021-06-18 13:44:24 +02:00
|
|
|
|
|
|
|
Target struct {
|
|
|
|
Platform struct {
|
|
|
|
// List of modules required by the core variant.
|
|
|
|
Required []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// List of modules not required by the core variant.
|
|
|
|
Exclude_required []string `android:"arch_variant"`
|
|
|
|
} `android:"arch_variant"`
|
|
|
|
|
|
|
|
Recovery struct {
|
|
|
|
// List of modules required by the recovery variant.
|
|
|
|
Required []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// List of modules not required by the recovery variant.
|
|
|
|
Exclude_required []string `android:"arch_variant"`
|
|
|
|
} `android:"arch_variant"`
|
|
|
|
} `android:"arch_variant"`
|
2017-09-14 03:37:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type VendorProperties struct {
|
2017-08-16 07:05:54 +02:00
|
|
|
// whether this module should be allowed to be directly depended by other
|
|
|
|
// modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
|
2020-10-29 08:49:43 +01:00
|
|
|
// If set to true, two variants will be built separately, one like
|
|
|
|
// normal, and the other limited to the set of libraries and headers
|
|
|
|
// that are exposed to /vendor modules.
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
//
|
2020-10-29 08:49:43 +01:00
|
|
|
// The vendor variant may be used with a different (newer) /system,
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
// so it shouldn't have any unversioned runtime dependencies, or
|
|
|
|
// make assumptions about the system that may not be true in the
|
|
|
|
// future.
|
|
|
|
//
|
2020-10-29 08:49:43 +01:00
|
|
|
// If set to false, this module becomes inaccessible from /vendor modules.
|
2017-08-16 07:05:54 +02:00
|
|
|
//
|
2020-10-29 10:24:11 +01:00
|
|
|
// The modules with vndk: {enabled: true} must define 'vendor_available'
|
2021-01-08 07:22:34 +01:00
|
|
|
// to 'true'.
|
2017-08-16 07:05:54 +02:00
|
|
|
//
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
|
|
|
|
Vendor_available *bool
|
2018-04-09 05:03:06 +02:00
|
|
|
|
2021-01-08 10:00:19 +01:00
|
|
|
// This is the same as the "vendor_available" except that the install path
|
|
|
|
// of the vendor variant is /odm or /vendor/odm.
|
|
|
|
// By replacing "vendor_available: true" with "odm_available: true", the
|
|
|
|
// module will install its vendor variant to the /odm partition or /vendor/odm.
|
|
|
|
// As the modules with "odm_available: true" still create the vendor variants,
|
|
|
|
// they can link to the other vendor modules as the vendor_available modules do.
|
|
|
|
// Also, the vendor modules can link to odm_available modules.
|
|
|
|
//
|
|
|
|
// It may not be used for VNDK modules.
|
|
|
|
Odm_available *bool
|
|
|
|
|
2020-10-29 08:49:43 +01:00
|
|
|
// whether this module should be allowed to be directly depended by other
|
|
|
|
// modules with `product_specific: true` or `product_available: true`.
|
|
|
|
// If set to true, an additional product variant will be built separately
|
|
|
|
// that is limited to the set of libraries and headers that are exposed to
|
|
|
|
// /product modules.
|
|
|
|
//
|
|
|
|
// The product variant may be used with a different (newer) /system,
|
|
|
|
// so it shouldn't have any unversioned runtime dependencies, or
|
|
|
|
// make assumptions about the system that may not be true in the
|
|
|
|
// future.
|
|
|
|
//
|
2020-10-29 10:24:11 +01:00
|
|
|
// If set to false, this module becomes inaccessible from /product modules.
|
|
|
|
//
|
|
|
|
// Different from the 'vendor_available' property, the modules with
|
|
|
|
// vndk: {enabled: true} don't have to define 'product_available'. The VNDK
|
|
|
|
// library without 'product_available' may not be depended on by any other
|
|
|
|
// modules that has product variants including the product available VNDKs.
|
2020-10-29 08:49:43 +01:00
|
|
|
//
|
|
|
|
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
|
|
|
|
// and PRODUCT_PRODUCT_VNDK_VERSION isn't set.
|
|
|
|
Product_available *bool
|
|
|
|
|
2018-04-09 05:03:06 +02:00
|
|
|
// whether this module is capable of being loaded with other instance
|
|
|
|
// (possibly an older version) of the same module in the same process.
|
|
|
|
// Currently, a shared library that is a member of VNDK (vndk: {enabled: true})
|
|
|
|
// can be double loaded in a vendor process if the library is also a
|
|
|
|
// (direct and indirect) dependency of an LLNDK library. Such libraries must be
|
|
|
|
// explicitly marked as `double_loadable: true` by the owner, or the dependency
|
|
|
|
// from the LLNDK lib should be cut if the lib is not designed to be double loaded.
|
|
|
|
Double_loadable *bool
|
2020-12-17 01:46:01 +01:00
|
|
|
|
|
|
|
// IsLLNDK is set to true for the vendor variant of a cc_library module that has LLNDK stubs.
|
|
|
|
IsLLNDK bool `blueprint:"mutated"`
|
|
|
|
|
2021-01-06 23:51:30 +01:00
|
|
|
// IsVNDKUsingCoreVariant is true for VNDK modules if the global VndkUseCoreVariant option is
|
|
|
|
// set and the module is not listed in VndkMustUseVendorVariantList.
|
|
|
|
IsVNDKUsingCoreVariant bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// IsVNDKCore is set if a VNDK module does not set the vndk.support_system_process property.
|
|
|
|
IsVNDKCore bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// IsVNDKSP is set if a VNDK module sets the vndk.support_system_process property.
|
|
|
|
IsVNDKSP bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// IsVNDKPrivate is set if a VNDK module sets the vndk.private property or an LLNDK
|
|
|
|
// module sets the llndk.private property.
|
|
|
|
IsVNDKPrivate bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// IsVNDKProduct is set if a VNDK module sets the product_available property.
|
|
|
|
IsVNDKProduct bool `blueprint:"mutated"`
|
2021-04-27 22:06:04 +02:00
|
|
|
|
|
|
|
// IsVendorPublicLibrary is set for the core and product variants of a library that has
|
|
|
|
// vendor_public_library stubs.
|
|
|
|
IsVendorPublicLibrary bool `blueprint:"mutated"`
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// ModuleContextIntf is an interface (on a module context helper) consisting of functions related
|
|
|
|
// to understanding details about the type of the current module.
|
|
|
|
// For example, one might call these functions to determine whether the current module is a static
|
|
|
|
// library and/or is installed in vendor directories.
|
2016-01-04 23:34:37 +01:00
|
|
|
type ModuleContextIntf interface {
|
|
|
|
static() bool
|
|
|
|
staticBinary() bool
|
2020-04-29 00:09:12 +02:00
|
|
|
testBinary() bool
|
2019-07-29 14:27:18 +02:00
|
|
|
header() bool
|
2020-06-01 14:53:49 +02:00
|
|
|
binary() bool
|
2020-06-01 16:23:05 +02:00
|
|
|
object() bool
|
2016-07-29 22:44:28 +02:00
|
|
|
toolchain() config.Toolchain
|
2020-03-06 19:45:53 +01:00
|
|
|
canUseSdk() bool
|
2017-09-28 02:01:44 +02:00
|
|
|
useSdk() bool
|
2016-01-04 23:34:37 +01:00
|
|
|
sdkVersion() string
|
2020-08-10 08:59:36 +02:00
|
|
|
minSdkVersion() string
|
|
|
|
isSdkVariant() bool
|
2017-09-28 02:01:44 +02:00
|
|
|
useVndk() bool
|
2020-10-30 04:47:22 +01:00
|
|
|
isNdk(config android.Config) bool
|
2020-12-17 01:46:01 +01:00
|
|
|
IsLlndk() bool
|
|
|
|
IsLlndkPublic() bool
|
|
|
|
isImplementationForLLNDKPublic() bool
|
|
|
|
IsVndkPrivate() bool
|
2017-06-23 12:24:43 +02:00
|
|
|
isVndk() bool
|
|
|
|
isVndkSp() bool
|
2020-12-02 15:00:51 +01:00
|
|
|
IsVndkExt() bool
|
2021-04-27 22:06:04 +02:00
|
|
|
IsVendorPublicLibrary() bool
|
2019-11-18 11:52:14 +01:00
|
|
|
inProduct() bool
|
|
|
|
inVendor() bool
|
2020-01-22 00:53:22 +01:00
|
|
|
inRamdisk() bool
|
2020-10-22 00:17:56 +02:00
|
|
|
inVendorRamdisk() bool
|
2018-01-31 16:54:12 +01:00
|
|
|
inRecovery() bool
|
2016-03-31 06:00:30 +02:00
|
|
|
selectedStl() string
|
2016-10-07 01:12:58 +02:00
|
|
|
baseModuleName() string
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
getVndkExtendsModuleName() string
|
2022-02-14 13:00:10 +01:00
|
|
|
isAfdoCompile() bool
|
2018-02-14 11:16:12 +01:00
|
|
|
isPgoCompile() bool
|
2022-08-19 10:02:45 +02:00
|
|
|
isCfi() bool
|
2018-12-11 00:12:40 +01:00
|
|
|
isNDKStubLibrary() bool
|
2018-11-27 23:33:03 +01:00
|
|
|
useClangLld(actx ModuleContext) bool
|
2019-12-03 20:18:32 +01:00
|
|
|
isForPlatform() bool
|
2020-08-13 20:24:56 +02:00
|
|
|
apexVariationName() string
|
2020-07-23 07:32:17 +02:00
|
|
|
apexSdkVersion() android.ApiLevel
|
2019-01-16 14:53:13 +01:00
|
|
|
bootstrap() bool
|
2018-11-13 05:19:56 +01:00
|
|
|
mustUseVendorVariant() bool
|
2019-03-25 18:21:31 +01:00
|
|
|
nativeCoverage() bool
|
2020-09-16 03:30:11 +02:00
|
|
|
directlyInAnyApex() bool
|
2020-12-16 20:06:50 +01:00
|
|
|
isPreventInstall() bool
|
2021-01-09 17:25:22 +01:00
|
|
|
isCfiAssemblySupportEnabled() bool
|
2022-01-09 04:56:09 +01:00
|
|
|
getSharedFlags() *SharedFlags
|
|
|
|
}
|
|
|
|
|
|
|
|
type SharedFlags struct {
|
|
|
|
numSharedFlags int
|
|
|
|
flagsMap map[string]string
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleContext interface {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.ModuleContext
|
2016-01-04 23:34:37 +01:00
|
|
|
ModuleContextIntf
|
|
|
|
}
|
|
|
|
|
|
|
|
type BaseModuleContext interface {
|
2019-06-06 23:33:29 +02:00
|
|
|
android.BaseModuleContext
|
2016-01-04 23:34:37 +01:00
|
|
|
ModuleContextIntf
|
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
type DepsContext interface {
|
|
|
|
android.BottomUpMutatorContext
|
|
|
|
ModuleContextIntf
|
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// feature represents additional (optional) steps to building cc-related modules, such as invocation
|
|
|
|
// of clang-tidy.
|
2016-01-04 23:34:37 +01:00
|
|
|
type feature interface {
|
|
|
|
flags(ctx ModuleContext, flags Flags) Flags
|
|
|
|
props() []interface{}
|
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// compiler is the interface for a compiler helper object. Different module decorators may implement
|
2022-01-07 16:53:37 +01:00
|
|
|
// this helper differently.
|
2016-01-04 23:34:37 +01:00
|
|
|
type compiler interface {
|
2016-08-01 22:20:05 +02:00
|
|
|
compilerInit(ctx BaseModuleContext)
|
2016-12-14 02:06:13 +01:00
|
|
|
compilerDeps(ctx DepsContext, deps Deps) Deps
|
2017-11-16 23:33:08 +01:00
|
|
|
compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
|
2016-08-01 22:20:05 +02:00
|
|
|
compilerProps() []interface{}
|
|
|
|
|
2016-07-27 19:31:13 +02:00
|
|
|
appendCflags([]string)
|
|
|
|
appendAsflags([]string)
|
2016-09-27 02:33:01 +02:00
|
|
|
compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// linker is the interface for a linker decorator object. Individual module types can provide
|
|
|
|
// their own implementation for this decorator, and thus specify custom logic regarding build
|
|
|
|
// statements pertaining to linking.
|
2016-01-04 23:34:37 +01:00
|
|
|
type linker interface {
|
2016-08-01 22:20:05 +02:00
|
|
|
linkerInit(ctx BaseModuleContext)
|
2016-12-14 02:06:13 +01:00
|
|
|
linkerDeps(ctx DepsContext, deps Deps) Deps
|
2016-08-01 22:20:05 +02:00
|
|
|
linkerFlags(ctx ModuleContext, flags Flags) Flags
|
|
|
|
linkerProps() []interface{}
|
2018-11-27 23:33:03 +01:00
|
|
|
useClangLld(actx ModuleContext) bool
|
2016-08-01 22:20:05 +02:00
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
|
2016-07-27 19:31:13 +02:00
|
|
|
appendLdflags([]string)
|
2019-01-31 04:21:23 +01:00
|
|
|
unstrippedOutputFilePath() android.Path
|
2019-03-25 18:21:31 +01:00
|
|
|
|
|
|
|
nativeCoverage() bool
|
2019-08-09 07:44:36 +02:00
|
|
|
coverageOutputFilePath() android.OptionalPath
|
2020-03-06 13:30:43 +01:00
|
|
|
|
|
|
|
// Get the deps that have been explicitly specified in the properties.
|
|
|
|
linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps
|
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// specifiedDeps is a tuple struct representing dependencies of a linked binary owned by the linker.
|
2020-03-06 13:30:43 +01:00
|
|
|
type specifiedDeps struct {
|
2020-12-02 00:26:21 +01:00
|
|
|
sharedLibs []string
|
|
|
|
// Note nil and [] are semantically distinct. [] prevents linking against the defaults (usually
|
|
|
|
// libc, libm, etc.)
|
2021-07-22 20:39:44 +02:00
|
|
|
systemSharedLibs []string
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// installer is the interface for an installer helper object. This helper is responsible for
|
|
|
|
// copying build outputs to the appropriate locations so that they may be installed on device.
|
2016-01-04 23:34:37 +01:00
|
|
|
type installer interface {
|
2016-08-01 22:20:05 +02:00
|
|
|
installerProps() []interface{}
|
2016-05-19 00:37:25 +02:00
|
|
|
install(ctx ModuleContext, path android.Path)
|
2020-03-04 15:52:46 +01:00
|
|
|
everInstallable() bool
|
2016-01-04 23:34:37 +01:00
|
|
|
inData() bool
|
2017-03-30 07:00:18 +02:00
|
|
|
inSanitizerDir() bool
|
2016-09-29 01:18:03 +02:00
|
|
|
hostToolPath() android.OptionalPath
|
2019-02-01 04:03:59 +01:00
|
|
|
relativeInstallPath() string
|
2020-08-06 23:34:42 +02:00
|
|
|
makeUninstallable(mod *Module)
|
2021-06-14 05:03:51 +02:00
|
|
|
installInRoot() bool
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2018-11-06 01:49:08 +01:00
|
|
|
type xref interface {
|
|
|
|
XrefCcFiles() android.Paths
|
|
|
|
}
|
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
type libraryDependencyKind int
|
|
|
|
|
|
|
|
const (
|
|
|
|
headerLibraryDependency = iota
|
|
|
|
sharedLibraryDependency
|
|
|
|
staticLibraryDependency
|
|
|
|
)
|
|
|
|
|
|
|
|
func (k libraryDependencyKind) String() string {
|
|
|
|
switch k {
|
|
|
|
case headerLibraryDependency:
|
|
|
|
return "headerLibraryDependency"
|
|
|
|
case sharedLibraryDependency:
|
|
|
|
return "sharedLibraryDependency"
|
|
|
|
case staticLibraryDependency:
|
|
|
|
return "staticLibraryDependency"
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown libraryDependencyKind %d", k))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type libraryDependencyOrder int
|
|
|
|
|
|
|
|
const (
|
|
|
|
earlyLibraryDependency = -1
|
|
|
|
normalLibraryDependency = 0
|
|
|
|
lateLibraryDependency = 1
|
|
|
|
)
|
|
|
|
|
|
|
|
func (o libraryDependencyOrder) String() string {
|
|
|
|
switch o {
|
|
|
|
case earlyLibraryDependency:
|
|
|
|
return "earlyLibraryDependency"
|
|
|
|
case normalLibraryDependency:
|
|
|
|
return "normalLibraryDependency"
|
|
|
|
case lateLibraryDependency:
|
|
|
|
return "lateLibraryDependency"
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown libraryDependencyOrder %d", o))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// libraryDependencyTag is used to tag dependencies on libraries. Unlike many dependency
|
|
|
|
// tags that have a set of predefined tag objects that are reused for each dependency, a
|
|
|
|
// libraryDependencyTag is designed to contain extra metadata and is constructed as needed.
|
|
|
|
// That means that comparing a libraryDependencyTag for equality will only be equal if all
|
|
|
|
// of the metadata is equal. Most usages will want to type assert to libraryDependencyTag and
|
|
|
|
// then check individual metadata fields instead.
|
|
|
|
type libraryDependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
|
|
|
|
// These are exported so that fmt.Printf("%#v") can call their String methods.
|
|
|
|
Kind libraryDependencyKind
|
|
|
|
Order libraryDependencyOrder
|
|
|
|
|
|
|
|
wholeStatic bool
|
|
|
|
|
|
|
|
reexportFlags bool
|
|
|
|
explicitlyVersioned bool
|
|
|
|
dataLib bool
|
|
|
|
ndk bool
|
|
|
|
|
|
|
|
staticUnwinder bool
|
|
|
|
|
|
|
|
makeSuffix string
|
2020-12-03 09:28:25 +01:00
|
|
|
|
2020-12-10 16:12:38 +01:00
|
|
|
// Whether or not this dependency should skip the apex dependency check
|
|
|
|
skipApexAllowedDependenciesCheck bool
|
|
|
|
|
2020-12-03 09:28:25 +01:00
|
|
|
// Whether or not this dependency has to be followed for the apex variants
|
|
|
|
excludeInApex bool
|
2022-06-18 00:17:05 +02:00
|
|
|
|
|
|
|
// If true, don't automatically export symbols from the static library into a shared library.
|
|
|
|
unexportedSymbols bool
|
2020-07-28 06:26:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// header returns true if the libraryDependencyTag is tagging a header lib dependency.
|
|
|
|
func (d libraryDependencyTag) header() bool {
|
|
|
|
return d.Kind == headerLibraryDependency
|
|
|
|
}
|
|
|
|
|
|
|
|
// shared returns true if the libraryDependencyTag is tagging a shared lib dependency.
|
|
|
|
func (d libraryDependencyTag) shared() bool {
|
|
|
|
return d.Kind == sharedLibraryDependency
|
|
|
|
}
|
|
|
|
|
|
|
|
// shared returns true if the libraryDependencyTag is tagging a static lib dependency.
|
|
|
|
func (d libraryDependencyTag) static() bool {
|
|
|
|
return d.Kind == staticLibraryDependency
|
|
|
|
}
|
|
|
|
|
2021-12-11 00:05:02 +01:00
|
|
|
func (d libraryDependencyTag) LicenseAnnotations() []android.LicenseAnnotation {
|
|
|
|
if d.shared() {
|
|
|
|
return []android.LicenseAnnotation{android.LicenseAnnotationSharedDependency}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ android.LicenseAnnotationsDependencyTag = libraryDependencyTag{}
|
|
|
|
|
2020-11-11 03:12:15 +01:00
|
|
|
// InstallDepNeeded returns true for shared libraries so that shared library dependencies of
|
|
|
|
// binaries or other shared libraries are installed as dependencies.
|
|
|
|
func (d libraryDependencyTag) InstallDepNeeded() bool {
|
|
|
|
return d.shared()
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ android.InstallNeededDependencyTag = libraryDependencyTag{}
|
|
|
|
|
|
|
|
// dependencyTag is used for tagging miscellaneous dependency types that don't fit into
|
2020-07-28 06:26:48 +02:00
|
|
|
// libraryDependencyTag. Each tag object is created globally and reused for multiple
|
|
|
|
// dependencies (although since the object contains no references, assigning a tag to a
|
|
|
|
// variable and modifying it will not modify the original). Users can compare the tag
|
|
|
|
// returned by ctx.OtherModuleDependencyTag against the global original
|
|
|
|
type dependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2020-11-11 03:12:15 +01:00
|
|
|
// installDependencyTag is used for tagging miscellaneous dependency types that don't fit into
|
|
|
|
// libraryDependencyTag, but where the dependency needs to be installed when the parent is
|
|
|
|
// installed.
|
|
|
|
type installDependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
android.InstallAlwaysNeededDependencyTag
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
var (
|
2020-07-28 06:26:48 +02:00
|
|
|
genSourceDepTag = dependencyTag{name: "gen source"}
|
|
|
|
genHeaderDepTag = dependencyTag{name: "gen header"}
|
|
|
|
genHeaderExportDepTag = dependencyTag{name: "gen header export"}
|
|
|
|
objDepTag = dependencyTag{name: "obj"}
|
2020-11-25 03:47:24 +01:00
|
|
|
dynamicLinkerDepTag = installDependencyTag{name: "dynamic linker"}
|
2020-07-28 06:26:48 +02:00
|
|
|
reuseObjTag = dependencyTag{name: "reuse objects"}
|
|
|
|
staticVariantTag = dependencyTag{name: "static variant"}
|
|
|
|
vndkExtDepTag = dependencyTag{name: "vndk extends"}
|
|
|
|
dataLibDepTag = dependencyTag{name: "data lib"}
|
2021-09-25 01:50:14 +02:00
|
|
|
dataBinDepTag = dependencyTag{name: "data bin"}
|
2020-11-11 03:12:15 +01:00
|
|
|
runtimeDepTag = installDependencyTag{name: "runtime lib"}
|
2020-07-28 06:26:48 +02:00
|
|
|
testPerSrcDepTag = dependencyTag{name: "test_per_src"}
|
2020-09-18 23:15:30 +02:00
|
|
|
stubImplDepTag = dependencyTag{name: "stub_impl"}
|
2022-03-25 23:50:53 +01:00
|
|
|
JniFuzzLibTag = dependencyTag{name: "jni_fuzz_lib_tag"}
|
2016-04-12 00:06:20 +02:00
|
|
|
)
|
|
|
|
|
2019-07-29 17:22:59 +02:00
|
|
|
func IsSharedDepTag(depTag blueprint.DependencyTag) bool {
|
2020-07-28 06:26:48 +02:00
|
|
|
ccLibDepTag, ok := depTag.(libraryDependencyTag)
|
|
|
|
return ok && ccLibDepTag.shared()
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsStaticDepTag(depTag blueprint.DependencyTag) bool {
|
|
|
|
ccLibDepTag, ok := depTag.(libraryDependencyTag)
|
|
|
|
return ok && ccLibDepTag.static()
|
2019-07-29 17:22:59 +02:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:56:27 +01:00
|
|
|
func IsHeaderDepTag(depTag blueprint.DependencyTag) bool {
|
|
|
|
ccLibDepTag, ok := depTag.(libraryDependencyTag)
|
|
|
|
return ok && ccLibDepTag.header()
|
|
|
|
}
|
|
|
|
|
2019-07-29 17:22:59 +02:00
|
|
|
func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool {
|
2020-11-11 03:12:15 +01:00
|
|
|
return depTag == runtimeDepTag
|
2019-07-29 17:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool {
|
2020-07-28 06:26:48 +02:00
|
|
|
ccDepTag, ok := depTag.(dependencyTag)
|
2019-07-29 17:22:59 +02:00
|
|
|
return ok && ccDepTag == testPerSrcDepTag
|
|
|
|
}
|
|
|
|
|
2022-05-10 19:50:12 +02:00
|
|
|
// bazelHandler is the interface for a helper object related to deferring to Bazel for
|
|
|
|
// processing a cc module (during Bazel mixed builds). Individual module types should define
|
|
|
|
// their own bazel handler if they support being handled by Bazel.
|
|
|
|
type BazelHandler interface {
|
|
|
|
// QueueBazelCall invokes request-queueing functions on the BazelContext
|
|
|
|
//so that these requests are handled when Bazel's cquery is invoked.
|
|
|
|
QueueBazelCall(ctx android.BaseModuleContext, label string)
|
|
|
|
|
|
|
|
// ProcessBazelQueryResponse uses information retrieved from Bazel to set properties
|
|
|
|
// on the current module with given label.
|
|
|
|
ProcessBazelQueryResponse(ctx android.ModuleContext, label string)
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
// Module contains the properties and members used by all C/C++ module types, and implements
|
|
|
|
// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
|
2020-12-02 00:26:21 +01:00
|
|
|
// to construct the output file. Behavior can be customized with a Customizer, or "decorator",
|
|
|
|
// interface.
|
|
|
|
//
|
|
|
|
// To define a C/C++ related module, construct a new Module object and point its delegates to
|
|
|
|
// type-specific structs. These delegates will be invoked to register module-specific build
|
|
|
|
// statements which may be unique to the module type. For example, module.compiler.compile() should
|
|
|
|
// be defined so as to register build statements which are responsible for compiling the module.
|
|
|
|
//
|
|
|
|
// Another example: to construct a cc_binary module, one can create a `cc.binaryDecorator` struct
|
|
|
|
// which implements the `linker` and `installer` interfaces, and points the `linker` and `installer`
|
|
|
|
// members of the cc.Module to this decorator. Thus, a cc_binary module has custom linker and
|
|
|
|
// installer logic.
|
2016-01-04 23:34:37 +01:00
|
|
|
type Module struct {
|
2021-07-22 21:05:08 +02:00
|
|
|
fuzz.FuzzModule
|
2021-07-07 23:00:07 +02:00
|
|
|
|
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
|
|
|
android.SdkBase
|
2021-02-17 16:17:28 +01:00
|
|
|
android.BazelModuleBase
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
VendorProperties VendorProperties
|
2021-07-07 23:00:07 +02:00
|
|
|
Properties BaseProperties
|
2016-01-04 23:34:37 +01:00
|
|
|
|
|
|
|
// initialize before calling Init
|
2021-11-01 20:32:43 +01:00
|
|
|
hod android.HostOrDeviceSupported
|
|
|
|
multilib android.Multilib
|
|
|
|
bazelable bool
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2019-12-13 20:50:38 +01:00
|
|
|
// Allowable SdkMemberTypes of this module type.
|
|
|
|
sdkMemberTypes []android.SdkMemberType
|
|
|
|
|
2020-12-02 00:26:21 +01:00
|
|
|
// decorator delegates, initialize before calling Init
|
|
|
|
// these may contain module-specific implementations, and effectively allow for custom
|
|
|
|
// type-specific logic. These members may reference different objects or the same object.
|
|
|
|
// Functions of these decorators will be invoked to initialize and register type-specific
|
|
|
|
// build statements.
|
2021-02-22 22:13:50 +01:00
|
|
|
compiler compiler
|
|
|
|
linker linker
|
|
|
|
installer installer
|
2022-05-10 19:50:12 +02:00
|
|
|
bazelHandler BazelHandler
|
2020-12-02 00:26:21 +01:00
|
|
|
|
|
|
|
features []feature
|
|
|
|
stl *stl
|
|
|
|
sanitize *sanitize
|
|
|
|
coverage *coverage
|
2022-06-07 22:12:06 +02:00
|
|
|
fuzzer *fuzzer
|
2020-12-02 00:26:21 +01:00
|
|
|
sabi *sabi
|
|
|
|
vndkdep *vndkdep
|
|
|
|
lto *lto
|
2021-12-09 11:06:29 +01:00
|
|
|
afdo *afdo
|
2020-12-02 00:26:21 +01:00
|
|
|
pgo *pgo
|
2016-01-06 23:41:07 +01:00
|
|
|
|
2020-10-24 02:22:06 +02:00
|
|
|
library libraryInterface
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
outputFile android.OptionalPath
|
2015-04-28 22:30:13 +02:00
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
cachedToolchain config.Toolchain
|
2016-07-30 02:28:03 +02:00
|
|
|
|
|
|
|
subAndroidMkOnce map[subAndroidMkProvider]bool
|
2017-01-11 01:21:22 +01:00
|
|
|
|
|
|
|
// Flags used to compile this module
|
|
|
|
flags Flags
|
2017-09-28 02:05:30 +02:00
|
|
|
|
2022-01-09 04:56:09 +01:00
|
|
|
// Shared flags among build rules of this module
|
|
|
|
sharedFlags SharedFlags
|
|
|
|
|
2017-11-28 00:48:57 +01:00
|
|
|
// only non-nil when this is a shared library that reuses the objects of a static library
|
2020-09-18 23:15:30 +02:00
|
|
|
staticAnalogue *StaticLibraryInfo
|
2019-05-09 03:56:13 +02:00
|
|
|
|
|
|
|
makeLinkType string
|
2018-11-06 01:49:08 +01:00
|
|
|
// Kythe (source file indexer) paths for this compilation module
|
|
|
|
kytheFiles android.Paths
|
2021-10-12 01:46:56 +02:00
|
|
|
// Object .o file output paths for this compilation module
|
|
|
|
objFiles android.Paths
|
|
|
|
// Tidy .tidy file output paths for this compilation module
|
|
|
|
tidyFiles android.Paths
|
Enforce apex.min_sdk_version for bundled builds
Previously, when Q-targeting apexes are bundled-built, they are built
against the latest stubs.
It was because unwinder is linked dynamically in R and APIs are provided
by libc while Q apexes should run on Q where libc doesn't provide those
APIs. To make Q apexes run on Q device, libc++ should be linked with
static unwinder. But, because libc++ with static unwinder may cause problem
on HWASAN build, Q apexes were built against the latest stubs for bundled
build.
However, Q apexes should be built against Q stubs.
Now, only for HWASAN builds, Q apexes are built against the latest stubs
(and native modules are not linked with static unwinder).
Bug: 151912436
Test: TARGET_SANITIZE=hwaddress m
=> Q apexes(media, resolv, ..) are linked with the latest stubs
m
=> Q apexes are linked with Q stubs,
and Q apexes' libc++ is linked with static unwinder
Merged-In: If32f1b547e6d93e3955c7521eec8aef5851f908c
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
(cherry picked from commit 7406660685a9a085c433ba7081cc6984f66fa732)
Exempt-From-Owner-Approval: cp from internal
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
2020-03-19 20:29:24 +01:00
|
|
|
|
|
|
|
// For apex variants, this is set as apex.min_sdk_version
|
2020-07-23 07:32:17 +02:00
|
|
|
apexSdkVersion android.ApiLevel
|
2020-09-16 03:30:11 +02:00
|
|
|
|
|
|
|
hideApexVariantFromMake bool
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
2021-06-25 09:11:22 +02:00
|
|
|
func (c *Module) AddJSONData(d *map[string]interface{}) {
|
2021-08-17 23:29:51 +02:00
|
|
|
var hasAidl, hasLex, hasProto, hasRenderscript, hasSysprop, hasWinMsg, hasYacc bool
|
|
|
|
if b, ok := c.compiler.(*baseCompiler); ok {
|
|
|
|
hasAidl = b.hasSrcExt(".aidl")
|
|
|
|
hasLex = b.hasSrcExt(".l") || b.hasSrcExt(".ll")
|
|
|
|
hasProto = b.hasSrcExt(".proto")
|
|
|
|
hasRenderscript = b.hasSrcExt(".rscript") || b.hasSrcExt(".fs")
|
|
|
|
hasSysprop = b.hasSrcExt(".sysprop")
|
|
|
|
hasWinMsg = b.hasSrcExt(".mc")
|
|
|
|
hasYacc = b.hasSrcExt(".y") || b.hasSrcExt(".yy")
|
|
|
|
}
|
2021-06-25 09:11:22 +02:00
|
|
|
c.AndroidModuleBase().AddJSONData(d)
|
|
|
|
(*d)["Cc"] = map[string]interface{}{
|
|
|
|
"SdkVersion": c.SdkVersion(),
|
|
|
|
"MinSdkVersion": c.MinSdkVersion(),
|
|
|
|
"VndkVersion": c.VndkVersion(),
|
|
|
|
"ProductSpecific": c.ProductSpecific(),
|
|
|
|
"SocSpecific": c.SocSpecific(),
|
|
|
|
"DeviceSpecific": c.DeviceSpecific(),
|
|
|
|
"InProduct": c.InProduct(),
|
|
|
|
"InVendor": c.InVendor(),
|
|
|
|
"InRamdisk": c.InRamdisk(),
|
|
|
|
"InVendorRamdisk": c.InVendorRamdisk(),
|
|
|
|
"InRecovery": c.InRecovery(),
|
|
|
|
"VendorAvailable": c.VendorAvailable(),
|
|
|
|
"ProductAvailable": c.ProductAvailable(),
|
|
|
|
"RamdiskAvailable": c.RamdiskAvailable(),
|
|
|
|
"VendorRamdiskAvailable": c.VendorRamdiskAvailable(),
|
|
|
|
"RecoveryAvailable": c.RecoveryAvailable(),
|
|
|
|
"OdmAvailable": c.OdmAvailable(),
|
|
|
|
"InstallInData": c.InstallInData(),
|
|
|
|
"InstallInRamdisk": c.InstallInRamdisk(),
|
|
|
|
"InstallInSanitizerDir": c.InstallInSanitizerDir(),
|
|
|
|
"InstallInVendorRamdisk": c.InstallInVendorRamdisk(),
|
|
|
|
"InstallInRecovery": c.InstallInRecovery(),
|
|
|
|
"InstallInRoot": c.InstallInRoot(),
|
|
|
|
"IsVndk": c.IsVndk(),
|
|
|
|
"IsVndkExt": c.IsVndkExt(),
|
|
|
|
"IsVndkPrivate": c.IsVndkPrivate(),
|
|
|
|
"IsVndkSp": c.IsVndkSp(),
|
|
|
|
"IsLlndk": c.IsLlndk(),
|
|
|
|
"IsLlndkPublic": c.IsLlndkPublic(),
|
|
|
|
"IsSnapshotLibrary": c.IsSnapshotLibrary(),
|
|
|
|
"IsSnapshotPrebuilt": c.IsSnapshotPrebuilt(),
|
|
|
|
"IsVendorPublicLibrary": c.IsVendorPublicLibrary(),
|
|
|
|
"ApexSdkVersion": c.apexSdkVersion,
|
|
|
|
"TestFor": c.TestFor(),
|
2021-08-17 23:29:51 +02:00
|
|
|
"AidlSrcs": hasAidl,
|
|
|
|
"LexSrcs": hasLex,
|
|
|
|
"ProtoSrcs": hasProto,
|
|
|
|
"RenderscriptSrcs": hasRenderscript,
|
|
|
|
"SyspropSrcs": hasSysprop,
|
|
|
|
"WinMsgSrcs": hasWinMsg,
|
|
|
|
"YaccSrsc": hasYacc,
|
|
|
|
"OnlyCSrcs": !(hasAidl || hasLex || hasProto || hasRenderscript || hasSysprop || hasWinMsg || hasYacc),
|
2021-06-25 09:11:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-14 17:27:52 +01:00
|
|
|
func (c *Module) SetPreventInstall() {
|
|
|
|
c.Properties.PreventInstall = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SetHideFromMake() {
|
|
|
|
c.Properties.HideFromMake = true
|
|
|
|
}
|
|
|
|
|
2021-04-01 15:49:36 +02:00
|
|
|
func (c *Module) HiddenFromMake() bool {
|
|
|
|
return c.Properties.HideFromMake
|
|
|
|
}
|
|
|
|
|
2021-06-18 13:44:24 +02:00
|
|
|
func (c *Module) RequiredModuleNames() []string {
|
|
|
|
required := android.CopyOf(c.ModuleBase.RequiredModuleNames())
|
|
|
|
if c.ImageVariation().Variation == android.CoreVariation {
|
|
|
|
required = append(required, c.Properties.Target.Platform.Required...)
|
|
|
|
required = removeListFromList(required, c.Properties.Target.Platform.Exclude_required)
|
|
|
|
} else if c.InRecovery() {
|
|
|
|
required = append(required, c.Properties.Target.Recovery.Required...)
|
|
|
|
required = removeListFromList(required, c.Properties.Target.Recovery.Exclude_required)
|
|
|
|
}
|
|
|
|
return android.FirstUniqueStrings(required)
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) Toc() android.OptionalPath {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
|
|
|
return library.toc()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("Toc() called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) ApiLevel() string {
|
|
|
|
if c.linker != nil {
|
|
|
|
if stub, ok := c.linker.(*stubDecorator); ok {
|
Replace stringly-typed API levels.
Handling of API levels within Soong is currently fairly difficult
since it isn't always clear based on context what kind of API level a
given string represents, how much canonicalizing and error checking
the code receiving the string are expected to do, or how those errors
should be treated.
The API level struct does not export its raw data, so as to keep its
"constructor" private to the android package, and to prevent misuse of
the `number` field, which is only an implementation detail for preview
API levels. API levels can be parsed with either
`android.ApiLevelFromUser`, which returns any errors to the caller, or
`android.ApiLevelOrPanic`, which is used in the case where the input
is trusted and any errors in parsing should panic. Even within the
`android` package, these APIs should be preferred over direct
construction.
For cases where there are context specific parsing requirements, such
as handling the "minimum" alias in the cc module,
`nativeApiLevelFromUser` and `nativeApiLevelOrPanic` should be used
instead.
Test: treehugger
Bug: http://b/154667674
Change-Id: Id52921fda32cb437fb1775ac2183299dedc0cf20
2020-07-06 23:49:35 +02:00
|
|
|
return stub.apiLevel.String()
|
2019-10-18 23:49:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("ApiLevel() called on non-stub library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) Static() bool {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
|
|
|
return library.static()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("Static() called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) Shared() bool {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
|
|
|
return library.shared()
|
|
|
|
}
|
|
|
|
}
|
2022-06-13 20:50:39 +02:00
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
panic(fmt.Errorf("Shared() called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SelectedStl() string {
|
2020-04-07 18:50:32 +02:00
|
|
|
if c.stl != nil {
|
|
|
|
return c.stl.Properties.SelectedStl
|
|
|
|
}
|
|
|
|
return ""
|
2019-10-18 23:49:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) NdkPrebuiltStl() bool {
|
|
|
|
if _, ok := c.linker.(*ndkPrebuiltStlLinker); ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) StubDecorator() bool {
|
|
|
|
if _, ok := c.linker.(*stubDecorator); ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SdkVersion() string {
|
|
|
|
return String(c.Properties.Sdk_version)
|
|
|
|
}
|
|
|
|
|
2020-04-27 19:53:18 +02:00
|
|
|
func (c *Module) MinSdkVersion() string {
|
|
|
|
return String(c.Properties.Min_sdk_version)
|
|
|
|
}
|
|
|
|
|
2021-08-25 09:18:46 +02:00
|
|
|
func (c *Module) isCrt() bool {
|
2020-07-15 22:33:30 +02:00
|
|
|
if linker, ok := c.linker.(*objectLinker); ok {
|
|
|
|
return linker.isCrt()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-08-25 09:18:46 +02:00
|
|
|
func (c *Module) SplitPerApiLevel() bool {
|
|
|
|
return c.canUseSdk() && c.isCrt()
|
|
|
|
}
|
|
|
|
|
2020-04-07 18:50:32 +02:00
|
|
|
func (c *Module) AlwaysSdk() bool {
|
|
|
|
return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only)
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
func (c *Module) CcLibrary() bool {
|
|
|
|
if c.linker != nil {
|
|
|
|
if _, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
return true
|
|
|
|
}
|
2020-09-24 05:37:24 +02:00
|
|
|
if _, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
|
|
return true
|
|
|
|
}
|
2019-10-18 23:18:45 +02:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) CcLibraryInterface() bool {
|
2019-10-18 23:49:46 +02:00
|
|
|
if _, ok := c.linker.(libraryInterface); ok {
|
2019-10-18 23:18:45 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-11-21 21:30:50 +01:00
|
|
|
func (c *Module) NonCcVariants() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
func (c *Module) SetStatic() {
|
|
|
|
if c.linker != nil {
|
2019-10-18 23:49:46 +02:00
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
2019-10-18 23:18:45 +02:00
|
|
|
library.setStatic()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("SetStatic called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SetShared() {
|
|
|
|
if c.linker != nil {
|
2019-10-18 23:49:46 +02:00
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
2019-10-18 23:18:45 +02:00
|
|
|
library.setShared()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("SetShared called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) BuildStaticVariant() bool {
|
|
|
|
if c.linker != nil {
|
2019-10-18 23:49:46 +02:00
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
2019-10-18 23:18:45 +02:00
|
|
|
return library.buildStatic()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("BuildStaticVariant called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) BuildSharedVariant() bool {
|
|
|
|
if c.linker != nil {
|
2019-10-18 23:49:46 +02:00
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
2019-10-18 23:18:45 +02:00
|
|
|
return library.buildShared()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("BuildSharedVariant called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) Module() android.Module {
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2018-09-05 15:36:17 +02:00
|
|
|
func (c *Module) OutputFile() android.OptionalPath {
|
|
|
|
return c.outputFile
|
|
|
|
}
|
|
|
|
|
2020-04-09 15:56:02 +02:00
|
|
|
func (c *Module) CoverageFiles() android.Paths {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(libraryInterface); ok {
|
|
|
|
return library.objs().coverageFiles
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("CoverageFiles called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
var _ LinkableInterface = (*Module)(nil)
|
|
|
|
|
2019-01-12 16:39:51 +01:00
|
|
|
func (c *Module) UnstrippedOutputFile() android.Path {
|
2019-01-31 04:21:23 +01:00
|
|
|
if c.linker != nil {
|
|
|
|
return c.linker.unstrippedOutputFilePath()
|
2019-01-12 16:39:51 +01:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-08-09 07:44:36 +02:00
|
|
|
func (c *Module) CoverageOutputFile() android.OptionalPath {
|
|
|
|
if c.linker != nil {
|
|
|
|
return c.linker.coverageOutputFilePath()
|
|
|
|
}
|
|
|
|
return android.OptionalPath{}
|
|
|
|
}
|
|
|
|
|
2019-02-01 04:03:59 +01:00
|
|
|
func (c *Module) RelativeInstallPath() string {
|
|
|
|
if c.installer != nil {
|
|
|
|
return c.installer.relativeInstallPath()
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2019-08-23 04:17:39 +02:00
|
|
|
func (c *Module) VndkVersion() string {
|
2019-11-18 11:52:14 +01:00
|
|
|
return c.Properties.VndkVersion
|
2019-08-23 04:17:39 +02:00
|
|
|
}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
func (c *Module) Init() android.Module {
|
2018-05-09 22:45:03 +02:00
|
|
|
c.AddProperties(&c.Properties, &c.VendorProperties)
|
2016-01-04 23:34:37 +01:00
|
|
|
if c.compiler != nil {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(c.compiler.compilerProps()...)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
if c.linker != nil {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(c.linker.linkerProps()...)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
if c.installer != nil {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(c.installer.installerProps()...)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-04-05 00:07:06 +02:00
|
|
|
if c.stl != nil {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(c.stl.props()...)
|
2016-04-05 00:07:06 +02:00
|
|
|
}
|
2016-01-06 23:41:07 +01:00
|
|
|
if c.sanitize != nil {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(c.sanitize.props()...)
|
2016-01-06 23:41:07 +01:00
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
if c.coverage != nil {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(c.coverage.props()...)
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
2022-06-07 22:12:06 +02:00
|
|
|
if c.fuzzer != nil {
|
|
|
|
c.AddProperties(c.fuzzer.props()...)
|
|
|
|
}
|
2017-02-08 22:45:53 +01:00
|
|
|
if c.sabi != nil {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(c.sabi.props()...)
|
2017-02-08 22:45:53 +01:00
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
if c.vndkdep != nil {
|
|
|
|
c.AddProperties(c.vndkdep.props()...)
|
|
|
|
}
|
2017-05-10 00:44:35 +02:00
|
|
|
if c.lto != nil {
|
|
|
|
c.AddProperties(c.lto.props()...)
|
|
|
|
}
|
2021-12-09 11:06:29 +01:00
|
|
|
if c.afdo != nil {
|
|
|
|
c.AddProperties(c.afdo.props()...)
|
|
|
|
}
|
2017-09-01 08:38:27 +02:00
|
|
|
if c.pgo != nil {
|
|
|
|
c.AddProperties(c.pgo.props()...)
|
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
for _, feature := range c.features {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(feature.props()...)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2015-03-17 23:06:21 +01:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
2021-11-01 20:32:43 +01:00
|
|
|
if c.bazelable {
|
|
|
|
android.InitBazelModule(c)
|
|
|
|
}
|
2019-09-30 12:13:12 +02:00
|
|
|
android.InitApexModule(c)
|
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
|
|
|
android.InitSdkAwareModule(c)
|
2019-11-13 02:50:48 +01:00
|
|
|
android.InitDefaultableModule(c)
|
2018-10-02 17:38:19 +02:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
return c
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2015-03-17 23:06:21 +01:00
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) UseVndk() bool {
|
2019-08-26 09:52:35 +02:00
|
|
|
return c.Properties.VndkVersion != ""
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
}
|
|
|
|
|
2020-04-07 18:50:32 +02:00
|
|
|
func (c *Module) canUseSdk() bool {
|
2021-01-19 23:56:07 +01:00
|
|
|
return c.Os() == android.Android && c.Target().NativeBridge == android.NativeBridgeDisabled &&
|
|
|
|
!c.UseVndk() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
|
2020-04-07 18:50:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) UseSdk() bool {
|
|
|
|
if c.canUseSdk() {
|
2020-10-01 22:37:16 +02:00
|
|
|
return String(c.Properties.Sdk_version) != ""
|
2020-04-07 18:50:32 +02:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-12-11 00:12:40 +01:00
|
|
|
func (c *Module) isCoverageVariant() bool {
|
|
|
|
return c.coverage.Properties.IsCoverageVariant
|
|
|
|
}
|
|
|
|
|
2020-10-30 04:47:22 +01:00
|
|
|
func (c *Module) IsNdk(config android.Config) bool {
|
|
|
|
return inList(c.BaseModuleName(), *getNDKKnownLibs(config))
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
func (c *Module) IsLlndk() bool {
|
|
|
|
return c.VendorProperties.IsLLNDK
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
func (c *Module) IsLlndkPublic() bool {
|
2021-01-06 23:51:30 +01:00
|
|
|
return c.VendorProperties.IsLLNDK && !c.VendorProperties.IsVNDKPrivate
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2021-04-27 03:37:44 +02:00
|
|
|
func (m *Module) NeedsLlndkVariants() bool {
|
2021-03-30 18:19:36 +02:00
|
|
|
lib := moduleLibraryInterface(m)
|
2021-04-27 03:37:44 +02:00
|
|
|
return lib != nil && (lib.hasLLNDKStubs() || lib.hasLLNDKHeaders())
|
2021-03-30 18:19:36 +02:00
|
|
|
}
|
|
|
|
|
2021-04-27 22:06:04 +02:00
|
|
|
func (m *Module) NeedsVendorPublicLibraryVariants() bool {
|
|
|
|
lib := moduleLibraryInterface(m)
|
|
|
|
return lib != nil && (lib.hasVendorPublicLibrary())
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsVendorPublicLibrary returns true for vendor public libraries.
|
|
|
|
func (c *Module) IsVendorPublicLibrary() bool {
|
|
|
|
return c.VendorProperties.IsVendorPublicLibrary
|
|
|
|
}
|
|
|
|
|
2022-04-12 19:08:36 +02:00
|
|
|
func (c *Module) IsVndkPrebuiltLibrary() bool {
|
|
|
|
if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SdkAndPlatformVariantVisibleToMake() bool {
|
|
|
|
return c.Properties.SdkAndPlatformVariantVisibleToMake
|
|
|
|
}
|
|
|
|
|
2021-04-01 15:49:36 +02:00
|
|
|
func (c *Module) HasLlndkStubs() bool {
|
|
|
|
lib := moduleLibraryInterface(c)
|
|
|
|
return lib != nil && lib.hasLLNDKStubs()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) StubsVersion() string {
|
|
|
|
if lib, ok := c.linker.(versionedInterface); ok {
|
|
|
|
return lib.stubsVersion()
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("StubsVersion called on non-versioned module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
// isImplementationForLLNDKPublic returns true for any variant of a cc_library that has LLNDK stubs
|
|
|
|
// and does not set llndk.vendor_available: false.
|
|
|
|
func (c *Module) isImplementationForLLNDKPublic() bool {
|
|
|
|
library, _ := c.library.(*libraryDecorator)
|
|
|
|
return library != nil && library.hasLLNDKStubs() &&
|
2021-03-02 20:00:07 +01:00
|
|
|
!Bool(library.Properties.Llndk.Private)
|
2020-12-17 01:46:01 +01:00
|
|
|
}
|
|
|
|
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
// Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
|
2020-12-17 01:46:01 +01:00
|
|
|
func (c *Module) IsVndkPrivate() bool {
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
// Check if VNDK-core-private or VNDK-SP-private
|
|
|
|
if c.IsVndk() {
|
2021-01-07 09:45:31 +01:00
|
|
|
return Bool(c.vndkdep.Properties.Vndk.Private)
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if LLNDK-private
|
|
|
|
if library, ok := c.library.(*libraryDecorator); ok && c.IsLlndk() {
|
2021-01-07 09:45:31 +01:00
|
|
|
return Bool(library.Properties.Llndk.Private)
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) IsVndk() bool {
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
if vndkdep := c.vndkdep; vndkdep != nil {
|
|
|
|
return vndkdep.isVndk()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-02-14 13:00:10 +01:00
|
|
|
func (c *Module) isAfdoCompile() bool {
|
|
|
|
if afdo := c.afdo; afdo != nil {
|
|
|
|
return afdo.Properties.AfdoTarget != nil
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:16:12 +01:00
|
|
|
func (c *Module) isPgoCompile() bool {
|
|
|
|
if pgo := c.pgo; pgo != nil {
|
|
|
|
return pgo.Properties.PgoCompile
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-08-19 10:02:45 +02:00
|
|
|
func (c *Module) isCfi() bool {
|
|
|
|
if sanitize := c.sanitize; sanitize != nil {
|
|
|
|
return Bool(sanitize.Properties.Sanitize.Cfi)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-12-11 00:12:40 +01:00
|
|
|
func (c *Module) isNDKStubLibrary() bool {
|
|
|
|
if _, ok := c.compiler.(*stubDecorator); ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-04-01 15:49:36 +02:00
|
|
|
func (c *Module) IsVndkSp() bool {
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
if vndkdep := c.vndkdep; vndkdep != nil {
|
|
|
|
return vndkdep.isVndkSp()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-12-02 15:00:51 +01:00
|
|
|
func (c *Module) IsVndkExt() bool {
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
if vndkdep := c.vndkdep; vndkdep != nil {
|
|
|
|
return vndkdep.isVndkExt()
|
2017-06-23 12:24:43 +02:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-04-02 18:41:32 +02:00
|
|
|
func (c *Module) SubName() string {
|
|
|
|
return c.Properties.SubName
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) MustUseVendorVariant() bool {
|
2021-04-01 15:49:36 +02:00
|
|
|
return c.IsVndkSp() || c.Properties.MustUseVendorVariant
|
2018-11-13 05:19:56 +01:00
|
|
|
}
|
|
|
|
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
func (c *Module) getVndkExtendsModuleName() string {
|
|
|
|
if vndkdep := c.vndkdep; vndkdep != nil {
|
|
|
|
return vndkdep.getVndkExtendsModuleName()
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
func (c *Module) IsStubs() bool {
|
2020-10-24 02:22:06 +02:00
|
|
|
if lib := c.library; lib != nil {
|
|
|
|
return lib.buildStubs()
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) HasStubsVariants() bool {
|
2020-10-24 02:22:06 +02:00
|
|
|
if lib := c.library; lib != nil {
|
|
|
|
return lib.hasStubsVariants()
|
2019-04-24 23:41:12 +02:00
|
|
|
}
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-10-14 03:43:54 +02:00
|
|
|
// If this is a stubs library, ImplementationModuleName returns the name of the module that contains
|
|
|
|
// the implementation. If it is an implementation library it returns its own name.
|
|
|
|
func (c *Module) ImplementationModuleName(ctx android.BaseModuleContext) string {
|
|
|
|
name := ctx.OtherModuleName(c)
|
|
|
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
|
|
name = versioned.implementationModuleName(name)
|
|
|
|
}
|
|
|
|
return name
|
|
|
|
}
|
|
|
|
|
2020-12-02 16:03:42 +01:00
|
|
|
// Similar to ImplementationModuleName, but uses the Make variant of the module
|
|
|
|
// name as base name, for use in AndroidMk output. E.g. for a prebuilt module
|
|
|
|
// where the Soong name is prebuilt_foo, this returns foo (which works in Make
|
|
|
|
// under the premise that the prebuilt module overrides its source counterpart
|
|
|
|
// if it is exposed to Make).
|
|
|
|
func (c *Module) ImplementationModuleNameForMake(ctx android.BaseModuleContext) string {
|
|
|
|
name := c.BaseModuleName()
|
|
|
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
|
|
name = versioned.implementationModuleName(name)
|
|
|
|
}
|
|
|
|
return name
|
|
|
|
}
|
|
|
|
|
2021-06-11 10:22:09 +02:00
|
|
|
func (c *Module) Bootstrap() bool {
|
2019-01-16 14:53:13 +01:00
|
|
|
return Bool(c.Properties.Bootstrap)
|
|
|
|
}
|
|
|
|
|
2019-03-25 18:21:31 +01:00
|
|
|
func (c *Module) nativeCoverage() bool {
|
2019-09-12 22:18:48 +02:00
|
|
|
// Bug: http://b/137883967 - native-bridge modules do not currently work with coverage
|
|
|
|
if c.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
return false
|
|
|
|
}
|
2019-03-25 18:21:31 +01:00
|
|
|
return c.linker != nil && c.linker.nativeCoverage()
|
|
|
|
}
|
|
|
|
|
2021-03-30 18:19:36 +02:00
|
|
|
func (c *Module) IsSnapshotPrebuilt() bool {
|
2021-05-26 21:33:11 +02:00
|
|
|
if p, ok := c.linker.(SnapshotInterface); ok {
|
|
|
|
return p.IsSnapshotPrebuilt()
|
2020-01-22 03:11:29 +01:00
|
|
|
}
|
|
|
|
return false
|
2019-11-15 01:59:12 +01:00
|
|
|
}
|
|
|
|
|
2020-09-01 01:07:58 +02:00
|
|
|
func (c *Module) ExcludeFromVendorSnapshot() bool {
|
|
|
|
return Bool(c.Properties.Exclude_from_vendor_snapshot)
|
|
|
|
}
|
|
|
|
|
2020-11-13 21:07:36 +01:00
|
|
|
func (c *Module) ExcludeFromRecoverySnapshot() bool {
|
|
|
|
return Bool(c.Properties.Exclude_from_recovery_snapshot)
|
|
|
|
}
|
|
|
|
|
2019-02-25 03:05:47 +01:00
|
|
|
func isBionic(name string) bool {
|
|
|
|
switch name {
|
2020-11-30 06:42:14 +01:00
|
|
|
case "libc", "libm", "libdl", "libdl_android", "linker", "linkerconfig":
|
2019-02-25 03:05:47 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-09-11 00:18:20 +02:00
|
|
|
func InstallToBootstrap(name string, config android.Config) bool {
|
2022-02-10 20:41:18 +01:00
|
|
|
if name == "libclang_rt.hwasan" {
|
2020-05-15 12:05:05 +02:00
|
|
|
return true
|
2019-04-24 23:41:12 +02:00
|
|
|
}
|
|
|
|
return isBionic(name)
|
|
|
|
}
|
|
|
|
|
2018-11-06 01:49:08 +01:00
|
|
|
func (c *Module) XrefCcFiles() android.Paths {
|
|
|
|
return c.kytheFiles
|
|
|
|
}
|
|
|
|
|
2021-01-09 17:25:22 +01:00
|
|
|
func (c *Module) isCfiAssemblySupportEnabled() bool {
|
|
|
|
return c.sanitize != nil &&
|
|
|
|
Bool(c.sanitize.Properties.Sanitize.Config.Cfi_assembly_support)
|
|
|
|
}
|
|
|
|
|
2021-06-14 05:03:51 +02:00
|
|
|
func (c *Module) InstallInRoot() bool {
|
|
|
|
return c.installer != nil && c.installer.installInRoot()
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
type baseModuleContext struct {
|
2019-06-06 23:33:29 +02:00
|
|
|
android.BaseModuleContext
|
2016-01-04 23:34:37 +01:00
|
|
|
moduleContextImpl
|
|
|
|
}
|
2015-11-03 01:43:11 +01:00
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
type depsContext struct {
|
|
|
|
android.BottomUpMutatorContext
|
|
|
|
moduleContextImpl
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
type moduleContext struct {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.ModuleContext
|
2016-01-04 23:34:37 +01:00
|
|
|
moduleContextImpl
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
type moduleContextImpl struct {
|
|
|
|
mod *Module
|
|
|
|
ctx BaseModuleContext
|
|
|
|
}
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
func (ctx *moduleContextImpl) toolchain() config.Toolchain {
|
2016-01-04 23:34:37 +01:00
|
|
|
return ctx.mod.toolchain(ctx.ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) static() bool {
|
2017-11-01 10:20:21 +01:00
|
|
|
return ctx.mod.static()
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
func (ctx *moduleContextImpl) staticBinary() bool {
|
2018-12-18 18:47:14 +01:00
|
|
|
return ctx.mod.staticBinary()
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-04-29 00:09:12 +02:00
|
|
|
func (ctx *moduleContextImpl) testBinary() bool {
|
|
|
|
return ctx.mod.testBinary()
|
|
|
|
}
|
|
|
|
|
2019-07-29 14:27:18 +02:00
|
|
|
func (ctx *moduleContextImpl) header() bool {
|
2020-12-14 17:27:52 +01:00
|
|
|
return ctx.mod.Header()
|
2019-07-29 14:27:18 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 14:53:49 +02:00
|
|
|
func (ctx *moduleContextImpl) binary() bool {
|
2021-04-01 15:49:36 +02:00
|
|
|
return ctx.mod.Binary()
|
2020-06-01 14:53:49 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 16:23:05 +02:00
|
|
|
func (ctx *moduleContextImpl) object() bool {
|
2021-04-01 15:49:36 +02:00
|
|
|
return ctx.mod.Object()
|
2020-06-01 16:23:05 +02:00
|
|
|
}
|
|
|
|
|
2020-03-06 19:45:53 +01:00
|
|
|
func (ctx *moduleContextImpl) canUseSdk() bool {
|
2020-04-07 18:50:32 +02:00
|
|
|
return ctx.mod.canUseSdk()
|
2020-03-06 19:45:53 +01:00
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
func (ctx *moduleContextImpl) useSdk() bool {
|
2020-04-07 18:50:32 +02:00
|
|
|
return ctx.mod.UseSdk()
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) sdkVersion() string {
|
2016-06-07 21:34:45 +02:00
|
|
|
if ctx.ctx.Device() {
|
2017-09-28 02:01:44 +02:00
|
|
|
if ctx.useVndk() {
|
2019-11-18 11:52:14 +01:00
|
|
|
vndkVer := ctx.mod.VndkVersion()
|
2020-04-08 02:22:26 +02:00
|
|
|
if inList(vndkVer, ctx.ctx.Config().PlatformVersionActiveCodenames()) {
|
2019-11-18 11:52:14 +01:00
|
|
|
return "current"
|
2018-03-23 09:43:47 +01:00
|
|
|
}
|
2019-11-18 11:52:14 +01:00
|
|
|
return vndkVer
|
2016-11-18 23:54:24 +01:00
|
|
|
}
|
2018-03-23 09:43:47 +01:00
|
|
|
return String(ctx.mod.Properties.Sdk_version)
|
2016-06-07 21:34:45 +02:00
|
|
|
}
|
|
|
|
return ""
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 08:59:36 +02:00
|
|
|
func (ctx *moduleContextImpl) minSdkVersion() string {
|
|
|
|
ver := ctx.mod.MinSdkVersion()
|
|
|
|
if ver == "apex_inherit" && !ctx.isForPlatform() {
|
|
|
|
ver = ctx.apexSdkVersion().String()
|
|
|
|
}
|
|
|
|
if ver == "apex_inherit" || ver == "" {
|
|
|
|
ver = ctx.sdkVersion()
|
|
|
|
}
|
2021-03-19 14:18:04 +01:00
|
|
|
// For crt objects, the meaning of min_sdk_version is very different from other types of
|
|
|
|
// module. For them, min_sdk_version defines the oldest version that the build system will
|
|
|
|
// create versioned variants for. For example, if min_sdk_version is 16, then sdk variant of
|
|
|
|
// the crt object has local variants of 16, 17, ..., up to the latest version. sdk_version
|
|
|
|
// and min_sdk_version properties of the variants are set to the corresponding version
|
2021-08-25 09:18:46 +02:00
|
|
|
// numbers. However, the non-sdk variant (for apex or platform) of the crt object is left
|
|
|
|
// untouched. min_sdk_version: 16 doesn't actually mean that the non-sdk variant has to
|
|
|
|
// support such an old version. The version is set to the later version in case when the
|
|
|
|
// non-sdk variant is for the platform, or the min_sdk_version of the containing APEX if
|
|
|
|
// it's for an APEX.
|
|
|
|
if ctx.mod.isCrt() && !ctx.isSdkVariant() {
|
|
|
|
if ctx.isForPlatform() {
|
|
|
|
ver = strconv.Itoa(android.FutureApiLevelInt)
|
|
|
|
} else { // for apex
|
|
|
|
ver = ctx.apexSdkVersion().String()
|
|
|
|
if ver == "" { // in case when min_sdk_version was not set by the APEX
|
|
|
|
ver = ctx.sdkVersion()
|
|
|
|
}
|
|
|
|
}
|
2021-03-19 14:18:04 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 08:59:36 +02:00
|
|
|
// Also make sure that minSdkVersion is not greater than sdkVersion, if they are both numbers
|
|
|
|
sdkVersionInt, err := strconv.Atoi(ctx.sdkVersion())
|
|
|
|
minSdkVersionInt, err2 := strconv.Atoi(ver)
|
|
|
|
if err == nil && err2 == nil {
|
|
|
|
if sdkVersionInt < minSdkVersionInt {
|
|
|
|
return strconv.Itoa(sdkVersionInt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ver
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) isSdkVariant() bool {
|
|
|
|
return ctx.mod.IsSdkVariant()
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
func (ctx *moduleContextImpl) useVndk() bool {
|
2019-10-18 23:49:46 +02:00
|
|
|
return ctx.mod.UseVndk()
|
2017-09-28 02:01:44 +02:00
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
|
2020-10-30 04:47:22 +01:00
|
|
|
func (ctx *moduleContextImpl) isNdk(config android.Config) bool {
|
|
|
|
return ctx.mod.IsNdk(config)
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
func (ctx *moduleContextImpl) IsLlndk() bool {
|
|
|
|
return ctx.mod.IsLlndk()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) IsLlndkPublic() bool {
|
|
|
|
return ctx.mod.IsLlndkPublic()
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
func (ctx *moduleContextImpl) isImplementationForLLNDKPublic() bool {
|
|
|
|
return ctx.mod.isImplementationForLLNDKPublic()
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
func (ctx *moduleContextImpl) IsVndkPrivate() bool {
|
|
|
|
return ctx.mod.IsVndkPrivate()
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
func (ctx *moduleContextImpl) isVndk() bool {
|
2019-10-18 23:49:46 +02:00
|
|
|
return ctx.mod.IsVndk()
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
}
|
|
|
|
|
2022-02-14 13:00:10 +01:00
|
|
|
func (ctx *moduleContextImpl) isAfdoCompile() bool {
|
|
|
|
return ctx.mod.isAfdoCompile()
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:16:12 +01:00
|
|
|
func (ctx *moduleContextImpl) isPgoCompile() bool {
|
|
|
|
return ctx.mod.isPgoCompile()
|
|
|
|
}
|
|
|
|
|
2022-08-19 10:02:45 +02:00
|
|
|
func (ctx *moduleContextImpl) isCfi() bool {
|
|
|
|
return ctx.mod.isCfi()
|
|
|
|
}
|
|
|
|
|
2018-12-11 00:12:40 +01:00
|
|
|
func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
|
|
|
|
return ctx.mod.isNDKStubLibrary()
|
|
|
|
}
|
|
|
|
|
2017-06-23 12:24:43 +02:00
|
|
|
func (ctx *moduleContextImpl) isVndkSp() bool {
|
2021-04-01 15:49:36 +02:00
|
|
|
return ctx.mod.IsVndkSp()
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 15:00:51 +01:00
|
|
|
func (ctx *moduleContextImpl) IsVndkExt() bool {
|
|
|
|
return ctx.mod.IsVndkExt()
|
2017-06-23 12:24:43 +02:00
|
|
|
}
|
|
|
|
|
2021-04-27 22:06:04 +02:00
|
|
|
func (ctx *moduleContextImpl) IsVendorPublicLibrary() bool {
|
|
|
|
return ctx.mod.IsVendorPublicLibrary()
|
|
|
|
}
|
|
|
|
|
2018-11-13 05:19:56 +01:00
|
|
|
func (ctx *moduleContextImpl) mustUseVendorVariant() bool {
|
2019-10-18 23:49:46 +02:00
|
|
|
return ctx.mod.MustUseVendorVariant()
|
2018-11-13 05:19:56 +01:00
|
|
|
}
|
|
|
|
|
2016-03-31 06:00:30 +02:00
|
|
|
func (ctx *moduleContextImpl) selectedStl() string {
|
|
|
|
if stl := ctx.mod.stl; stl != nil {
|
|
|
|
return stl.Properties.SelectedStl
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2018-11-27 23:33:03 +01:00
|
|
|
func (ctx *moduleContextImpl) useClangLld(actx ModuleContext) bool {
|
|
|
|
return ctx.mod.linker.useClangLld(actx)
|
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
func (ctx *moduleContextImpl) baseModuleName() string {
|
|
|
|
return ctx.mod.ModuleBase.BaseModuleName()
|
|
|
|
}
|
|
|
|
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
|
|
|
|
return ctx.mod.getVndkExtendsModuleName()
|
|
|
|
}
|
|
|
|
|
2019-12-03 20:18:32 +01:00
|
|
|
func (ctx *moduleContextImpl) isForPlatform() bool {
|
2020-09-16 03:30:11 +02:00
|
|
|
return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
|
2019-12-03 20:18:32 +01:00
|
|
|
}
|
|
|
|
|
2020-08-13 20:24:56 +02:00
|
|
|
func (ctx *moduleContextImpl) apexVariationName() string {
|
2020-09-16 03:30:11 +02:00
|
|
|
return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
}
|
|
|
|
|
2020-07-23 07:32:17 +02:00
|
|
|
func (ctx *moduleContextImpl) apexSdkVersion() android.ApiLevel {
|
Enforce apex.min_sdk_version for bundled builds
Previously, when Q-targeting apexes are bundled-built, they are built
against the latest stubs.
It was because unwinder is linked dynamically in R and APIs are provided
by libc while Q apexes should run on Q where libc doesn't provide those
APIs. To make Q apexes run on Q device, libc++ should be linked with
static unwinder. But, because libc++ with static unwinder may cause problem
on HWASAN build, Q apexes were built against the latest stubs for bundled
build.
However, Q apexes should be built against Q stubs.
Now, only for HWASAN builds, Q apexes are built against the latest stubs
(and native modules are not linked with static unwinder).
Bug: 151912436
Test: TARGET_SANITIZE=hwaddress m
=> Q apexes(media, resolv, ..) are linked with the latest stubs
m
=> Q apexes are linked with Q stubs,
and Q apexes' libc++ is linked with static unwinder
Merged-In: If32f1b547e6d93e3955c7521eec8aef5851f908c
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
(cherry picked from commit 7406660685a9a085c433ba7081cc6984f66fa732)
Exempt-From-Owner-Approval: cp from internal
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
2020-03-19 20:29:24 +01:00
|
|
|
return ctx.mod.apexSdkVersion
|
2020-03-06 19:45:53 +01:00
|
|
|
}
|
|
|
|
|
2019-01-16 14:53:13 +01:00
|
|
|
func (ctx *moduleContextImpl) bootstrap() bool {
|
2021-06-11 10:22:09 +02:00
|
|
|
return ctx.mod.Bootstrap()
|
2019-01-16 14:53:13 +01:00
|
|
|
}
|
|
|
|
|
2019-03-25 18:21:31 +01:00
|
|
|
func (ctx *moduleContextImpl) nativeCoverage() bool {
|
|
|
|
return ctx.mod.nativeCoverage()
|
|
|
|
}
|
|
|
|
|
2020-09-16 03:30:11 +02:00
|
|
|
func (ctx *moduleContextImpl) directlyInAnyApex() bool {
|
|
|
|
return ctx.mod.DirectlyInAnyApex()
|
|
|
|
}
|
|
|
|
|
2020-12-16 20:06:50 +01:00
|
|
|
func (ctx *moduleContextImpl) isPreventInstall() bool {
|
|
|
|
return ctx.mod.Properties.PreventInstall
|
|
|
|
}
|
|
|
|
|
2022-01-09 04:56:09 +01:00
|
|
|
func (ctx *moduleContextImpl) getSharedFlags() *SharedFlags {
|
|
|
|
shared := &ctx.mod.sharedFlags
|
|
|
|
if shared.flagsMap == nil {
|
|
|
|
shared.numSharedFlags = 0
|
|
|
|
shared.flagsMap = make(map[string]string)
|
|
|
|
}
|
|
|
|
return shared
|
|
|
|
}
|
|
|
|
|
2021-01-09 17:25:22 +01:00
|
|
|
func (ctx *moduleContextImpl) isCfiAssemblySupportEnabled() bool {
|
|
|
|
return ctx.mod.isCfiAssemblySupportEnabled()
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
|
2016-01-04 23:34:37 +01:00
|
|
|
return &Module{
|
|
|
|
hod: hod,
|
|
|
|
multilib: multilib,
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
|
2016-01-04 23:34:37 +01:00
|
|
|
module := newBaseModule(hod, multilib)
|
2016-09-27 00:45:04 +02:00
|
|
|
module.features = []feature{
|
|
|
|
&tidyFeature{},
|
|
|
|
}
|
2016-04-05 00:07:06 +02:00
|
|
|
module.stl = &stl{}
|
2016-01-06 23:41:07 +01:00
|
|
|
module.sanitize = &sanitize{}
|
2017-02-10 01:16:31 +01:00
|
|
|
module.coverage = &coverage{}
|
2022-06-07 22:12:06 +02:00
|
|
|
module.fuzzer = &fuzzer{}
|
2017-02-08 22:45:53 +01:00
|
|
|
module.sabi = &sabi{}
|
2017-06-23 12:24:43 +02:00
|
|
|
module.vndkdep = &vndkdep{}
|
2017-05-10 00:44:35 +02:00
|
|
|
module.lto = <o{}
|
2021-12-09 11:06:29 +01:00
|
|
|
module.afdo = &afdo{}
|
2017-09-01 08:38:27 +02:00
|
|
|
module.pgo = &pgo{}
|
2016-01-04 23:34:37 +01:00
|
|
|
return module
|
|
|
|
}
|
2015-03-19 01:17:35 +01:00
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
func (c *Module) Prebuilt() *android.Prebuilt {
|
|
|
|
if p, ok := c.linker.(prebuiltLinkerInterface); ok {
|
|
|
|
return p.prebuilt()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-12-14 17:27:52 +01:00
|
|
|
func (c *Module) IsPrebuilt() bool {
|
|
|
|
return c.Prebuilt() != nil
|
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
func (c *Module) Name() string {
|
|
|
|
name := c.ModuleBase.Name()
|
2017-04-08 00:21:13 +02:00
|
|
|
if p, ok := c.linker.(interface {
|
|
|
|
Name(string) string
|
|
|
|
}); ok {
|
2016-10-07 01:12:58 +02:00
|
|
|
name = p.Name(name)
|
|
|
|
}
|
|
|
|
return name
|
|
|
|
}
|
|
|
|
|
2019-01-18 23:37:31 +01:00
|
|
|
func (c *Module) Symlinks() []string {
|
|
|
|
if p, ok := c.installer.(interface {
|
|
|
|
symlinkList() []string
|
|
|
|
}); ok {
|
|
|
|
return p.symlinkList()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-07-29 17:22:59 +02:00
|
|
|
func (c *Module) IsTestPerSrcAllTestsVariation() bool {
|
|
|
|
test, ok := c.linker.(testPerSrc)
|
|
|
|
return ok && test.isAllTestsVariation()
|
|
|
|
}
|
|
|
|
|
2020-07-09 23:12:52 +02:00
|
|
|
func (c *Module) DataPaths() []android.DataPath {
|
2020-05-13 00:26:55 +02:00
|
|
|
if p, ok := c.installer.(interface {
|
2020-07-09 23:12:52 +02:00
|
|
|
dataPaths() []android.DataPath
|
2020-05-13 00:26:55 +02:00
|
|
|
}); ok {
|
|
|
|
return p.dataPaths()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-04-12 19:08:36 +02:00
|
|
|
func getNameSuffixWithVndkVersion(ctx android.ModuleContext, c LinkableInterface) string {
|
2019-11-18 11:52:14 +01:00
|
|
|
// Returns the name suffix for product and vendor variants. If the VNDK version is not
|
|
|
|
// "current", it will append the VNDK version to the name suffix.
|
|
|
|
var vndkVersion string
|
|
|
|
var nameSuffix string
|
2020-12-02 15:00:51 +01:00
|
|
|
if c.InProduct() {
|
2021-02-03 11:43:02 +01:00
|
|
|
if c.ProductSpecific() {
|
|
|
|
// If the module is product specific with 'product_specific: true',
|
|
|
|
// do not add a name suffix because it is a base module.
|
|
|
|
return ""
|
|
|
|
}
|
2019-11-18 11:52:14 +01:00
|
|
|
vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
|
2021-05-27 19:01:36 +02:00
|
|
|
nameSuffix = ProductSuffix
|
2019-11-18 11:52:14 +01:00
|
|
|
} else {
|
|
|
|
vndkVersion = ctx.DeviceConfig().VndkVersion()
|
2021-02-05 16:57:43 +01:00
|
|
|
nameSuffix = VendorSuffix
|
2019-11-18 11:52:14 +01:00
|
|
|
}
|
|
|
|
if vndkVersion == "current" {
|
|
|
|
vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
|
|
|
|
}
|
2022-04-12 19:08:36 +02:00
|
|
|
if c.VndkVersion() != vndkVersion && c.VndkVersion() != "" {
|
2019-11-18 11:52:14 +01:00
|
|
|
// add version suffix only if the module is using different vndk version than the
|
|
|
|
// version in product or vendor partition.
|
2022-04-12 19:08:36 +02:00
|
|
|
nameSuffix += "." + c.VndkVersion()
|
2019-11-18 11:52:14 +01:00
|
|
|
}
|
|
|
|
return nameSuffix
|
|
|
|
}
|
|
|
|
|
2022-04-12 19:08:36 +02:00
|
|
|
func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string {
|
|
|
|
var subName = ""
|
2019-08-26 09:52:35 +02:00
|
|
|
|
|
|
|
if c.Target().NativeBridge == android.NativeBridgeEnabled {
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += NativeBridgeSuffix
|
2019-08-26 09:52:35 +02:00
|
|
|
}
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
llndk := c.IsLlndk()
|
2021-04-27 01:53:58 +02:00
|
|
|
if llndk || (c.UseVndk() && c.HasNonSystemVariants()) {
|
2019-11-18 11:52:14 +01:00
|
|
|
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
|
|
|
|
// added for product variant only when we have vendor and product variants with core
|
|
|
|
// variant. The suffix is not added for vendor-only or product-only module.
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += getNameSuffixWithVndkVersion(actx, c)
|
2021-04-27 22:06:04 +02:00
|
|
|
} else if c.IsVendorPublicLibrary() {
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += vendorPublicLibrarySuffix
|
|
|
|
} else if c.IsVndkPrebuiltLibrary() {
|
2019-08-26 09:52:35 +02:00
|
|
|
// .vendor suffix is added for backward compatibility with VNDK snapshot whose names with
|
|
|
|
// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += VendorSuffix
|
2020-01-22 00:53:22 +01:00
|
|
|
} else if c.InRamdisk() && !c.OnlyInRamdisk() {
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += RamdiskSuffix
|
2020-10-22 00:17:56 +02:00
|
|
|
} else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() {
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += VendorRamdiskSuffix
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if c.InRecovery() && !c.OnlyInRecovery() {
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += RecoverySuffix
|
|
|
|
} else if c.IsSdkVariant() && (c.SdkAndPlatformVariantVisibleToMake() || c.SplitPerApiLevel()) {
|
|
|
|
subName += sdkSuffix
|
2020-07-15 22:33:30 +02:00
|
|
|
if c.SplitPerApiLevel() {
|
2022-04-12 19:08:36 +02:00
|
|
|
subName += "." + c.SdkVersion()
|
2020-07-15 22:33:30 +02:00
|
|
|
}
|
2019-08-26 09:52:35 +02:00
|
|
|
}
|
2022-04-12 19:08:36 +02:00
|
|
|
|
|
|
|
return subName
|
2021-02-22 22:13:50 +01:00
|
|
|
}
|
|
|
|
|
2022-05-10 19:50:12 +02:00
|
|
|
var _ android.MixedBuildBuildable = (*Module)(nil)
|
|
|
|
|
|
|
|
func (c *Module) getBazelModuleLabel(ctx android.BaseModuleContext) string {
|
2022-05-17 23:59:36 +02:00
|
|
|
var bazelModuleLabel string
|
2021-12-22 21:31:40 +01:00
|
|
|
if c.typ() == fullLibrary && c.static() {
|
2021-12-03 23:27:16 +01:00
|
|
|
// cc_library is a special case in bp2build; two targets are generated -- one for each
|
|
|
|
// of the shared and static variants. The shared variant keeps the module name, but the
|
|
|
|
// static variant uses a different suffixed name.
|
2022-05-17 23:59:36 +02:00
|
|
|
bazelModuleLabel = bazelLabelForStaticModule(ctx, c)
|
|
|
|
} else {
|
|
|
|
bazelModuleLabel = c.GetBazelLabel(ctx, c)
|
|
|
|
}
|
|
|
|
labelNoPrebuilt := bazelModuleLabel
|
|
|
|
if c.IsPrebuilt() {
|
|
|
|
labelNoPrebuilt = android.RemoveOptionalPrebuiltPrefixFromBazelLabel(bazelModuleLabel)
|
2021-12-03 23:27:16 +01:00
|
|
|
}
|
2022-05-17 23:59:36 +02:00
|
|
|
return labelNoPrebuilt
|
2022-05-10 19:50:12 +02:00
|
|
|
}
|
2021-12-22 21:31:40 +01:00
|
|
|
|
2022-05-10 19:50:12 +02:00
|
|
|
func (c *Module) QueueBazelCall(ctx android.BaseModuleContext) {
|
|
|
|
c.bazelHandler.QueueBazelCall(ctx, c.getBazelModuleLabel(ctx))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) IsMixedBuildSupported(ctx android.BaseModuleContext) bool {
|
|
|
|
return c.bazelHandler != nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) ProcessBazelQueryResponse(ctx android.ModuleContext) {
|
|
|
|
bazelModuleLabel := c.getBazelModuleLabel(ctx)
|
|
|
|
|
|
|
|
c.bazelHandler.ProcessBazelQueryResponse(ctx, bazelModuleLabel)
|
|
|
|
|
|
|
|
c.Properties.SubName = GetSubnameProperty(ctx, c)
|
|
|
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
|
|
|
if !apexInfo.IsForPlatform() {
|
|
|
|
c.hideApexVariantFromMake = true
|
|
|
|
}
|
|
|
|
|
|
|
|
c.makeLinkType = GetMakeLinkType(ctx, c)
|
|
|
|
|
|
|
|
mctx := &moduleContext{
|
|
|
|
ModuleContext: ctx,
|
|
|
|
moduleContextImpl: moduleContextImpl{
|
|
|
|
mod: c,
|
|
|
|
},
|
2021-02-22 22:13:50 +01:00
|
|
|
}
|
2022-05-10 19:50:12 +02:00
|
|
|
mctx.ctx = mctx
|
|
|
|
|
|
|
|
c.maybeInstall(mctx, apexInfo)
|
2021-02-22 22:13:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|
|
|
// Handle the case of a test module split by `test_per_src` mutator.
|
|
|
|
//
|
|
|
|
// The `test_per_src` mutator adds an extra variation named "", depending on all the other
|
|
|
|
// `test_per_src` variations of the test module. Set `outputFile` to an empty path for this
|
|
|
|
// module and return early, as this module does not produce an output file per se.
|
|
|
|
if c.IsTestPerSrcAllTestsVariation() {
|
|
|
|
c.outputFile = android.OptionalPath{}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-12 19:08:36 +02:00
|
|
|
c.Properties.SubName = GetSubnameProperty(actx, c)
|
2021-02-22 22:13:50 +01:00
|
|
|
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
|
|
|
if !apexInfo.IsForPlatform() {
|
|
|
|
c.hideApexVariantFromMake = true
|
|
|
|
}
|
|
|
|
|
2021-04-02 23:36:47 +02:00
|
|
|
c.makeLinkType = GetMakeLinkType(actx, c)
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
ctx := &moduleContext{
|
2016-05-19 00:37:25 +02:00
|
|
|
ModuleContext: actx,
|
2016-01-04 23:34:37 +01:00
|
|
|
moduleContextImpl: moduleContextImpl{
|
|
|
|
mod: c,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
ctx.ctx = ctx
|
|
|
|
|
2017-11-16 23:33:08 +01:00
|
|
|
deps := c.depsToPaths(ctx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-10-08 05:54:34 +02:00
|
|
|
if c.Properties.Clang != nil && *c.Properties.Clang == false {
|
|
|
|
ctx.PropertyErrorf("clang", "false (GCC) is no longer supported")
|
2022-04-21 01:00:58 +02:00
|
|
|
} else if c.Properties.Clang != nil && !ctx.DeviceConfig().BuildBrokenClangProperty() {
|
|
|
|
ctx.PropertyErrorf("clang", "property is deprecated, see Changes.md file")
|
2018-10-08 05:54:34 +02:00
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
flags := Flags{
|
|
|
|
Toolchain: c.toolchain(ctx),
|
2018-11-06 01:49:08 +01:00
|
|
|
EmitXrefs: ctx.Config().EmitXrefRules(),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
if c.compiler != nil {
|
2017-11-16 23:33:08 +01:00
|
|
|
flags = c.compiler.compilerFlags(ctx, flags, deps)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
if c.linker != nil {
|
2016-08-01 22:20:05 +02:00
|
|
|
flags = c.linker.linkerFlags(ctx, flags)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-04-05 00:07:06 +02:00
|
|
|
if c.stl != nil {
|
|
|
|
flags = c.stl.flags(ctx, flags)
|
|
|
|
}
|
2016-01-06 23:41:07 +01:00
|
|
|
if c.sanitize != nil {
|
|
|
|
flags = c.sanitize.flags(ctx, flags)
|
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
if c.coverage != nil {
|
2019-07-02 23:55:35 +02:00
|
|
|
flags, deps = c.coverage.flags(ctx, flags, deps)
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
2022-06-07 22:12:06 +02:00
|
|
|
if c.fuzzer != nil {
|
|
|
|
flags = c.fuzzer.flags(ctx, flags)
|
|
|
|
}
|
2017-05-10 00:44:35 +02:00
|
|
|
if c.lto != nil {
|
|
|
|
flags = c.lto.flags(ctx, flags)
|
|
|
|
}
|
2021-12-09 11:06:29 +01:00
|
|
|
if c.afdo != nil {
|
|
|
|
flags = c.afdo.flags(ctx, flags)
|
|
|
|
}
|
2017-09-01 08:38:27 +02:00
|
|
|
if c.pgo != nil {
|
|
|
|
flags = c.pgo.flags(ctx, flags)
|
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
for _, feature := range c.features {
|
|
|
|
flags = feature.flags(ctx, flags)
|
|
|
|
}
|
2015-03-18 21:28:46 +01:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-11-04 18:37:55 +01:00
|
|
|
flags.Local.CFlags, _ = filterList(flags.Local.CFlags, config.IllegalFlags)
|
|
|
|
flags.Local.CppFlags, _ = filterList(flags.Local.CppFlags, config.IllegalFlags)
|
|
|
|
flags.Local.ConlyFlags, _ = filterList(flags.Local.ConlyFlags, config.IllegalFlags)
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2019-11-04 18:37:55 +01:00
|
|
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags, deps.Flags...)
|
2019-06-03 12:10:47 +02:00
|
|
|
|
|
|
|
for _, dir := range deps.IncludeDirs {
|
2019-11-04 18:37:55 +01:00
|
|
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+dir.String())
|
2019-06-03 12:10:47 +02:00
|
|
|
}
|
|
|
|
for _, dir := range deps.SystemIncludeDirs {
|
2019-11-04 18:37:55 +01:00
|
|
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-isystem "+dir.String())
|
2019-06-03 12:10:47 +02:00
|
|
|
}
|
|
|
|
|
2022-06-18 00:17:05 +02:00
|
|
|
flags.Local.LdFlags = append(flags.Local.LdFlags, deps.LdFlags...)
|
|
|
|
|
2017-01-11 01:21:22 +01:00
|
|
|
c.flags = flags
|
2017-06-15 23:45:18 +02:00
|
|
|
// We need access to all the flags seen by a source file.
|
|
|
|
if c.sabi != nil {
|
|
|
|
flags = c.sabi.flags(ctx, flags)
|
|
|
|
}
|
2019-08-28 06:20:40 +02:00
|
|
|
|
2019-11-04 18:37:55 +01:00
|
|
|
flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.Local.AsFlags)
|
2019-08-28 06:20:40 +02:00
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
var objs Objects
|
2016-01-04 23:34:37 +01:00
|
|
|
if c.compiler != nil {
|
2016-09-27 02:33:01 +02:00
|
|
|
objs = c.compiler.compile(ctx, flags, deps)
|
2016-01-04 23:34:37 +01:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2018-11-06 01:49:08 +01:00
|
|
|
c.kytheFiles = objs.kytheFiles
|
2021-10-12 01:46:56 +02:00
|
|
|
c.objFiles = objs.objFiles
|
|
|
|
c.tidyFiles = objs.tidyFiles
|
2015-03-18 22:01:18 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
if c.linker != nil {
|
2016-09-27 02:33:01 +02:00
|
|
|
outputFile := c.linker.link(ctx, flags, deps, objs)
|
2016-01-04 23:34:37 +01:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2016-05-19 00:37:25 +02:00
|
|
|
c.outputFile = android.OptionalPathForPath(outputFile)
|
2018-12-20 14:10:17 +01:00
|
|
|
|
2021-06-04 21:03:47 +02:00
|
|
|
c.maybeUnhideFromMake()
|
2020-03-03 14:06:32 +01:00
|
|
|
|
2020-12-11 22:36:29 +01:00
|
|
|
// glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or
|
|
|
|
// RECOVERY_SNAPSHOT_VERSION is current.
|
|
|
|
if i, ok := c.linker.(snapshotLibraryInterface); ok {
|
2021-04-01 15:49:36 +02:00
|
|
|
if ShouldCollectHeadersForSnapshot(ctx, c, apexInfo) {
|
2020-03-03 14:06:32 +01:00
|
|
|
i.collectHeadersForSnapshot(ctx)
|
|
|
|
}
|
|
|
|
}
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2021-06-04 21:03:47 +02:00
|
|
|
c.maybeInstall(ctx, apexInfo)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) maybeUnhideFromMake() {
|
|
|
|
// If a lib is directly included in any of the APEXes or is not available to the
|
|
|
|
// platform (which is often the case when the stub is provided as a prebuilt),
|
|
|
|
// unhide the stubs variant having the latest version gets visible to make. In
|
|
|
|
// addition, the non-stubs variant is renamed to <libname>.bootstrap. This is to
|
|
|
|
// force anything in the make world to link against the stubs library. (unless it
|
|
|
|
// is explicitly referenced via .bootstrap suffix or the module is marked with
|
|
|
|
// 'bootstrap: true').
|
|
|
|
if c.HasStubsVariants() && c.NotInPlatform() && !c.InRamdisk() &&
|
|
|
|
!c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
|
|
|
|
c.IsStubs() && !c.InVendorRamdisk() {
|
|
|
|
c.Properties.HideFromMake = false // unhide
|
|
|
|
// Note: this is still non-installable
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) maybeInstall(ctx ModuleContext, apexInfo android.ApexInfo) {
|
2021-10-28 22:25:54 +02:00
|
|
|
if !proptools.BoolDefault(c.Installable(), true) {
|
2020-03-04 15:52:46 +01:00
|
|
|
// If the module has been specifically configure to not be installed then
|
2020-12-16 19:20:23 +01:00
|
|
|
// hide from make as otherwise it will break when running inside make
|
2020-03-04 15:52:46 +01:00
|
|
|
// as the output path to install will not be specified. Not all uninstallable
|
2020-12-16 19:20:23 +01:00
|
|
|
// modules can be hidden from make as some are needed for resolving make side
|
2020-03-04 15:52:46 +01:00
|
|
|
// dependencies.
|
2020-12-16 19:20:23 +01:00
|
|
|
c.HideFromMake()
|
2021-04-01 15:49:36 +02:00
|
|
|
} else if !installable(c, apexInfo) {
|
2020-03-04 15:52:46 +01:00
|
|
|
c.SkipInstall()
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2020-12-16 19:20:23 +01:00
|
|
|
|
|
|
|
// Still call c.installer.install though, the installs will be stored as PackageSpecs
|
|
|
|
// to allow using the outputs in a genrule.
|
|
|
|
if c.installer != nil && c.outputFile.Valid() {
|
|
|
|
c.installer.install(ctx, c.outputFile.Path())
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
|
2016-01-04 23:34:37 +01:00
|
|
|
if c.cachedToolchain == nil {
|
2021-01-26 15:18:53 +01:00
|
|
|
c.cachedToolchain = config.FindToolchainWithContext(ctx)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
return c.cachedToolchain
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
func (c *Module) begin(ctx BaseModuleContext) {
|
|
|
|
if c.compiler != nil {
|
2016-08-01 22:20:05 +02:00
|
|
|
c.compiler.compilerInit(ctx)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
if c.linker != nil {
|
2016-08-01 22:20:05 +02:00
|
|
|
c.linker.linkerInit(ctx)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-04-05 00:07:06 +02:00
|
|
|
if c.stl != nil {
|
|
|
|
c.stl.begin(ctx)
|
|
|
|
}
|
2016-01-06 23:41:07 +01:00
|
|
|
if c.sanitize != nil {
|
|
|
|
c.sanitize.begin(ctx)
|
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
if c.coverage != nil {
|
|
|
|
c.coverage.begin(ctx)
|
|
|
|
}
|
2017-05-10 00:44:35 +02:00
|
|
|
if c.lto != nil {
|
|
|
|
c.lto.begin(ctx)
|
|
|
|
}
|
2021-12-09 11:06:29 +01:00
|
|
|
if c.afdo != nil {
|
|
|
|
c.afdo.begin(ctx)
|
|
|
|
}
|
2017-09-01 08:38:27 +02:00
|
|
|
if c.pgo != nil {
|
|
|
|
c.pgo.begin(ctx)
|
|
|
|
}
|
2020-07-15 22:33:30 +02:00
|
|
|
if ctx.useSdk() && c.IsSdkVariant() {
|
Replace stringly-typed API levels.
Handling of API levels within Soong is currently fairly difficult
since it isn't always clear based on context what kind of API level a
given string represents, how much canonicalizing and error checking
the code receiving the string are expected to do, or how those errors
should be treated.
The API level struct does not export its raw data, so as to keep its
"constructor" private to the android package, and to prevent misuse of
the `number` field, which is only an implementation detail for preview
API levels. API levels can be parsed with either
`android.ApiLevelFromUser`, which returns any errors to the caller, or
`android.ApiLevelOrPanic`, which is used in the case where the input
is trusted and any errors in parsing should panic. Even within the
`android` package, these APIs should be preferred over direct
construction.
For cases where there are context specific parsing requirements, such
as handling the "minimum" alias in the cc module,
`nativeApiLevelFromUser` and `nativeApiLevelOrPanic` should be used
instead.
Test: treehugger
Bug: http://b/154667674
Change-Id: Id52921fda32cb437fb1775ac2183299dedc0cf20
2020-07-06 23:49:35 +02:00
|
|
|
version, err := nativeApiLevelFromUser(ctx, ctx.sdkVersion())
|
2016-08-06 01:37:52 +02:00
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version", err.Error())
|
Replace stringly-typed API levels.
Handling of API levels within Soong is currently fairly difficult
since it isn't always clear based on context what kind of API level a
given string represents, how much canonicalizing and error checking
the code receiving the string are expected to do, or how those errors
should be treated.
The API level struct does not export its raw data, so as to keep its
"constructor" private to the android package, and to prevent misuse of
the `number` field, which is only an implementation detail for preview
API levels. API levels can be parsed with either
`android.ApiLevelFromUser`, which returns any errors to the caller, or
`android.ApiLevelOrPanic`, which is used in the case where the input
is trusted and any errors in parsing should panic. Even within the
`android` package, these APIs should be preferred over direct
construction.
For cases where there are context specific parsing requirements, such
as handling the "minimum" alias in the cc module,
`nativeApiLevelFromUser` and `nativeApiLevelOrPanic` should be used
instead.
Test: treehugger
Bug: http://b/154667674
Change-Id: Id52921fda32cb437fb1775ac2183299dedc0cf20
2020-07-06 23:49:35 +02:00
|
|
|
c.Properties.Sdk_version = nil
|
|
|
|
} else {
|
|
|
|
c.Properties.Sdk_version = StringPtr(version.String())
|
2016-08-06 01:37:52 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-25 02:31:52 +02:00
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
func (c *Module) deps(ctx DepsContext) Deps {
|
2016-04-12 00:06:20 +02:00
|
|
|
deps := Deps{}
|
|
|
|
|
|
|
|
if c.compiler != nil {
|
2016-08-01 22:20:05 +02:00
|
|
|
deps = c.compiler.compilerDeps(ctx, deps)
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
|
|
|
if c.linker != nil {
|
2016-08-01 22:20:05 +02:00
|
|
|
deps = c.linker.linkerDeps(ctx, deps)
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
2016-04-05 00:07:06 +02:00
|
|
|
if c.stl != nil {
|
|
|
|
deps = c.stl.deps(ctx, deps)
|
|
|
|
}
|
2018-04-24 00:44:39 +02:00
|
|
|
if c.coverage != nil {
|
|
|
|
deps = c.coverage.deps(ctx, deps)
|
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
|
2017-10-24 20:13:31 +02:00
|
|
|
deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
|
|
|
|
deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
|
|
|
|
deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
|
|
|
|
deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
|
|
|
|
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
|
|
|
|
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
|
2017-12-19 18:17:32 +01:00
|
|
|
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
|
2016-04-12 00:06:20 +02:00
|
|
|
|
2016-06-07 03:22:19 +02:00
|
|
|
for _, lib := range deps.ReexportSharedLibHeaders {
|
|
|
|
if !inList(lib, deps.SharedLibs) {
|
|
|
|
ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, lib := range deps.ReexportStaticLibHeaders {
|
2021-04-02 00:17:50 +02:00
|
|
|
if !inList(lib, deps.StaticLibs) && !inList(lib, deps.WholeStaticLibs) {
|
|
|
|
ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs or whole_static_libs: '%s'", lib)
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-13 21:50:57 +01:00
|
|
|
for _, lib := range deps.ReexportHeaderLibHeaders {
|
|
|
|
if !inList(lib, deps.HeaderLibs) {
|
|
|
|
ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-29 02:34:58 +02:00
|
|
|
for _, gen := range deps.ReexportGeneratedHeaders {
|
|
|
|
if !inList(gen, deps.GeneratedHeaders) {
|
|
|
|
ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2016-08-04 22:02:36 +02:00
|
|
|
func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
|
2016-01-04 23:34:37 +01:00
|
|
|
ctx := &baseModuleContext{
|
2019-06-06 23:33:29 +02:00
|
|
|
BaseModuleContext: actx,
|
2016-01-04 23:34:37 +01:00
|
|
|
moduleContextImpl: moduleContextImpl{
|
|
|
|
mod: c,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
ctx.ctx = ctx
|
2015-03-24 22:15:58 +01:00
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
c.begin(ctx)
|
2016-08-04 22:02:36 +02:00
|
|
|
}
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
// Split name#version into name and version
|
2019-10-22 13:31:18 +02:00
|
|
|
func StubsLibNameAndVersion(name string) (string, string) {
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
if sharp := strings.LastIndex(name, "#"); sharp != -1 && sharp != len(name)-1 {
|
|
|
|
version := name[sharp+1:]
|
|
|
|
libname := name[:sharp]
|
|
|
|
return libname, version
|
|
|
|
}
|
|
|
|
return name, ""
|
|
|
|
}
|
|
|
|
|
2020-07-15 22:33:30 +02:00
|
|
|
func GetCrtVariations(ctx android.BottomUpMutatorContext,
|
|
|
|
m LinkableInterface) []blueprint.Variation {
|
|
|
|
if ctx.Os() != android.Android {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if m.UseSdk() {
|
2021-03-19 14:18:04 +01:00
|
|
|
// Choose the CRT that best satisfies the min_sdk_version requirement of this module
|
|
|
|
minSdkVersion := m.MinSdkVersion()
|
|
|
|
if minSdkVersion == "" || minSdkVersion == "apex_inherit" {
|
|
|
|
minSdkVersion = m.SdkVersion()
|
|
|
|
}
|
2021-06-08 02:49:48 +02:00
|
|
|
apiLevel, err := android.ApiLevelFromUser(ctx, minSdkVersion)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("min_sdk_version", err.Error())
|
|
|
|
}
|
2020-07-15 22:33:30 +02:00
|
|
|
return []blueprint.Variation{
|
|
|
|
{Mutator: "sdk", Variation: "sdk"},
|
2021-06-08 02:49:48 +02:00
|
|
|
{Mutator: "version", Variation: apiLevel.String()},
|
2020-07-15 22:33:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return []blueprint.Variation{
|
|
|
|
{Mutator: "sdk", Variation: ""},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 19:01:32 +02:00
|
|
|
func AddSharedLibDependenciesWithVersions(ctx android.BottomUpMutatorContext, mod LinkableInterface,
|
|
|
|
variations []blueprint.Variation, depTag blueprint.DependencyTag, name, version string, far bool) {
|
2020-09-24 18:56:18 +02:00
|
|
|
|
|
|
|
variations = append([]blueprint.Variation(nil), variations...)
|
|
|
|
|
2022-04-08 21:41:00 +02:00
|
|
|
if version != "" && canBeOrLinkAgainstVersionVariants(mod) {
|
2020-09-24 18:56:18 +02:00
|
|
|
// Version is explicitly specified. i.e. libFoo#30
|
|
|
|
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
|
2021-05-20 19:01:32 +02:00
|
|
|
if tag, ok := depTag.(libraryDependencyTag); ok {
|
|
|
|
tag.explicitlyVersioned = true
|
|
|
|
} else {
|
|
|
|
panic(fmt.Errorf("Unexpected dependency tag: %T", depTag))
|
|
|
|
}
|
2020-09-24 18:56:18 +02:00
|
|
|
}
|
2020-09-18 23:15:30 +02:00
|
|
|
|
2020-09-24 18:56:18 +02:00
|
|
|
if far {
|
2020-09-18 23:15:30 +02:00
|
|
|
ctx.AddFarVariationDependencies(variations, depTag, name)
|
2020-09-24 18:56:18 +02:00
|
|
|
} else {
|
2020-09-18 23:15:30 +02:00
|
|
|
ctx.AddVariationDependencies(variations, depTag, name)
|
2020-09-24 18:56:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
func GetApiImports(c LinkableInterface, actx android.BottomUpMutatorContext) multitree.ApiImportInfo {
|
|
|
|
apiImportInfo := multitree.ApiImportInfo{}
|
|
|
|
|
|
|
|
if c.Device() {
|
|
|
|
var apiImportModule []blueprint.Module
|
|
|
|
if actx.OtherModuleExists("api_imports") {
|
|
|
|
apiImportModule = actx.AddDependency(c, nil, "api_imports")
|
|
|
|
if len(apiImportModule) > 0 && apiImportModule[0] != nil {
|
|
|
|
apiInfo := actx.OtherModuleProvider(apiImportModule[0], multitree.ApiImportsProvider).(multitree.ApiImportInfo)
|
|
|
|
apiImportInfo = apiInfo
|
|
|
|
actx.SetProvider(multitree.ApiImportsProvider, apiInfo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return apiImportInfo
|
|
|
|
}
|
|
|
|
|
2021-05-20 19:01:32 +02:00
|
|
|
func GetSnapshot(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext) SnapshotInfo {
|
2021-07-02 15:26:00 +02:00
|
|
|
// Only device modules with BOARD_VNDK_VERSION uses snapshot. Others use the zero value of
|
2021-05-20 19:01:32 +02:00
|
|
|
// SnapshotInfo, which provides no mappings.
|
2021-07-02 15:26:00 +02:00
|
|
|
if *snapshotInfo == nil && c.Device() {
|
2021-05-20 19:01:32 +02:00
|
|
|
// Only retrieve the snapshot on demand in order to avoid circular dependencies
|
|
|
|
// between the modules in the snapshot and the snapshot itself.
|
|
|
|
var snapshotModule []blueprint.Module
|
|
|
|
if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() {
|
|
|
|
snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot")
|
|
|
|
} else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() {
|
|
|
|
snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot")
|
|
|
|
}
|
2021-07-02 15:26:00 +02:00
|
|
|
if len(snapshotModule) > 0 && snapshotModule[0] != nil {
|
2021-05-20 19:01:32 +02:00
|
|
|
snapshot := actx.OtherModuleProvider(snapshotModule[0], SnapshotInfoProvider).(SnapshotInfo)
|
|
|
|
*snapshotInfo = &snapshot
|
|
|
|
// republish the snapshot for use in later mutators on this module
|
|
|
|
actx.SetProvider(SnapshotInfoProvider, snapshot)
|
|
|
|
}
|
|
|
|
}
|
2021-07-02 15:26:00 +02:00
|
|
|
if *snapshotInfo == nil {
|
|
|
|
*snapshotInfo = &SnapshotInfo{}
|
|
|
|
}
|
2021-05-20 19:01:32 +02:00
|
|
|
return **snapshotInfo
|
|
|
|
}
|
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
func GetReplaceModuleName(lib string, replaceMap map[string]string) string {
|
|
|
|
if snapshot, ok := replaceMap[lib]; ok {
|
2021-05-20 19:01:32 +02:00
|
|
|
return snapshot
|
|
|
|
}
|
|
|
|
|
|
|
|
return lib
|
|
|
|
}
|
|
|
|
|
|
|
|
// RewriteLibs takes a list of names of shared libraries and scans it for three types
|
|
|
|
// of names:
|
|
|
|
//
|
|
|
|
// 1. Name of an NDK library that refers to a prebuilt module.
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
//
|
|
|
|
// For each of these, it adds the name of the prebuilt module (which will be in
|
|
|
|
// prebuilts/ndk) to the list of nonvariant libs.
|
|
|
|
//
|
2021-05-20 19:01:32 +02:00
|
|
|
// 2. Name of an NDK library that refers to an ndk_library module.
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
//
|
|
|
|
// For each of these, it adds the name of the ndk_library module to the list of
|
|
|
|
// variant libs.
|
|
|
|
//
|
2021-05-20 19:01:32 +02:00
|
|
|
// 3. Anything else (so anything that isn't an NDK library).
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
//
|
|
|
|
// It adds these to the nonvariantLibs list.
|
2021-05-20 19:01:32 +02:00
|
|
|
//
|
|
|
|
// The caller can then know to add the variantLibs dependencies differently from the
|
|
|
|
// nonvariantLibs
|
|
|
|
func RewriteLibs(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) {
|
|
|
|
variantLibs = []string{}
|
|
|
|
|
|
|
|
nonvariantLibs = []string{}
|
|
|
|
for _, entry := range list {
|
|
|
|
// strip #version suffix out
|
|
|
|
name, _ := StubsLibNameAndVersion(entry)
|
|
|
|
if c.InRecovery() {
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
|
2021-05-20 19:01:32 +02:00
|
|
|
} else if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) {
|
|
|
|
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
|
|
|
|
} else if c.UseVndk() {
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
|
2021-05-20 19:01:32 +02:00
|
|
|
} else {
|
|
|
|
// put name#version back
|
|
|
|
nonvariantLibs = append(nonvariantLibs, entry)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nonvariantLibs, variantLibs
|
|
|
|
}
|
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
func updateDepsWithApiImports(deps Deps, apiImports multitree.ApiImportInfo) Deps {
|
|
|
|
for idx, lib := range deps.SharedLibs {
|
|
|
|
deps.SharedLibs[idx] = GetReplaceModuleName(lib, apiImports.SharedLibs)
|
|
|
|
}
|
|
|
|
|
|
|
|
for idx, lib := range deps.LateSharedLibs {
|
|
|
|
deps.LateSharedLibs[idx] = GetReplaceModuleName(lib, apiImports.SharedLibs)
|
|
|
|
}
|
|
|
|
|
|
|
|
for idx, lib := range deps.RuntimeLibs {
|
|
|
|
deps.RuntimeLibs[idx] = GetReplaceModuleName(lib, apiImports.SharedLibs)
|
|
|
|
}
|
|
|
|
|
2022-08-24 07:10:46 +02:00
|
|
|
for idx, lib := range deps.SystemSharedLibs {
|
|
|
|
deps.SystemSharedLibs[idx] = GetReplaceModuleName(lib, apiImports.SharedLibs)
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}
|
2022-08-24 07:10:46 +02:00
|
|
|
|
|
|
|
for idx, lib := range deps.ReexportSharedLibHeaders {
|
|
|
|
deps.ReexportSharedLibHeaders[idx] = GetReplaceModuleName(lib, apiImports.SharedLibs)
|
|
|
|
}
|
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
2020-01-22 03:11:29 +01:00
|
|
|
if !c.Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
ctx := &depsContext{
|
|
|
|
BottomUpMutatorContext: actx,
|
2016-08-04 22:02:36 +02:00
|
|
|
moduleContextImpl: moduleContextImpl{
|
|
|
|
mod: c,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
ctx.ctx = ctx
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
deps := c.deps(ctx)
|
2015-04-28 22:30:13 +02:00
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
apiImportInfo := GetApiImports(c, actx)
|
|
|
|
deps = updateDepsWithApiImports(deps, apiImportInfo)
|
|
|
|
|
2020-09-22 12:45:04 +02:00
|
|
|
c.Properties.AndroidMkSystemSharedLibs = deps.SystemSharedLibs
|
|
|
|
|
2021-01-12 02:31:17 +01:00
|
|
|
var snapshotInfo *SnapshotInfo
|
|
|
|
|
2016-06-18 01:45:24 +02:00
|
|
|
variantNdkLibs := []string{}
|
|
|
|
variantLateNdkLibs := []string{}
|
2017-03-19 21:44:32 +01:00
|
|
|
if ctx.Os() == android.Android {
|
2021-05-20 19:01:32 +02:00
|
|
|
deps.SharedLibs, variantNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.SharedLibs)
|
|
|
|
deps.LateSharedLibs, variantLateNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.LateSharedLibs)
|
|
|
|
deps.ReexportSharedLibHeaders, _ = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.ReexportSharedLibHeaders)
|
2016-04-12 00:06:20 +02:00
|
|
|
|
2021-01-12 02:31:17 +01:00
|
|
|
for idx, lib := range deps.RuntimeLibs {
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
deps.RuntimeLibs[idx] = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).SharedLibs)
|
2020-01-22 03:11:29 +01:00
|
|
|
}
|
2020-12-11 22:36:29 +01:00
|
|
|
}
|
|
|
|
|
2016-12-15 16:39:51 +01:00
|
|
|
for _, lib := range deps.HeaderLibs {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag := libraryDependencyTag{Kind: headerLibraryDependency}
|
2016-12-15 16:39:51 +01:00
|
|
|
if inList(lib, deps.ReexportHeaderLibHeaders) {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag.reexportFlags = true
|
2016-12-15 16:39:51 +01:00
|
|
|
}
|
2020-01-22 03:11:29 +01:00
|
|
|
|
2022-08-24 07:10:46 +02:00
|
|
|
// Check header lib replacement from API surface first, and then check again with VSDK
|
|
|
|
lib = GetReplaceModuleName(lib, apiImportInfo.HeaderLibs)
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).HeaderLibs)
|
2020-01-22 03:11:29 +01:00
|
|
|
|
2022-08-19 01:26:00 +02:00
|
|
|
if c.isNDKStubLibrary() {
|
|
|
|
// ndk_headers do not have any variations
|
|
|
|
actx.AddFarVariationDependencies([]blueprint.Variation{}, depTag, lib)
|
2022-08-24 07:10:46 +02:00
|
|
|
} else if c.IsStubs() && !c.isImportedApiLibrary() {
|
2019-11-19 01:00:16 +01:00
|
|
|
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
|
2019-10-16 20:03:10 +02:00
|
|
|
depTag, lib)
|
2019-01-28 08:16:54 +01:00
|
|
|
} else {
|
|
|
|
actx.AddVariationDependencies(nil, depTag, lib)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-30 23:32:55 +02:00
|
|
|
if c.isNDKStubLibrary() {
|
|
|
|
// NDK stubs depend on their implementation because the ABI dumps are
|
|
|
|
// generated from the implementation library.
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
apiImportName := c.BaseModuleName() + multitree.GetApiImportSuffix()
|
|
|
|
|
|
|
|
// If original library exists as imported API, set dependency on the imported library
|
|
|
|
if actx.OtherModuleExists(apiImportName) {
|
|
|
|
actx.AddFarVariationDependencies(append(ctx.Target().Variations(),
|
|
|
|
c.ImageVariation(),
|
|
|
|
blueprint.Variation{Mutator: "link", Variation: "shared"},
|
|
|
|
), stubImplementation, apiImportName)
|
|
|
|
} else {
|
|
|
|
actx.AddFarVariationDependencies(append(ctx.Target().Variations(),
|
|
|
|
c.ImageVariation(),
|
|
|
|
blueprint.Variation{Mutator: "link", Variation: "shared"},
|
|
|
|
), stubImplementation, c.BaseModuleName())
|
|
|
|
}
|
2020-07-30 23:32:55 +02:00
|
|
|
}
|
|
|
|
|
2020-11-23 06:43:02 +01:00
|
|
|
// sysprop_library has to support both C++ and Java. So sysprop_library internally creates one
|
|
|
|
// C++ implementation library and one Java implementation library. When a module links against
|
|
|
|
// sysprop_library, the C++ implementation library has to be linked. syspropImplLibraries is a
|
|
|
|
// map from sysprop_library to implementation library; it will be used in whole_static_libs,
|
|
|
|
// static_libs, and shared_libs.
|
2019-02-08 13:00:45 +01:00
|
|
|
syspropImplLibraries := syspropImplLibraries(actx.Config())
|
|
|
|
|
2019-02-25 14:14:17 +01:00
|
|
|
for _, lib := range deps.WholeStaticLibs {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
|
2019-02-25 14:14:17 +01:00
|
|
|
if impl, ok := syspropImplLibraries[lib]; ok {
|
|
|
|
lib = impl
|
|
|
|
}
|
2020-01-22 03:11:29 +01:00
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
|
2020-01-22 03:11:29 +01:00
|
|
|
|
2019-02-25 14:14:17 +01:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "static"},
|
|
|
|
}, depTag, lib)
|
|
|
|
}
|
|
|
|
|
2016-06-07 03:22:19 +02:00
|
|
|
for _, lib := range deps.StaticLibs {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag := libraryDependencyTag{Kind: staticLibraryDependency}
|
2016-06-07 03:22:19 +02:00
|
|
|
if inList(lib, deps.ReexportStaticLibHeaders) {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag.reexportFlags = true
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2020-12-03 09:28:25 +01:00
|
|
|
if inList(lib, deps.ExcludeLibsForApex) {
|
|
|
|
depTag.excludeInApex = true
|
|
|
|
}
|
2019-02-08 13:00:45 +01:00
|
|
|
|
|
|
|
if impl, ok := syspropImplLibraries[lib]; ok {
|
|
|
|
lib = impl
|
|
|
|
}
|
|
|
|
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
|
2020-01-22 03:11:29 +01:00
|
|
|
|
2018-07-23 06:18:45 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "static"},
|
|
|
|
}, depTag, lib)
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2015-03-24 22:15:58 +01:00
|
|
|
|
Enforce apex.min_sdk_version for bundled builds
Previously, when Q-targeting apexes are bundled-built, they are built
against the latest stubs.
It was because unwinder is linked dynamically in R and APIs are provided
by libc while Q apexes should run on Q where libc doesn't provide those
APIs. To make Q apexes run on Q device, libc++ should be linked with
static unwinder. But, because libc++ with static unwinder may cause problem
on HWASAN build, Q apexes were built against the latest stubs for bundled
build.
However, Q apexes should be built against Q stubs.
Now, only for HWASAN builds, Q apexes are built against the latest stubs
(and native modules are not linked with static unwinder).
Bug: 151912436
Test: TARGET_SANITIZE=hwaddress m
=> Q apexes(media, resolv, ..) are linked with the latest stubs
m
=> Q apexes are linked with Q stubs,
and Q apexes' libc++ is linked with static unwinder
Merged-In: If32f1b547e6d93e3955c7521eec8aef5851f908c
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
(cherry picked from commit 7406660685a9a085c433ba7081cc6984f66fa732)
Exempt-From-Owner-Approval: cp from internal
Change-Id: If32f1b547e6d93e3955c7521eec8aef5851f908c
2020-03-19 20:29:24 +01:00
|
|
|
// staticUnwinderDep is treated as staticDep for Q apexes
|
|
|
|
// so that native libraries/binaries are linked with static unwinder
|
|
|
|
// because Q libc doesn't have unwinder APIs
|
|
|
|
if deps.StaticUnwinderIfLegacy {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true}
|
2020-02-13 02:13:25 +01:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "static"},
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}, depTag, GetReplaceModuleName(staticUnwinder(actx), GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
|
2020-02-13 02:13:25 +01:00
|
|
|
}
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
// shared lib names without the #version suffix
|
|
|
|
var sharedLibNames []string
|
|
|
|
|
2016-06-07 03:22:19 +02:00
|
|
|
for _, lib := range deps.SharedLibs {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag := libraryDependencyTag{Kind: sharedLibraryDependency}
|
2016-06-07 03:22:19 +02:00
|
|
|
if inList(lib, deps.ReexportSharedLibHeaders) {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag.reexportFlags = true
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2020-12-03 09:28:25 +01:00
|
|
|
if inList(lib, deps.ExcludeLibsForApex) {
|
|
|
|
depTag.excludeInApex = true
|
|
|
|
}
|
2019-02-08 13:00:45 +01:00
|
|
|
|
|
|
|
if impl, ok := syspropImplLibraries[lib]; ok {
|
|
|
|
lib = impl
|
|
|
|
}
|
|
|
|
|
2019-10-22 13:31:18 +02:00
|
|
|
name, version := StubsLibNameAndVersion(lib)
|
2019-02-08 13:00:45 +01:00
|
|
|
sharedLibNames = append(sharedLibNames, name)
|
|
|
|
|
2020-09-24 18:56:18 +02:00
|
|
|
variations := []blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}
|
2021-05-20 19:01:32 +02:00
|
|
|
AddSharedLibDependenciesWithVersions(ctx, c, variations, depTag, name, version, false)
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2021-06-15 01:13:03 +02:00
|
|
|
for _, lib := range deps.LateStaticLibs {
|
|
|
|
depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "static"},
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
|
2021-06-15 01:13:03 +02:00
|
|
|
}
|
|
|
|
|
2022-06-18 00:17:05 +02:00
|
|
|
for _, lib := range deps.UnexportedStaticLibs {
|
|
|
|
depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, unexportedSymbols: true}
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "static"},
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
|
2022-06-18 00:17:05 +02:00
|
|
|
}
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
for _, lib := range deps.LateSharedLibs {
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
if inList(lib, sharedLibNames) {
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
// This is to handle the case that some of the late shared libs (libc, libdl, libm, ...)
|
|
|
|
// are added also to SharedLibs with version (e.g., libc#10). If not skipped, we will be
|
|
|
|
// linking against both the stubs lib and the non-stubs lib at the same time.
|
|
|
|
continue
|
|
|
|
}
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency}
|
2020-09-24 18:56:18 +02:00
|
|
|
variations := []blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}
|
2021-05-20 19:01:32 +02:00
|
|
|
AddSharedLibDependenciesWithVersions(ctx, c, variations, depTag, lib, "", false)
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
}
|
2016-04-11 23:37:39 +02:00
|
|
|
|
2020-06-05 23:26:16 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, dataLibDepTag, deps.DataLibs...)
|
|
|
|
|
2021-09-25 01:50:14 +02:00
|
|
|
actx.AddVariationDependencies(nil, dataBinDepTag, deps.DataBins...)
|
|
|
|
|
2018-07-23 06:18:45 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, runtimeDepTag, deps.RuntimeLibs...)
|
2017-12-19 18:17:32 +01:00
|
|
|
|
2016-07-08 19:41:41 +02:00
|
|
|
actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...)
|
2016-09-29 02:34:58 +02:00
|
|
|
|
|
|
|
for _, gen := range deps.GeneratedHeaders {
|
|
|
|
depTag := genHeaderDepTag
|
|
|
|
if inList(gen, deps.ReexportGeneratedHeaders) {
|
|
|
|
depTag = genHeaderExportDepTag
|
|
|
|
}
|
|
|
|
actx.AddDependency(c, depTag, gen)
|
|
|
|
}
|
2016-04-20 23:21:14 +02:00
|
|
|
|
2020-07-15 22:33:30 +02:00
|
|
|
crtVariations := GetCrtVariations(ctx, c)
|
2020-09-30 21:27:01 +02:00
|
|
|
actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
|
2021-06-12 03:00:04 +02:00
|
|
|
for _, crt := range deps.CrtBegin {
|
2020-07-15 22:33:30 +02:00
|
|
|
actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects))
|
2015-03-24 22:15:58 +01:00
|
|
|
}
|
2021-06-12 03:00:04 +02:00
|
|
|
for _, crt := range deps.CrtEnd {
|
2020-07-15 22:33:30 +02:00
|
|
|
actx.AddVariationDependencies(crtVariations, CrtEndDepTag,
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects))
|
2015-03-24 22:15:58 +01:00
|
|
|
}
|
2018-10-12 09:24:23 +02:00
|
|
|
if deps.DynamicLinker != "" {
|
|
|
|
actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker)
|
2017-09-19 08:19:12 +02:00
|
|
|
}
|
2016-06-18 01:45:24 +02:00
|
|
|
|
|
|
|
version := ctx.sdkVersion()
|
2020-07-28 06:26:48 +02:00
|
|
|
|
|
|
|
ndkStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, ndk: true, makeSuffix: "." + version}
|
2016-06-18 01:45:24 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
2020-09-30 20:41:33 +02:00
|
|
|
{Mutator: "version", Variation: version},
|
2018-07-23 06:18:45 +02:00
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, ndkStubDepTag, variantNdkLibs...)
|
2020-07-28 06:26:48 +02:00
|
|
|
|
|
|
|
ndkLateStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, ndk: true, makeSuffix: "." + version}
|
2016-06-18 01:45:24 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
2020-09-30 20:41:33 +02:00
|
|
|
{Mutator: "version", Variation: version},
|
2018-07-23 06:18:45 +02:00
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, ndkLateStubDepTag, variantLateNdkLibs...)
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
|
|
|
|
if vndkdep := c.vndkdep; vndkdep != nil {
|
|
|
|
if vndkdep.isVndkExt() {
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
2019-11-19 01:00:16 +01:00
|
|
|
c.ImageVariation(),
|
2018-07-23 06:18:45 +02:00
|
|
|
{Mutator: "link", Variation: "shared"},
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}, vndkExtDepTag, GetReplaceModuleName(vndkdep.getVndkExtendsModuleName(), GetSnapshot(c, &snapshotInfo, actx).SharedLibs))
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
}
|
|
|
|
}
|
2015-10-29 23:25:03 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-03 07:25:58 +02:00
|
|
|
func BeginMutator(ctx android.BottomUpMutatorContext) {
|
2016-08-04 22:02:36 +02:00
|
|
|
if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
|
|
|
|
c.beginMutator(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// Whether a module can link to another module, taking into
|
|
|
|
// account NDK linking.
|
2020-10-19 11:51:07 +02:00
|
|
|
func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to LinkableInterface,
|
2020-07-28 06:26:48 +02:00
|
|
|
tag blueprint.DependencyTag) {
|
|
|
|
|
|
|
|
switch t := tag.(type) {
|
|
|
|
case dependencyTag:
|
|
|
|
if t != vndkExtDepTag {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
case libraryDependencyTag:
|
|
|
|
default:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-02 15:00:51 +01:00
|
|
|
if from.Target().Os != android.Android {
|
2017-09-28 02:01:44 +02:00
|
|
|
// Host code is not restricted
|
|
|
|
return
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
|
|
|
|
// VNDK is cc.Module supported only for now.
|
|
|
|
if ccFrom, ok := from.(*Module); ok && from.UseVndk() {
|
2020-10-29 08:49:43 +01:00
|
|
|
// Though allowed dependency is limited by the image mutator,
|
|
|
|
// each vendor and product module needs to check link-type
|
|
|
|
// for VNDK.
|
2019-10-18 23:49:46 +02:00
|
|
|
if ccTo, ok := to.(*Module); ok {
|
|
|
|
if ccFrom.vndkdep != nil {
|
|
|
|
ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag)
|
|
|
|
}
|
2021-04-02 18:41:32 +02:00
|
|
|
} else if _, ok := to.(LinkableInterface); !ok {
|
2019-10-18 23:49:46 +02:00
|
|
|
ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type")
|
2016-08-03 23:12:14 +02:00
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
return
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if from.SdkVersion() == "" {
|
2017-09-28 02:01:44 +02:00
|
|
|
// Platform code can link to anything
|
|
|
|
return
|
|
|
|
}
|
2020-01-22 00:53:22 +01:00
|
|
|
if from.InRamdisk() {
|
|
|
|
// Ramdisk code is not NDK
|
|
|
|
return
|
|
|
|
}
|
2020-10-22 00:17:56 +02:00
|
|
|
if from.InVendorRamdisk() {
|
|
|
|
// Vendor ramdisk code is not NDK
|
|
|
|
return
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if from.InRecovery() {
|
2018-01-31 16:54:12 +01:00
|
|
|
// Recovery code is not NDK
|
|
|
|
return
|
|
|
|
}
|
2020-10-24 02:22:06 +02:00
|
|
|
if c, ok := to.(*Module); ok {
|
|
|
|
if c.NdkPrebuiltStl() {
|
|
|
|
// These are allowed, but they don't set sdk_version
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if c.StubDecorator() {
|
|
|
|
// These aren't real libraries, but are the stub shared libraries that are included in
|
|
|
|
// the NDK.
|
|
|
|
return
|
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
}
|
2019-01-14 08:39:03 +01:00
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
if strings.HasPrefix(ctx.ModuleName(), "libclang_rt.") && to.Module().Name() == "libc++" {
|
2019-01-14 08:39:03 +01:00
|
|
|
// Bug: http://b/121358700 - Allow libclang_rt.* shared libraries (with sdk_version)
|
|
|
|
// to link to libc++ (non-NDK and without sdk_version).
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
if to.SdkVersion() == "" {
|
2017-09-28 02:01:44 +02:00
|
|
|
// NDK code linking to platform code is never okay.
|
|
|
|
ctx.ModuleErrorf("depends on non-NDK-built library %q",
|
2019-10-18 23:49:46 +02:00
|
|
|
ctx.OtherModuleName(to.Module()))
|
2019-02-07 03:30:02 +01:00
|
|
|
return
|
2017-09-28 02:01:44 +02:00
|
|
|
}
|
2016-08-03 23:12:14 +02:00
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// At this point we know we have two NDK libraries, but we need to
|
|
|
|
// check that we're not linking against anything built against a higher
|
|
|
|
// API level, as it is only valid to link against older or equivalent
|
|
|
|
// APIs.
|
2016-08-03 23:12:14 +02:00
|
|
|
|
2018-04-11 02:48:45 +02:00
|
|
|
// Current can link against anything.
|
2019-10-18 23:49:46 +02:00
|
|
|
if from.SdkVersion() != "current" {
|
2018-04-11 02:48:45 +02:00
|
|
|
// Otherwise we need to check.
|
2019-10-18 23:49:46 +02:00
|
|
|
if to.SdkVersion() == "current" {
|
2018-04-11 02:48:45 +02:00
|
|
|
// Current can't be linked against by anything else.
|
|
|
|
ctx.ModuleErrorf("links %q built against newer API version %q",
|
2019-10-18 23:49:46 +02:00
|
|
|
ctx.OtherModuleName(to.Module()), "current")
|
2018-04-11 02:48:45 +02:00
|
|
|
} else {
|
2019-10-18 23:49:46 +02:00
|
|
|
fromApi, err := strconv.Atoi(from.SdkVersion())
|
2018-04-11 02:48:45 +02:00
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version",
|
2018-04-11 03:13:16 +02:00
|
|
|
"Invalid sdk_version value (must be int or current): %q",
|
2019-10-18 23:49:46 +02:00
|
|
|
from.SdkVersion())
|
2018-04-11 02:48:45 +02:00
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
toApi, err := strconv.Atoi(to.SdkVersion())
|
2018-04-11 02:48:45 +02:00
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version",
|
2018-04-11 03:13:16 +02:00
|
|
|
"Invalid sdk_version value (must be int or current): %q",
|
2019-10-18 23:49:46 +02:00
|
|
|
to.SdkVersion())
|
2018-04-11 02:48:45 +02:00
|
|
|
}
|
2016-08-03 23:12:14 +02:00
|
|
|
|
2018-04-11 02:48:45 +02:00
|
|
|
if toApi > fromApi {
|
|
|
|
ctx.ModuleErrorf("links %q built against newer API version %q",
|
2019-10-18 23:49:46 +02:00
|
|
|
ctx.OtherModuleName(to.Module()), to.SdkVersion())
|
2018-04-11 02:48:45 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-07 21:34:45 +02:00
|
|
|
}
|
2017-12-15 22:56:59 +01:00
|
|
|
|
|
|
|
// Also check that the two STL choices are compatible.
|
2019-10-18 23:49:46 +02:00
|
|
|
fromStl := from.SelectedStl()
|
|
|
|
toStl := to.SelectedStl()
|
2017-12-15 22:56:59 +01:00
|
|
|
if fromStl == "" || toStl == "" {
|
|
|
|
// Libraries that don't use the STL are unrestricted.
|
2018-04-11 08:41:38 +02:00
|
|
|
} else if fromStl == "ndk_system" || toStl == "ndk_system" {
|
2017-12-15 22:56:59 +01:00
|
|
|
// We can be permissive with the system "STL" since it is only the C++
|
|
|
|
// ABI layer, but in the future we should make sure that everyone is
|
|
|
|
// using either libc++ or nothing.
|
2018-09-05 01:28:17 +02:00
|
|
|
} else if getNdkStlFamily(from) != getNdkStlFamily(to) {
|
2017-12-15 22:56:59 +01:00
|
|
|
ctx.ModuleErrorf("uses %q and depends on %q which uses incompatible %q",
|
2019-10-18 23:49:46 +02:00
|
|
|
from.SelectedStl(), ctx.OtherModuleName(to.Module()),
|
|
|
|
to.SelectedStl())
|
2017-12-15 22:56:59 +01:00
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
}
|
2016-06-07 21:34:45 +02:00
|
|
|
|
2020-10-19 11:51:07 +02:00
|
|
|
func checkLinkTypeMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
if c, ok := ctx.Module().(*Module); ok {
|
|
|
|
ctx.VisitDirectDeps(func(dep android.Module) {
|
|
|
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
|
|
|
ccDep, ok := dep.(LinkableInterface)
|
|
|
|
if ok {
|
|
|
|
checkLinkType(ctx, c, ccDep, depTag)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-09 05:03:06 +02:00
|
|
|
// Tests whether the dependent library is okay to be double loaded inside a single process.
|
2019-01-18 07:20:43 +01:00
|
|
|
// If a library has a vendor variant and is a (transitive) dependency of an LLNDK library,
|
|
|
|
// it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true
|
2018-04-09 05:03:06 +02:00
|
|
|
// or as vndk-sp (vndk: { enabled: true, support_system_process: true}).
|
2019-01-18 07:20:43 +01:00
|
|
|
func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
|
|
|
|
check := func(child, parent android.Module) bool {
|
|
|
|
to, ok := child.(*Module)
|
|
|
|
if !ok {
|
2020-10-19 11:51:07 +02:00
|
|
|
return false
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
|
|
|
|
return false
|
|
|
|
}
|
2018-04-09 05:03:06 +02:00
|
|
|
|
2021-01-14 06:26:06 +01:00
|
|
|
// These dependencies are not excercised at runtime. Tracking these will give us
|
|
|
|
// false negative, so skip.
|
2020-12-01 15:40:09 +01:00
|
|
|
depTag := ctx.OtherModuleDependencyTag(child)
|
|
|
|
if IsHeaderDepTag(depTag) {
|
|
|
|
return false
|
|
|
|
}
|
2021-01-14 06:26:06 +01:00
|
|
|
if depTag == staticVariantTag {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if depTag == stubImplDepTag {
|
|
|
|
return false
|
|
|
|
}
|
2020-12-01 15:40:09 +01:00
|
|
|
|
2020-10-29 08:49:43 +01:00
|
|
|
// Even if target lib has no vendor variant, keep checking dependency
|
|
|
|
// graph in case it depends on vendor_available or product_available
|
|
|
|
// but not double_loadable transtively.
|
|
|
|
if !to.HasNonSystemVariants() {
|
2019-01-18 07:20:43 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2021-01-14 06:26:06 +01:00
|
|
|
// The happy path. Keep tracking dependencies until we hit a non double-loadable
|
|
|
|
// one.
|
|
|
|
if Bool(to.VendorProperties.Double_loadable) {
|
|
|
|
return true
|
2018-04-09 05:03:06 +02:00
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
|
2021-04-01 15:49:36 +02:00
|
|
|
if to.IsVndkSp() || to.IsLlndk() {
|
2021-01-14 06:26:06 +01:00
|
|
|
return false
|
2018-04-09 05:03:06 +02:00
|
|
|
}
|
2021-01-14 06:26:06 +01:00
|
|
|
|
2019-01-18 07:20:43 +01:00
|
|
|
ctx.ModuleErrorf("links a library %q which is not LL-NDK, "+
|
|
|
|
"VNDK-SP, or explicitly marked as 'double_loadable:true'. "+
|
2021-01-14 06:26:06 +01:00
|
|
|
"Dependency list: %s", ctx.OtherModuleName(to), ctx.GetPathString(false))
|
2019-01-18 07:20:43 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
if module, ok := ctx.Module().(*Module); ok {
|
|
|
|
if lib, ok := module.linker.(*libraryDecorator); ok && lib.shared() {
|
2021-01-14 06:26:06 +01:00
|
|
|
if lib.hasLLNDKStubs() {
|
2019-01-18 07:20:43 +01:00
|
|
|
ctx.WalkDeps(check)
|
|
|
|
}
|
2018-04-09 05:03:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// Convert dependencies to paths. Returns a PathDeps containing paths
|
|
|
|
func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|
|
|
var depPaths PathDeps
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
var directStaticDeps []StaticLibraryInfo
|
|
|
|
var directSharedDeps []SharedLibraryInfo
|
2017-09-28 02:05:30 +02:00
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
reexportExporter := func(exporter FlagExporterInfo) {
|
|
|
|
depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, exporter.IncludeDirs...)
|
|
|
|
depPaths.ReexportedSystemDirs = append(depPaths.ReexportedSystemDirs, exporter.SystemIncludeDirs...)
|
|
|
|
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, exporter.Flags...)
|
|
|
|
depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, exporter.Deps...)
|
|
|
|
depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.GeneratedHeaders...)
|
2019-06-03 12:10:47 +02:00
|
|
|
}
|
|
|
|
|
2020-07-23 06:04:15 +02:00
|
|
|
// For the dependency from platform to apex, use the latest stubs
|
|
|
|
c.apexSdkVersion = android.FutureApiLevel
|
2020-09-16 03:30:11 +02:00
|
|
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
|
|
|
if !apexInfo.IsForPlatform() {
|
2021-04-15 08:17:54 +02:00
|
|
|
c.apexSdkVersion = apexInfo.MinSdkVersion
|
2020-07-23 06:04:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if android.InList("hwaddress", ctx.Config().SanitizeDevice()) {
|
|
|
|
// In hwasan build, we override apexSdkVersion to the FutureApiLevel(10000)
|
|
|
|
// so that even Q(29/Android10) apexes could use the dynamic unwinder by linking the newer stubs(e.g libc(R+)).
|
|
|
|
// (b/144430859)
|
|
|
|
c.apexSdkVersion = android.FutureApiLevel
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:59:01 +02:00
|
|
|
ctx.VisitDirectDeps(func(dep android.Module) {
|
2017-09-28 02:01:44 +02:00
|
|
|
depName := ctx.OtherModuleName(dep)
|
|
|
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
|
|
|
|
2021-10-20 05:24:49 +02:00
|
|
|
if depTag == android.DarwinUniversalVariantTag {
|
|
|
|
depPaths.DarwinSecondArchOutput = dep.(*Module).OutputFile()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
ccDep, ok := dep.(LinkableInterface)
|
|
|
|
if !ok {
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// handling for a few module types that aren't cc Module but that are also supported
|
|
|
|
switch depTag {
|
2016-04-20 23:21:14 +02:00
|
|
|
case genSourceDepTag:
|
2017-09-28 02:01:44 +02:00
|
|
|
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
|
2016-04-20 23:21:14 +02:00
|
|
|
depPaths.GeneratedSources = append(depPaths.GeneratedSources,
|
|
|
|
genRule.GeneratedSourceFiles()...)
|
|
|
|
} else {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
|
2016-04-20 23:21:14 +02:00
|
|
|
}
|
2017-04-27 01:59:26 +02:00
|
|
|
// Support exported headers from a generated_sources dependency
|
|
|
|
fallthrough
|
2016-09-29 02:34:58 +02:00
|
|
|
case genHeaderDepTag, genHeaderExportDepTag:
|
2017-09-28 02:01:44 +02:00
|
|
|
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
|
2019-12-06 05:15:38 +01:00
|
|
|
depPaths.GeneratedDeps = append(depPaths.GeneratedDeps,
|
2018-02-22 03:28:18 +01:00
|
|
|
genRule.GeneratedDeps()...)
|
2019-10-22 13:19:51 +02:00
|
|
|
dirs := genRule.GeneratedHeaderDirs()
|
2019-06-03 12:10:47 +02:00
|
|
|
depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...)
|
2017-09-28 02:01:44 +02:00
|
|
|
if depTag == genHeaderExportDepTag {
|
2019-06-03 12:10:47 +02:00
|
|
|
depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...)
|
2019-12-06 05:15:38 +01:00
|
|
|
depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders,
|
|
|
|
genRule.GeneratedSourceFiles()...)
|
2019-06-03 12:10:47 +02:00
|
|
|
depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...)
|
2017-04-20 15:53:59 +02:00
|
|
|
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
|
2019-10-22 13:19:51 +02:00
|
|
|
c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs.Strings()...)
|
2017-04-20 15:53:59 +02:00
|
|
|
|
2016-09-29 02:34:58 +02:00
|
|
|
}
|
2016-04-20 23:21:14 +02:00
|
|
|
} else {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("module %q is not a genrule", depName)
|
2016-04-20 23:21:14 +02:00
|
|
|
}
|
2021-06-12 03:01:26 +02:00
|
|
|
case CrtBeginDepTag:
|
|
|
|
depPaths.CrtBegin = append(depPaths.CrtBegin, android.OutputFileForModule(ctx, dep, ""))
|
|
|
|
case CrtEndDepTag:
|
|
|
|
depPaths.CrtEnd = append(depPaths.CrtEnd, android.OutputFileForModule(ctx, dep, ""))
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
return
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2019-03-29 03:30:56 +01:00
|
|
|
if depTag == android.ProtoPluginDepTag {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:59:01 +02:00
|
|
|
if dep.Target().Os != ctx.Os() {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
|
2016-06-02 02:09:44 +02:00
|
|
|
return
|
|
|
|
}
|
2017-10-24 02:59:01 +02:00
|
|
|
if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
|
2020-03-21 15:21:46 +01:00
|
|
|
ctx.ModuleErrorf("Arch mismatch between %q(%v) and %q(%v)",
|
|
|
|
ctx.ModuleName(), ctx.Arch().ArchType, depName, dep.Target().Arch.ArchType)
|
2016-04-12 00:06:20 +02:00
|
|
|
return
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2015-04-22 22:07:53 +02:00
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
if depTag == reuseObjTag {
|
2020-10-23 23:53:06 +02:00
|
|
|
// Skip reused objects for stub libraries, they use their own stub object file instead.
|
|
|
|
// The reuseObjTag dependency still exists because the LinkageMutator runs before the
|
|
|
|
// version mutator, so the stubs variant is created from the shared variant that
|
|
|
|
// already has the reuseObjTag dependency on the static variant.
|
2020-10-24 02:22:06 +02:00
|
|
|
if !c.library.buildStubs() {
|
2020-10-23 23:53:06 +02:00
|
|
|
staticAnalogue := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
|
|
|
|
objs := staticAnalogue.ReuseObjects
|
|
|
|
depPaths.Objs = depPaths.Objs.Append(objs)
|
|
|
|
depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
|
|
|
|
reexportExporter(depExporterInfo)
|
|
|
|
}
|
2020-09-18 23:15:30 +02:00
|
|
|
return
|
2019-01-31 16:31:10 +01:00
|
|
|
}
|
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
linkFile := ccDep.OutputFile()
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
if libDepTag, ok := depTag.(libraryDependencyTag); ok {
|
|
|
|
// Only use static unwinder for legacy (min_sdk_version = 29) apexes (b/144430859)
|
2020-07-23 07:32:17 +02:00
|
|
|
if libDepTag.staticUnwinder && c.apexSdkVersion.GreaterThan(android.SdkVersion_Android10) {
|
2020-07-28 06:26:48 +02:00
|
|
|
return
|
2018-12-20 10:18:08 +01:00
|
|
|
}
|
2020-07-28 06:26:48 +02:00
|
|
|
|
2020-12-03 09:28:25 +01:00
|
|
|
if !apexInfo.IsForPlatform() && libDepTag.excludeInApex {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
|
|
|
|
|
|
|
|
var ptr *android.Paths
|
|
|
|
var depPtr *android.Paths
|
|
|
|
|
|
|
|
depFile := android.OptionalPath{}
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case libDepTag.header():
|
2020-12-10 21:30:21 +01:00
|
|
|
if !ctx.OtherModuleHasProvider(dep, HeaderLibraryInfoProvider) {
|
|
|
|
if !ctx.Config().AllowMissingDependencies() {
|
|
|
|
ctx.ModuleErrorf("module %q is not a header library", depName)
|
|
|
|
} else {
|
|
|
|
ctx.AddMissingDependencies([]string{depName})
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2020-09-18 23:15:30 +02:00
|
|
|
case libDepTag.shared():
|
|
|
|
if !ctx.OtherModuleHasProvider(dep, SharedLibraryInfoProvider) {
|
|
|
|
if !ctx.Config().AllowMissingDependencies() {
|
|
|
|
ctx.ModuleErrorf("module %q is not a shared library", depName)
|
|
|
|
} else {
|
|
|
|
ctx.AddMissingDependencies([]string{depName})
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2020-12-03 09:28:25 +01:00
|
|
|
|
2021-06-11 10:22:09 +02:00
|
|
|
sharedLibraryInfo, returnedDepExporterInfo := ChooseStubOrImpl(ctx, dep)
|
|
|
|
depExporterInfo = returnedDepExporterInfo
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
|
2020-12-01 15:40:09 +01:00
|
|
|
// Stubs lib doesn't link to the shared lib dependencies. Don't set
|
|
|
|
// linkFile, depFile, and ptr.
|
|
|
|
if c.IsStubs() {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
linkFile = android.OptionalPathForPath(sharedLibraryInfo.SharedLibrary)
|
|
|
|
depFile = sharedLibraryInfo.TableOfContents
|
2019-11-07 04:15:49 +01:00
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
ptr = &depPaths.SharedLibs
|
|
|
|
switch libDepTag.Order {
|
|
|
|
case earlyLibraryDependency:
|
|
|
|
ptr = &depPaths.EarlySharedLibs
|
|
|
|
depPtr = &depPaths.EarlySharedLibsDeps
|
|
|
|
case normalLibraryDependency:
|
|
|
|
ptr = &depPaths.SharedLibs
|
|
|
|
depPtr = &depPaths.SharedLibsDeps
|
2020-09-18 23:15:30 +02:00
|
|
|
directSharedDeps = append(directSharedDeps, sharedLibraryInfo)
|
2020-07-28 06:26:48 +02:00
|
|
|
case lateLibraryDependency:
|
|
|
|
ptr = &depPaths.LateSharedLibs
|
|
|
|
depPtr = &depPaths.LateSharedLibsDeps
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
|
|
|
|
}
|
|
|
|
case libDepTag.static():
|
2020-09-18 23:15:30 +02:00
|
|
|
if !ctx.OtherModuleHasProvider(dep, StaticLibraryInfoProvider) {
|
|
|
|
if !ctx.Config().AllowMissingDependencies() {
|
|
|
|
ctx.ModuleErrorf("module %q is not a static library", depName)
|
|
|
|
} else {
|
|
|
|
ctx.AddMissingDependencies([]string{depName})
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2020-12-01 15:40:09 +01:00
|
|
|
|
|
|
|
// Stubs lib doesn't link to the static lib dependencies. Don't set
|
|
|
|
// linkFile, depFile, and ptr.
|
|
|
|
if c.IsStubs() {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
staticLibraryInfo := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
|
|
|
|
linkFile = android.OptionalPathForPath(staticLibraryInfo.StaticLibrary)
|
2020-07-28 06:26:48 +02:00
|
|
|
if libDepTag.wholeStatic {
|
|
|
|
ptr = &depPaths.WholeStaticLibs
|
2020-09-18 23:15:30 +02:00
|
|
|
if len(staticLibraryInfo.Objects.objFiles) > 0 {
|
|
|
|
depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLibraryInfo.Objects)
|
2020-07-28 06:26:48 +02:00
|
|
|
} else {
|
2020-09-18 23:15:30 +02:00
|
|
|
// This case normally catches prebuilt static
|
|
|
|
// libraries, but it can also occur when
|
|
|
|
// AllowMissingDependencies is on and the
|
|
|
|
// dependencies has no sources of its own
|
|
|
|
// but has a whole_static_libs dependency
|
|
|
|
// on a missing library. We want to depend
|
|
|
|
// on the .a file so that there is something
|
|
|
|
// in the dependency tree that contains the
|
|
|
|
// error rule for the missing transitive
|
|
|
|
// dependency.
|
|
|
|
depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts, linkFile.Path())
|
2019-10-18 23:49:46 +02:00
|
|
|
}
|
2022-02-11 22:11:55 +01:00
|
|
|
depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts,
|
|
|
|
staticLibraryInfo.WholeStaticLibsFromPrebuilts...)
|
2020-04-17 18:34:31 +02:00
|
|
|
} else {
|
2020-07-28 06:26:48 +02:00
|
|
|
switch libDepTag.Order {
|
|
|
|
case earlyLibraryDependency:
|
|
|
|
panic(fmt.Errorf("early static libs not suppported"))
|
|
|
|
case normalLibraryDependency:
|
|
|
|
// static dependencies will be handled separately so they can be ordered
|
|
|
|
// using transitive dependencies.
|
|
|
|
ptr = nil
|
2020-09-18 23:15:30 +02:00
|
|
|
directStaticDeps = append(directStaticDeps, staticLibraryInfo)
|
2020-07-28 06:26:48 +02:00
|
|
|
case lateLibraryDependency:
|
|
|
|
ptr = &depPaths.LateStaticLibs
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
|
|
|
|
}
|
2020-04-17 18:34:31 +02:00
|
|
|
}
|
2022-06-18 00:17:05 +02:00
|
|
|
if libDepTag.unexportedSymbols {
|
|
|
|
depPaths.LdFlags = append(depPaths.LdFlags,
|
|
|
|
"-Wl,--exclude-libs="+staticLibraryInfo.StaticLibrary.Base())
|
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
if libDepTag.static() && !libDepTag.wholeStatic {
|
|
|
|
if !ccDep.CcLibraryInterface() || !ccDep.Static() {
|
|
|
|
ctx.ModuleErrorf("module %q not a static library", depName)
|
|
|
|
return
|
2019-10-15 11:16:05 +02:00
|
|
|
}
|
2016-10-01 02:10:16 +02:00
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
// When combining coverage files for shared libraries and executables, coverage files
|
|
|
|
// in static libraries act as if they were whole static libraries. The same goes for
|
|
|
|
// source based Abi dump files.
|
|
|
|
if c, ok := ccDep.(*Module); ok {
|
|
|
|
staticLib := c.linker.(libraryInterface)
|
|
|
|
depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
|
|
|
|
staticLib.objs().coverageFiles...)
|
|
|
|
depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
|
|
|
|
staticLib.objs().sAbiDumpFiles...)
|
2020-09-18 23:15:30 +02:00
|
|
|
} else {
|
2020-07-28 06:26:48 +02:00
|
|
|
// Handle non-CC modules here
|
|
|
|
depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
|
2020-09-18 23:15:30 +02:00
|
|
|
ccDep.CoverageFiles()...)
|
2020-07-28 06:26:48 +02:00
|
|
|
}
|
2016-10-01 02:10:16 +02:00
|
|
|
}
|
2020-03-13 17:30:34 +01:00
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
if ptr != nil {
|
|
|
|
if !linkFile.Valid() {
|
|
|
|
if !ctx.Config().AllowMissingDependencies() {
|
|
|
|
ctx.ModuleErrorf("module %q missing output file", depName)
|
2020-01-22 03:11:29 +01:00
|
|
|
} else {
|
2020-07-28 06:26:48 +02:00
|
|
|
ctx.AddMissingDependencies([]string{depName})
|
2020-01-22 03:11:29 +01:00
|
|
|
}
|
2020-07-28 06:26:48 +02:00
|
|
|
return
|
2020-01-22 03:11:29 +01:00
|
|
|
}
|
2020-07-28 06:26:48 +02:00
|
|
|
*ptr = append(*ptr, linkFile.Path())
|
2020-01-22 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
if depPtr != nil {
|
|
|
|
dep := depFile
|
|
|
|
if !dep.Valid() {
|
|
|
|
dep = linkFile
|
|
|
|
}
|
|
|
|
*depPtr = append(*depPtr, dep.Path())
|
2017-07-18 06:23:39 +02:00
|
|
|
}
|
2017-12-19 18:17:32 +01:00
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
depPaths.IncludeDirs = append(depPaths.IncludeDirs, depExporterInfo.IncludeDirs...)
|
|
|
|
depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, depExporterInfo.SystemIncludeDirs...)
|
|
|
|
depPaths.GeneratedDeps = append(depPaths.GeneratedDeps, depExporterInfo.Deps...)
|
|
|
|
depPaths.Flags = append(depPaths.Flags, depExporterInfo.Flags...)
|
|
|
|
|
|
|
|
if libDepTag.reexportFlags {
|
|
|
|
reexportExporter(depExporterInfo)
|
|
|
|
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
|
|
|
|
// Re-exported shared library headers must be included as well since they can help us with type information
|
|
|
|
// about template instantiations (instantiated from their headers).
|
|
|
|
// -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version
|
|
|
|
// scripts.
|
|
|
|
c.sabi.Properties.ReexportedIncludes = append(
|
|
|
|
c.sabi.Properties.ReexportedIncludes, depExporterInfo.IncludeDirs.Strings()...)
|
|
|
|
}
|
|
|
|
|
2021-04-02 18:41:32 +02:00
|
|
|
makeLibName := MakeLibName(ctx, c, ccDep, depName) + libDepTag.makeSuffix
|
2020-07-28 06:26:48 +02:00
|
|
|
switch {
|
|
|
|
case libDepTag.header():
|
2020-07-29 21:48:33 +02:00
|
|
|
c.Properties.AndroidMkHeaderLibs = append(
|
|
|
|
c.Properties.AndroidMkHeaderLibs, makeLibName)
|
2020-07-28 06:26:48 +02:00
|
|
|
case libDepTag.shared():
|
2020-10-24 02:22:06 +02:00
|
|
|
if lib := moduleLibraryInterface(dep); lib != nil {
|
|
|
|
if lib.buildStubs() && dep.(android.ApexModule).InAnyApex() {
|
2020-07-28 06:26:48 +02:00
|
|
|
// Add the dependency to the APEX(es) providing the library so that
|
|
|
|
// m <module> can trigger building the APEXes as well.
|
2020-09-16 03:30:11 +02:00
|
|
|
depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
|
2021-05-12 10:13:56 +02:00
|
|
|
for _, an := range depApexInfo.InApexVariants {
|
2020-07-28 06:26:48 +02:00
|
|
|
c.Properties.ApexesProvidingSharedLibs = append(
|
|
|
|
c.Properties.ApexesProvidingSharedLibs, an)
|
|
|
|
}
|
2018-12-07 15:08:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
// Note: the order of libs in this list is not important because
|
|
|
|
// they merely serve as Make dependencies and do not affect this lib itself.
|
2020-07-29 21:48:33 +02:00
|
|
|
c.Properties.AndroidMkSharedLibs = append(
|
|
|
|
c.Properties.AndroidMkSharedLibs, makeLibName)
|
2021-05-20 19:01:32 +02:00
|
|
|
// Record BaseLibName for snapshots.
|
|
|
|
c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, BaseLibName(depName))
|
2020-07-28 06:26:48 +02:00
|
|
|
case libDepTag.static():
|
|
|
|
if libDepTag.wholeStatic {
|
|
|
|
c.Properties.AndroidMkWholeStaticLibs = append(
|
|
|
|
c.Properties.AndroidMkWholeStaticLibs, makeLibName)
|
|
|
|
} else {
|
|
|
|
c.Properties.AndroidMkStaticLibs = append(
|
|
|
|
c.Properties.AndroidMkStaticLibs, makeLibName)
|
|
|
|
}
|
2021-06-29 13:50:37 +02:00
|
|
|
// Record BaseLibName for snapshots.
|
|
|
|
c.Properties.SnapshotStaticLibs = append(c.Properties.SnapshotStaticLibs, BaseLibName(depName))
|
2020-07-28 06:26:48 +02:00
|
|
|
}
|
2020-12-01 15:40:09 +01:00
|
|
|
} else if !c.IsStubs() {
|
|
|
|
// Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies.
|
|
|
|
|
2020-07-28 06:26:48 +02:00
|
|
|
switch depTag {
|
|
|
|
case runtimeDepTag:
|
|
|
|
c.Properties.AndroidMkRuntimeLibs = append(
|
2021-04-02 18:41:32 +02:00
|
|
|
c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, depName)+libDepTag.makeSuffix)
|
2021-05-20 19:01:32 +02:00
|
|
|
// Record BaseLibName for snapshots.
|
|
|
|
c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName))
|
2020-07-28 06:26:48 +02:00
|
|
|
case objDepTag:
|
|
|
|
depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
|
|
|
|
case CrtBeginDepTag:
|
2021-06-12 03:00:04 +02:00
|
|
|
depPaths.CrtBegin = append(depPaths.CrtBegin, linkFile.Path())
|
2020-07-28 06:26:48 +02:00
|
|
|
case CrtEndDepTag:
|
2021-06-12 03:00:04 +02:00
|
|
|
depPaths.CrtEnd = append(depPaths.CrtEnd, linkFile.Path())
|
2020-07-28 06:26:48 +02:00
|
|
|
case dynamicLinkerDepTag:
|
|
|
|
depPaths.DynamicLinker = linkFile
|
|
|
|
}
|
2017-07-18 06:23:39 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
})
|
|
|
|
|
2017-09-28 02:05:30 +02:00
|
|
|
// use the ordered dependencies as this module's dependencies
|
2020-09-18 23:15:30 +02:00
|
|
|
orderedStaticPaths, transitiveStaticLibs := orderStaticModuleDeps(directStaticDeps, directSharedDeps)
|
|
|
|
depPaths.TranstiveStaticLibrariesForOrdering = transitiveStaticLibs
|
|
|
|
depPaths.StaticLibs = append(depPaths.StaticLibs, orderedStaticPaths...)
|
2017-09-28 02:05:30 +02:00
|
|
|
|
2017-05-17 22:44:16 +02:00
|
|
|
// Dedup exported flags from dependencies
|
2017-10-24 20:13:31 +02:00
|
|
|
depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
|
2019-10-22 13:19:51 +02:00
|
|
|
depPaths.IncludeDirs = android.FirstUniquePaths(depPaths.IncludeDirs)
|
|
|
|
depPaths.SystemIncludeDirs = android.FirstUniquePaths(depPaths.SystemIncludeDirs)
|
2019-12-06 05:15:38 +01:00
|
|
|
depPaths.GeneratedDeps = android.FirstUniquePaths(depPaths.GeneratedDeps)
|
2019-10-22 13:19:51 +02:00
|
|
|
depPaths.ReexportedDirs = android.FirstUniquePaths(depPaths.ReexportedDirs)
|
|
|
|
depPaths.ReexportedSystemDirs = android.FirstUniquePaths(depPaths.ReexportedSystemDirs)
|
2017-10-24 20:13:31 +02:00
|
|
|
depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
|
2019-06-03 12:10:47 +02:00
|
|
|
depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps)
|
2019-12-06 05:15:38 +01:00
|
|
|
depPaths.ReexportedGeneratedHeaders = android.FirstUniquePaths(depPaths.ReexportedGeneratedHeaders)
|
2017-08-29 21:28:37 +02:00
|
|
|
|
|
|
|
if c.sabi != nil {
|
2019-06-03 12:10:47 +02:00
|
|
|
c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes)
|
2017-08-29 21:28:37 +02:00
|
|
|
}
|
2017-05-17 22:44:16 +02:00
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
return depPaths
|
|
|
|
}
|
|
|
|
|
2021-06-11 10:22:09 +02:00
|
|
|
// ChooseStubOrImpl determines whether a given dependency should be redirected to the stub variant
|
|
|
|
// of the dependency or not, and returns the SharedLibraryInfo and FlagExporterInfo for the right
|
|
|
|
// dependency. The stub variant is selected when the dependency crosses a boundary where each side
|
|
|
|
// has different level of updatability. For example, if a library foo in an APEX depends on a
|
|
|
|
// library bar which provides stable interface and exists in the platform, foo uses the stub variant
|
|
|
|
// of bar. If bar doesn't provide a stable interface (i.e. buildStubs() == false) or is in the
|
|
|
|
// same APEX as foo, the non-stub variant of bar is used.
|
|
|
|
func ChooseStubOrImpl(ctx android.ModuleContext, dep android.Module) (SharedLibraryInfo, FlagExporterInfo) {
|
|
|
|
depName := ctx.OtherModuleName(dep)
|
|
|
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
|
|
|
libDepTag, ok := depTag.(libraryDependencyTag)
|
|
|
|
if !ok || !libDepTag.shared() {
|
|
|
|
panic(fmt.Errorf("Unexpected dependency tag: %T", depTag))
|
|
|
|
}
|
|
|
|
|
|
|
|
thisModule, ok := ctx.Module().(android.ApexModule)
|
|
|
|
if !ok {
|
|
|
|
panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
useVndk := false
|
|
|
|
bootstrap := false
|
|
|
|
if linkable, ok := ctx.Module().(LinkableInterface); !ok {
|
|
|
|
panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName()))
|
|
|
|
} else {
|
|
|
|
useVndk = linkable.UseVndk()
|
|
|
|
bootstrap = linkable.Bootstrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo)
|
|
|
|
depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
|
|
|
|
sharedLibraryStubsInfo := ctx.OtherModuleProvider(dep, SharedLibraryStubsProvider).(SharedLibraryStubsInfo)
|
|
|
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
|
|
|
|
|
|
|
if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedStubLibraries) > 0 {
|
|
|
|
useStubs := false
|
|
|
|
|
|
|
|
if lib := moduleLibraryInterface(dep); lib.buildStubs() && useVndk { // LLNDK
|
|
|
|
if !apexInfo.IsForPlatform() {
|
|
|
|
// For platform libraries, use current version of LLNDK
|
|
|
|
// If this is for use_vendor apex we will apply the same rules
|
|
|
|
// of apex sdk enforcement below to choose right version.
|
|
|
|
useStubs = true
|
|
|
|
}
|
2021-06-22 13:23:05 +02:00
|
|
|
} else if apexInfo.IsForPlatform() || apexInfo.UsePlatformApis {
|
|
|
|
// If not building for APEX or the containing APEX allows the use of
|
|
|
|
// platform APIs, use stubs only when it is from an APEX (and not from
|
|
|
|
// platform) However, for host, ramdisk, vendor_ramdisk, recovery or
|
|
|
|
// bootstrap modules, always link to non-stub variant
|
2021-06-11 10:22:09 +02:00
|
|
|
useStubs = dep.(android.ApexModule).NotInPlatform() && !bootstrap
|
|
|
|
if useStubs {
|
|
|
|
// Another exception: if this module is a test for an APEX, then
|
|
|
|
// it is linked with the non-stub variant of a module in the APEX
|
|
|
|
// as if this is part of the APEX.
|
|
|
|
testFor := ctx.Provider(android.ApexTestForInfoProvider).(android.ApexTestForInfo)
|
|
|
|
for _, apexContents := range testFor.ApexContents {
|
|
|
|
if apexContents.DirectlyInApex(depName) {
|
|
|
|
useStubs = false
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if useStubs {
|
|
|
|
// Yet another exception: If this module and the dependency are
|
|
|
|
// available to the same APEXes then skip stubs between their
|
|
|
|
// platform variants. This complements the test_for case above,
|
|
|
|
// which avoids the stubs on a direct APEX library dependency, by
|
|
|
|
// avoiding stubs for indirect test dependencies as well.
|
|
|
|
//
|
|
|
|
// TODO(b/183882457): This doesn't work if the two libraries have
|
|
|
|
// only partially overlapping apex_available. For that test_for
|
|
|
|
// modules would need to be split into APEX variants and resolved
|
|
|
|
// separately for each APEX they have access to.
|
|
|
|
if android.AvailableToSameApexes(thisModule, dep.(android.ApexModule)) {
|
|
|
|
useStubs = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// If building for APEX, use stubs when the parent is in any APEX that
|
|
|
|
// the child is not in.
|
|
|
|
useStubs = !android.DirectlyInAllApexes(apexInfo, depName)
|
|
|
|
}
|
|
|
|
|
|
|
|
// when to use (unspecified) stubs, use the latest one.
|
|
|
|
if useStubs {
|
|
|
|
stubs := sharedLibraryStubsInfo.SharedStubLibraries
|
|
|
|
toUse := stubs[len(stubs)-1]
|
|
|
|
sharedLibraryInfo = toUse.SharedLibraryInfo
|
|
|
|
depExporterInfo = toUse.FlagExporterInfo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sharedLibraryInfo, depExporterInfo
|
|
|
|
}
|
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
// orderStaticModuleDeps rearranges the order of the static library dependencies of the module
|
|
|
|
// to match the topological order of the dependency tree, including any static analogues of
|
|
|
|
// direct shared libraries. It returns the ordered static dependencies, and an android.DepSet
|
|
|
|
// of the transitive dependencies.
|
|
|
|
func orderStaticModuleDeps(staticDeps []StaticLibraryInfo, sharedDeps []SharedLibraryInfo) (ordered android.Paths, transitive *android.DepSet) {
|
|
|
|
transitiveStaticLibsBuilder := android.NewDepSetBuilder(android.TOPOLOGICAL)
|
|
|
|
var staticPaths android.Paths
|
|
|
|
for _, staticDep := range staticDeps {
|
|
|
|
staticPaths = append(staticPaths, staticDep.StaticLibrary)
|
|
|
|
transitiveStaticLibsBuilder.Transitive(staticDep.TransitiveStaticLibrariesForOrdering)
|
|
|
|
}
|
|
|
|
for _, sharedDep := range sharedDeps {
|
2021-06-08 21:37:09 +02:00
|
|
|
if sharedDep.TransitiveStaticLibrariesForOrdering != nil {
|
|
|
|
transitiveStaticLibsBuilder.Transitive(sharedDep.TransitiveStaticLibrariesForOrdering)
|
2020-09-18 23:15:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
transitiveStaticLibs := transitiveStaticLibsBuilder.Build()
|
|
|
|
|
|
|
|
orderedTransitiveStaticLibs := transitiveStaticLibs.ToList()
|
|
|
|
|
|
|
|
// reorder the dependencies based on transitive dependencies
|
|
|
|
staticPaths = android.FirstUniquePaths(staticPaths)
|
|
|
|
_, orderedStaticPaths := android.FilterPathList(orderedTransitiveStaticLibs, staticPaths)
|
|
|
|
|
|
|
|
if len(orderedStaticPaths) != len(staticPaths) {
|
|
|
|
missing, _ := android.FilterPathList(staticPaths, orderedStaticPaths)
|
|
|
|
panic(fmt.Errorf("expected %d ordered static paths , got %d, missing %q %q %q", len(staticPaths), len(orderedStaticPaths), missing, orderedStaticPaths, staticPaths))
|
|
|
|
}
|
|
|
|
|
|
|
|
return orderedStaticPaths, transitiveStaticLibs
|
|
|
|
}
|
|
|
|
|
2021-05-20 19:01:32 +02:00
|
|
|
// BaseLibName trims known prefixes and suffixes
|
|
|
|
func BaseLibName(depName string) string {
|
2020-07-28 06:26:48 +02:00
|
|
|
libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
|
|
|
|
libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix)
|
2020-12-11 19:13:08 +01:00
|
|
|
libName = android.RemoveOptionalPrebuiltPrefix(libName)
|
2020-07-28 06:26:48 +02:00
|
|
|
return libName
|
|
|
|
}
|
|
|
|
|
2021-04-02 18:41:32 +02:00
|
|
|
func MakeLibName(ctx android.ModuleContext, c LinkableInterface, ccDep LinkableInterface, depName string) string {
|
2021-05-20 19:01:32 +02:00
|
|
|
libName := BaseLibName(depName)
|
2020-12-17 01:46:01 +01:00
|
|
|
ccDepModule, _ := ccDep.(*Module)
|
|
|
|
isLLndk := ccDepModule != nil && ccDepModule.IsLlndk()
|
2021-02-03 11:24:13 +01:00
|
|
|
nonSystemVariantsExist := ccDep.HasNonSystemVariants() || isLLndk
|
2020-07-28 06:26:48 +02:00
|
|
|
|
2021-02-03 11:24:13 +01:00
|
|
|
if ccDepModule != nil {
|
2021-04-02 18:41:32 +02:00
|
|
|
// TODO(ivanlozano) Support snapshots for Rust-produced C library variants.
|
2020-07-28 06:26:48 +02:00
|
|
|
// Use base module name for snapshots when exporting to Makefile.
|
2021-05-26 21:33:11 +02:00
|
|
|
if snapshotPrebuilt, ok := ccDepModule.linker.(SnapshotInterface); ok {
|
2021-02-03 11:24:13 +01:00
|
|
|
baseName := ccDepModule.BaseModuleName()
|
2020-07-28 06:26:48 +02:00
|
|
|
|
2021-05-26 21:33:11 +02:00
|
|
|
return baseName + snapshotPrebuilt.SnapshotAndroidMkSuffix()
|
2020-07-28 06:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-22 00:17:56 +02:00
|
|
|
if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() &&
|
|
|
|
!c.InRamdisk() && !c.InVendorRamdisk() && !c.InRecovery() {
|
2020-07-28 06:26:48 +02:00
|
|
|
// The vendor module is a no-vendor-variant VNDK library. Depend on the
|
|
|
|
// core module instead.
|
|
|
|
return libName
|
2021-04-02 18:41:32 +02:00
|
|
|
} else if ccDep.UseVndk() && nonSystemVariantsExist {
|
2021-02-03 11:24:13 +01:00
|
|
|
// The vendor and product modules in Make will have been renamed to not conflict with the
|
|
|
|
// core module, so update the dependency name here accordingly.
|
2021-04-02 18:41:32 +02:00
|
|
|
return libName + ccDep.SubName()
|
2020-07-28 06:26:48 +02:00
|
|
|
} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
|
2021-07-13 23:12:37 +02:00
|
|
|
return libName + RamdiskSuffix
|
2020-10-22 00:17:56 +02:00
|
|
|
} else if ccDep.InVendorRamdisk() && !ccDep.OnlyInVendorRamdisk() {
|
2021-02-05 16:57:43 +01:00
|
|
|
return libName + VendorRamdiskSuffix
|
2020-07-28 06:26:48 +02:00
|
|
|
} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
|
2021-02-11 21:31:46 +01:00
|
|
|
return libName + RecoverySuffix
|
2020-12-02 15:00:51 +01:00
|
|
|
} else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled {
|
2021-05-27 20:09:11 +02:00
|
|
|
return libName + NativeBridgeSuffix
|
2020-07-28 06:26:48 +02:00
|
|
|
} else {
|
|
|
|
return libName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
func (c *Module) InstallInData() bool {
|
|
|
|
if c.installer == nil {
|
|
|
|
return false
|
|
|
|
}
|
2017-03-30 07:00:18 +02:00
|
|
|
return c.installer.inData()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) InstallInSanitizerDir() bool {
|
|
|
|
if c.installer == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if c.sanitize != nil && c.sanitize.inSanitizerDir() {
|
2016-08-29 22:41:32 +02:00
|
|
|
return true
|
|
|
|
}
|
2017-03-30 07:00:18 +02:00
|
|
|
return c.installer.inSanitizerDir()
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2020-01-22 00:53:22 +01:00
|
|
|
func (c *Module) InstallInRamdisk() bool {
|
|
|
|
return c.InRamdisk()
|
|
|
|
}
|
|
|
|
|
2020-10-22 00:17:56 +02:00
|
|
|
func (c *Module) InstallInVendorRamdisk() bool {
|
|
|
|
return c.InVendorRamdisk()
|
|
|
|
}
|
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
func (c *Module) InstallInRecovery() bool {
|
2019-10-18 23:49:46 +02:00
|
|
|
return c.InRecovery()
|
2018-01-31 16:54:12 +01:00
|
|
|
}
|
|
|
|
|
2020-08-06 23:34:42 +02:00
|
|
|
func (c *Module) MakeUninstallable() {
|
2020-03-31 17:05:34 +02:00
|
|
|
if c.installer == nil {
|
2020-08-06 23:34:42 +02:00
|
|
|
c.ModuleBase.MakeUninstallable()
|
2020-03-31 17:05:34 +02:00
|
|
|
return
|
|
|
|
}
|
2020-08-06 23:34:42 +02:00
|
|
|
c.installer.makeUninstallable(c)
|
2020-03-31 17:05:34 +02:00
|
|
|
}
|
|
|
|
|
2016-09-29 01:18:03 +02:00
|
|
|
func (c *Module) HostToolPath() android.OptionalPath {
|
|
|
|
if c.installer == nil {
|
|
|
|
return android.OptionalPath{}
|
|
|
|
}
|
|
|
|
return c.installer.hostToolPath()
|
|
|
|
}
|
|
|
|
|
2017-07-12 21:55:28 +02:00
|
|
|
func (c *Module) IntermPathForModuleOut() android.OptionalPath {
|
|
|
|
return c.outputFile
|
|
|
|
}
|
|
|
|
|
2019-05-29 23:40:35 +02:00
|
|
|
func (c *Module) OutputFiles(tag string) (android.Paths, error) {
|
|
|
|
switch tag {
|
|
|
|
case "":
|
|
|
|
if c.outputFile.Valid() {
|
|
|
|
return android.Paths{c.outputFile.Path()}, nil
|
|
|
|
}
|
|
|
|
return android.Paths{}, nil
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
2017-09-14 03:37:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-01 10:20:21 +01:00
|
|
|
func (c *Module) static() bool {
|
|
|
|
if static, ok := c.linker.(interface {
|
|
|
|
static() bool
|
|
|
|
}); ok {
|
|
|
|
return static.static()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-12-18 18:47:14 +01:00
|
|
|
func (c *Module) staticBinary() bool {
|
|
|
|
if static, ok := c.linker.(interface {
|
|
|
|
staticBinary() bool
|
|
|
|
}); ok {
|
|
|
|
return static.staticBinary()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-04-29 00:09:12 +02:00
|
|
|
func (c *Module) testBinary() bool {
|
|
|
|
if test, ok := c.linker.(interface {
|
|
|
|
testBinary() bool
|
|
|
|
}); ok {
|
|
|
|
return test.testBinary()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-08-24 13:53:27 +02:00
|
|
|
func (c *Module) testLibrary() bool {
|
|
|
|
if test, ok := c.linker.(interface {
|
|
|
|
testLibrary() bool
|
|
|
|
}); ok {
|
|
|
|
return test.testLibrary()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-11-01 20:32:43 +01:00
|
|
|
func (c *Module) benchmarkBinary() bool {
|
|
|
|
if b, ok := c.linker.(interface {
|
|
|
|
benchmarkBinary() bool
|
|
|
|
}); ok {
|
|
|
|
return b.benchmarkBinary()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) fuzzBinary() bool {
|
|
|
|
if f, ok := c.linker.(interface {
|
|
|
|
fuzzBinary() bool
|
|
|
|
}); ok {
|
|
|
|
return f.fuzzBinary()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-12-14 17:27:52 +01:00
|
|
|
// Header returns true if the module is a header-only variant. (See cc/library.go header()).
|
|
|
|
func (c *Module) Header() bool {
|
2019-07-29 14:27:18 +02:00
|
|
|
if h, ok := c.linker.(interface {
|
|
|
|
header() bool
|
|
|
|
}); ok {
|
|
|
|
return h.header()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-04-01 15:49:36 +02:00
|
|
|
func (c *Module) Binary() bool {
|
2020-06-01 14:53:49 +02:00
|
|
|
if b, ok := c.linker.(interface {
|
|
|
|
binary() bool
|
|
|
|
}); ok {
|
|
|
|
return b.binary()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-06-29 13:50:37 +02:00
|
|
|
func (c *Module) StaticExecutable() bool {
|
|
|
|
if b, ok := c.linker.(*binaryDecorator); ok {
|
|
|
|
return b.static()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-04-01 15:49:36 +02:00
|
|
|
func (c *Module) Object() bool {
|
2020-06-01 16:23:05 +02:00
|
|
|
if o, ok := c.linker.(interface {
|
|
|
|
object() bool
|
|
|
|
}); ok {
|
|
|
|
return o.object()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-12-02 15:00:51 +01:00
|
|
|
func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
|
2019-10-18 23:49:46 +02:00
|
|
|
if c.UseVndk() {
|
2020-12-17 01:46:01 +01:00
|
|
|
if c.IsLlndk() {
|
|
|
|
if !c.IsLlndkPublic() {
|
2020-12-02 15:00:51 +01:00
|
|
|
return "native:vndk_private"
|
2018-09-05 01:28:17 +02:00
|
|
|
}
|
2020-12-17 01:46:01 +01:00
|
|
|
return "native:vndk"
|
2019-05-15 21:01:54 +02:00
|
|
|
}
|
2020-12-02 15:00:51 +01:00
|
|
|
if c.IsVndk() && !c.IsVndkExt() {
|
2020-12-17 01:46:01 +01:00
|
|
|
if c.IsVndkPrivate() {
|
2020-12-02 15:00:51 +01:00
|
|
|
return "native:vndk_private"
|
2019-05-15 21:01:54 +02:00
|
|
|
}
|
2020-12-02 15:00:51 +01:00
|
|
|
return "native:vndk"
|
2018-09-05 01:28:17 +02:00
|
|
|
}
|
2020-12-02 15:00:51 +01:00
|
|
|
if c.InProduct() {
|
2019-11-18 11:52:14 +01:00
|
|
|
return "native:product"
|
|
|
|
}
|
2019-05-15 21:01:54 +02:00
|
|
|
return "native:vendor"
|
2020-01-22 00:53:22 +01:00
|
|
|
} else if c.InRamdisk() {
|
|
|
|
return "native:ramdisk"
|
2020-10-22 00:17:56 +02:00
|
|
|
} else if c.InVendorRamdisk() {
|
|
|
|
return "native:vendor_ramdisk"
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if c.InRecovery() {
|
2018-09-05 01:28:17 +02:00
|
|
|
return "native:recovery"
|
2020-12-02 15:00:51 +01:00
|
|
|
} else if c.Target().Os == android.Android && c.SdkVersion() != "" {
|
2018-09-05 01:28:17 +02:00
|
|
|
return "native:ndk:none:none"
|
|
|
|
// TODO(b/114741097): use the correct ndk stl once build errors have been fixed
|
|
|
|
//family, link := getNdkStlFamilyAndLinkType(c)
|
|
|
|
//return fmt.Sprintf("native:ndk:%s:%s", family, link)
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if actx.DeviceConfig().VndkUseCoreVariant() && !c.MustUseVendorVariant() {
|
2018-11-13 05:19:56 +01:00
|
|
|
return "native:platform_vndk"
|
2018-09-05 01:28:17 +02:00
|
|
|
} else {
|
|
|
|
return "native:platform"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-02 17:38:19 +02:00
|
|
|
// Overrides ApexModule.IsInstallabeToApex()
|
2019-07-29 17:22:59 +02:00
|
|
|
// Only shared/runtime libraries and "test_per_src" tests are installable to APEX.
|
2018-10-02 17:38:19 +02:00
|
|
|
func (c *Module) IsInstallableToApex() bool {
|
2020-10-24 02:22:06 +02:00
|
|
|
if lib := c.library; lib != nil {
|
2019-10-22 13:31:18 +02:00
|
|
|
// Stub libs and prebuilt libs in a versioned SDK are not
|
|
|
|
// installable to APEX even though they are shared libs.
|
2020-10-24 02:22:06 +02:00
|
|
|
return lib.shared() && !lib.buildStubs() && c.ContainingSdk().Unversioned()
|
2019-07-29 17:22:59 +02:00
|
|
|
} else if _, ok := c.linker.(testPerSrc); ok {
|
|
|
|
return true
|
2018-10-02 17:38:19 +02:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-10-07 08:47:24 +02:00
|
|
|
func (c *Module) AvailableFor(what string) bool {
|
|
|
|
if linker, ok := c.linker.(interface {
|
|
|
|
availableFor(string) bool
|
|
|
|
}); ok {
|
|
|
|
return c.ApexModuleBase.AvailableFor(what) || linker.availableFor(what)
|
|
|
|
} else {
|
|
|
|
return c.ApexModuleBase.AvailableFor(what)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-13 09:19:48 +02:00
|
|
|
func (c *Module) TestFor() []string {
|
2020-12-04 10:02:13 +01:00
|
|
|
return c.Properties.Test_for
|
2020-04-13 09:19:48 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 15:52:46 +01:00
|
|
|
func (c *Module) EverInstallable() bool {
|
|
|
|
return c.installer != nil &&
|
|
|
|
// Check to see whether the module is actually ever installable.
|
|
|
|
c.installer.everInstallable()
|
|
|
|
}
|
|
|
|
|
2021-04-01 15:49:36 +02:00
|
|
|
func (c *Module) PreventInstall() bool {
|
|
|
|
return c.Properties.PreventInstall
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) Installable() *bool {
|
2021-10-28 22:25:54 +02:00
|
|
|
if c.library != nil {
|
|
|
|
if i := c.library.installable(); i != nil {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
2021-04-01 15:49:36 +02:00
|
|
|
return c.Properties.Installable
|
|
|
|
}
|
|
|
|
|
|
|
|
func installable(c LinkableInterface, apexInfo android.ApexInfo) bool {
|
2020-03-04 15:52:46 +01:00
|
|
|
ret := c.EverInstallable() &&
|
|
|
|
// Check to see whether the module has been configured to not be installed.
|
2021-04-01 15:49:36 +02:00
|
|
|
proptools.BoolDefault(c.Installable(), true) &&
|
|
|
|
!c.PreventInstall() && c.OutputFile().Valid()
|
2020-01-07 08:59:44 +01:00
|
|
|
|
|
|
|
// The platform variant doesn't need further condition. Apex variants however might not
|
|
|
|
// be installable because it will likely to be included in the APEX and won't appear
|
|
|
|
// in the system partition.
|
2020-09-16 03:30:11 +02:00
|
|
|
if apexInfo.IsForPlatform() {
|
2020-01-07 08:59:44 +01:00
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special case for modules that are configured to be installed to /data, which includes
|
|
|
|
// test modules. For these modules, both APEX and non-APEX variants are considered as
|
|
|
|
// installable. This is because even the APEX variants won't be included in the APEX, but
|
|
|
|
// will anyway be installed to /data/*.
|
|
|
|
// See b/146995717
|
|
|
|
if c.InstallInData() {
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
2019-05-09 06:29:15 +02:00
|
|
|
}
|
|
|
|
|
2019-04-10 07:33:58 +02:00
|
|
|
func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-15 14:29:02 +01:00
|
|
|
var _ android.ApexModule = (*Module)(nil)
|
|
|
|
|
|
|
|
// Implements android.ApexModule
|
2019-10-15 08:20:07 +02:00
|
|
|
func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
2020-07-28 06:26:48 +02:00
|
|
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
|
|
|
libDepTag, isLibDepTag := depTag.(libraryDependencyTag)
|
|
|
|
|
|
|
|
if cc, ok := dep.(*Module); ok {
|
|
|
|
if cc.HasStubsVariants() {
|
|
|
|
if isLibDepTag && libDepTag.shared() {
|
|
|
|
// dynamic dep to a stubs lib crosses APEX boundary
|
|
|
|
return false
|
shared_lib dependency from a static lib crosses the APEX boundary
cc_library_static {
name: "libfoo",
shared_libs: ["libbar"],
}
cc_library {
name: "libbar",
}
If libfoo is part of an APEX, then libbar is no longer considered as a
member of the APEX, because it isn't actually linked to libfoo.
To distinguish such a shared lib dependency from a static library from a
shared lib dependency from a shared library, a new dep type
SharedFromStaticDepTag is introduced. It is treated exactly the same as
SharedDepTag, except when we determine whether a dependency is crossing
the APEX boundary or not.
This allows us to check the apex_available property more correctly.
Previously, modules were incorrectly considered as being used for an
APEX due to the shared lib dependency from a static lib.
As a good side effect, this also reduces the number of APEX variants.
Specifically, on aosp_arm64, the number of the generated modules were
reduced from 44745 to 44180.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: I899ccb9eae1574effef77ca1bc3a0df145983861
(cherry picked from commit 931b676a69c092451ed25a5dda67accf90ce6457)
Change-Id: I899ccb9eae1574effef77ca1bc3a0df145983861
2020-01-16 09:14:23 +01:00
|
|
|
}
|
2020-07-28 06:26:48 +02:00
|
|
|
if IsRuntimeDepTag(depTag) {
|
|
|
|
// runtime dep to a stubs lib also crosses APEX boundary
|
shared_lib dependency from a static lib crosses the APEX boundary
cc_library_static {
name: "libfoo",
shared_libs: ["libbar"],
}
cc_library {
name: "libbar",
}
If libfoo is part of an APEX, then libbar is no longer considered as a
member of the APEX, because it isn't actually linked to libfoo.
To distinguish such a shared lib dependency from a static library from a
shared lib dependency from a shared library, a new dep type
SharedFromStaticDepTag is introduced. It is treated exactly the same as
SharedDepTag, except when we determine whether a dependency is crossing
the APEX boundary or not.
This allows us to check the apex_available property more correctly.
Previously, modules were incorrectly considered as being used for an
APEX due to the shared lib dependency from a static lib.
As a good side effect, this also reduces the number of APEX variants.
Specifically, on aosp_arm64, the number of the generated modules were
reduced from 44745 to 44180.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: I899ccb9eae1574effef77ca1bc3a0df145983861
(cherry picked from commit 931b676a69c092451ed25a5dda67accf90ce6457)
Change-Id: I899ccb9eae1574effef77ca1bc3a0df145983861
2020-01-16 09:14:23 +01:00
|
|
|
return false
|
|
|
|
}
|
2019-10-15 08:20:07 +02:00
|
|
|
}
|
2021-04-24 19:47:08 +02:00
|
|
|
if cc.IsLlndk() {
|
|
|
|
return false
|
|
|
|
}
|
2020-07-29 21:51:56 +02:00
|
|
|
if isLibDepTag && c.static() && libDepTag.shared() {
|
2020-07-28 06:26:48 +02:00
|
|
|
// shared_lib dependency from a static lib is considered as crossing
|
|
|
|
// the APEX boundary because the dependency doesn't actually is
|
|
|
|
// linked; the dependency is used only during the compilation phase.
|
|
|
|
return false
|
|
|
|
}
|
2020-12-03 09:28:25 +01:00
|
|
|
|
|
|
|
if isLibDepTag && libDepTag.excludeInApex {
|
|
|
|
return false
|
|
|
|
}
|
2020-07-28 06:26:48 +02:00
|
|
|
}
|
2021-05-06 22:42:48 +02:00
|
|
|
if depTag == stubImplDepTag {
|
|
|
|
// We don't track from an implementation library to its stubs.
|
2020-05-10 08:16:24 +02:00
|
|
|
return false
|
2019-10-15 08:20:07 +02:00
|
|
|
}
|
2021-01-05 06:37:15 +01:00
|
|
|
if depTag == staticVariantTag {
|
|
|
|
// This dependency is for optimization (reuse *.o from the static lib). It doesn't
|
|
|
|
// actually mean that the static lib (and its dependencies) are copied into the
|
|
|
|
// APEX.
|
|
|
|
return false
|
|
|
|
}
|
2019-10-15 08:20:07 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-12-15 14:29:02 +01:00
|
|
|
// Implements android.ApexModule
|
2020-07-23 07:32:17 +02:00
|
|
|
func (c *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
|
|
|
sdkVersion android.ApiLevel) error {
|
2020-04-15 04:03:39 +02:00
|
|
|
// We ignore libclang_rt.* prebuilt libs since they declare sdk_version: 14(b/121358700)
|
|
|
|
if strings.HasPrefix(ctx.OtherModuleName(c), "libclang_rt") {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
// We don't check for prebuilt modules
|
|
|
|
if _, ok := c.linker.(prebuiltLinkerInterface); ok {
|
|
|
|
return nil
|
|
|
|
}
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
|
2020-04-15 04:03:39 +02:00
|
|
|
minSdkVersion := c.MinSdkVersion()
|
|
|
|
if minSdkVersion == "apex_inherit" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if minSdkVersion == "" {
|
|
|
|
// JNI libs within APK-in-APEX fall into here
|
|
|
|
// Those are okay to set sdk_version instead
|
|
|
|
// We don't have to check if this is a SDK variant because
|
|
|
|
// non-SDK variant resets sdk_version, which works too.
|
|
|
|
minSdkVersion = c.SdkVersion()
|
|
|
|
}
|
2020-07-23 07:32:17 +02:00
|
|
|
if minSdkVersion == "" {
|
|
|
|
return fmt.Errorf("neither min_sdk_version nor sdk_version specificed")
|
|
|
|
}
|
|
|
|
// Not using nativeApiLevelFromUser because the context here is not
|
|
|
|
// necessarily a native context.
|
|
|
|
ver, err := android.ApiLevelFromUser(ctx, minSdkVersion)
|
2020-04-15 04:03:39 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-07-23 07:32:17 +02:00
|
|
|
|
|
|
|
if ver.GreaterThan(sdkVersion) {
|
2020-04-15 04:03:39 +02:00
|
|
|
return fmt.Errorf("newer SDK(%v)", ver)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-05-12 17:16:51 +02:00
|
|
|
// Implements android.ApexModule
|
|
|
|
func (c *Module) AlwaysRequiresPlatformApexVariant() bool {
|
|
|
|
// stub libraries and native bridge libraries are always available to platform
|
|
|
|
return c.IsStubs() || c.Target().NativeBridge == android.NativeBridgeEnabled
|
|
|
|
}
|
|
|
|
|
2022-02-04 04:36:33 +01:00
|
|
|
// Overrides android.ApexModuleBase.UniqueApexVariations
|
|
|
|
func (c *Module) UniqueApexVariations() bool {
|
|
|
|
// When a vendor APEX needs a VNDK lib in it (use_vndk_as_stable: false), it should be a unique
|
|
|
|
// APEX variation. Otherwise, another vendor APEX with use_vndk_as_stable:true may use a wrong
|
|
|
|
// variation of the VNDK lib because APEX variations are merged/grouped.
|
|
|
|
return c.UseVndk() && c.IsVndk()
|
|
|
|
}
|
|
|
|
|
2021-08-10 22:42:03 +02:00
|
|
|
var _ snapshot.RelativeInstallPath = (*Module)(nil)
|
|
|
|
|
2021-12-22 21:31:40 +01:00
|
|
|
type moduleType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
unknownType moduleType = iota
|
|
|
|
binary
|
|
|
|
object
|
|
|
|
fullLibrary
|
|
|
|
staticLibrary
|
|
|
|
sharedLibrary
|
|
|
|
headerLibrary
|
2022-08-24 13:53:27 +02:00
|
|
|
testBin // testBinary already declared
|
2021-12-22 21:31:40 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (c *Module) typ() moduleType {
|
2022-08-24 13:53:27 +02:00
|
|
|
if c.testBinary() {
|
|
|
|
// testBinary is also a binary, so this comes before the c.Binary()
|
|
|
|
// conditional. A testBinary has additional implicit dependencies and
|
|
|
|
// other test-only semantics.
|
|
|
|
return testBin
|
|
|
|
} else if c.Binary() {
|
2021-12-22 21:31:40 +01:00
|
|
|
return binary
|
2021-11-01 20:32:43 +01:00
|
|
|
} else if c.Object() {
|
2021-12-22 21:31:40 +01:00
|
|
|
return object
|
2022-08-24 13:53:27 +02:00
|
|
|
} else if c.testLibrary() {
|
|
|
|
// TODO(b/244431896) properly convert cc_test_library to its own macro. This
|
|
|
|
// will let them add implicit compile deps on gtest, for example.
|
|
|
|
//
|
|
|
|
// For now, treat them as regular shared libraries.
|
|
|
|
return sharedLibrary
|
2021-11-01 20:32:43 +01:00
|
|
|
} else if c.CcLibrary() {
|
2021-12-10 00:10:18 +01:00
|
|
|
static := false
|
|
|
|
shared := false
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
static = library.MutatedProperties.BuildStatic
|
|
|
|
shared = library.MutatedProperties.BuildShared
|
|
|
|
} else if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
|
|
static = library.MutatedProperties.BuildStatic
|
|
|
|
shared = library.MutatedProperties.BuildShared
|
|
|
|
}
|
2021-11-01 20:32:43 +01:00
|
|
|
if static && shared {
|
2021-12-22 21:31:40 +01:00
|
|
|
return fullLibrary
|
2021-11-01 20:32:43 +01:00
|
|
|
} else if !static && !shared {
|
2021-12-22 21:31:40 +01:00
|
|
|
return headerLibrary
|
2021-11-01 20:32:43 +01:00
|
|
|
} else if static {
|
2021-12-22 21:31:40 +01:00
|
|
|
return staticLibrary
|
|
|
|
}
|
|
|
|
return sharedLibrary
|
|
|
|
}
|
|
|
|
return unknownType
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConvertWithBp2build converts Module to Bazel for bp2build.
|
|
|
|
func (c *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|
|
|
prebuilt := c.IsPrebuilt()
|
|
|
|
switch c.typ() {
|
|
|
|
case binary:
|
|
|
|
if !prebuilt {
|
2022-08-24 13:53:27 +02:00
|
|
|
binaryBp2build(ctx, c)
|
|
|
|
}
|
|
|
|
case testBin:
|
|
|
|
if !prebuilt {
|
|
|
|
testBinaryBp2build(ctx, c)
|
2021-12-22 21:31:40 +01:00
|
|
|
}
|
|
|
|
case object:
|
|
|
|
if !prebuilt {
|
|
|
|
objectBp2Build(ctx, c)
|
|
|
|
}
|
|
|
|
case fullLibrary:
|
|
|
|
if !prebuilt {
|
|
|
|
libraryBp2Build(ctx, c)
|
2022-04-07 22:36:39 +02:00
|
|
|
} else {
|
|
|
|
prebuiltLibraryBp2Build(ctx, c)
|
2021-12-22 21:31:40 +01:00
|
|
|
}
|
|
|
|
case headerLibrary:
|
|
|
|
libraryHeadersBp2Build(ctx, c)
|
|
|
|
case staticLibrary:
|
|
|
|
if prebuilt {
|
2022-04-07 22:36:39 +02:00
|
|
|
prebuiltLibraryStaticBp2Build(ctx, c, false)
|
2021-12-22 21:31:40 +01:00
|
|
|
} else {
|
|
|
|
sharedOrStaticLibraryBp2Build(ctx, c, true)
|
|
|
|
}
|
|
|
|
case sharedLibrary:
|
|
|
|
if prebuilt {
|
|
|
|
prebuiltLibrarySharedBp2Build(ctx, c)
|
|
|
|
} else {
|
|
|
|
sharedOrStaticLibraryBp2Build(ctx, c, false)
|
2021-11-01 20:32:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
// Defaults
|
|
|
|
type Defaults struct {
|
|
|
|
android.ModuleBase
|
2017-07-07 23:33:33 +02:00
|
|
|
android.DefaultsModuleBase
|
2018-10-02 17:38:19 +02:00
|
|
|
android.ApexModuleBase
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2019-03-20 01:00:29 +01:00
|
|
|
// cc_defaults provides a set of properties that can be inherited by other cc
|
|
|
|
// modules. A module can use the properties from a cc_defaults using
|
|
|
|
// `defaults: ["<:default_module_name>"]`. Properties of both modules are
|
|
|
|
// merged (when possible) by prepending the default module's values to the
|
|
|
|
// depending module's values.
|
2017-06-24 00:06:31 +02:00
|
|
|
func defaultsFactory() android.Module {
|
2016-08-18 23:18:32 +02:00
|
|
|
return DefaultsFactory()
|
|
|
|
}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
func DefaultsFactory(props ...interface{}) android.Module {
|
2016-07-29 21:48:20 +02:00
|
|
|
module := &Defaults{}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
module.AddProperties(props...)
|
|
|
|
module.AddProperties(
|
2016-07-29 21:48:20 +02:00
|
|
|
&BaseProperties{},
|
2017-09-14 03:37:08 +02:00
|
|
|
&VendorProperties{},
|
2016-07-29 21:48:20 +02:00
|
|
|
&BaseCompilerProperties{},
|
|
|
|
&BaseLinkerProperties{},
|
2019-07-18 13:31:26 +02:00
|
|
|
&ObjectLinkerProperties{},
|
2016-07-30 02:28:03 +02:00
|
|
|
&LibraryProperties{},
|
2019-09-24 23:55:04 +02:00
|
|
|
&StaticProperties{},
|
|
|
|
&SharedProperties{},
|
2016-07-29 21:48:20 +02:00
|
|
|
&FlagExporterProperties{},
|
|
|
|
&BinaryLinkerProperties{},
|
2022-03-24 22:06:14 +01:00
|
|
|
&TestLinkerProperties{},
|
|
|
|
&TestInstallerProperties{},
|
2016-07-30 02:28:03 +02:00
|
|
|
&TestBinaryProperties{},
|
2020-06-30 19:15:07 +02:00
|
|
|
&BenchmarkProperties{},
|
2021-07-22 21:05:08 +02:00
|
|
|
&fuzz.FuzzProperties{},
|
2016-07-29 21:48:20 +02:00
|
|
|
&StlProperties{},
|
|
|
|
&SanitizeProperties{},
|
|
|
|
&StripProperties{},
|
2016-09-01 22:45:39 +02:00
|
|
|
&InstallerProperties{},
|
2016-09-27 00:45:04 +02:00
|
|
|
&TidyProperties{},
|
2017-02-10 01:16:31 +01:00
|
|
|
&CoverageProperties{},
|
2017-02-08 22:45:53 +01:00
|
|
|
&SAbiProperties{},
|
2017-07-26 07:22:10 +02:00
|
|
|
&VndkProperties{},
|
2017-05-10 00:44:35 +02:00
|
|
|
<OProperties{},
|
2021-12-09 11:06:29 +01:00
|
|
|
&AfdoProperties{},
|
2017-09-01 08:38:27 +02:00
|
|
|
&PgoProperties{},
|
2018-03-08 22:27:59 +01:00
|
|
|
&android.ProtoProperties{},
|
2020-09-25 22:08:34 +02:00
|
|
|
// RustBindgenProperties is included here so that cc_defaults can be used for rust_bindgen modules.
|
|
|
|
&RustBindgenClangProperties{},
|
2021-06-24 00:56:39 +02:00
|
|
|
&prebuiltLinkerProperties{},
|
2016-08-18 23:18:32 +02:00
|
|
|
)
|
2016-04-20 23:21:14 +02:00
|
|
|
|
2019-09-25 08:18:44 +02:00
|
|
|
android.InitDefaultsModule(module)
|
2017-06-24 00:06:31 +02:00
|
|
|
|
|
|
|
return module
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
Don't create version variants for SDK variants
When a lib has sdk_version set, an SDK variant and a platform variant
are created by the sdkMutator. Then by the versionMutator, if the
library had 'stubs.versions' property, one or more versioned variants
and one impl variant are created for each of the two (SDK and platform)
variants. As a concrete example,
cc_library {
name: "foo",
sdk_version: "current",
stubs: { versions: ["1", "2"], },
}
would create 6 variants:
1) (sdk: "", version: "")
2) (sdk: "", version: "1")
3) (sdk: "", version: "2")
4) (sdk: "sdk", version: "")
5) (sdk: "sdk", version: "1")
6) (sdk: "sdk", version: "2")
This is somewhat uncessary because the need for the SDK mutator is to
have the platform variant (sdk:"") of a lib where sdk_version is unset,
which actually makes sens for the impl variant (version:""), but not
the versioned variants (version:"1" or version:"2").
This is not only unncessary, but also causes duplicate module
definitions in the Make side when doing an unbundled build. Specifically,
The #1 and #4 above both are emitted to Make and get the same name
"foo".
To fix the problem and not to create unnecessary variants, the versioned
variants are no longer created for the sdk variant. So, foo now has
the following variants only.
1) (sdk: "", version: "") // not emitted to Make (by versionMutator)
2) (sdk: "", version: "1") // not emitted to Make (by versionMutator)
3) (sdk: "", version: "2") // emitted to Make (by versionMutator)
4) (sdk: "sdk", version: "") // not emitted to Make (by versionMutator)
Bug: 159106705
Test: Add sdk_version:"minimum" to libnativehelper in libnativehelper/Android.bp.
m SOONG_ALLOW_MISSING_DEPENDENCIES=true TARGET_BUILD_UNBUNDLED=true libnativehelper
Change-Id: I6f02f4189e5504286174ccff1642166da82d00c9
2020-06-16 14:58:53 +02:00
|
|
|
func (c *Module) IsSdkVariant() bool {
|
2021-06-17 09:32:36 +02:00
|
|
|
return c.Properties.IsSdkVariant
|
Don't create version variants for SDK variants
When a lib has sdk_version set, an SDK variant and a platform variant
are created by the sdkMutator. Then by the versionMutator, if the
library had 'stubs.versions' property, one or more versioned variants
and one impl variant are created for each of the two (SDK and platform)
variants. As a concrete example,
cc_library {
name: "foo",
sdk_version: "current",
stubs: { versions: ["1", "2"], },
}
would create 6 variants:
1) (sdk: "", version: "")
2) (sdk: "", version: "1")
3) (sdk: "", version: "2")
4) (sdk: "sdk", version: "")
5) (sdk: "sdk", version: "1")
6) (sdk: "sdk", version: "2")
This is somewhat uncessary because the need for the SDK mutator is to
have the platform variant (sdk:"") of a lib where sdk_version is unset,
which actually makes sens for the impl variant (version:""), but not
the versioned variants (version:"1" or version:"2").
This is not only unncessary, but also causes duplicate module
definitions in the Make side when doing an unbundled build. Specifically,
The #1 and #4 above both are emitted to Make and get the same name
"foo".
To fix the problem and not to create unnecessary variants, the versioned
variants are no longer created for the sdk variant. So, foo now has
the following variants only.
1) (sdk: "", version: "") // not emitted to Make (by versionMutator)
2) (sdk: "", version: "1") // not emitted to Make (by versionMutator)
3) (sdk: "", version: "2") // emitted to Make (by versionMutator)
4) (sdk: "sdk", version: "") // not emitted to Make (by versionMutator)
Bug: 159106705
Test: Add sdk_version:"minimum" to libnativehelper in libnativehelper/Android.bp.
m SOONG_ALLOW_MISSING_DEPENDENCIES=true TARGET_BUILD_UNBUNDLED=true libnativehelper
Change-Id: I6f02f4189e5504286174ccff1642166da82d00c9
2020-06-16 14:58:53 +02:00
|
|
|
}
|
|
|
|
|
2022-08-24 07:10:46 +02:00
|
|
|
func (c *Module) isImportedApiLibrary() bool {
|
|
|
|
_, ok := c.linker.(*apiLibraryDecorator)
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2018-11-06 01:49:08 +01:00
|
|
|
func kytheExtractAllFactory() android.Singleton {
|
|
|
|
return &kytheExtractAllSingleton{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type kytheExtractAllSingleton struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ks *kytheExtractAllSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|
|
|
var xrefTargets android.Paths
|
|
|
|
ctx.VisitAllModules(func(module android.Module) {
|
|
|
|
if ccModule, ok := module.(xref); ok {
|
|
|
|
xrefTargets = append(xrefTargets, ccModule.XrefCcFiles()...)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
// TODO(asmundak): Perhaps emit a rule to output a warning if there were no xrefTargets
|
|
|
|
if len(xrefTargets) > 0 {
|
2020-06-04 22:25:17 +02:00
|
|
|
ctx.Phony("xref_cxx", xrefTargets...)
|
2018-11-06 01:49:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 01:23:31 +01:00
|
|
|
var Bool = proptools.Bool
|
2018-04-11 01:14:46 +02:00
|
|
|
var BoolDefault = proptools.BoolDefault
|
2017-11-07 19:57:05 +01:00
|
|
|
var BoolPtr = proptools.BoolPtr
|
|
|
|
var String = proptools.String
|
|
|
|
var StringPtr = proptools.StringPtr
|