apex: remove use_vendor
Should manually cut dependencies instead. Previously, this was used to take advantage of the limited dependencies of variant libs in some APEXes. Fixes: 175318864 Test: m nothing Change-Id: Id559fd1bea5c8b8696cf7ab8acc711a7c3844d14
This commit is contained in:
63
apex/apex.go
63
apex/apex.go
@@ -130,11 +130,6 @@ type apexBundleProperties struct {
|
|||||||
// Default: true.
|
// Default: true.
|
||||||
Compressible *bool
|
Compressible *bool
|
||||||
|
|
||||||
// For native libraries and binaries, use the vendor variant instead of the core (platform)
|
|
||||||
// variant. Default is false. DO NOT use this for APEXes that are installed to the system or
|
|
||||||
// system_ext partition.
|
|
||||||
Use_vendor *bool
|
|
||||||
|
|
||||||
// If set true, VNDK libs are considered as stable libs and are not included in this APEX.
|
// If set true, VNDK libs are considered as stable libs and are not included in this APEX.
|
||||||
// Should be only used in non-system apexes (e.g. vendor: true). Default is false.
|
// Should be only used in non-system apexes (e.g. vendor: true). Default is false.
|
||||||
Use_vndk_as_stable *bool
|
Use_vndk_as_stable *bool
|
||||||
@@ -626,10 +621,7 @@ func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) strin
|
|||||||
var prefix string
|
var prefix string
|
||||||
var vndkVersion string
|
var vndkVersion string
|
||||||
if deviceConfig.VndkVersion() != "" {
|
if deviceConfig.VndkVersion() != "" {
|
||||||
if proptools.Bool(a.properties.Use_vendor) {
|
if a.SocSpecific() || a.DeviceSpecific() {
|
||||||
prefix = cc.VendorVariationPrefix
|
|
||||||
vndkVersion = deviceConfig.PlatformVndkVersion()
|
|
||||||
} else if a.SocSpecific() || a.DeviceSpecific() {
|
|
||||||
prefix = cc.VendorVariationPrefix
|
prefix = cc.VendorVariationPrefix
|
||||||
vndkVersion = deviceConfig.VndkVersion()
|
vndkVersion = deviceConfig.VndkVersion()
|
||||||
} else if a.ProductSpecific() {
|
} else if a.ProductSpecific() {
|
||||||
@@ -648,9 +640,6 @@ func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
// TODO(jiyong): move this kind of checks to GenerateAndroidBuildActions?
|
|
||||||
checkUseVendorProperty(ctx, a)
|
|
||||||
|
|
||||||
// apexBundle is a multi-arch targets module. Arch variant of apexBundle is set to 'common'.
|
// apexBundle is a multi-arch targets module. Arch variant of apexBundle is set to 'common'.
|
||||||
// arch-specific targets are enabled by the compile_multilib setting of the apex bundle. For
|
// arch-specific targets are enabled by the compile_multilib setting of the apex bundle. For
|
||||||
// each target os/architectures, appropriate dependencies are selected by their
|
// each target os/architectures, appropriate dependencies are selected by their
|
||||||
@@ -1185,42 +1174,6 @@ func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkUseVendorProperty checks if the use of `use_vendor` property is allowed for the given APEX.
|
|
||||||
// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
|
|
||||||
// which may cause compatibility issues. (e.g. libbinder) Even though libbinder restricts its
|
|
||||||
// availability via 'apex_available' property and relies on yet another macro
|
|
||||||
// __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules to avoid
|
|
||||||
// similar problems.
|
|
||||||
func checkUseVendorProperty(ctx android.BottomUpMutatorContext, a *apexBundle) {
|
|
||||||
if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) {
|
|
||||||
ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
useVendorAllowListKey = android.NewOnceKey("useVendorAllowList")
|
|
||||||
)
|
|
||||||
|
|
||||||
func useVendorAllowList(config android.Config) []string {
|
|
||||||
return config.Once(useVendorAllowListKey, func() interface{} {
|
|
||||||
return []string{
|
|
||||||
// swcodec uses "vendor" variants for smaller size
|
|
||||||
"com.android.media.swcodec",
|
|
||||||
"test_com.android.media.swcodec",
|
|
||||||
}
|
|
||||||
}).([]string)
|
|
||||||
}
|
|
||||||
|
|
||||||
// setUseVendorAllowListForTest returns a FixturePreparer that overrides useVendorAllowList and
|
|
||||||
// must be called before the first call to useVendorAllowList()
|
|
||||||
func setUseVendorAllowListForTest(allowList []string) android.FixturePreparer {
|
|
||||||
return android.FixtureModifyConfig(func(config android.Config) {
|
|
||||||
config.Once(useVendorAllowListKey, func() interface{} {
|
|
||||||
return allowList
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ android.DepIsInSameApex = (*apexBundle)(nil)
|
var _ android.DepIsInSameApex = (*apexBundle)(nil)
|
||||||
|
|
||||||
// Implements android.DepInInSameApex
|
// Implements android.DepInInSameApex
|
||||||
@@ -1847,13 +1800,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// system libraries.
|
// system libraries.
|
||||||
if !am.DirectlyInAnyApex() {
|
if !am.DirectlyInAnyApex() {
|
||||||
// we need a module name for Make
|
// we need a module name for Make
|
||||||
name := cc.ImplementationModuleNameForMake(ctx)
|
name := cc.ImplementationModuleNameForMake(ctx) + cc.Properties.SubName
|
||||||
|
|
||||||
if !proptools.Bool(a.properties.Use_vendor) {
|
|
||||||
// we don't use subName(.vendor) for a "use_vendor: true" apex
|
|
||||||
// which is supposed to be installed in /system
|
|
||||||
name += cc.Properties.SubName
|
|
||||||
}
|
|
||||||
if !android.InList(name, a.requiredDeps) {
|
if !android.InList(name, a.requiredDeps) {
|
||||||
a.requiredDeps = append(a.requiredDeps, name)
|
a.requiredDeps = append(a.requiredDeps, name)
|
||||||
}
|
}
|
||||||
@@ -2026,7 +1973,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// the same library in the system partition, thus effectively sharing the same libraries
|
// the same library in the system partition, thus effectively sharing the same libraries
|
||||||
// across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
|
// across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
|
||||||
// in the APEX.
|
// in the APEX.
|
||||||
a.linkToSystemLib = !ctx.Config().UnbundledBuild() && a.installable() && !proptools.Bool(a.properties.Use_vendor)
|
a.linkToSystemLib = !ctx.Config().UnbundledBuild() && a.installable()
|
||||||
|
|
||||||
// APEXes targeting other than system/system_ext partitions use vendor/product variants.
|
// APEXes targeting other than system/system_ext partitions use vendor/product variants.
|
||||||
// So we can't link them to /system/lib libs which are core variants.
|
// So we can't link them to /system/lib libs which are core variants.
|
||||||
@@ -2214,10 +2161,6 @@ func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) {
|
|||||||
if a.testApex || a.vndkApex {
|
if a.testApex || a.vndkApex {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Meaningless to check min_sdk_version when building use_vendor modules against non-Trebleized targets
|
|
||||||
if proptools.Bool(a.properties.Use_vendor) && ctx.DeviceConfig().VndkVersion() == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// apexBundle::minSdkVersion reports its own errors.
|
// apexBundle::minSdkVersion reports its own errors.
|
||||||
minSdkVersion := a.minSdkVersion(ctx)
|
minSdkVersion := a.minSdkVersion(ctx)
|
||||||
android.CheckMinSdkVersion(a, ctx, minSdkVersion)
|
android.CheckMinSdkVersion(a, ctx, minSdkVersion)
|
||||||
|
@@ -1326,7 +1326,6 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
|
|||||||
apex {
|
apex {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
key: "myapex.key",
|
key: "myapex.key",
|
||||||
use_vendor: true,
|
|
||||||
native_shared_libs: ["mylib"],
|
native_shared_libs: ["mylib"],
|
||||||
updatable: false,
|
updatable: false,
|
||||||
`+tc.minSdkVersion+`
|
`+tc.minSdkVersion+`
|
||||||
@@ -1363,7 +1362,6 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
|
|||||||
symbol_file: "",
|
symbol_file: "",
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
setUseVendorAllowListForTest([]string{"myapex"}),
|
|
||||||
withUnbundledBuild,
|
withUnbundledBuild,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1377,13 +1375,13 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
|
|||||||
ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
|
ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
|
||||||
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libbar.so")
|
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libbar.so")
|
||||||
|
|
||||||
mylibLdFlags := ctx.ModuleForTests("mylib", "android_vendor.29_arm64_armv8-a_shared_"+tc.apexVariant).Rule("ld").Args["libFlags"]
|
mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_"+tc.apexVariant).Rule("ld").Args["libFlags"]
|
||||||
ensureContains(t, mylibLdFlags, "libbar/android_vendor.29_arm64_armv8-a_shared_"+tc.shouldLink+"/libbar.so")
|
ensureContains(t, mylibLdFlags, "libbar/android_arm64_armv8-a_shared_"+tc.shouldLink+"/libbar.so")
|
||||||
for _, ver := range tc.shouldNotLink {
|
for _, ver := range tc.shouldNotLink {
|
||||||
ensureNotContains(t, mylibLdFlags, "libbar/android_vendor.29_arm64_armv8-a_shared_"+ver+"/libbar.so")
|
ensureNotContains(t, mylibLdFlags, "libbar/android_arm64_armv8-a_shared_"+ver+"/libbar.so")
|
||||||
}
|
}
|
||||||
|
|
||||||
mylibCFlags := ctx.ModuleForTests("mylib", "android_vendor.29_arm64_armv8-a_static_"+tc.apexVariant).Rule("cc").Args["cFlags"]
|
mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_"+tc.apexVariant).Rule("cc").Args["cFlags"]
|
||||||
ver := tc.shouldLink
|
ver := tc.shouldLink
|
||||||
if tc.shouldLink == "current" {
|
if tc.shouldLink == "current" {
|
||||||
ver = strconv.Itoa(android.FutureApiLevelInt)
|
ver = strconv.Itoa(android.FutureApiLevelInt)
|
||||||
@@ -2375,119 +2373,6 @@ func TestFilesInSubDirWhenNativeBridgeEnabled(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUseVendor(t *testing.T) {
|
|
||||||
ctx := testApex(t, `
|
|
||||||
apex {
|
|
||||||
name: "myapex",
|
|
||||||
key: "myapex.key",
|
|
||||||
native_shared_libs: ["mylib"],
|
|
||||||
use_vendor: true,
|
|
||||||
updatable: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
apex_key {
|
|
||||||
name: "myapex.key",
|
|
||||||
public_key: "testkey.avbpubkey",
|
|
||||||
private_key: "testkey.pem",
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_library {
|
|
||||||
name: "mylib",
|
|
||||||
srcs: ["mylib.cpp"],
|
|
||||||
shared_libs: ["mylib2"],
|
|
||||||
system_shared_libs: [],
|
|
||||||
vendor_available: true,
|
|
||||||
stl: "none",
|
|
||||||
apex_available: [ "myapex" ],
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_library {
|
|
||||||
name: "mylib2",
|
|
||||||
srcs: ["mylib.cpp"],
|
|
||||||
system_shared_libs: [],
|
|
||||||
vendor_available: true,
|
|
||||||
stl: "none",
|
|
||||||
apex_available: [ "myapex" ],
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
setUseVendorAllowListForTest([]string{"myapex"}),
|
|
||||||
)
|
|
||||||
|
|
||||||
inputsList := []string{}
|
|
||||||
for _, i := range ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().BuildParamsForTests() {
|
|
||||||
for _, implicit := range i.Implicits {
|
|
||||||
inputsList = append(inputsList, implicit.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inputsString := strings.Join(inputsList, " ")
|
|
||||||
|
|
||||||
// ensure that the apex includes vendor variants of the direct and indirect deps
|
|
||||||
ensureContains(t, inputsString, "android_vendor.29_arm64_armv8-a_shared_apex10000/mylib.so")
|
|
||||||
ensureContains(t, inputsString, "android_vendor.29_arm64_armv8-a_shared_apex10000/mylib2.so")
|
|
||||||
|
|
||||||
// ensure that the apex does not include core variants
|
|
||||||
ensureNotContains(t, inputsString, "android_arm64_armv8-a_shared_apex10000/mylib.so")
|
|
||||||
ensureNotContains(t, inputsString, "android_arm64_armv8-a_shared_apex10000/mylib2.so")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUseVendorNotAllowedForSystemApexes(t *testing.T) {
|
|
||||||
testApexError(t, `module "myapex" .*: use_vendor: not allowed`, `
|
|
||||||
apex {
|
|
||||||
name: "myapex",
|
|
||||||
key: "myapex.key",
|
|
||||||
use_vendor: true,
|
|
||||||
}
|
|
||||||
apex_key {
|
|
||||||
name: "myapex.key",
|
|
||||||
public_key: "testkey.avbpubkey",
|
|
||||||
private_key: "testkey.pem",
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
setUseVendorAllowListForTest([]string{""}),
|
|
||||||
)
|
|
||||||
// no error with allow list
|
|
||||||
testApex(t, `
|
|
||||||
apex {
|
|
||||||
name: "myapex",
|
|
||||||
key: "myapex.key",
|
|
||||||
use_vendor: true,
|
|
||||||
updatable: false,
|
|
||||||
}
|
|
||||||
apex_key {
|
|
||||||
name: "myapex.key",
|
|
||||||
public_key: "testkey.avbpubkey",
|
|
||||||
private_key: "testkey.pem",
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
setUseVendorAllowListForTest([]string{"myapex"}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUseVendorFailsIfNotVendorAvailable(t *testing.T) {
|
|
||||||
testApexError(t, `dependency "mylib" of "myapex" missing variant:\n.*image:vendor`, `
|
|
||||||
apex {
|
|
||||||
name: "myapex",
|
|
||||||
key: "myapex.key",
|
|
||||||
native_shared_libs: ["mylib"],
|
|
||||||
use_vendor: true,
|
|
||||||
updatable: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
apex_key {
|
|
||||||
name: "myapex.key",
|
|
||||||
public_key: "testkey.avbpubkey",
|
|
||||||
private_key: "testkey.pem",
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_library {
|
|
||||||
name: "mylib",
|
|
||||||
srcs: ["mylib.cpp"],
|
|
||||||
system_shared_libs: [],
|
|
||||||
stl: "none",
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestVendorApex(t *testing.T) {
|
func TestVendorApex(t *testing.T) {
|
||||||
ctx := testApex(t, `
|
ctx := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
@@ -2662,41 +2547,6 @@ func TestApex_withPrebuiltFirmware(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAndroidMk_UseVendorRequired(t *testing.T) {
|
|
||||||
ctx := testApex(t, `
|
|
||||||
apex {
|
|
||||||
name: "myapex",
|
|
||||||
key: "myapex.key",
|
|
||||||
use_vendor: true,
|
|
||||||
native_shared_libs: ["mylib"],
|
|
||||||
updatable: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
apex_key {
|
|
||||||
name: "myapex.key",
|
|
||||||
public_key: "testkey.avbpubkey",
|
|
||||||
private_key: "testkey.pem",
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_library {
|
|
||||||
name: "mylib",
|
|
||||||
vendor_available: true,
|
|
||||||
apex_available: ["myapex"],
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
setUseVendorAllowListForTest([]string{"myapex"}),
|
|
||||||
)
|
|
||||||
|
|
||||||
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
|
||||||
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
|
|
||||||
name := apexBundle.BaseModuleName()
|
|
||||||
prefix := "TARGET_"
|
|
||||||
var builder strings.Builder
|
|
||||||
data.Custom(&builder, name, prefix, "", data)
|
|
||||||
androidMk := builder.String()
|
|
||||||
ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += libc libm libdl\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAndroidMk_VendorApexRequired(t *testing.T) {
|
func TestAndroidMk_VendorApexRequired(t *testing.T) {
|
||||||
ctx := testApex(t, `
|
ctx := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
|
2
cc/cc.go
2
cc/cc.go
@@ -2632,8 +2632,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
if lib := moduleLibraryInterface(dep); lib.buildStubs() && c.UseVndk() { // LLNDK
|
if lib := moduleLibraryInterface(dep); lib.buildStubs() && c.UseVndk() { // LLNDK
|
||||||
if !apexInfo.IsForPlatform() {
|
if !apexInfo.IsForPlatform() {
|
||||||
// For platform libraries, use current version of LLNDK
|
// For platform libraries, use current version of LLNDK
|
||||||
// If this is for use_vendor apex we will apply the same rules
|
|
||||||
// of apex sdk enforcement below to choose right version.
|
|
||||||
useStubs = true
|
useStubs = true
|
||||||
}
|
}
|
||||||
} else if apexInfo.IsForPlatform() {
|
} else if apexInfo.IsForPlatform() {
|
||||||
|
Reference in New Issue
Block a user