aboutsummaryrefslogtreecommitdiffstats
path: root/cc/library.go
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-04-06 12:43:22 -0700
committerDan Willemsen <dwillemsen@google.com>2017-04-11 12:27:41 -0700
commit4416e5db6931629995fcd35c90b295c285be50c8 (patch)
tree556a7a5685f20e311c0b23480423fa67624209af /cc/library.go
parent01a90597bcab97c4dace82a13a32da76875883cb (diff)
downloadbuild_soong-4416e5db6931629995fcd35c90b295c285be50c8.tar.gz
build_soong-4416e5db6931629995fcd35c90b295c285be50c8.tar.bz2
build_soong-4416e5db6931629995fcd35c90b295c285be50c8.zip
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
Diffstat (limited to 'cc/library.go')
-rw-r--r--cc/library.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/cc/library.go b/cc/library.go
index e9e796ed..0ba7088b 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -84,6 +84,16 @@ type FlagExporterProperties struct {
// be added to the include path (using -I) for this module and any module that links
// against this module
Export_include_dirs []string `android:"arch_variant"`
+
+ Target struct {
+ Vendor struct {
+ // list of exported include directories, like
+ // export_include_dirs, that will be applied to the
+ // vendor variant of this library. This will overwrite
+ // any other declarations.
+ Export_include_dirs []string
+ }
+ }
}
func init() {
@@ -144,8 +154,16 @@ type flagExporter struct {
flagsDeps android.Paths
}
+func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
+ if ctx.Vendor() && f.Properties.Target.Vendor.Export_include_dirs != nil {
+ return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Export_include_dirs)
+ } else {
+ return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
+ }
+}
+
func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
- includeDirs := android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
+ includeDirs := f.exportedIncludes(ctx)
for _, dir := range includeDirs.Strings() {
f.flags = append(f.flags, inc+dir)
}
@@ -277,7 +295,7 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla
}
func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
- exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
+ exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
if len(exportIncludeDirs) > 0 {
flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(exportIncludeDirs))
}
@@ -369,7 +387,7 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
} else if library.shared() {
if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
- if !ctx.sdk() && !ctx.vndk() {
+ if !ctx.sdk() {
deps.CrtBegin = "crtbegin_so"
deps.CrtEnd = "crtend_so"
} else {