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
This commit is contained in:
Jiyong Park
2019-10-07 15:47:24 +09:00
parent 8785e55e1c
commit a90ca00786
4 changed files with 66 additions and 5 deletions

View File

@@ -140,14 +140,18 @@ const (
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 @@ func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []blu
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
}