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
diff --git a/cc/library.go b/cc/library.go
index e9e796e..0ba7088 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -84,6 +84,16 @@
// 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 @@
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) 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 @@
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 {