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 (
|
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() {
|
2016-10-12 23:28:16 +02:00
|
|
|
android.RegisterModuleType("cc_defaults", defaultsFactory)
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
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
|
|
|
ctx.BottomUp("image", vendorMutator).Parallel()
|
2016-10-12 23:38:15 +02:00
|
|
|
ctx.BottomUp("link", linkageMutator).Parallel()
|
2017-08-03 14:22:50 +02:00
|
|
|
ctx.BottomUp("vndk", vndkMutator).Parallel()
|
2016-10-12 23:38:15 +02:00
|
|
|
ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
|
|
|
|
ctx.BottomUp("test_per_src", testPerSrcMutator).Parallel()
|
|
|
|
ctx.BottomUp("begin", beginMutator).Parallel()
|
|
|
|
})
|
2016-01-06 23:41:07 +01:00
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.TopDown("asan_deps", sanitizerDepsMutator(asan))
|
|
|
|
ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel()
|
2016-01-06 23:41:07 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
ctx.BottomUp("coverage", coverageLinkingMutator).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()
|
2016-10-12 23:38:15 +02:00
|
|
|
})
|
2016-07-29 22:44:28 +02:00
|
|
|
|
|
|
|
pctx.Import("android/soong/cc/config")
|
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
|
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
|
|
|
|
|
2016-09-29 02:34:58 +02:00
|
|
|
ReexportGeneratedHeaders []string
|
|
|
|
|
2015-03-24 01:50:24 +01:00
|
|
|
CrtBegin, CrtEnd string
|
2017-09-19 08:19:12 +02:00
|
|
|
LinkerScript 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
|
|
|
|
SharedLibs, LateSharedLibs android.Paths
|
|
|
|
// Paths to the dependencies to use for .so files (.so.toc files)
|
|
|
|
SharedLibsDeps, LateSharedLibsDeps android.Paths
|
|
|
|
// 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
|
2016-04-20 23:21:14 +02:00
|
|
|
|
2016-07-09 09:14:08 +02:00
|
|
|
Flags, ReexportedFlags []string
|
2016-09-29 21:13:36 +02:00
|
|
|
ReexportedFlagsDeps 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
|
2017-09-19 08:19:12 +02:00
|
|
|
LinkerScript android.OptionalPath
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
type Flags struct {
|
2017-06-15 23:45:18 +02:00
|
|
|
GlobalFlags []string // Flags that apply to C, C++, and assembly source files
|
|
|
|
ArFlags []string // Flags that apply to ar
|
|
|
|
AsFlags []string // Flags that apply to assembly source files
|
|
|
|
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
|
|
|
|
YaccFlags []string // Flags that apply to Yacc source files
|
|
|
|
protoFlags []string // Flags that apply to proto source files
|
|
|
|
aidlFlags []string // Flags that apply to aidl source files
|
|
|
|
rsFlags []string // Flags that apply to renderscript source files
|
|
|
|
LdFlags []string // Flags that apply to linker command lines
|
|
|
|
libFlags []string // Flags to add libraries early to the link order
|
|
|
|
TidyFlags []string // Flags that apply to clang-tidy
|
|
|
|
SAbiFlags []string // Flags that apply to header-abi-dumper
|
|
|
|
YasmFlags []string // Flags that apply to yasm assembly source files
|
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
|
|
|
|
// These must be after any module include flags, which will be in GlobalFlags.
|
|
|
|
SystemIncludeFlags []string
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
Toolchain config.Toolchain
|
2015-04-22 22:07:53 +02:00
|
|
|
Clang bool
|
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
|
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
|
|
|
|
|
|
|
GroupStaticLibs bool
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
2016-04-11 23:37:39 +02:00
|
|
|
type ObjectLinkerProperties struct {
|
|
|
|
// names of other cc_object modules to link into this module using partial linking
|
|
|
|
Objs []string `android:"arch_variant"`
|
2017-09-19 07:47:20 +02:00
|
|
|
|
|
|
|
// if set, add an extra objcopy --prefix-symbols= step
|
|
|
|
Prefix_symbols string
|
2016-04-11 23:37:39 +02:00
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
// Properties used to compile all C or C++ modules
|
|
|
|
type BaseProperties struct {
|
|
|
|
// compile module with clang instead of gcc
|
|
|
|
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
|
|
|
|
Sdk_version string
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
// don't insert default compiler flags into asflags, cflags,
|
|
|
|
// cppflags, conlyflags, ldflags, or include_dirs
|
|
|
|
No_default_compiler_flags *bool
|
2016-04-12 00:06:20 +02:00
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
|
|
|
HideFromMake bool `blueprint:"mutated"`
|
|
|
|
PreventInstall bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
UseVndk bool `blueprint:"mutated"`
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type UnusedProperties struct {
|
2017-02-10 01:16:31 +01:00
|
|
|
Tags []string
|
2015-11-03 01:43:11 +01:00
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
type ModuleContextIntf interface {
|
|
|
|
static() bool
|
|
|
|
staticBinary() bool
|
|
|
|
clang() bool
|
2016-07-29 22:44:28 +02:00
|
|
|
toolchain() config.Toolchain
|
2016-01-04 23:34:37 +01:00
|
|
|
noDefaultCompilerFlags() bool
|
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
|
2017-06-23 12:24:43 +02:00
|
|
|
isVndk() bool
|
|
|
|
isVndkSp() bool
|
2017-02-08 22:45:53 +01:00
|
|
|
createVndkSourceAbiDump() bool
|
2016-03-31 06:00:30 +02:00
|
|
|
selectedStl() string
|
2016-10-07 01:12:58 +02:00
|
|
|
baseModuleName() string
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleContext interface {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.ModuleContext
|
2016-01-04 23:34:37 +01:00
|
|
|
ModuleContextIntf
|
|
|
|
}
|
|
|
|
|
|
|
|
type BaseModuleContext interface {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.BaseContext
|
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
|
2016-08-01 22:20:05 +02:00
|
|
|
compilerFlags(ctx ModuleContext, flags Flags) Flags
|
|
|
|
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{}
|
|
|
|
|
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)
|
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
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
type dependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
name string
|
|
|
|
library bool
|
2016-06-07 03:22:19 +02:00
|
|
|
|
|
|
|
reexportFlags bool
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2016-09-29 02:34:58 +02:00
|
|
|
sharedDepTag = dependencyTag{name: "shared", library: true}
|
|
|
|
sharedExportDepTag = dependencyTag{name: "shared", library: true, reexportFlags: true}
|
|
|
|
lateSharedDepTag = dependencyTag{name: "late shared", library: true}
|
|
|
|
staticDepTag = dependencyTag{name: "static", library: 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}
|
2016-12-15 16:39:51 +01:00
|
|
|
headerDepTag = dependencyTag{name: "header", library: true}
|
|
|
|
headerExportDepTag = dependencyTag{name: "header", library: true, reexportFlags: true}
|
2016-09-29 02:34:58 +02:00
|
|
|
genSourceDepTag = dependencyTag{name: "gen source"}
|
|
|
|
genHeaderDepTag = dependencyTag{name: "gen header"}
|
|
|
|
genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true}
|
|
|
|
objDepTag = dependencyTag{name: "obj"}
|
|
|
|
crtBeginDepTag = dependencyTag{name: "crtbegin"}
|
|
|
|
crtEndDepTag = dependencyTag{name: "crtend"}
|
2017-09-19 08:19:12 +02:00
|
|
|
linkerScriptDepTag = dependencyTag{name: "linker script"}
|
2016-09-29 02:34:58 +02:00
|
|
|
reuseObjTag = dependencyTag{name: "reuse objects"}
|
|
|
|
ndkStubDepTag = dependencyTag{name: "ndk stub", library: true}
|
|
|
|
ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true}
|
2016-04-12 00:06:20 +02:00
|
|
|
)
|
|
|
|
|
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
|
2015-04-25 02:31:52 +02:00
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
Properties BaseProperties
|
|
|
|
VendorProperties VendorProperties
|
|
|
|
unused UnusedProperties
|
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
|
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
|
|
|
|
// line invocation. staticDepsInLinkOrder stores the proper ordering of all of the transitive
|
|
|
|
// deps of this module
|
|
|
|
staticDepsInLinkOrder android.Paths
|
2015-03-17 23:06:21 +01:00
|
|
|
}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
func (c *Module) Init() android.Module {
|
2017-09-14 03:37:08 +02:00
|
|
|
c.AddProperties(&c.Properties, &c.VendorProperties, &c.unused)
|
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()...)
|
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
for _, feature := range c.features {
|
2017-06-24 00:06:31 +02:00
|
|
|
c.AddProperties(feature.props()...)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2015-03-17 23:06:21 +01:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
2015-03-17 23:06:21 +01:00
|
|
|
|
2017-07-07 23:33:33 +02:00
|
|
|
android.InitDefaultableModule(c)
|
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
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
func (c *Module) useVndk() bool {
|
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
|
|
|
return c.Properties.UseVndk
|
|
|
|
}
|
|
|
|
|
2017-06-23 12:24:43 +02:00
|
|
|
func (c *Module) isVndk() bool {
|
|
|
|
if c.vndkdep != nil {
|
|
|
|
return c.vndkdep.isVndk()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-08-16 07:05:54 +02:00
|
|
|
// Returns true only when this module is configured to have core and vendor
|
|
|
|
// variants.
|
|
|
|
func (c *Module) hasVendorVariant() bool {
|
|
|
|
return c.isVndk() || Bool(c.VendorProperties.Vendor_available)
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
type baseModuleContext struct {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.BaseContext
|
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-09-28 02:01:44 +02:00
|
|
|
func (ctx *moduleContext) InstallOnVendorPartition() bool {
|
|
|
|
return ctx.ModuleContext.InstallOnVendorPartition() || (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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) clang() bool {
|
|
|
|
return ctx.mod.clang(ctx.ctx)
|
|
|
|
}
|
|
|
|
|
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 {
|
2016-07-30 02:28:03 +02:00
|
|
|
if static, ok := ctx.mod.linker.(interface {
|
|
|
|
static() bool
|
|
|
|
}); ok {
|
|
|
|
return static.static()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
return false
|
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 {
|
2016-07-30 02:28:03 +02:00
|
|
|
if static, ok := ctx.mod.linker.(interface {
|
|
|
|
staticBinary() bool
|
|
|
|
}); ok {
|
|
|
|
return static.staticBinary()
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
return false
|
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) noDefaultCompilerFlags() bool {
|
|
|
|
return Bool(ctx.mod.Properties.No_default_compiler_flags)
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
func (ctx *moduleContextImpl) useSdk() bool {
|
|
|
|
if ctx.ctx.Device() && !ctx.useVndk() {
|
2016-06-07 21:34:45 +02:00
|
|
|
return ctx.mod.Properties.Sdk_version != ""
|
|
|
|
}
|
|
|
|
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() {
|
2017-03-20 02:30:37 +01:00
|
|
|
return "current"
|
2016-11-18 23:54:24 +01:00
|
|
|
} else {
|
|
|
|
return ctx.mod.Properties.Sdk_version
|
|
|
|
}
|
2016-06-07 21:34:45 +02:00
|
|
|
}
|
|
|
|
return ""
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2017-06-23 12:24:43 +02:00
|
|
|
func (ctx *moduleContextImpl) isVndk() bool {
|
|
|
|
return ctx.mod.isVndk()
|
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
func (ctx *moduleContextImpl) useVndk() bool {
|
|
|
|
return ctx.mod.useVndk()
|
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
|
|
|
|
func (ctx *moduleContextImpl) isVndkSp() bool {
|
|
|
|
if vndk := ctx.mod.vndkdep; vndk != nil {
|
|
|
|
return vndk.isVndkSp()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
// Create source abi dumps if the module belongs to the list of VndkLibraries.
|
|
|
|
func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
|
2017-09-28 02:01:44 +02:00
|
|
|
return ctx.ctx.Device() && ((ctx.useVndk() && ctx.isVndk()) || inList(ctx.baseModuleName(), llndkLibraries))
|
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 ""
|
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
func (ctx *moduleContextImpl) baseModuleName() string {
|
|
|
|
return ctx.mod.ModuleBase.BaseModuleName()
|
|
|
|
}
|
|
|
|
|
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{}
|
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
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
func orderDeps(directDeps []android.Path, transitiveDeps map[android.Path][]android.Path) (orderedAllDeps []android.Path, orderedDeclaredDeps []android.Path) {
|
|
|
|
// 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
|
|
|
|
for _, dep := range directDeps {
|
|
|
|
orderedAllDeps = append(orderedAllDeps, dep)
|
|
|
|
orderedAllDeps = append(orderedAllDeps, transitiveDeps[dep]...)
|
|
|
|
}
|
|
|
|
|
2017-10-24 20:13:31 +02:00
|
|
|
orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
|
2017-09-28 02:05:30 +02:00
|
|
|
|
|
|
|
// We don't want to add any new dependencies into directDeps (to allow the caller to
|
|
|
|
// intentionally exclude or replace any unwanted transitive dependencies), so we limit the
|
|
|
|
// resultant list to only what the caller has chosen to include in directDeps
|
|
|
|
_, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directDeps)
|
|
|
|
|
|
|
|
return orderedAllDeps, orderedDeclaredDeps
|
|
|
|
}
|
|
|
|
|
|
|
|
func orderStaticModuleDeps(module *Module, deps []*Module) (results []android.Path) {
|
|
|
|
// make map of transitive dependencies
|
|
|
|
transitiveStaticDepNames := make(map[android.Path][]android.Path, len(deps))
|
|
|
|
for _, dep := range deps {
|
|
|
|
transitiveStaticDepNames[dep.outputFile.Path()] = dep.staticDepsInLinkOrder
|
|
|
|
}
|
|
|
|
// get the output file for each declared dependency
|
|
|
|
depFiles := []android.Path{}
|
|
|
|
for _, dep := range deps {
|
|
|
|
depFiles = append(depFiles, dep.outputFile.Path())
|
|
|
|
}
|
|
|
|
|
|
|
|
// reorder the dependencies based on transitive dependencies
|
|
|
|
module.staticDepsInLinkOrder, results = orderDeps(depFiles, transitiveStaticDepNames)
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
2017-09-28 02:01:44 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
flags := Flags{
|
|
|
|
Toolchain: c.toolchain(ctx),
|
|
|
|
Clang: c.clang(ctx),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
if c.compiler != nil {
|
2016-08-01 22:20:05 +02:00
|
|
|
flags = c.compiler.compilerFlags(ctx, flags)
|
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 {
|
|
|
|
flags = c.coverage.flags(ctx, flags)
|
|
|
|
}
|
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)
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
flags.CFlags, _ = filterList(flags.CFlags, config.IllegalFlags)
|
|
|
|
flags.CppFlags, _ = filterList(flags.CppFlags, config.IllegalFlags)
|
|
|
|
flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags)
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2017-01-11 01:21:22 +01:00
|
|
|
deps := c.depsToPaths(ctx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...)
|
|
|
|
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)
|
|
|
|
}
|
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
|
|
|
|
ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " "))
|
|
|
|
ctx.Variable(pctx, "cppflags", strings.Join(flags.CppFlags, " "))
|
|
|
|
ctx.Variable(pctx, "asflags", strings.Join(flags.AsFlags, " "))
|
|
|
|
flags.CFlags = []string{"$cflags"}
|
|
|
|
flags.CppFlags = []string{"$cppflags"}
|
|
|
|
flags.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
|
|
|
|
}
|
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)
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
if c.installer != nil && !c.Properties.PreventInstall && c.outputFile.Valid() {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
func (c *Module) toolchain(ctx 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())
|
|
|
|
}
|
2016-11-08 23:34:24 +01:00
|
|
|
c.Properties.Sdk_version = 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
|
|
|
}
|
2017-10-05 01:47:29 +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().
|
|
|
|
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)
|
|
|
|
}
|
2017-02-10 01:16:31 +01: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)
|
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{
|
2016-05-19 00:37:25 +02:00
|
|
|
BaseContext: 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
|
|
|
}
|
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|
|
|
if !c.Enabled() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
ctx := &depsContext{
|
|
|
|
BottomUpMutatorContext: actx,
|
2016-08-04 22:02:36 +02:00
|
|
|
moduleContextImpl: moduleContextImpl{
|
|
|
|
mod: c,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
ctx.ctx = ctx
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
deps := c.deps(ctx)
|
2015-04-28 22:30:13 +02:00
|
|
|
|
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
|
|
|
|
rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
|
|
|
|
variantLibs = []string{}
|
|
|
|
nonvariantLibs = []string{}
|
2016-06-18 01:45:24 +02:00
|
|
|
for _, entry := range list {
|
2017-09-28 02:01:44 +02:00
|
|
|
if ctx.useSdk() && inList(entry, ndkPrebuiltSharedLibraries) {
|
2016-06-18 01:45:24 +02:00
|
|
|
if !inList(entry, ndkMigratedLibs) {
|
|
|
|
nonvariantLibs = append(nonvariantLibs, entry+".ndk."+version)
|
|
|
|
} else {
|
|
|
|
variantLibs = append(variantLibs, entry+ndkLibrarySuffix)
|
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
} else if ctx.useVndk() && inList(entry, llndkLibraries) {
|
2017-03-19 21:44:32 +01:00
|
|
|
nonvariantLibs = append(nonvariantLibs, entry+llndkLibrarySuffix)
|
2016-06-18 01:45:24 +02:00
|
|
|
} else {
|
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
|
|
|
|
2016-12-15 16:39:51 +01:00
|
|
|
for _, lib := range deps.HeaderLibs {
|
|
|
|
depTag := headerDepTag
|
|
|
|
if inList(lib, deps.ReexportHeaderLibHeaders) {
|
|
|
|
depTag = headerExportDepTag
|
|
|
|
}
|
|
|
|
actx.AddVariationDependencies(nil, depTag, lib)
|
|
|
|
}
|
2016-12-13 21:50:57 +01:00
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, wholeStaticDepTag,
|
|
|
|
deps.WholeStaticLibs...)
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2016-06-07 03:22:19 +02:00
|
|
|
for _, lib := range deps.StaticLibs {
|
|
|
|
depTag := staticDepTag
|
|
|
|
if inList(lib, deps.ReexportStaticLibHeaders) {
|
|
|
|
depTag = staticExportDepTag
|
|
|
|
}
|
2016-07-14 23:49:58 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, depTag, lib)
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2015-03-24 22:15:58 +01:00
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, lateStaticDepTag,
|
|
|
|
deps.LateStaticLibs...)
|
2015-03-24 22:15:58 +01:00
|
|
|
|
2016-06-07 03:22:19 +02:00
|
|
|
for _, lib := range deps.SharedLibs {
|
|
|
|
depTag := sharedDepTag
|
|
|
|
if inList(lib, deps.ReexportSharedLibHeaders) {
|
|
|
|
depTag = sharedExportDepTag
|
|
|
|
}
|
2016-07-14 23:49:58 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, depTag, lib)
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, lateSharedDepTag,
|
|
|
|
deps.LateSharedLibs...)
|
2016-04-11 23:37:39 +02: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
|
|
|
|
2016-07-08 19:41:41 +02:00
|
|
|
actx.AddDependency(c, objDepTag, deps.ObjFiles...)
|
2016-04-12 00:06:20 +02:00
|
|
|
|
|
|
|
if deps.CrtBegin != "" {
|
2016-07-08 19:41:41 +02:00
|
|
|
actx.AddDependency(c, crtBeginDepTag, deps.CrtBegin)
|
2015-03-24 22:15:58 +01:00
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
if deps.CrtEnd != "" {
|
2016-07-08 19:41:41 +02:00
|
|
|
actx.AddDependency(c, crtEndDepTag, deps.CrtEnd)
|
2015-03-24 22:15:58 +01:00
|
|
|
}
|
2017-09-19 08:19:12 +02:00
|
|
|
if deps.LinkerScript != "" {
|
|
|
|
actx.AddDependency(c, linkerScriptDepTag, deps.LinkerScript)
|
|
|
|
}
|
2016-06-18 01:45:24 +02:00
|
|
|
|
|
|
|
version := ctx.sdkVersion()
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{"ndk_api", version}, {"link", "shared"}}, ndkStubDepTag, variantNdkLibs...)
|
|
|
|
actx.AddVariationDependencies([]blueprint.Variation{
|
|
|
|
{"ndk_api", version}, {"link", "shared"}}, ndkLateStubDepTag, variantLateNdkLibs...)
|
2015-10-29 23:25:03 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-08-04 22:02:36 +02:00
|
|
|
func beginMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
|
|
|
|
c.beginMutator(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:34:37 +01:00
|
|
|
func (c *Module) clang(ctx BaseModuleContext) bool {
|
|
|
|
clang := Bool(c.Properties.Clang)
|
|
|
|
|
|
|
|
if c.Properties.Clang == nil {
|
|
|
|
if ctx.Host() {
|
|
|
|
clang = true
|
|
|
|
}
|
|
|
|
|
|
|
|
if ctx.Device() && ctx.AConfig().DeviceUsesClang() {
|
|
|
|
clang = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !c.toolchain(ctx).ClangSupported() {
|
|
|
|
clang = false
|
|
|
|
}
|
|
|
|
|
|
|
|
return clang
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// Whether a module can link to another module, taking into
|
|
|
|
// account NDK linking.
|
|
|
|
func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) {
|
|
|
|
if from.Target().Os != android.Android {
|
|
|
|
// Host code is not restricted
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if from.Properties.UseVndk {
|
|
|
|
// Though vendor code is limited by the vendor mutator,
|
|
|
|
// each vendor-available module needs to check
|
|
|
|
// link-type for VNDK.
|
|
|
|
if from.vndkdep != nil {
|
|
|
|
from.vndkdep.vndkCheckLinkType(ctx, to)
|
2016-08-03 23:12:14 +02:00
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if from.Properties.Sdk_version == "" {
|
|
|
|
// Platform code can link to anything
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if _, ok := to.linker.(*toolchainLibraryDecorator); ok {
|
|
|
|
// These are always allowed
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if _, ok := to.linker.(*ndkPrebuiltLibraryLinker); ok {
|
|
|
|
// These are allowed, but they don't set sdk_version
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok {
|
|
|
|
// These are allowed, but they don't set sdk_version
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if _, ok := to.linker.(*stubDecorator); ok {
|
|
|
|
// These aren't real libraries, but are the stub shared libraries that are included in
|
|
|
|
// the NDK.
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if to.Properties.Sdk_version == "" {
|
|
|
|
// NDK code linking to platform code is never okay.
|
|
|
|
ctx.ModuleErrorf("depends on non-NDK-built library %q",
|
|
|
|
ctx.OtherModuleName(to))
|
|
|
|
}
|
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
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
if from.Properties.Sdk_version == "current" {
|
|
|
|
// Current can link against anything.
|
|
|
|
return
|
|
|
|
} else if to.Properties.Sdk_version == "current" {
|
|
|
|
// Current can't be linked against by anything else.
|
|
|
|
ctx.ModuleErrorf("links %q built against newer API version %q",
|
|
|
|
ctx.OtherModuleName(to), "current")
|
|
|
|
}
|
2016-08-03 23:12:14 +02:00
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
fromApi, err := strconv.Atoi(from.Properties.Sdk_version)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version",
|
|
|
|
"Invalid sdk_version value (must be int): %q",
|
|
|
|
from.Properties.Sdk_version)
|
|
|
|
}
|
|
|
|
toApi, err := strconv.Atoi(to.Properties.Sdk_version)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version",
|
|
|
|
"Invalid sdk_version value (must be int): %q",
|
|
|
|
to.Properties.Sdk_version)
|
|
|
|
}
|
2016-08-03 23:12:14 +02:00
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
if toApi > fromApi {
|
|
|
|
ctx.ModuleErrorf("links %q built against newer API version %q",
|
|
|
|
ctx.OtherModuleName(to), to.Properties.Sdk_version)
|
2016-06-07 21:34:45 +02:00
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
}
|
2016-06-07 21:34:45 +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
|
|
|
|
2017-09-28 02:05:30 +02:00
|
|
|
directStaticDeps := []*Module{}
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
ccDep, _ := dep.(*Module)
|
|
|
|
if ccDep == nil {
|
|
|
|
// handling for a few module types that aren't cc Module but that are also supported
|
|
|
|
switch depTag {
|
2016-12-14 00:23:47 +01:00
|
|
|
case android.DefaultsDepTag, android.SourceDepTag:
|
2017-09-14 00:46:47 +02:00
|
|
|
// Nothing to do
|
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,
|
|
|
|
genRule.GeneratedSourceFiles()...)
|
2016-11-22 21:55:55 +01:00
|
|
|
flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
|
2016-09-29 02:34:58 +02:00
|
|
|
depPaths.Flags = append(depPaths.Flags, flags)
|
2017-09-28 02:01:44 +02:00
|
|
|
if depTag == genHeaderExportDepTag {
|
2016-09-29 02:34:58 +02:00
|
|
|
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
|
2016-09-29 21:13:36 +02:00
|
|
|
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
|
|
|
|
genRule.GeneratedSourceFiles()...)
|
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.
|
|
|
|
c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
|
|
|
|
|
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
|
|
|
}
|
2017-09-19 08:19:12 +02:00
|
|
|
case linkerScriptDepTag:
|
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 {
|
|
|
|
depPaths.LinkerScript = android.OptionalPathForPath(files[0])
|
|
|
|
} else if len(files) > 1 {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("module %q can only generate a single file if used for a linker script", 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-04-20 23:21:14 +02:00
|
|
|
default:
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("depends on non-cc module %q", depName)
|
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
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
if l, ok := ccDep.compiler.(libraryInterface); ok {
|
2017-05-04 01:24:55 +02:00
|
|
|
objs, flags, deps := l.reuseObjs()
|
2017-05-03 20:01:58 +02:00
|
|
|
depPaths.Objs = depPaths.Objs.Append(objs)
|
|
|
|
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
|
2017-05-04 01:24:55 +02:00
|
|
|
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
|
2016-11-24 00:45:05 +01:00
|
|
|
return
|
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
if t, ok := depTag.(dependencyTag); ok && t.library {
|
|
|
|
if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
|
2016-07-09 09:14:08 +02:00
|
|
|
flags := i.exportedFlags()
|
2016-09-29 21:13:36 +02:00
|
|
|
deps := i.exportedFlagsDeps()
|
2016-07-09 09:14:08 +02:00
|
|
|
depPaths.Flags = append(depPaths.Flags, flags...)
|
2016-09-29 21:13:36 +02:00
|
|
|
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...)
|
2016-06-07 03:22:19 +02:00
|
|
|
|
|
|
|
if t.reexportFlags {
|
2016-07-09 09:14:08 +02:00
|
|
|
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
|
2016-09-29 21:13:36 +02:00
|
|
|
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
|
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.
|
2017-08-24 01:08:29 +02:00
|
|
|
// 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).
|
|
|
|
c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...)
|
2016-06-07 03:22:19 +02:00
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
2016-06-07 21:34:45 +02:00
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
checkLinkType(ctx, c, ccDep)
|
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
|
|
|
|
2017-09-28 02:01:44 +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 {
|
2016-06-18 01:45:24 +02:00
|
|
|
case ndkStubDepTag, sharedDepTag, sharedExportDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
ptr = &depPaths.SharedLibs
|
|
|
|
depPtr = &depPaths.SharedLibsDeps
|
2017-09-28 02:01:44 +02:00
|
|
|
depFile = ccDep.linker.(libraryInterface).toc()
|
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
|
2017-09-28 02:01:44 +02:00
|
|
|
depFile = ccDep.linker.(libraryInterface).toc()
|
2016-06-07 03:22:19 +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
|
2017-09-28 02:01:44 +02:00
|
|
|
staticLib, ok := ccDep.linker.(libraryInterface)
|
2016-07-30 02:28:03 +02:00
|
|
|
if !ok || !staticLib.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
|
|
|
|
2016-04-12 00:06:20 +02:00
|
|
|
if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
|
2017-09-28 02:01:44 +02:00
|
|
|
postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
|
2016-04-12 00:06:20 +02:00
|
|
|
for i := range missingDeps {
|
|
|
|
missingDeps[i] += postfix
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-04-12 00:06:20 +02:00
|
|
|
ctx.AddMissingDependencies(missingDeps)
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
2016-09-27 02:33:01 +02:00
|
|
|
depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
|
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())
|
2016-04-12 00:06:20 +02:00
|
|
|
case crtBeginDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
depPaths.CrtBegin = linkFile
|
2016-04-12 00:06:20 +02:00
|
|
|
case crtEndDepTag:
|
2016-10-01 02:10:16 +02:00
|
|
|
depPaths.CrtEnd = linkFile
|
2016-04-12 00:06:20 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
switch depTag {
|
2017-02-10 01:16:31 +01:00
|
|
|
case staticDepTag, staticExportDepTag, lateStaticDepTag:
|
2017-09-28 02:01:44 +02:00
|
|
|
staticLib, ok := ccDep.linker.(libraryInterface)
|
2017-02-10 01:16:31 +01:00
|
|
|
if !ok || !staticLib.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.
|
2017-02-10 01:16:31 +01:00
|
|
|
depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
|
|
|
|
staticLib.objs().coverageFiles...)
|
2017-02-08 22:45:53 +01:00
|
|
|
depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
|
|
|
|
staticLib.objs().sAbiDumpFiles...)
|
2017-09-28 02:01:44 +02:00
|
|
|
|
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() {
|
2017-09-28 02:01:44 +02:00
|
|
|
ctx.ModuleErrorf("module %q missing output file", 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-09-28 02:01:44 +02:00
|
|
|
// Export the shared libs to Make.
|
|
|
|
switch depTag {
|
2017-07-18 06:23:39 +02:00
|
|
|
case sharedDepTag, sharedExportDepTag, lateSharedDepTag:
|
2017-09-28 02:01:44 +02:00
|
|
|
libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
|
2017-07-18 06:23:39 +02:00
|
|
|
libName = strings.TrimPrefix(libName, "prebuilt_")
|
2017-08-03 14:22:50 +02:00
|
|
|
isLLndk := inList(libName, llndkLibraries)
|
2017-09-28 02:01:44 +02:00
|
|
|
var makeLibName string
|
|
|
|
bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk
|
|
|
|
if c.useVndk() && bothVendorAndCoreVariantsExist {
|
|
|
|
// The vendor module in Make will have been renamed to not conflict with the core
|
|
|
|
// module, so update the dependency name here accordingly.
|
|
|
|
makeLibName = libName + vendorSuffix
|
|
|
|
} else {
|
|
|
|
makeLibName = libName
|
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.
|
|
|
|
c.Properties.AndroidMkSharedLibs = append(c.Properties.AndroidMkSharedLibs, makeLibName)
|
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
|
|
|
|
depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps)...)
|
|
|
|
|
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)
|
2017-08-29 21:28:37 +02:00
|
|
|
depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
|
2017-10-24 20:13:31 +02:00
|
|
|
depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
|
2017-08-29 21:28:37 +02:00
|
|
|
depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps)
|
|
|
|
|
|
|
|
if c.sabi != nil {
|
2017-10-24 20:13:31 +02:00
|
|
|
c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags)
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
func (c *Module) Srcs() android.Paths {
|
|
|
|
if c.outputFile.Valid() {
|
|
|
|
return android.Paths{c.outputFile.Path()}
|
|
|
|
}
|
|
|
|
return android.Paths{}
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
//
|
|
|
|
// Defaults
|
|
|
|
//
|
|
|
|
type Defaults struct {
|
|
|
|
android.ModuleBase
|
2017-07-07 23:33:33 +02:00
|
|
|
android.DefaultsModuleBase
|
2016-01-04 23:34:37 +01:00
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2016-04-20 23:21:14 +02:00
|
|
|
}
|
2016-01-04 23:34:37 +01:00
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
}
|
|
|
|
|
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{},
|
2016-07-30 02:28:03 +02:00
|
|
|
&LibraryProperties{},
|
2016-07-29 21:48:20 +02:00
|
|
|
&FlagExporterProperties{},
|
|
|
|
&BinaryLinkerProperties{},
|
2016-07-30 02:28:03 +02:00
|
|
|
&TestProperties{},
|
|
|
|
&TestBinaryProperties{},
|
2016-07-29 21:48:20 +02:00
|
|
|
&UnusedProperties{},
|
|
|
|
&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{},
|
2016-08-18 23:18:32 +02:00
|
|
|
)
|
2016-04-20 23:21:14 +02:00
|
|
|
|
2017-07-07 23:33:33 +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 (
|
|
|
|
// coreMode is the variant used for framework-private libraries, or
|
|
|
|
// SDK libraries. (which framework-private libraries can use)
|
|
|
|
coreMode = "core"
|
|
|
|
|
|
|
|
// vendorMode is the variant used for /vendor code that compiles
|
|
|
|
// against the VNDK.
|
|
|
|
vendorMode = "vendor"
|
|
|
|
)
|
|
|
|
|
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...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
func vendorMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if mctx.Os() != android.Android {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-09-14 03:37:08 +02:00
|
|
|
if genrule, ok := mctx.Module().(*genrule.Module); ok {
|
|
|
|
if props, ok := genrule.Extra.(*VendorProperties); ok {
|
|
|
|
if !mctx.DeviceConfig().CompileVndk() {
|
|
|
|
mctx.CreateVariations(coreMode)
|
|
|
|
} else if Bool(props.Vendor_available) {
|
|
|
|
mctx.CreateVariations(coreMode, vendorMode)
|
2017-09-28 02:01:44 +02:00
|
|
|
} else if mctx.InstallOnVendorPartition() {
|
2017-09-14 03:37:08 +02:00
|
|
|
mctx.CreateVariations(vendorMode)
|
|
|
|
} else {
|
|
|
|
mctx.CreateVariations(coreMode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
m, ok := mctx.Module().(*Module)
|
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sanity check
|
2017-09-28 02:01:44 +02:00
|
|
|
if m.VendorProperties.Vendor_available != nil && mctx.InstallOnVendorPartition() {
|
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",
|
|
|
|
"doesn't make sense at the same time as `vendor: true` or `proprietary: true`")
|
|
|
|
return
|
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
if vndk := m.vndkdep; vndk != nil {
|
2017-08-16 07:05:54 +02:00
|
|
|
if vndk.isVndk() && m.VendorProperties.Vendor_available == nil {
|
2017-06-23 12:24:43 +02:00
|
|
|
mctx.PropertyErrorf("vndk",
|
2017-08-16 07:05:54 +02:00
|
|
|
"vendor_available must be set to either true or false when `vndk: {enabled: true}`")
|
2017-06-23 12:24:43 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if !vndk.isVndk() && vndk.isVndkSp() {
|
|
|
|
mctx.PropertyErrorf("vndk",
|
|
|
|
"must set `enabled: true` to set `support_system_process: true`")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
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 !mctx.DeviceConfig().CompileVndk() {
|
|
|
|
// If the device isn't compiling against the VNDK, we always
|
|
|
|
// use the core mode.
|
|
|
|
mctx.CreateVariations(coreMode)
|
|
|
|
} 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.
|
|
|
|
mctx.CreateVariations(vendorMode)
|
2017-08-16 07:05:54 +02:00
|
|
|
} else if m.hasVendorVariant() {
|
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.
|
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
|
|
|
mod := mctx.CreateVariations(coreMode, vendorMode)
|
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
|
|
|
vendor := mod[1].(*Module)
|
|
|
|
vendor.Properties.UseVndk = true
|
|
|
|
squashVendorSrcs(vendor)
|
2017-09-28 02:01:44 +02:00
|
|
|
} else if mctx.InstallOnVendorPartition() && m.Properties.Sdk_version == "" {
|
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 /vendor only
|
|
|
|
mod := mctx.CreateVariations(vendorMode)
|
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
|
|
|
vendor := mod[0].(*Module)
|
|
|
|
vendor.Properties.UseVndk = true
|
|
|
|
squashVendorSrcs(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
|
|
|
} 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.
|
|
|
|
mctx.CreateVariations(coreMode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-09 19:21:52 +02:00
|
|
|
func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
|
|
|
|
if ctx.AConfig().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
|
|
|
|
return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
|
|
|
|
}
|
|
|
|
return ctx.AConfig().PlatformSdkVersion()
|
|
|
|
}
|
|
|
|
|
2015-10-29 01:23:31 +01:00
|
|
|
var Bool = proptools.Bool
|