Allow static/shared modules to be disabled per-arch
libz has a case where the static and shared versions of the device
library are supported, but the host shared library must not be defined,
since it would conflict with the system provided version. There's a
separate module 'libz-host' that provides the host shared library
implementation.
So extend the 'static'/'shared' properties to include 'enabled', which
uses arch_variant so that it can be mutated per-arch. It cannot override
a top level 'enabled: false'.
Change-Id: Ia0f1ff31ad77dc4cb148c531b70158e3245031d5
diff --git a/cc/cc.go b/cc/cc.go
index cea8cde..66b7b4f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -360,11 +360,13 @@
type LibraryLinkerProperties struct {
Static struct {
+ Enabled *bool `android:"arch_variant"`
Whole_static_libs []string `android:"arch_variant"`
Static_libs []string `android:"arch_variant"`
Shared_libs []string `android:"arch_variant"`
} `android:"arch_variant"`
Shared struct {
+ Enabled *bool `android:"arch_variant"`
Whole_static_libs []string `android:"arch_variant"`
Static_libs []string `android:"arch_variant"`
Shared_libs []string `android:"arch_variant"`
@@ -1548,6 +1550,21 @@
var _ linker = (*libraryLinker)(nil)
+func (library *libraryLinker) begin(ctx BaseModuleContext) {
+ library.baseLinker.begin(ctx)
+ if library.static() {
+ if library.Properties.Static.Enabled != nil &&
+ !*library.Properties.Static.Enabled {
+ ctx.module().Disable()
+ }
+ } else {
+ if library.Properties.Shared.Enabled != nil &&
+ !*library.Properties.Shared.Enabled {
+ ctx.module().Disable()
+ }
+ }
+}
+
func (library *libraryLinker) props() []interface{} {
props := library.baseLinker.props()
return append(props,