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"
|
2015-03-18 21:28:46 +01:00
|
|
|
"android/soong/genrule"
|
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) {
|
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-12-09 10:21:48 +01:00
|
|
|
ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
|
2019-06-28 16:41:19 +02:00
|
|
|
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
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
|
|
|
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) {
|
2016-10-12 23:38:15 +02:00
|
|
|
ctx.TopDown("asan_deps", sanitizerDepsMutator(asan))
|
|
|
|
ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel()
|
2016-01-06 23:41:07 +01:00
|
|
|
|
2018-08-03 01:19:13 +02:00
|
|
|
ctx.TopDown("hwasan_deps", sanitizerDepsMutator(hwasan))
|
|
|
|
ctx.BottomUp("hwasan", sanitizerMutator(hwasan)).Parallel()
|
|
|
|
|
2019-05-01 23:42:05 +02:00
|
|
|
ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(fuzzer))
|
|
|
|
ctx.BottomUp("fuzzer", sanitizerMutator(fuzzer)).Parallel()
|
|
|
|
|
2019-07-29 14:27:18 +02:00
|
|
|
// cfi mutator shouldn't run before sanitizers that return true for
|
|
|
|
// incompatibleWithCfi()
|
2017-11-01 10:20:21 +01:00
|
|
|
ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi))
|
|
|
|
ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel()
|
|
|
|
|
2018-11-20 01:03:58 +01:00
|
|
|
ctx.TopDown("scs_deps", sanitizerDepsMutator(scs))
|
|
|
|
ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel()
|
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
|
|
|
|
ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()
|
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
|
|
|
|
2018-12-11 00:12:40 +01:00
|
|
|
ctx.BottomUp("coverage", coverageMutator).Parallel()
|
2017-02-08 22:45:53 +01:00
|
|
|
ctx.TopDown("vndk_deps", sabiDepsMutator)
|
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
|
|
|
|
|
|
|
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
|
2016-10-12 23:38:15 +02:00
|
|
|
})
|
2016-07-29 22:44:28 +02:00
|
|
|
|
2018-11-06 01:49:08 +01:00
|
|
|
android.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
|
2015-06-17 23:20:06 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2015-03-24 01:50:24 +01:00
|
|
|
CrtBegin, CrtEnd string
|
2018-10-12 09:24:23 +02:00
|
|
|
|
|
|
|
// Used for host bionic
|
|
|
|
LinkerFlagsFile string
|
|
|
|
DynamicLinker string
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to .o files
|
2016-09-27 02:33:01 +02:00
|
|
|
Objs Objects
|
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
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
// Paths to generated source files
|
2016-05-19 00:37:25 +02:00
|
|
|
GeneratedSources android.Paths
|
|
|
|
GeneratedHeaders 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
|
|
|
|
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
|
2016-05-19 00:37:25 +02:00
|
|
|
CrtBegin, CrtEnd android.OptionalPath
|
2018-10-12 09:24:23 +02:00
|
|
|
|
|
|
|
// Path to the file container flags to use with the linker
|
|
|
|
LinkerFlagsFile android.OptionalPath
|
|
|
|
|
|
|
|
// Path to the dynamic linker binary
|
|
|
|
DynamicLinker 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
|
|
|
}
|
|
|
|
|
|
|
|
type Flags struct {
|
|
|
|
Local LocalOrGlobalFlags
|
|
|
|
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
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
Toolchain config.Toolchain
|
2016-09-27 00:45:04 +02:00
|
|
|
Tidy bool
|
2017-02-10 01:16:31 +01:00
|
|
|
Coverage bool
|
2017-02-08 22:45:53 +01:00
|
|
|
SAbiDump bool
|
2018-11-06 01:49:08 +01:00
|
|
|
EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
|
2016-01-04 23:34:37 +01:00
|
|
|
|
|
|
|
RequiredInstructionSet string
|
2016-01-06 23:41:07 +01:00
|
|
|
DynamicLinker string
|
|
|
|
|
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
|
|
|
|
2019-08-28 06:20:40 +02:00
|
|
|
AssemblerWithCpp bool
|
|
|
|
GroupStaticLibs 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
|
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
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// Minimum sdk version supported when compiling against the ndk
|
2017-11-07 19:57:05 +01:00
|
|
|
Sdk_version *string
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2018-12-07 15:08:36 +01:00
|
|
|
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
|
|
|
AndroidMkStaticLibs []string `blueprint:"mutated"`
|
|
|
|
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
|
|
|
|
AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
|
|
|
|
HideFromMake bool `blueprint:"mutated"`
|
|
|
|
PreventInstall bool `blueprint:"mutated"`
|
|
|
|
ApexesProvidingSharedLibs []string `blueprint:"mutated"`
|
2017-09-14 03:37:08 +02:00
|
|
|
|
2019-08-26 09:52:35 +02:00
|
|
|
VndkVersion string `blueprint:"mutated"`
|
|
|
|
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
|
|
|
|
|
|
|
// Make this module available when building for recovery
|
|
|
|
Recovery_available *bool
|
|
|
|
|
2019-11-20 22:35:50 +01:00
|
|
|
// Set by imageMutator
|
2019-11-19 01:00:16 +01:00
|
|
|
CoreVariantNeeded bool `blueprint:"mutated"`
|
|
|
|
RecoveryVariantNeeded bool `blueprint:"mutated"`
|
|
|
|
VendorVariants []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"`
|
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`.
|
|
|
|
// 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
|
|
|
//
|
|
|
|
// The vendor 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.
|
|
|
|
//
|
2017-08-16 07:05:54 +02:00
|
|
|
// If set to false, this module becomes inaccessible from /vendor modules.
|
|
|
|
//
|
|
|
|
// Default value is true when vndk: {enabled: true} or vendor: true.
|
|
|
|
//
|
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
|
|
|
|
|
|
|
// 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
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleContextIntf interface {
|
|
|
|
static() bool
|
|
|
|
staticBinary() bool
|
2019-07-29 14:27:18 +02:00
|
|
|
header() bool
|
2016-07-29 22:44:28 +02:00
|
|
|
toolchain() config.Toolchain
|
2017-09-28 02:01:44 +02:00
|
|
|
useSdk() bool
|
2016-01-04 23:34:37 +01:00
|
|
|
sdkVersion() string
|
2017-09-28 02:01:44 +02:00
|
|
|
useVndk() bool
|
2019-01-16 13:19:51 +01:00
|
|
|
isNdk() bool
|
2019-05-09 03:56:13 +02:00
|
|
|
isLlndk(config android.Config) bool
|
|
|
|
isLlndkPublic(config android.Config) bool
|
|
|
|
isVndkPrivate(config android.Config) bool
|
2017-06-23 12:24:43 +02:00
|
|
|
isVndk() bool
|
|
|
|
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
|
|
|
isVndkExt() bool
|
2018-01-31 16:54:12 +01:00
|
|
|
inRecovery() bool
|
2019-07-29 11:46:59 +02:00
|
|
|
shouldCreateSourceAbiDump() 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
|
2018-02-14 11:16:12 +01:00
|
|
|
isPgoCompile() 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
|
2019-01-19 11:24:06 +01:00
|
|
|
apexName() string
|
2018-12-20 14:10:17 +01:00
|
|
|
hasStubsVariants() bool
|
|
|
|
isStubs() bool
|
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
|
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
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
type feature interface {
|
|
|
|
begin(ctx BaseModuleContext)
|
2016-12-14 02:06:13 +01:00
|
|
|
deps(ctx DepsContext, deps Deps) Deps
|
2016-01-04 23:34:37 +01:00
|
|
|
flags(ctx ModuleContext, flags Flags) Flags
|
|
|
|
props() []interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
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)
|
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
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2018-11-06 01:49:08 +01:00
|
|
|
type xref interface {
|
|
|
|
XrefCcFiles() android.Paths
|
|
|
|
}
|
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
var (
|
2019-10-18 23:18:45 +02:00
|
|
|
sharedExportDepTag = DependencyTag{Name: "shared", Library: true, Shared: true, ReexportFlags: true}
|
|
|
|
earlySharedDepTag = DependencyTag{Name: "early_shared", Library: true, Shared: true}
|
|
|
|
lateSharedDepTag = DependencyTag{Name: "late shared", Library: true, Shared: true}
|
|
|
|
staticExportDepTag = DependencyTag{Name: "static", Library: true, ReexportFlags: true}
|
|
|
|
lateStaticDepTag = DependencyTag{Name: "late static", Library: true}
|
|
|
|
wholeStaticDepTag = DependencyTag{Name: "whole static", Library: true, ReexportFlags: true}
|
|
|
|
headerDepTag = DependencyTag{Name: "header", Library: true}
|
|
|
|
headerExportDepTag = DependencyTag{Name: "header", Library: true, ReexportFlags: true}
|
|
|
|
genSourceDepTag = DependencyTag{Name: "gen source"}
|
|
|
|
genHeaderDepTag = DependencyTag{Name: "gen header"}
|
|
|
|
genHeaderExportDepTag = DependencyTag{Name: "gen header", ReexportFlags: true}
|
|
|
|
objDepTag = DependencyTag{Name: "obj"}
|
|
|
|
linkerFlagsDepTag = DependencyTag{Name: "linker flags file"}
|
|
|
|
dynamicLinkerDepTag = DependencyTag{Name: "dynamic linker"}
|
|
|
|
reuseObjTag = DependencyTag{Name: "reuse objects"}
|
|
|
|
staticVariantTag = DependencyTag{Name: "static variant"}
|
|
|
|
ndkStubDepTag = DependencyTag{Name: "ndk stub", Library: true}
|
|
|
|
ndkLateStubDepTag = DependencyTag{Name: "ndk late stub", Library: true}
|
|
|
|
vndkExtDepTag = DependencyTag{Name: "vndk extends", Library: true}
|
|
|
|
runtimeDepTag = DependencyTag{Name: "runtime lib"}
|
|
|
|
coverageDepTag = DependencyTag{Name: "coverage"}
|
|
|
|
testPerSrcDepTag = DependencyTag{Name: "test_per_src"}
|
2016-04-12 00:06:20 +02:00
|
|
|
)
|
|
|
|
|
2019-07-29 17:22:59 +02:00
|
|
|
func IsSharedDepTag(depTag blueprint.DependencyTag) bool {
|
2019-10-18 23:18:45 +02:00
|
|
|
ccDepTag, ok := depTag.(DependencyTag)
|
|
|
|
return ok && ccDepTag.Shared
|
2019-07-29 17:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool {
|
2019-10-18 23:18:45 +02:00
|
|
|
ccDepTag, ok := depTag.(DependencyTag)
|
2019-07-29 17:22:59 +02:00
|
|
|
return ok && ccDepTag == runtimeDepTag
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool {
|
2019-10-18 23:18:45 +02:00
|
|
|
ccDepTag, ok := depTag.(DependencyTag)
|
2019-07-29 17:22:59 +02:00
|
|
|
return ok && ccDepTag == testPerSrcDepTag
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
// to construct the output file. Behavior can be customized with a Customizer interface
|
|
|
|
type Module struct {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.ModuleBase
|
2017-07-07 23:33:33 +02:00
|
|
|
android.DefaultableModuleBase
|
2018-10-02 17:38:19 +02:00
|
|
|
android.ApexModuleBase
|
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
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
Properties BaseProperties
|
|
|
|
VendorProperties VendorProperties
|
2016-01-04 23:34:37 +01:00
|
|
|
|
|
|
|
// initialize before calling Init
|
2016-05-19 00:37:25 +02:00
|
|
|
hod android.HostOrDeviceSupported
|
|
|
|
multilib android.Multilib
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
// delegates, initialize before calling Init
|
2016-09-13 22:41:39 +02:00
|
|
|
features []feature
|
|
|
|
compiler compiler
|
|
|
|
linker linker
|
|
|
|
installer installer
|
|
|
|
stl *stl
|
|
|
|
sanitize *sanitize
|
2017-02-10 01:16:31 +01:00
|
|
|
coverage *coverage
|
2017-02-08 22:45:53 +01:00
|
|
|
sabi *sabi
|
2017-06-23 12:24:43 +02:00
|
|
|
vndkdep *vndkdep
|
2017-05-10 00:44:35 +02:00
|
|
|
lto *lto
|
2017-09-01 08:38:27 +02:00
|
|
|
pgo *pgo
|
2018-11-21 17:59:37 +01:00
|
|
|
xom *xom
|
2016-01-06 23:41:07 +01:00
|
|
|
|
|
|
|
androidMkSharedLibDeps []string
|
2015-03-17 23:06:21 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
// When calling a linker, if module A depends on module B, then A must precede B in its command
|
2017-11-28 00:48:57 +01:00
|
|
|
// line invocation. depsInLinkOrder stores the proper ordering of all of the transitive
|
2017-09-28 02:05:30 +02:00
|
|
|
// deps of this module
|
2017-11-28 00:48:57 +01:00
|
|
|
depsInLinkOrder android.Paths
|
|
|
|
|
|
|
|
// only non-nil when this is a shared library that reuses the objects of a static library
|
2019-10-18 23:49:46 +02:00
|
|
|
staticVariant LinkableInterface
|
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
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
return stub.properties.ApiLevel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("Shared() called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SelectedStl() string {
|
|
|
|
return c.stl.Properties.SelectedStl
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) ToolchainLibrary() bool {
|
|
|
|
if _, ok := c.linker.(*toolchainLibraryDecorator); ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2019-11-07 04:15:49 +01:00
|
|
|
func (c *Module) IncludeDirs() android.Paths {
|
2019-10-18 23:18:45 +02:00
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(exportedFlagsProducer); ok {
|
|
|
|
return library.exportedDirs()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("IncludeDirs called on non-exportedFlagsProducer module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) HasStaticVariant() bool {
|
|
|
|
if c.staticVariant != nil {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) GetStaticVariant() LinkableInterface {
|
|
|
|
return c.staticVariant
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SetDepsInLinkOrder(depsInLinkOrder []android.Path) {
|
|
|
|
c.depsInLinkOrder = depsInLinkOrder
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) GetDepsInLinkOrder() []android.Path {
|
|
|
|
return c.depsInLinkOrder
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) StubsVersions() []string {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
return library.Properties.Stubs.Versions
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) CcLibrary() bool {
|
|
|
|
if c.linker != nil {
|
|
|
|
if _, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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) SetBuildStubs() {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
library.MutatedProperties.BuildStubs = true
|
2019-10-18 23:49:46 +02:00
|
|
|
c.Properties.HideFromMake = true
|
|
|
|
c.sanitize = nil
|
|
|
|
c.stl = nil
|
|
|
|
c.Properties.PreventInstall = true
|
2019-10-18 23:18:45 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("SetBuildStubs called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) BuildStubs() bool {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
return library.buildStubs()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
func (c *Module) SetStubsVersions(version string) {
|
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
library.MutatedProperties.StubsVersion = version
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic(fmt.Errorf("SetStubsVersions called on non-library module: %q", c.BaseModuleName()))
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
return c.vndkVersion()
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
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()...)
|
|
|
|
}
|
2017-09-01 08:38:27 +02:00
|
|
|
if c.pgo != nil {
|
|
|
|
c.AddProperties(c.pgo.props()...)
|
|
|
|
}
|
2018-11-21 17:59:37 +01:00
|
|
|
if c.xom != nil {
|
|
|
|
c.AddProperties(c.xom.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
|
|
|
|
2018-10-02 22:59:46 +02:00
|
|
|
c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
|
|
|
|
switch class {
|
|
|
|
case android.Device:
|
|
|
|
return ctx.Config().DevicePrefer32BitExecutables()
|
|
|
|
case android.HostCross:
|
|
|
|
// Windows builds always prefer 32-bit
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
2017-06-24 00:06:31 +02:00
|
|
|
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
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
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
// Returns true for dependency roots (binaries)
|
|
|
|
// TODO(ccross): also handle dlopenable libraries
|
|
|
|
func (c *Module) isDependencyRoot() bool {
|
|
|
|
if root, ok := c.linker.(interface {
|
|
|
|
isDependencyRoot() bool
|
|
|
|
}); ok {
|
|
|
|
return root.isDependencyRoot()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-12-11 00:12:40 +01:00
|
|
|
func (c *Module) isCoverageVariant() bool {
|
|
|
|
return c.coverage.Properties.IsCoverageVariant
|
|
|
|
}
|
|
|
|
|
2019-12-18 01:46:18 +01:00
|
|
|
func (c *Module) IsNdk() bool {
|
2019-01-16 13:19:51 +01:00
|
|
|
return inList(c.Name(), ndkMigratedLibs)
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:56:13 +02:00
|
|
|
func (c *Module) isLlndk(config android.Config) bool {
|
2019-01-16 13:19:51 +01:00
|
|
|
// Returns true for both LLNDK (public) and LLNDK-private libs.
|
2019-10-30 10:43:49 +01:00
|
|
|
return isLlndkLibrary(c.BaseModuleName(), config)
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2019-05-09 03:56:13 +02:00
|
|
|
func (c *Module) isLlndkPublic(config android.Config) bool {
|
2019-01-16 13:19:51 +01:00
|
|
|
// Returns true only for LLNDK (public) libs.
|
2019-10-30 10:43:49 +01:00
|
|
|
name := c.BaseModuleName()
|
|
|
|
return isLlndkLibrary(name, config) && !isVndkPrivateLibrary(name, config)
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2019-05-09 03:56:13 +02:00
|
|
|
func (c *Module) isVndkPrivate(config android.Config) bool {
|
2019-01-16 13:19:51 +01:00
|
|
|
// Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
|
2019-10-30 10:43:49 +01:00
|
|
|
return isVndkPrivateLibrary(c.BaseModuleName(), config)
|
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
|
|
|
|
}
|
|
|
|
|
2019-05-20 11:49:10 +02:00
|
|
|
func (c *Module) vndkVersion() string {
|
2019-08-26 09:52:35 +02:00
|
|
|
return c.Properties.VndkVersion
|
2019-05-20 11:49:10 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-12-11 00:12:40 +01:00
|
|
|
func (c *Module) isNDKStubLibrary() bool {
|
|
|
|
if _, ok := c.compiler.(*stubDecorator); ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
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) isVndkSp() bool {
|
|
|
|
if vndkdep := c.vndkdep; vndkdep != nil {
|
|
|
|
return vndkdep.isVndkSp()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) isVndkExt() bool {
|
|
|
|
if vndkdep := c.vndkdep; vndkdep != nil {
|
|
|
|
return vndkdep.isVndkExt()
|
2017-06-23 12:24:43 +02:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) MustUseVendorVariant() bool {
|
2019-10-22 12:32:18 +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 ""
|
|
|
|
}
|
|
|
|
|
2017-08-16 07:05:54 +02:00
|
|
|
// Returns true only when this module is configured to have core and vendor
|
|
|
|
// variants.
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) HasVendorVariant() bool {
|
|
|
|
return c.IsVndk() || Bool(c.VendorProperties.Vendor_available)
|
2017-08-16 07:05:54 +02:00
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) InRecovery() bool {
|
2019-11-19 01:00:16 +01:00
|
|
|
return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
|
2018-01-31 16:54:12 +01:00
|
|
|
}
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
func (c *Module) OnlyInRecovery() bool {
|
2018-01-31 16:54:12 +01:00
|
|
|
return c.ModuleBase.InstallInRecovery()
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
return library.buildStubs()
|
2018-12-18 18:47:14 +01:00
|
|
|
} else if _, ok := c.linker.(*llndkStubDecorator); ok {
|
|
|
|
return true
|
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 {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
return len(library.Properties.Stubs.Versions) > 0
|
|
|
|
}
|
2019-04-24 23:41:12 +02:00
|
|
|
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
|
|
return len(library.Properties.Stubs.Versions) > 0
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
2019-01-16 14:53:13 +01:00
|
|
|
func (c *Module) bootstrap() bool {
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2019-10-22 13:31:18 +02:00
|
|
|
func (c *Module) ExportedIncludeDirs() android.Paths {
|
|
|
|
if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
|
|
|
|
return flagsProducer.exportedDirs()
|
|
|
|
}
|
2019-11-04 04:23:40 +01:00
|
|
|
return nil
|
2019-10-22 13:31:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) ExportedSystemIncludeDirs() android.Paths {
|
|
|
|
if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
|
|
|
|
return flagsProducer.exportedSystemDirs()
|
|
|
|
}
|
2019-11-04 04:23:40 +01:00
|
|
|
return nil
|
2019-10-22 13:31:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) ExportedFlags() []string {
|
|
|
|
if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
|
|
|
|
return flagsProducer.exportedFlags()
|
|
|
|
}
|
2019-11-04 04:23:40 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) ExportedDeps() android.Paths {
|
|
|
|
if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
|
|
|
|
return flagsProducer.exportedDeps()
|
|
|
|
}
|
|
|
|
return nil
|
2019-10-22 13:31:18 +02:00
|
|
|
}
|
|
|
|
|
2019-12-06 05:15:38 +01:00
|
|
|
func (c *Module) ExportedGeneratedHeaders() android.Paths {
|
|
|
|
if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
|
|
|
|
return flagsProducer.exportedGeneratedHeaders()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-02-25 03:05:47 +01:00
|
|
|
func isBionic(name string) bool {
|
|
|
|
switch name {
|
2019-11-11 16:33:27 +01:00
|
|
|
case "libc", "libm", "libdl", "libdl_android", "linker":
|
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 {
|
2019-04-24 23:41:12 +02:00
|
|
|
if name == "libclang_rt.hwasan-aarch64-android" {
|
|
|
|
return inList("hwaddress", config.SanitizeDevice())
|
|
|
|
}
|
|
|
|
return isBionic(name)
|
|
|
|
}
|
|
|
|
|
2018-11-06 01:49:08 +01:00
|
|
|
func (c *Module) XrefCcFiles() android.Paths {
|
|
|
|
return c.kytheFiles
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
func (ctx *moduleContext) SocSpecific() bool {
|
|
|
|
return ctx.ModuleContext.SocSpecific() ||
|
2019-10-18 23:49:46 +02:00
|
|
|
(ctx.mod.HasVendorVariant() && ctx.mod.UseVndk() && !ctx.mod.IsVndk())
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-07-29 14:27:18 +02:00
|
|
|
func (ctx *moduleContextImpl) header() bool {
|
|
|
|
return ctx.mod.header()
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
func (ctx *moduleContextImpl) useSdk() bool {
|
2019-01-17 23:44:05 +01:00
|
|
|
if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRecovery() && !ctx.ctx.Fuchsia() {
|
2017-11-07 19:57:05 +01:00
|
|
|
return String(ctx.mod.Properties.Sdk_version) != ""
|
2016-06-07 21:34:45 +02:00
|
|
|
}
|
|
|
|
return false
|
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() {
|
2018-03-23 09:43:47 +01:00
|
|
|
vndk_ver := ctx.ctx.DeviceConfig().VndkVersion()
|
2018-03-27 06:25:27 +02:00
|
|
|
if vndk_ver == "current" {
|
2018-03-23 09:43:47 +01:00
|
|
|
platform_vndk_ver := ctx.ctx.DeviceConfig().PlatformVndkVersion()
|
|
|
|
if inList(platform_vndk_ver, ctx.ctx.Config().PlatformVersionCombinedCodenames()) {
|
|
|
|
return "current"
|
|
|
|
}
|
|
|
|
return platform_vndk_ver
|
|
|
|
}
|
|
|
|
return vndk_ver
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-01-16 13:19:51 +01:00
|
|
|
func (ctx *moduleContextImpl) isNdk() bool {
|
2019-12-18 01:46:18 +01:00
|
|
|
return ctx.mod.IsNdk()
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2019-05-09 03:56:13 +02:00
|
|
|
func (ctx *moduleContextImpl) isLlndk(config android.Config) bool {
|
|
|
|
return ctx.mod.isLlndk(config)
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2019-05-09 03:56:13 +02:00
|
|
|
func (ctx *moduleContextImpl) isLlndkPublic(config android.Config) bool {
|
|
|
|
return ctx.mod.isLlndkPublic(config)
|
2019-01-16 13:19:51 +01:00
|
|
|
}
|
|
|
|
|
2019-05-09 03:56:13 +02:00
|
|
|
func (ctx *moduleContextImpl) isVndkPrivate(config android.Config) bool {
|
|
|
|
return ctx.mod.isVndkPrivate(config)
|
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
|
|
|
}
|
|
|
|
|
2018-02-14 11:16:12 +01:00
|
|
|
func (ctx *moduleContextImpl) isPgoCompile() bool {
|
|
|
|
return ctx.mod.isPgoCompile()
|
|
|
|
}
|
|
|
|
|
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 {
|
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
|
|
|
return ctx.mod.isVndkSp()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) isVndkExt() bool {
|
|
|
|
return ctx.mod.isVndkExt()
|
2017-06-23 12:24:43 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
func (ctx *moduleContextImpl) inRecovery() bool {
|
2019-10-18 23:49:46 +02:00
|
|
|
return ctx.mod.InRecovery()
|
2018-01-31 16:54:12 +01:00
|
|
|
}
|
|
|
|
|
2018-07-10 09:01:19 +02:00
|
|
|
// Check whether ABI dumps should be created for this module.
|
2019-07-29 11:46:59 +02:00
|
|
|
func (ctx *moduleContextImpl) shouldCreateSourceAbiDump() bool {
|
2018-07-10 09:01:19 +02:00
|
|
|
if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") {
|
|
|
|
return false
|
2018-03-02 04:12:16 +01:00
|
|
|
}
|
2019-01-17 23:44:05 +01:00
|
|
|
|
|
|
|
if ctx.ctx.Fuchsia() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-07-10 09:01:19 +02:00
|
|
|
if sanitize := ctx.mod.sanitize; sanitize != nil {
|
|
|
|
if !sanitize.isVariantOnProductionDevice() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !ctx.ctx.Device() {
|
|
|
|
// Host modules do not need ABI dumps.
|
|
|
|
return false
|
|
|
|
}
|
2019-06-25 08:46:52 +02:00
|
|
|
if ctx.isStubs() {
|
|
|
|
// Stubs do not need ABI dumps.
|
|
|
|
return false
|
|
|
|
}
|
2019-07-29 11:46:59 +02:00
|
|
|
return true
|
2017-02-08 22:45:53 +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 {
|
|
|
|
return ctx.mod.IsForPlatform()
|
|
|
|
}
|
|
|
|
|
2019-01-19 11:24:06 +01:00
|
|
|
func (ctx *moduleContextImpl) apexName() string {
|
|
|
|
return ctx.mod.ApexName()
|
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
|
|
|
}
|
|
|
|
|
2018-12-20 14:10:17 +01:00
|
|
|
func (ctx *moduleContextImpl) hasStubsVariants() bool {
|
|
|
|
return ctx.mod.HasStubsVariants()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) isStubs() bool {
|
|
|
|
return ctx.mod.IsStubs()
|
|
|
|
}
|
|
|
|
|
2019-01-16 14:53:13 +01:00
|
|
|
func (ctx *moduleContextImpl) bootstrap() bool {
|
|
|
|
return ctx.mod.bootstrap()
|
|
|
|
}
|
|
|
|
|
2019-03-25 18:21:31 +01:00
|
|
|
func (ctx *moduleContextImpl) nativeCoverage() bool {
|
|
|
|
return ctx.mod.nativeCoverage()
|
|
|
|
}
|
|
|
|
|
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{}
|
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{}
|
2017-09-01 08:38:27 +02:00
|
|
|
module.pgo = &pgo{}
|
2018-11-21 17:59:37 +01:00
|
|
|
module.xom = &xom{}
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:05:30 +02:00
|
|
|
// orderDeps reorders dependencies into a list such that if module A depends on B, then
|
|
|
|
// A will precede B in the resultant list.
|
|
|
|
// This is convenient for passing into a linker.
|
2017-11-28 00:48:57 +01:00
|
|
|
// Note that directSharedDeps should be the analogous static library for each shared lib dep
|
|
|
|
func orderDeps(directStaticDeps []android.Path, directSharedDeps []android.Path, allTransitiveDeps map[android.Path][]android.Path) (orderedAllDeps []android.Path, orderedDeclaredDeps []android.Path) {
|
2017-09-28 02:05:30 +02:00
|
|
|
// If A depends on B, then
|
|
|
|
// Every list containing A will also contain B later in the list
|
|
|
|
// So, after concatenating all lists, the final instance of B will have come from the same
|
|
|
|
// original list as the final instance of A
|
|
|
|
// So, the final instance of B will be later in the concatenation than the final A
|
|
|
|
// So, keeping only the final instance of A and of B ensures that A is earlier in the output
|
|
|
|
// list than B
|
2017-11-28 00:48:57 +01:00
|
|
|
for _, dep := range directStaticDeps {
|
|
|
|
orderedAllDeps = append(orderedAllDeps, dep)
|
|
|
|
orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
|
|
|
|
}
|
|
|
|
for _, dep := range directSharedDeps {
|
2017-09-28 02:05:30 +02:00
|
|
|
orderedAllDeps = append(orderedAllDeps, dep)
|
2017-11-28 00:48:57 +01:00
|
|
|
orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
|
|
|
|
2017-10-24 20:13:31 +02:00
|
|
|
orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
|
2017-09-28 02:05:30 +02:00
|
|
|
|
2017-11-28 00:48:57 +01:00
|
|
|
// We don't want to add any new dependencies into directStaticDeps (to allow the caller to
|
2017-09-28 02:05:30 +02:00
|
|
|
// intentionally exclude or replace any unwanted transitive dependencies), so we limit the
|
2017-11-28 00:48:57 +01:00
|
|
|
// resultant list to only what the caller has chosen to include in directStaticDeps
|
|
|
|
_, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps)
|
2017-09-28 02:05:30 +02:00
|
|
|
|
|
|
|
return orderedAllDeps, orderedDeclaredDeps
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
func orderStaticModuleDeps(module LinkableInterface, staticDeps []LinkableInterface, sharedDeps []LinkableInterface) (results []android.Path) {
|
2017-11-28 00:48:57 +01:00
|
|
|
// convert Module to Path
|
2019-10-18 23:18:45 +02:00
|
|
|
var depsInLinkOrder []android.Path
|
2017-11-28 00:48:57 +01:00
|
|
|
allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps))
|
|
|
|
staticDepFiles := []android.Path{}
|
|
|
|
for _, dep := range staticDeps {
|
2019-10-18 23:18:45 +02:00
|
|
|
allTransitiveDeps[dep.OutputFile().Path()] = dep.GetDepsInLinkOrder()
|
|
|
|
staticDepFiles = append(staticDepFiles, dep.OutputFile().Path())
|
2017-11-28 00:48:57 +01:00
|
|
|
}
|
|
|
|
sharedDepFiles := []android.Path{}
|
|
|
|
for _, sharedDep := range sharedDeps {
|
2019-10-18 23:18:45 +02:00
|
|
|
if sharedDep.HasStaticVariant() {
|
|
|
|
staticAnalogue := sharedDep.GetStaticVariant()
|
|
|
|
allTransitiveDeps[staticAnalogue.OutputFile().Path()] = staticAnalogue.GetDepsInLinkOrder()
|
|
|
|
sharedDepFiles = append(sharedDepFiles, staticAnalogue.OutputFile().Path())
|
2017-11-28 00:48:57 +01:00
|
|
|
}
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// reorder the dependencies based on transitive dependencies
|
2019-10-18 23:18:45 +02:00
|
|
|
depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps)
|
|
|
|
module.SetDepsInLinkOrder(depsInLinkOrder)
|
2017-09-28 02:05:30 +02:00
|
|
|
|
|
|
|
return results
|
|
|
|
}
|
|
|
|
|
2019-07-29 17:22:59 +02:00
|
|
|
func (c *Module) IsTestPerSrcAllTestsVariation() bool {
|
|
|
|
test, ok := c.linker.(testPerSrc)
|
|
|
|
return ok && test.isAllTestsVariation()
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
2019-06-28 16:41:19 +02:00
|
|
|
// Handle the case of a test module split by `test_per_src` mutator.
|
2019-07-29 17:22:59 +02:00
|
|
|
//
|
|
|
|
// 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
|
2019-06-28 16:41:19 +02:00
|
|
|
}
|
|
|
|
|
2019-05-15 21:01:54 +02:00
|
|
|
c.makeLinkType = c.getMakeLinkType(actx)
|
2019-05-09 03:56:13 +02:00
|
|
|
|
2019-08-26 09:52:35 +02:00
|
|
|
c.Properties.SubName = ""
|
|
|
|
|
|
|
|
if c.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
c.Properties.SubName += nativeBridgeSuffix
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
|
|
|
|
// .vendor suffix is added for backward compatibility with VNDK snapshot whose names with
|
|
|
|
// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
|
|
|
|
c.Properties.SubName += vendorSuffix
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if _, ok := c.linker.(*llndkStubDecorator); ok || (c.UseVndk() && c.HasVendorVariant()) {
|
2019-08-26 09:52:35 +02:00
|
|
|
// .vendor.{version} suffix is added only when we will have two variants: core and vendor.
|
|
|
|
// The suffix is not added for vendor-only module.
|
|
|
|
c.Properties.SubName += vendorSuffix
|
|
|
|
vendorVersion := actx.DeviceConfig().VndkVersion()
|
|
|
|
if vendorVersion == "current" {
|
|
|
|
vendorVersion = actx.DeviceConfig().PlatformVndkVersion()
|
|
|
|
}
|
|
|
|
if c.Properties.VndkVersion != vendorVersion {
|
|
|
|
c.Properties.SubName += "." + c.Properties.VndkVersion
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if c.InRecovery() && !c.OnlyInRecovery() {
|
2019-08-26 09:52:35 +02:00
|
|
|
c.Properties.SubName += recoverySuffix
|
|
|
|
}
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2017-05-10 00:44:35 +02:00
|
|
|
if c.lto != nil {
|
|
|
|
flags = c.lto.flags(ctx, flags)
|
|
|
|
}
|
2017-09-01 08:38:27 +02:00
|
|
|
if c.pgo != nil {
|
|
|
|
flags = c.pgo.flags(ctx, flags)
|
|
|
|
}
|
2018-11-21 17:59:37 +01:00
|
|
|
if c.xom != nil {
|
|
|
|
flags = c.xom.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
|
|
|
}
|
|
|
|
|
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-01-04 23:34:37 +01:00
|
|
|
// Optimization to reduce size of build.ninja
|
|
|
|
// Replace the long list of flags for each file with a module-local variable
|
2019-11-04 18:37:55 +01:00
|
|
|
ctx.Variable(pctx, "cflags", strings.Join(flags.Local.CFlags, " "))
|
|
|
|
ctx.Variable(pctx, "cppflags", strings.Join(flags.Local.CppFlags, " "))
|
|
|
|
ctx.Variable(pctx, "asflags", strings.Join(flags.Local.AsFlags, " "))
|
|
|
|
flags.Local.CFlags = []string{"$cflags"}
|
|
|
|
flags.Local.CppFlags = []string{"$cppflags"}
|
|
|
|
flags.Local.AsFlags = []string{"$asflags"}
|
2015-03-18 21:28:46 +01: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
|
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
|
|
|
|
|
|
|
// If a lib is directly included in any of the APEXes, 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').
|
2019-01-15 20:53:23 +01:00
|
|
|
if c.HasStubsVariants() &&
|
|
|
|
android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) &&
|
2019-10-18 23:49:46 +02:00
|
|
|
!c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
|
2018-12-11 00:12:40 +01:00
|
|
|
c.IsStubs() {
|
2018-12-20 14:10:17 +01:00
|
|
|
c.Properties.HideFromMake = false // unhide
|
|
|
|
// Note: this is still non-installable
|
|
|
|
}
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2019-05-09 06:29:15 +02:00
|
|
|
if c.installable() {
|
2016-10-07 01:12:58 +02:00
|
|
|
c.installer.install(ctx, c.outputFile.Path())
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
}
|
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 {
|
2016-07-29 22:44:28 +02:00
|
|
|
c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
|
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-02-08 22:45:53 +01:00
|
|
|
if c.sabi != nil {
|
|
|
|
c.sabi.begin(ctx)
|
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
if c.vndkdep != nil {
|
|
|
|
c.vndkdep.begin(ctx)
|
|
|
|
}
|
2017-05-10 00:44:35 +02:00
|
|
|
if c.lto != nil {
|
|
|
|
c.lto.begin(ctx)
|
|
|
|
}
|
2017-09-01 08:38:27 +02:00
|
|
|
if c.pgo != nil {
|
|
|
|
c.pgo.begin(ctx)
|
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
for _, feature := range c.features {
|
|
|
|
feature.begin(ctx)
|
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
if ctx.useSdk() {
|
2017-08-18 01:19:59 +02:00
|
|
|
version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
|
2016-08-06 01:37:52 +02:00
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version", err.Error())
|
|
|
|
}
|
2017-11-07 19:57:05 +01:00
|
|
|
c.Properties.Sdk_version = StringPtr(version)
|
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
|
|
|
}
|
2018-04-24 00:44:39 +02:00
|
|
|
// Add the PGO dependency (the clang_rt.profile runtime library), which
|
|
|
|
// sometimes depends on symbols from libgcc, before libgcc gets added
|
|
|
|
// in linkerDeps().
|
2017-10-05 01:47:29 +02:00
|
|
|
if c.pgo != nil {
|
|
|
|
deps = c.pgo.deps(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)
|
|
|
|
}
|
2016-01-06 23:41:07 +01:00
|
|
|
if c.sanitize != nil {
|
|
|
|
deps = c.sanitize.deps(ctx, deps)
|
|
|
|
}
|
2018-04-24 00:44:39 +02:00
|
|
|
if c.coverage != nil {
|
|
|
|
deps = c.coverage.deps(ctx, deps)
|
|
|
|
}
|
2017-02-08 22:45:53 +01:00
|
|
|
if c.sabi != nil {
|
|
|
|
deps = c.sabi.deps(ctx, deps)
|
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
if c.vndkdep != nil {
|
|
|
|
deps = c.vndkdep.deps(ctx, deps)
|
|
|
|
}
|
2017-05-10 00:44:35 +02:00
|
|
|
if c.lto != nil {
|
|
|
|
deps = c.lto.deps(ctx, deps)
|
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
for _, feature := range c.features {
|
|
|
|
deps = feature.deps(ctx, deps)
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
if !inList(lib, deps.StaticLibs) {
|
|
|
|
ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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, ""
|
|
|
|
}
|
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
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
|
|
|
|
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 {
|
2016-06-18 01:45:24 +02:00
|
|
|
version := ctx.sdkVersion()
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
|
|
|
|
// of names:
|
2016-06-18 01:45:24 +02:00
|
|
|
//
|
2017-09-28 02:01:44 +02:00
|
|
|
// 1. Name of an NDK library that refers to a prebuilt module.
|
|
|
|
// For each of these, it adds the name of the prebuilt module (which will be in
|
|
|
|
// prebuilts/ndk) to the list of nonvariant libs.
|
|
|
|
// 2. Name of an NDK library that refers to an ndk_library module.
|
|
|
|
// For each of these, it adds the name of the ndk_library module to the list of
|
|
|
|
// variant libs.
|
|
|
|
// 3. Anything else (so anything that isn't an NDK library).
|
|
|
|
// It adds these to the nonvariantLibs list.
|
2016-06-18 01:45:24 +02:00
|
|
|
//
|
2017-09-28 02:01:44 +02:00
|
|
|
// The caller can then know to add the variantLibs dependencies differently from the
|
|
|
|
// nonvariantLibs
|
2019-05-09 03:56:13 +02:00
|
|
|
|
|
|
|
vendorPublicLibraries := vendorPublicLibraries(actx.Config())
|
2017-09-28 02:01:44 +02:00
|
|
|
rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
|
|
|
|
variantLibs = []string{}
|
|
|
|
nonvariantLibs = []string{}
|
2016-06-18 01:45:24 +02:00
|
|
|
for _, entry := range list {
|
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
|
|
|
// strip #version suffix out
|
2019-10-22 13:31:18 +02:00
|
|
|
name, _ := StubsLibNameAndVersion(entry)
|
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 ctx.useSdk() && inList(name, ndkPrebuiltSharedLibraries) {
|
|
|
|
if !inList(name, ndkMigratedLibs) {
|
|
|
|
nonvariantLibs = append(nonvariantLibs, name+".ndk."+version)
|
2016-06-18 01:45:24 +02:00
|
|
|
} else {
|
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
|
|
|
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
|
2016-06-18 01:45:24 +02:00
|
|
|
}
|
2019-10-30 10:43:49 +01:00
|
|
|
} else if ctx.useVndk() && isLlndkLibrary(name, ctx.Config()) {
|
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
|
|
|
nonvariantLibs = append(nonvariantLibs, name+llndkLibrarySuffix)
|
2019-05-09 03:56:13 +02:00
|
|
|
} else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) {
|
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
|
|
|
vendorPublicLib := name + vendorPublicLibrarySuffix
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
if actx.OtherModuleExists(vendorPublicLib) {
|
|
|
|
nonvariantLibs = append(nonvariantLibs, vendorPublicLib)
|
|
|
|
} else {
|
|
|
|
// This can happen if vendor_public_library module is defined in a
|
|
|
|
// namespace that isn't visible to the current module. In that case,
|
|
|
|
// link to the original library.
|
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
|
|
|
nonvariantLibs = append(nonvariantLibs, name)
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
}
|
2016-06-18 01:45:24 +02:00
|
|
|
} else {
|
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
|
|
|
// put name#version back
|
2017-03-28 09:08:30 +02:00
|
|
|
nonvariantLibs = append(nonvariantLibs, entry)
|
2016-07-09 08:23:48 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-18 01:45:24 +02:00
|
|
|
return nonvariantLibs, variantLibs
|
2016-07-09 08:23:48 +02:00
|
|
|
}
|
|
|
|
|
2016-06-18 01:45:24 +02:00
|
|
|
deps.SharedLibs, variantNdkLibs = rewriteNdkLibs(deps.SharedLibs)
|
|
|
|
deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
|
2017-07-05 06:41:55 +02:00
|
|
|
deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
|
2016-07-09 08:23:48 +02:00
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
|
2019-01-28 08:16:54 +01:00
|
|
|
buildStubs := 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
|
|
|
if c.linker != nil {
|
|
|
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
|
|
|
if library.buildStubs() {
|
2019-01-28 08:16:54 +01:00
|
|
|
buildStubs = true
|
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-12-15 16:39:51 +01:00
|
|
|
for _, lib := range deps.HeaderLibs {
|
|
|
|
depTag := headerDepTag
|
|
|
|
if inList(lib, deps.ReexportHeaderLibHeaders) {
|
|
|
|
depTag = headerExportDepTag
|
|
|
|
}
|
2019-01-28 08:16:54 +01:00
|
|
|
if buildStubs {
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if buildStubs {
|
|
|
|
// Stubs lib does not have dependency to other static/shared libraries.
|
|
|
|
// Don't proceed.
|
|
|
|
return
|
2016-12-15 16:39:51 +01:00
|
|
|
}
|
2016-12-13 21:50:57 +01:00
|
|
|
|
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 {
|
|
|
|
depTag := wholeStaticDepTag
|
|
|
|
if impl, ok := syspropImplLibraries[lib]; ok {
|
|
|
|
lib = impl
|
|
|
|
}
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "static"},
|
|
|
|
}, depTag, lib)
|
|
|
|
}
|
|
|
|
|
2016-06-07 03:22:19 +02:00
|
|
|
for _, lib := range deps.StaticLibs {
|
2019-10-18 23:18:45 +02:00
|
|
|
depTag := StaticDepTag
|
2016-06-07 03:22:19 +02:00
|
|
|
if inList(lib, deps.ReexportStaticLibHeaders) {
|
|
|
|
depTag = staticExportDepTag
|
|
|
|
}
|
2019-02-08 13:00:45 +01:00
|
|
|
|
|
|
|
if impl, ok := syspropImplLibraries[lib]; ok {
|
|
|
|
lib = impl
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2018-07-23 06:18:45 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "static"},
|
|
|
|
}, lateStaticDepTag, deps.LateStaticLibs...)
|
2015-03-24 22:15:58 +01:00
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
|
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
|
|
|
var variations []blueprint.Variation
|
|
|
|
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
|
2019-10-18 23:49:46 +02:00
|
|
|
versionVariantAvail := !ctx.useVndk() && !c.InRecovery()
|
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 version != "" && versionVariantAvail {
|
|
|
|
// Version is explicitly specified. i.e. libFoo#30
|
|
|
|
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
|
2019-10-18 23:18:45 +02:00
|
|
|
depTag.ExplicitlyVersioned = true
|
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
|
|
|
}
|
|
|
|
actx.AddVariationDependencies(variations, depTag, name)
|
|
|
|
|
|
|
|
// If the version is not specified, add dependency to the latest stubs library.
|
|
|
|
// The stubs library will be used when the depending module is built for APEX and
|
|
|
|
// the dependent module is not in the same APEX.
|
2019-10-22 13:31:18 +02:00
|
|
|
latestVersion := LatestStubsVersionFor(actx.Config(), name)
|
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 version == "" && latestVersion != "" && versionVariantAvail {
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
{Mutator: "version", Variation: latestVersion},
|
|
|
|
}, depTag, name)
|
2019-10-18 23:18:45 +02:00
|
|
|
// Note that depTag.ExplicitlyVersioned is false in this case.
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 {
|
2019-10-18 23:18:45 +02:00
|
|
|
depTag := SharedDepTag
|
2016-06-07 03:22:19 +02:00
|
|
|
if inList(lib, deps.ReexportSharedLibHeaders) {
|
|
|
|
depTag = sharedExportDepTag
|
|
|
|
}
|
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)
|
|
|
|
|
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
|
|
|
addSharedLibDependencies(depTag, name, version)
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +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
|
|
|
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
|
|
|
|
}
|
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
|
|
|
addSharedLibDependencies(lateSharedDepTag, lib, "")
|
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
|
|
|
|
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
|
|
|
|
2018-08-29 23:10:52 +02:00
|
|
|
actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
|
2016-04-12 00:06:20 +02:00
|
|
|
|
|
|
|
if deps.CrtBegin != "" {
|
2019-10-18 23:18:45 +02:00
|
|
|
actx.AddVariationDependencies(nil, CrtBeginDepTag, deps.CrtBegin)
|
2015-03-24 22:15:58 +01:00
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
if deps.CrtEnd != "" {
|
2019-10-18 23:18:45 +02:00
|
|
|
actx.AddVariationDependencies(nil, CrtEndDepTag, deps.CrtEnd)
|
2015-03-24 22:15:58 +01:00
|
|
|
}
|
2018-10-12 09:24:23 +02:00
|
|
|
if deps.LinkerFlagsFile != "" {
|
|
|
|
actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
|
|
|
|
}
|
|
|
|
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()
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
2018-07-23 06:18:45 +02:00
|
|
|
{Mutator: "ndk_api", Variation: version},
|
|
|
|
{Mutator: "link", Variation: "shared"},
|
|
|
|
}, ndkStubDepTag, variantNdkLibs...)
|
2016-06-18 01:45:24 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
2018-07-23 06:18:45 +02:00
|
|
|
{Mutator: "ndk_api", Variation: version},
|
|
|
|
{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"},
|
|
|
|
}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
|
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.
|
2019-10-18 23:49:46 +02:00
|
|
|
func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to LinkableInterface, tag DependencyTag) {
|
|
|
|
if from.Module().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() {
|
2017-09-28 02:01:44 +02:00
|
|
|
// Though vendor code is limited by the vendor mutator,
|
|
|
|
// each vendor-available 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)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
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
|
|
|
|
}
|
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
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if to.ToolchainLibrary() {
|
2017-09-28 02:01:44 +02:00
|
|
|
// These are always allowed
|
|
|
|
return
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if to.NdkPrebuiltStl() {
|
2017-09-28 02:01:44 +02:00
|
|
|
// These are allowed, but they don't set sdk_version
|
|
|
|
return
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if to.StubDecorator() {
|
2017-09-28 02:01:44 +02:00
|
|
|
// These aren't real libraries, but are the stub shared libraries that are included in
|
|
|
|
// the NDK.
|
|
|
|
return
|
|
|
|
}
|
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
|
|
|
|
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 {
|
|
|
|
// follow thru cc.Defaults, etc.
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
|
|
|
|
return false
|
|
|
|
}
|
2018-04-09 05:03:06 +02:00
|
|
|
|
2019-01-18 07:20:43 +01:00
|
|
|
// if target lib has no vendor variant, keep checking dependency graph
|
2019-10-18 23:49:46 +02:00
|
|
|
if !to.HasVendorVariant() {
|
2019-01-18 07:20:43 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-10-30 10:43:49 +01:00
|
|
|
if to.isVndkSp() || to.isLlndk(ctx.Config()) || Bool(to.VendorProperties.Double_loadable) {
|
2019-01-18 07:20:43 +01:00
|
|
|
return false
|
2018-04-09 05:03:06 +02:00
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
|
|
|
|
var stringPath []string
|
|
|
|
for _, m := range ctx.GetWalkPath() {
|
|
|
|
stringPath = append(stringPath, m.Name())
|
2018-04-09 05:03:06 +02: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'. "+
|
|
|
|
"(dependency: %s)", ctx.OtherModuleName(to), strings.Join(stringPath, " -> "))
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if module, ok := ctx.Module().(*Module); ok {
|
|
|
|
if lib, ok := module.linker.(*libraryDecorator); ok && lib.shared() {
|
2019-10-30 10:43:49 +01:00
|
|
|
if module.isLlndk(ctx.Config()) || Bool(module.VendorProperties.Double_loadable) {
|
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
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
directStaticDeps := []LinkableInterface{}
|
|
|
|
directSharedDeps := []LinkableInterface{}
|
2017-09-28 02:05:30 +02:00
|
|
|
|
2019-05-09 03:56:13 +02:00
|
|
|
vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
|
|
|
|
|
2019-06-03 12:10:47 +02:00
|
|
|
reexportExporter := func(exporter exportedFlagsProducer) {
|
|
|
|
depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, exporter.exportedDirs()...)
|
|
|
|
depPaths.ReexportedSystemDirs = append(depPaths.ReexportedSystemDirs, exporter.exportedSystemDirs()...)
|
|
|
|
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, exporter.exportedFlags()...)
|
|
|
|
depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, exporter.exportedDeps()...)
|
2019-12-06 05:15:38 +01:00
|
|
|
depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.exportedGeneratedHeaders()...)
|
2019-06-03 12:10:47 +02:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
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 {
|
2016-04-20 23:21:14 +02:00
|
|
|
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
|
2019-12-06 05:15:38 +01:00
|
|
|
genRule.GeneratedSourceFiles()...)
|
|
|
|
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
|
|
|
}
|
2018-10-12 09:24:23 +02:00
|
|
|
case linkerFlagsDepTag:
|
2017-09-28 02:01:44 +02:00
|
|
|
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
|
2017-09-19 08:19:12 +02:00
|
|
|
files := genRule.GeneratedSourceFiles()
|
|
|
|
if len(files) == 1 {
|
2018-10-12 09:24:23 +02:00
|
|
|
depPaths.LinkerFlagsFile = android.OptionalPathForPath(files[0])
|
2017-09-19 08:19:12 +02:00
|
|
|
} else if len(files) > 1 {
|
2018-10-12 09:24:23 +02:00
|
|
|
ctx.ModuleErrorf("module %q can only generate a single file if used for a linker flag file", depName)
|
2017-09-19 08:19:12 +02:00
|
|
|
}
|
|
|
|
} else {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("module %q is not a genrule", depName)
|
2017-09-19 08:19:12 +02:00
|
|
|
}
|
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 {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
|
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
|
|
|
// re-exporting flags
|
|
|
|
if depTag == reuseObjTag {
|
2019-10-18 23:49:46 +02:00
|
|
|
// reusing objects only make sense for cc.Modules.
|
|
|
|
if ccReuseDep, ok := ccDep.(*Module); ok && ccDep.CcLibraryInterface() {
|
2017-11-28 00:48:57 +01:00
|
|
|
c.staticVariant = ccDep
|
2019-10-18 23:49:46 +02:00
|
|
|
objs, exporter := ccReuseDep.compiler.(libraryInterface).reuseObjs()
|
2017-05-03 20:01:58 +02:00
|
|
|
depPaths.Objs = depPaths.Objs.Append(objs)
|
2019-06-03 12:10:47 +02:00
|
|
|
reexportExporter(exporter)
|
2016-11-24 00:45:05 +01:00
|
|
|
return
|
|
|
|
}
|
2016-04-12 00:06:20 +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
|
|
|
|
2019-01-31 16:31:10 +01:00
|
|
|
if depTag == staticVariantTag {
|
2019-10-18 23:49:46 +02:00
|
|
|
// staticVariants are a cc.Module specific concept.
|
|
|
|
if _, ok := ccDep.(*Module); ok && ccDep.CcLibraryInterface() {
|
2019-01-31 16:31:10 +01:00
|
|
|
c.staticVariant = ccDep
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
// Extract ExplicitlyVersioned field from the depTag and reset it inside the struct.
|
|
|
|
// Otherwise, SharedDepTag and lateSharedDepTag with ExplicitlyVersioned set to true
|
|
|
|
// won't be matched to SharedDepTag and lateSharedDepTag.
|
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
|
|
|
explicitlyVersioned := false
|
2019-10-18 23:18:45 +02:00
|
|
|
if t, ok := depTag.(DependencyTag); ok {
|
|
|
|
explicitlyVersioned = t.ExplicitlyVersioned
|
|
|
|
t.ExplicitlyVersioned = false
|
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
|
|
|
depTag = t
|
|
|
|
}
|
|
|
|
|
2019-10-18 23:18:45 +02:00
|
|
|
if t, ok := depTag.(DependencyTag); ok && t.Library {
|
2018-12-20 10:18:08 +01:00
|
|
|
depIsStatic := false
|
|
|
|
switch depTag {
|
2019-10-18 23:18:45 +02:00
|
|
|
case StaticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag:
|
2018-12-20 10:18:08 +01:00
|
|
|
depIsStatic = true
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if ccDep.CcLibrary() && !depIsStatic {
|
|
|
|
depIsStubs := ccDep.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
|
|
|
depHasStubs := ccDep.HasStubsVariants()
|
Don't create unnecessary APEX variations
This change fixes a problem that APEX variations are created for the
modules that actually shouldn't built for any APEX. For example,
consider this case.
apex { name: "myapex", native_shared_libs: ["mylib"],}
cc_library { name: "mylib", shared_libs: ["libfoo#10"],}
cc_library { name: "libfoo",
shared_libs: ["libbar"],
stubs: { versions: ["10"], }, }
cc_library { name: "libbar", ...}
Before this change, both the stubs and non-stubs variations of libfoo
were mutated with apexMuator, which is incorrect for the non-stubs
varia; there is no dependency chain from the apex "myapex" to the
non-stubs variation, but to the stubs variation due to the #10 syntax.
This was happening becauses we used the name of the module to determine
whether it should be built for APEX or not. Both stubs and non-stubs
variations have the same module name "libfoo".
Fixing this issue by recording the list of APEX variations required
directly on the module. So, the stubs variation of libfoo has myapex in
its apex variations list, but the non-stubs variation doesn't, and thus
apexMutator does not pick up the non-stubs variation.
Test: m (apex_test updated and passing)
Test: cherry-pick ag/5747464 and m
Change-Id: I31e618626809a828a55fff513ef5f81f79637afa
2018-12-10 17:35:25 +01:00
|
|
|
depInSameApex := android.DirectlyInApex(c.ApexName(), depName)
|
2019-01-15 20:53:23 +01:00
|
|
|
depInPlatform := !android.DirectlyInAnyApex(ctx, depName)
|
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
|
|
|
|
|
|
|
var useThisDep bool
|
|
|
|
if depIsStubs && explicitlyVersioned {
|
|
|
|
// Always respect dependency to the versioned stubs (i.e. libX#10)
|
|
|
|
useThisDep = true
|
|
|
|
} else if !depHasStubs {
|
|
|
|
// Use non-stub variant if that is the only choice
|
|
|
|
// (i.e. depending on a lib without stubs.version property)
|
|
|
|
useThisDep = true
|
|
|
|
} else if c.IsForPlatform() {
|
|
|
|
// If not building for APEX, use stubs only when it is from
|
|
|
|
// an APEX (and not from platform)
|
|
|
|
useThisDep = (depInPlatform != depIsStubs)
|
2019-10-18 23:49:46 +02:00
|
|
|
if c.InRecovery() || c.bootstrap() {
|
2018-12-20 14:10:17 +01:00
|
|
|
// However, for recovery or bootstrap modules,
|
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
|
|
|
// always link to non-stub variant
|
|
|
|
useThisDep = !depIsStubs
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// If building for APEX, use stubs only when it is not from
|
|
|
|
// the same APEX
|
|
|
|
useThisDep = (depInSameApex != depIsStubs)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !useThisDep {
|
|
|
|
return // stop processing this dep
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 04:15:49 +01:00
|
|
|
depPaths.IncludeDirs = append(depPaths.IncludeDirs, ccDep.IncludeDirs()...)
|
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
// Exporting flags only makes sense for cc.Modules
|
|
|
|
if _, ok := ccDep.(*Module); ok {
|
|
|
|
if i, ok := ccDep.(*Module).linker.(exportedFlagsProducer); ok {
|
|
|
|
depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, i.exportedSystemDirs()...)
|
2019-12-06 05:15:38 +01:00
|
|
|
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, i.exportedGeneratedHeaders()...)
|
|
|
|
depPaths.GeneratedDeps = append(depPaths.GeneratedDeps, i.exportedDeps()...)
|
2019-10-18 23:49:46 +02:00
|
|
|
depPaths.Flags = append(depPaths.Flags, i.exportedFlags()...)
|
|
|
|
|
|
|
|
if t.ReexportFlags {
|
|
|
|
reexportExporter(i)
|
|
|
|
// 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, i.exportedDirs().Strings()...)
|
|
|
|
}
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2016-04-12 00:06:20 +02: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
|
|
|
checkLinkType(ctx, c, ccDep, t)
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
var ptr *android.Paths
|
2016-05-19 00:37:25 +02:00
|
|
|
var depPtr *android.Paths
|
2016-04-12 00:06:20 +02:00
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
linkFile := ccDep.OutputFile()
|
2016-10-01 02:10:16 +02:00
|
|
|
depFile := android.OptionalPath{}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
switch depTag {
|
2019-10-18 23:18:45 +02:00
|
|
|
case ndkStubDepTag, SharedDepTag, sharedExportDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
ptr = &depPaths.SharedLibs
|
|
|
|
depPtr = &depPaths.SharedLibsDeps
|
2019-10-18 23:49:46 +02:00
|
|
|
depFile = ccDep.Toc()
|
2017-11-28 00:48:57 +01:00
|
|
|
directSharedDeps = append(directSharedDeps, ccDep)
|
2019-10-18 23:18:45 +02:00
|
|
|
|
2019-01-18 06:37:08 +01:00
|
|
|
case earlySharedDepTag:
|
|
|
|
ptr = &depPaths.EarlySharedLibs
|
|
|
|
depPtr = &depPaths.EarlySharedLibsDeps
|
2019-10-18 23:49:46 +02:00
|
|
|
depFile = ccDep.Toc()
|
2019-01-18 06:37:08 +01:00
|
|
|
directSharedDeps = append(directSharedDeps, ccDep)
|
2016-06-18 01:45:24 +02:00
|
|
|
case lateSharedDepTag, ndkLateStubDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
ptr = &depPaths.LateSharedLibs
|
|
|
|
depPtr = &depPaths.LateSharedLibsDeps
|
2019-10-18 23:49:46 +02:00
|
|
|
depFile = ccDep.Toc()
|
2019-10-18 23:18:45 +02:00
|
|
|
case StaticDepTag, staticExportDepTag:
|
2017-09-28 02:05:30 +02:00
|
|
|
ptr = nil
|
|
|
|
directStaticDeps = append(directStaticDeps, ccDep)
|
2016-04-12 00:06:20 +02:00
|
|
|
case lateStaticDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
ptr = &depPaths.LateStaticLibs
|
2016-04-12 00:06:20 +02:00
|
|
|
case wholeStaticDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
ptr = &depPaths.WholeStaticLibs
|
2019-10-18 23:49:46 +02:00
|
|
|
if !ccDep.CcLibraryInterface() || !ccDep.Static() {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("module %q not a static library", depName)
|
2016-04-12 00:06:20 +02:00
|
|
|
return
|
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
// Because the static library objects are included, this only makes sense
|
|
|
|
// in the context of proper cc.Modules.
|
|
|
|
if ccWholeStaticLib, ok := ccDep.(*Module); ok {
|
|
|
|
staticLib := ccWholeStaticLib.linker.(libraryInterface)
|
|
|
|
if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
|
|
|
|
postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
|
|
|
|
for i := range missingDeps {
|
|
|
|
missingDeps[i] += postfix
|
|
|
|
}
|
|
|
|
ctx.AddMissingDependencies(missingDeps)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf(
|
|
|
|
"non-cc.Modules cannot be included as whole static libraries.", depName)
|
|
|
|
return
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-12-13 21:50:57 +01:00
|
|
|
case headerDepTag:
|
|
|
|
// Nothing
|
2016-04-12 00:06:20 +02:00
|
|
|
case objDepTag:
|
2016-09-27 02:33:01 +02:00
|
|
|
depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
|
2019-10-18 23:18:45 +02:00
|
|
|
case CrtBeginDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
depPaths.CrtBegin = linkFile
|
2019-10-18 23:18:45 +02:00
|
|
|
case CrtEndDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
depPaths.CrtEnd = linkFile
|
2018-10-12 09:24:23 +02:00
|
|
|
case dynamicLinkerDepTag:
|
|
|
|
depPaths.DynamicLinker = linkFile
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
switch depTag {
|
2019-10-18 23:18:45 +02:00
|
|
|
case StaticDepTag, staticExportDepTag, lateStaticDepTag:
|
2019-10-18 23:49:46 +02:00
|
|
|
if !ccDep.CcLibraryInterface() || !ccDep.Static() {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("module %q not a static library", depName)
|
2017-02-10 01:16:31 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// When combining coverage files for shared libraries and executables, coverage files
|
2017-02-08 22:45:53 +01:00
|
|
|
// in static libraries act as if they were whole static libraries. The same goes for
|
|
|
|
// source based Abi dump files.
|
2019-10-18 23:49:46 +02:00
|
|
|
// This should only be done for cc.Modules
|
|
|
|
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...)
|
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
if ptr != nil {
|
2016-10-07 01:12:58 +02:00
|
|
|
if !linkFile.Valid() {
|
2019-10-15 11:16:05 +02:00
|
|
|
if !ctx.Config().AllowMissingDependencies() {
|
|
|
|
ctx.ModuleErrorf("module %q missing output file", depName)
|
|
|
|
} else {
|
|
|
|
ctx.AddMissingDependencies([]string{depName})
|
|
|
|
}
|
2016-10-07 01:12:58 +02:00
|
|
|
return
|
|
|
|
}
|
2016-10-01 02:10:16 +02:00
|
|
|
*ptr = append(*ptr, linkFile.Path())
|
|
|
|
}
|
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
if depPtr != nil {
|
2016-10-01 02:10:16 +02:00
|
|
|
dep := depFile
|
|
|
|
if !dep.Valid() {
|
|
|
|
dep = linkFile
|
|
|
|
}
|
|
|
|
*depPtr = append(*depPtr, dep.Path())
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2017-07-18 06:23:39 +02:00
|
|
|
|
2017-12-19 18:17:32 +01:00
|
|
|
makeLibName := func(depName string) string {
|
2017-09-28 02:01:44 +02:00
|
|
|
libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix)
|
2017-07-18 06:23:39 +02:00
|
|
|
libName = strings.TrimPrefix(libName, "prebuilt_")
|
2019-10-30 10:43:49 +01:00
|
|
|
isLLndk := isLlndkLibrary(libName, ctx.Config())
|
2019-05-09 03:56:13 +02:00
|
|
|
isVendorPublicLib := inList(libName, *vendorPublicLibraries)
|
2019-10-18 23:49:46 +02:00
|
|
|
bothVendorAndCoreVariantsExist := ccDep.HasVendorVariant() || isLLndk
|
2018-11-13 05:19:56 +01:00
|
|
|
|
2019-10-18 23:49:46 +02:00
|
|
|
if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() && !c.InRecovery() {
|
2018-11-13 05:19:56 +01:00
|
|
|
// The vendor module is a no-vendor-variant VNDK library. Depend on the
|
|
|
|
// core module instead.
|
|
|
|
return libName
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if c.UseVndk() && bothVendorAndCoreVariantsExist {
|
2017-09-28 02:01:44 +02:00
|
|
|
// The vendor module in Make will have been renamed to not conflict with the core
|
|
|
|
// module, so update the dependency name here accordingly.
|
2019-08-26 09:52:35 +02:00
|
|
|
ret := libName + vendorSuffix
|
|
|
|
vendorVersion := ctx.DeviceConfig().VndkVersion()
|
|
|
|
if vendorVersion == "current" {
|
|
|
|
vendorVersion = ctx.DeviceConfig().PlatformVndkVersion()
|
|
|
|
}
|
|
|
|
if c.Properties.VndkVersion != vendorVersion {
|
|
|
|
ret += "." + c.Properties.VndkVersion
|
|
|
|
}
|
|
|
|
return ret
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
} else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib {
|
2017-12-19 18:17:32 +01:00
|
|
|
return libName + vendorPublicLibrarySuffix
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
|
2018-01-31 16:54:12 +01:00
|
|
|
return libName + recoverySuffix
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if ccDep.Module().Target().NativeBridge == android.NativeBridgeEnabled {
|
2019-05-23 13:24:38 +02:00
|
|
|
return libName + nativeBridgeSuffix
|
2017-09-28 02:01:44 +02:00
|
|
|
} else {
|
2017-12-19 18:17:32 +01:00
|
|
|
return libName
|
2017-07-18 06:23:39 +02:00
|
|
|
}
|
2017-12-19 18:17:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Export the shared libs to Make.
|
|
|
|
switch depTag {
|
2019-10-18 23:18:45 +02:00
|
|
|
case SharedDepTag, sharedExportDepTag, lateSharedDepTag, earlySharedDepTag:
|
2019-10-18 23:49:46 +02:00
|
|
|
if ccDep.CcLibrary() {
|
|
|
|
if ccDep.BuildStubs() && android.InAnyApex(depName) {
|
2019-01-18 07:57:48 +01:00
|
|
|
// Add the dependency to the APEX(es) providing the library so that
|
2018-12-07 15:08:36 +01:00
|
|
|
// m <module> can trigger building the APEXes as well.
|
Don't create unnecessary APEX variations
This change fixes a problem that APEX variations are created for the
modules that actually shouldn't built for any APEX. For example,
consider this case.
apex { name: "myapex", native_shared_libs: ["mylib"],}
cc_library { name: "mylib", shared_libs: ["libfoo#10"],}
cc_library { name: "libfoo",
shared_libs: ["libbar"],
stubs: { versions: ["10"], }, }
cc_library { name: "libbar", ...}
Before this change, both the stubs and non-stubs variations of libfoo
were mutated with apexMuator, which is incorrect for the non-stubs
varia; there is no dependency chain from the apex "myapex" to the
non-stubs variation, but to the stubs variation due to the #10 syntax.
This was happening becauses we used the name of the module to determine
whether it should be built for APEX or not. Both stubs and non-stubs
variations have the same module name "libfoo".
Fixing this issue by recording the list of APEX variations required
directly on the module. So, the stubs variation of libfoo has myapex in
its apex variations list, but the non-stubs variation doesn't, and thus
apexMutator does not pick up the non-stubs variation.
Test: m (apex_test updated and passing)
Test: cherry-pick ag/5747464 and m
Change-Id: I31e618626809a828a55fff513ef5f81f79637afa
2018-12-10 17:35:25 +01:00
|
|
|
for _, an := range android.GetApexesForModule(depName) {
|
2018-12-07 15:08:36 +01:00
|
|
|
c.Properties.ApexesProvidingSharedLibs = append(
|
|
|
|
c.Properties.ApexesProvidingSharedLibs, an)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-18 06:23:39 +02:00
|
|
|
// Note: the order of libs in this list is not important because
|
2017-09-28 02:01:44 +02:00
|
|
|
// they merely serve as Make dependencies and do not affect this lib itself.
|
2017-12-19 18:17:32 +01:00
|
|
|
c.Properties.AndroidMkSharedLibs = append(
|
|
|
|
c.Properties.AndroidMkSharedLibs, makeLibName(depName))
|
2019-01-14 08:35:08 +01:00
|
|
|
case ndkStubDepTag, ndkLateStubDepTag:
|
|
|
|
c.Properties.AndroidMkSharedLibs = append(
|
|
|
|
c.Properties.AndroidMkSharedLibs,
|
2019-10-18 23:49:46 +02:00
|
|
|
depName+"."+ccDep.ApiLevel())
|
2019-10-18 23:18:45 +02:00
|
|
|
case StaticDepTag, staticExportDepTag, lateStaticDepTag:
|
2018-11-16 02:19:56 +01:00
|
|
|
c.Properties.AndroidMkStaticLibs = append(
|
|
|
|
c.Properties.AndroidMkStaticLibs, makeLibName(depName))
|
2017-12-19 18:17:32 +01:00
|
|
|
case runtimeDepTag:
|
|
|
|
c.Properties.AndroidMkRuntimeLibs = append(
|
|
|
|
c.Properties.AndroidMkRuntimeLibs, makeLibName(depName))
|
2018-11-16 02:19:56 +01:00
|
|
|
case wholeStaticDepTag:
|
|
|
|
c.Properties.AndroidMkWholeStaticLibs = append(
|
|
|
|
c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName))
|
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
|
2017-11-28 00:48:57 +01:00
|
|
|
depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...)
|
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)
|
2017-08-29 21:28:37 +02:00
|
|
|
depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-07-29 14:27:18 +02:00
|
|
|
func (c *Module) header() bool {
|
|
|
|
if h, ok := c.linker.(interface {
|
|
|
|
header() bool
|
|
|
|
}); ok {
|
|
|
|
return h.header()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-05-15 21:01:54 +02:00
|
|
|
func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
|
2019-10-18 23:49:46 +02:00
|
|
|
if c.UseVndk() {
|
2019-05-15 21:01:54 +02:00
|
|
|
if lib, ok := c.linker.(*llndkStubDecorator); ok {
|
|
|
|
if Bool(lib.Properties.Vendor_available) {
|
2018-09-05 01:28:17 +02:00
|
|
|
return "native:vndk"
|
|
|
|
}
|
2019-05-15 21:01:54 +02:00
|
|
|
return "native:vndk_private"
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if c.IsVndk() && !c.isVndkExt() {
|
2019-05-15 21:01:54 +02:00
|
|
|
if Bool(c.VendorProperties.Vendor_available) {
|
|
|
|
return "native:vndk"
|
|
|
|
}
|
|
|
|
return "native:vndk_private"
|
2018-09-05 01:28:17 +02:00
|
|
|
}
|
2019-05-15 21:01:54 +02:00
|
|
|
return "native:vendor"
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if c.InRecovery() {
|
2018-09-05 01:28:17 +02:00
|
|
|
return "native:recovery"
|
|
|
|
} else if c.Target().Os == android.Android && String(c.Properties.Sdk_version) != "" {
|
|
|
|
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 {
|
|
|
|
if shared, ok := c.linker.(interface {
|
|
|
|
shared() bool
|
|
|
|
}); ok {
|
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.
|
|
|
|
return shared.shared() && !c.IsStubs() && 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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-09 06:29:15 +02:00
|
|
|
func (c *Module) installable() bool {
|
|
|
|
return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid()
|
|
|
|
}
|
|
|
|
|
2019-03-03 23:58:15 +01:00
|
|
|
func (c *Module) IDEInfo(dpInfo *android.IdeInfo) {
|
2019-05-29 23:40:35 +02:00
|
|
|
outputFiles, err := c.OutputFiles("")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
dpInfo.Srcs = append(dpInfo.Srcs, outputFiles.Strings()...)
|
2019-03-03 23:58:15 +01: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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-15 08:20:07 +02:00
|
|
|
func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
2019-10-18 23:18:45 +02:00
|
|
|
if depTag, ok := ctx.OtherModuleDependencyTag(dep).(DependencyTag); ok {
|
|
|
|
if cc, ok := dep.(*Module); ok && cc.IsStubs() && depTag.Shared {
|
2019-10-15 08:20:07 +02:00
|
|
|
// dynamic dep to a stubs lib crosses APEX boundary
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
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{},
|
2016-07-30 02:28:03 +02:00
|
|
|
&TestProperties{},
|
|
|
|
&TestBinaryProperties{},
|
2019-09-14 02:32:50 +02:00
|
|
|
&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{},
|
2017-09-01 08:38:27 +02:00
|
|
|
&PgoProperties{},
|
2018-11-21 17:59:37 +01:00
|
|
|
&XomProperties{},
|
2018-03-08 22:27:59 +01:00
|
|
|
&android.ProtoProperties{},
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
const (
|
2019-11-19 01:00:16 +01:00
|
|
|
// VendorVariationPrefix is the variant prefix used for /vendor code that compiles
|
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
|
|
|
// against the VNDK.
|
2019-11-19 01:00:16 +01:00
|
|
|
VendorVariationPrefix = "vendor."
|
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
|
|
|
)
|
|
|
|
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 16:05:00 +02:00
|
|
|
func squashVendorSrcs(m *Module) {
|
|
|
|
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
|
|
|
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
|
|
|
|
lib.baseCompiler.Properties.Target.Vendor.Srcs...)
|
|
|
|
|
|
|
|
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
|
|
|
|
lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
func squashRecoverySrcs(m *Module) {
|
|
|
|
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
|
|
|
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
|
|
|
|
lib.baseCompiler.Properties.Target.Recovery.Srcs...)
|
|
|
|
|
|
|
|
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
|
|
|
|
lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-19 01:00:16 +01:00
|
|
|
var _ android.ImageInterface = (*Module)(nil)
|
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
|
|
|
|
2019-11-19 01:00:16 +01:00
|
|
|
func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
|
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
|
|
|
// Sanity check
|
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
|
|
|
vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
|
2018-11-28 07:14:47 +01:00
|
|
|
productSpecific := mctx.ProductSpecific()
|
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 m.VendorProperties.Vendor_available != nil && vendorSpecific {
|
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
|
|
|
mctx.PropertyErrorf("vendor_available",
|
2017-11-08 08:03:48 +01:00
|
|
|
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
|
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
|
|
|
}
|
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 := m.vndkdep; vndkdep != nil {
|
|
|
|
if vndkdep.isVndk() {
|
2018-11-28 07:14:47 +01:00
|
|
|
if productSpecific {
|
|
|
|
mctx.PropertyErrorf("product_specific",
|
|
|
|
"product_specific must not be true when `vndk: {enabled: true}`")
|
|
|
|
}
|
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 vendorSpecific {
|
|
|
|
if !vndkdep.isVndkExt() {
|
|
|
|
mctx.PropertyErrorf("vndk",
|
|
|
|
"must set `extends: \"...\"` to vndk extension")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if vndkdep.isVndkExt() {
|
|
|
|
mctx.PropertyErrorf("vndk",
|
|
|
|
"must set `vendor: true` to set `extends: %q`",
|
|
|
|
m.getVndkExtendsModuleName())
|
|
|
|
}
|
|
|
|
if m.VendorProperties.Vendor_available == nil {
|
|
|
|
mctx.PropertyErrorf("vndk",
|
|
|
|
"vendor_available must be set to either true or false when `vndk: {enabled: true}`")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if vndkdep.isVndkSp() {
|
|
|
|
mctx.PropertyErrorf("vndk",
|
|
|
|
"must set `enabled: true` to set `support_system_process: true`")
|
|
|
|
}
|
|
|
|
if vndkdep.isVndkExt() {
|
|
|
|
mctx.PropertyErrorf("vndk",
|
|
|
|
"must set `enabled: true` to set `extends: %q`",
|
|
|
|
m.getVndkExtendsModuleName())
|
|
|
|
}
|
2017-06-23 12:24:43 +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
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
var coreVariantNeeded bool = false
|
|
|
|
var recoveryVariantNeeded bool = false
|
|
|
|
|
2019-08-26 09:52:35 +02:00
|
|
|
var vendorVariants []string
|
|
|
|
|
|
|
|
platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
|
|
|
|
deviceVndkVersion := mctx.DeviceConfig().VndkVersion()
|
|
|
|
if deviceVndkVersion == "current" {
|
|
|
|
deviceVndkVersion = platformVndkVersion
|
|
|
|
}
|
|
|
|
|
Install VNDK snapshot libraries for system build
When BOARD_VNDK_VERSION := <VNDK version>, or
PRODUCT_EXTRA_VNDK_VERSIONS includes the needed <VNDK version> list,
the prebuilt VNDK libs in prebuilts/vndk/ directory will be
installed.
Each prebuilt VNDK module uses "vndk_prebuilt_shared" for shared
VNDK/VNDK-SP libs.
Following is the sample configuration of a vndk snapshot module:
vndk_prebuilt_shared {
name: "libfoo",
version: "27",
vendor_available: true,
vndk: {
enabled: true,
},
arch: {
arm64: {
srcs: ["arm/lib64/libfoo.so"],
},
arm: {
srcs: ["arm/lib/libfoo.so"],
},
},
}
The Android.bp for the snapshot modules will be auto-generated by a
script.
Bug: 38304393
Bug: 65377115
Bug: 68123344
Test: set BOARD_VNDK_VERSION := 27
copy a snapshot for v27
build with make command
Change-Id: Ib93107530dbabb4a24583f4d6e4f0c513c9adfec
2017-11-17 04:10:28 +01:00
|
|
|
if mctx.DeviceConfig().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
|
|
|
// If the device isn't compiling against the VNDK, we always
|
|
|
|
// use the core mode.
|
2018-01-31 16:54:12 +01:00
|
|
|
coreVariantNeeded = true
|
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
|
|
|
} else if _, ok := m.linker.(*llndkStubDecorator); ok {
|
|
|
|
// LL-NDK stubs only exist in the vendor variant, since the
|
|
|
|
// real libraries will be used in the core variant.
|
2019-08-26 09:52:35 +02:00
|
|
|
vendorVariants = append(vendorVariants,
|
|
|
|
platformVndkVersion,
|
|
|
|
deviceVndkVersion,
|
|
|
|
)
|
2017-10-19 08:59:33 +02:00
|
|
|
} else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
|
|
|
|
// ... and LL-NDK headers as well
|
2019-08-26 09:52:35 +02:00
|
|
|
vendorVariants = append(vendorVariants,
|
|
|
|
platformVndkVersion,
|
|
|
|
deviceVndkVersion,
|
|
|
|
)
|
|
|
|
} else if lib, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
|
Install VNDK snapshot libraries for system build
When BOARD_VNDK_VERSION := <VNDK version>, or
PRODUCT_EXTRA_VNDK_VERSIONS includes the needed <VNDK version> list,
the prebuilt VNDK libs in prebuilts/vndk/ directory will be
installed.
Each prebuilt VNDK module uses "vndk_prebuilt_shared" for shared
VNDK/VNDK-SP libs.
Following is the sample configuration of a vndk snapshot module:
vndk_prebuilt_shared {
name: "libfoo",
version: "27",
vendor_available: true,
vndk: {
enabled: true,
},
arch: {
arm64: {
srcs: ["arm/lib64/libfoo.so"],
},
arm: {
srcs: ["arm/lib/libfoo.so"],
},
},
}
The Android.bp for the snapshot modules will be auto-generated by a
script.
Bug: 38304393
Bug: 65377115
Bug: 68123344
Test: set BOARD_VNDK_VERSION := 27
copy a snapshot for v27
build with make command
Change-Id: Ib93107530dbabb4a24583f4d6e4f0c513c9adfec
2017-11-17 04:10:28 +01:00
|
|
|
// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
|
|
|
|
// PRODUCT_EXTRA_VNDK_VERSIONS.
|
2019-08-26 09:52:35 +02:00
|
|
|
vendorVariants = append(vendorVariants, lib.version())
|
2019-10-18 23:49:46 +02:00
|
|
|
} else if m.HasVendorVariant() && !vendorSpecific {
|
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
|
|
|
// This will be available in both /system and /vendor
|
2017-06-23 12:24:43 +02:00
|
|
|
// or a /system directory that is available to vendor.
|
2018-01-31 16:54:12 +01:00
|
|
|
coreVariantNeeded = true
|
2019-08-26 09:52:35 +02:00
|
|
|
vendorVariants = append(vendorVariants, platformVndkVersion)
|
2019-11-01 03:29:44 +01:00
|
|
|
// VNDK modules must not create BOARD_VNDK_VERSION variant because its
|
|
|
|
// code is PLATFORM_VNDK_VERSION.
|
|
|
|
// On the other hand, vendor_available modules which are not VNDK should
|
|
|
|
// also build BOARD_VNDK_VERSION because it's installed in /vendor.
|
|
|
|
if !m.IsVndk() {
|
2019-08-26 09:52:35 +02:00
|
|
|
vendorVariants = append(vendorVariants, deviceVndkVersion)
|
|
|
|
}
|
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
|
|
|
} else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
|
2017-11-08 08:03:48 +01:00
|
|
|
// This will be available in /vendor (or /odm) only
|
2019-08-26 09:52:35 +02:00
|
|
|
vendorVariants = append(vendorVariants, deviceVndkVersion)
|
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
|
|
|
} else {
|
|
|
|
// This is either in /system (or similar: /data), or is a
|
|
|
|
// modules built with the NDK. Modules built with the NDK
|
|
|
|
// will be restricted using the existing link type checks.
|
2018-01-31 16:54:12 +01:00
|
|
|
coreVariantNeeded = true
|
|
|
|
}
|
|
|
|
|
|
|
|
if Bool(m.Properties.Recovery_available) {
|
|
|
|
recoveryVariantNeeded = true
|
|
|
|
}
|
|
|
|
|
|
|
|
if m.ModuleBase.InstallInRecovery() {
|
|
|
|
recoveryVariantNeeded = true
|
|
|
|
coreVariantNeeded = false
|
|
|
|
}
|
|
|
|
|
2019-08-26 09:52:35 +02:00
|
|
|
for _, variant := range android.FirstUniqueStrings(vendorVariants) {
|
2019-11-19 01:00:16 +01:00
|
|
|
m.Properties.VendorVariants = append(m.Properties.VendorVariants, VendorVariationPrefix+variant)
|
2018-01-31 16:54:12 +01:00
|
|
|
}
|
2019-11-19 01:00:16 +01:00
|
|
|
|
|
|
|
m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
|
|
|
|
m.Properties.CoreVariantNeeded = coreVariantNeeded
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
|
|
|
|
return c.Properties.CoreVariantNeeded
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
|
|
|
|
return c.Properties.RecoveryVariantNeeded
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
|
|
|
|
return c.Properties.VendorVariants
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
|
|
|
|
m := module.(*Module)
|
|
|
|
if variant == android.RecoveryVariation {
|
|
|
|
m.MakeAsPlatform()
|
|
|
|
squashRecoverySrcs(m)
|
|
|
|
} else if strings.HasPrefix(variant, VendorVariationPrefix) {
|
|
|
|
m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
|
|
|
|
squashVendorSrcs(m)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-09 19:21:52 +02:00
|
|
|
func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
|
2017-11-29 09:27:14 +01:00
|
|
|
if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
|
2017-05-09 19:21:52 +02:00
|
|
|
return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
|
|
|
|
}
|
2017-11-29 09:27:14 +01:00
|
|
|
return ctx.Config().PlatformSdkVersion()
|
2017-05-09 19:21:52 +02:00
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Output: android.PathForPhony(ctx, "xref_cxx"),
|
|
|
|
Inputs: xrefTargets,
|
|
|
|
//Default: true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|