Merge "add [static|shared].apex_available to cc_library" am: a4cdb8dd40
am: 090366ef0c
Change-Id: I2644a1cb22eaec6486e2c6ab3f3ffa63fce6c9ef
This commit is contained in:
commit
a98ccc56a4
4 changed files with 66 additions and 5 deletions
|
@ -140,14 +140,18 @@ const (
|
||||||
availableToAnyApex = "//apex_available:anyapex"
|
availableToAnyApex = "//apex_available:anyapex"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *ApexModuleBase) AvailableFor(what string) bool {
|
func CheckAvailableForApex(what string, apex_available []string) bool {
|
||||||
if len(m.ApexProperties.Apex_available) == 0 {
|
if len(apex_available) == 0 {
|
||||||
// apex_available defaults to ["//apex_available:platform", "//apex_available:anyapex"],
|
// apex_available defaults to ["//apex_available:platform", "//apex_available:anyapex"],
|
||||||
// which means 'available to everybody'.
|
// which means 'available to everybody'.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return InList(what, m.ApexProperties.Apex_available) ||
|
return InList(what, apex_available) ||
|
||||||
(what != availableToPlatform && InList(availableToAnyApex, m.ApexProperties.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) {
|
func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
|
||||||
|
@ -166,7 +170,7 @@ func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []blu
|
||||||
m.checkApexAvailableProperty(mctx)
|
m.checkApexAvailableProperty(mctx)
|
||||||
sort.Strings(m.apexVariations)
|
sort.Strings(m.apexVariations)
|
||||||
variations := []string{}
|
variations := []string{}
|
||||||
availableForPlatform := m.AvailableFor(availableToPlatform)
|
availableForPlatform := mctx.Module().(ApexModule).AvailableFor(availableToPlatform)
|
||||||
if availableForPlatform {
|
if availableForPlatform {
|
||||||
variations = append(variations, "") // Original variation for platform
|
variations = append(variations, "") // Original variation for platform
|
||||||
}
|
}
|
||||||
|
|
|
@ -2579,6 +2579,36 @@ func TestApexAvailable(t *testing.T) {
|
||||||
// check that libfoo is created only for the platform
|
// check that libfoo is created only for the platform
|
||||||
ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared_myapex")
|
ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared_myapex")
|
||||||
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared")
|
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared")
|
||||||
|
|
||||||
|
ctx, _ = testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["libfoo"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libfoo",
|
||||||
|
stl: "none",
|
||||||
|
system_shared_libs: [],
|
||||||
|
apex_available: ["myapex"],
|
||||||
|
static: {
|
||||||
|
apex_available: ["//apex_available:platform"],
|
||||||
|
},
|
||||||
|
}`)
|
||||||
|
|
||||||
|
// shared variant of libfoo is only available to myapex
|
||||||
|
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared_myapex")
|
||||||
|
ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared")
|
||||||
|
// but the static variant is available to both myapex and the platform
|
||||||
|
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_static_myapex")
|
||||||
|
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_static")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
|
10
cc/cc.go
10
cc/cc.go
|
@ -2143,6 +2143,16 @@ func (c *Module) IsInstallableToApex() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Module) AvailableFor(what string) bool {
|
||||||
|
if linker, ok := c.linker.(interface {
|
||||||
|
availableFor(string) bool
|
||||||
|
}); ok {
|
||||||
|
return c.ApexModuleBase.AvailableFor(what) || linker.availableFor(what)
|
||||||
|
} else {
|
||||||
|
return c.ApexModuleBase.AvailableFor(what)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Module) installable() bool {
|
func (c *Module) installable() bool {
|
||||||
return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid()
|
return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid()
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,8 @@ type StaticOrSharedProperties struct {
|
||||||
|
|
||||||
Export_shared_lib_headers []string `android:"arch_variant"`
|
Export_shared_lib_headers []string `android:"arch_variant"`
|
||||||
Export_static_lib_headers []string `android:"arch_variant"`
|
Export_static_lib_headers []string `android:"arch_variant"`
|
||||||
|
|
||||||
|
Apex_available []string `android:"arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LibraryMutatedProperties struct {
|
type LibraryMutatedProperties struct {
|
||||||
|
@ -573,6 +575,8 @@ type libraryInterface interface {
|
||||||
|
|
||||||
// Write LOCAL_ADDITIONAL_DEPENDENCIES for ABI diff
|
// Write LOCAL_ADDITIONAL_DEPENDENCIES for ABI diff
|
||||||
androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer)
|
androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer)
|
||||||
|
|
||||||
|
availableFor(string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) getLibName(ctx BaseModuleContext) string {
|
func (library *libraryDecorator) getLibName(ctx BaseModuleContext) string {
|
||||||
|
@ -1134,6 +1138,19 @@ func (library *libraryDecorator) stubsVersion() string {
|
||||||
return library.MutatedProperties.StubsVersion
|
return library.MutatedProperties.StubsVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) availableFor(what string) bool {
|
||||||
|
var list []string
|
||||||
|
if library.static() {
|
||||||
|
list = library.StaticProperties.Static.Apex_available
|
||||||
|
} else if library.shared() {
|
||||||
|
list = library.SharedProperties.Shared.Apex_available
|
||||||
|
}
|
||||||
|
if len(list) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return android.CheckAvailableForApex(what, list)
|
||||||
|
}
|
||||||
|
|
||||||
var versioningMacroNamesListKey = android.NewOnceKey("versioningMacroNamesList")
|
var versioningMacroNamesListKey = android.NewOnceKey("versioningMacroNamesList")
|
||||||
|
|
||||||
func versioningMacroNamesList(config android.Config) *map[string]string {
|
func versioningMacroNamesList(config android.Config) *map[string]string {
|
||||||
|
|
Loading…
Reference in a new issue