add [static|shared].apex_available to cc_library
apex_available property can be appended differently per the linkage
type. This will be used to restrict certain libs (e.g.
libc_malloc_debug) to an APEX while allowing them to be statically
linkable from platform for testing purpose.
Test: m (apex_test amended)
Change-Id: I6dec23129c5ac93a3ef06fea28f26f240c0ba410
diff --git a/android/apex.go b/android/apex.go
index c548095..d3c0710 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -140,14 +140,18 @@
availableToAnyApex = "//apex_available:anyapex"
)
-func (m *ApexModuleBase) AvailableFor(what string) bool {
- if len(m.ApexProperties.Apex_available) == 0 {
+func CheckAvailableForApex(what string, apex_available []string) bool {
+ if len(apex_available) == 0 {
// apex_available defaults to ["//apex_available:platform", "//apex_available:anyapex"],
// which means 'available to everybody'.
return true
}
- return InList(what, m.ApexProperties.Apex_available) ||
- (what != availableToPlatform && InList(availableToAnyApex, m.ApexProperties.Apex_available))
+ return InList(what, apex_available) ||
+ (what != availableToPlatform && InList(availableToAnyApex, apex_available))
+}
+
+func (m *ApexModuleBase) AvailableFor(what string) bool {
+ return CheckAvailableForApex(what, m.ApexProperties.Apex_available)
}
func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
@@ -166,7 +170,7 @@
m.checkApexAvailableProperty(mctx)
sort.Strings(m.apexVariations)
variations := []string{}
- availableForPlatform := m.AvailableFor(availableToPlatform)
+ availableForPlatform := mctx.Module().(ApexModule).AvailableFor(availableToPlatform)
if availableForPlatform {
variations = append(variations, "") // Original variation for platform
}