apex: Don't run apex mutators if disabled am: 49f6701e9a
am: c080abef85
Change-Id: I897cba2391532ba33b2be9552f1f5eea1198bc3a
This commit is contained in:
11
apex/apex.go
11
apex/apex.go
@@ -846,10 +846,13 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
|
|||||||
// Mark the direct and transitive dependencies of apex bundles so that they
|
// Mark the direct and transitive dependencies of apex bundles so that they
|
||||||
// can be built for the apex bundles.
|
// can be built for the apex bundles.
|
||||||
func apexDepsMutator(mctx android.TopDownMutatorContext) {
|
func apexDepsMutator(mctx android.TopDownMutatorContext) {
|
||||||
|
if !mctx.Module().Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
var apexBundles []android.ApexInfo
|
var apexBundles []android.ApexInfo
|
||||||
var directDep bool
|
var directDep bool
|
||||||
if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
||||||
apexBundles = []android.ApexInfo{android.ApexInfo{
|
apexBundles = []android.ApexInfo{{
|
||||||
ApexName: mctx.ModuleName(),
|
ApexName: mctx.ModuleName(),
|
||||||
MinSdkVersion: a.minSdkVersion(mctx),
|
MinSdkVersion: a.minSdkVersion(mctx),
|
||||||
}}
|
}}
|
||||||
@@ -887,6 +890,9 @@ func inAnySdk(module android.Module) bool {
|
|||||||
|
|
||||||
// Create apex variations if a module is included in APEX(s).
|
// Create apex variations if a module is included in APEX(s).
|
||||||
func apexMutator(mctx android.BottomUpMutatorContext) {
|
func apexMutator(mctx android.BottomUpMutatorContext) {
|
||||||
|
if !mctx.Module().Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
|
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
|
||||||
am.CreateApexVariations(mctx)
|
am.CreateApexVariations(mctx)
|
||||||
} else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
} else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
||||||
@@ -924,6 +930,9 @@ func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
||||||
|
if !mctx.Module().Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if ab, ok := mctx.Module().(*apexBundle); ok {
|
if ab, ok := mctx.Module().(*apexBundle); ok {
|
||||||
var variants []string
|
var variants []string
|
||||||
switch proptools.StringDefault(ab.properties.Payload_type, "image") {
|
switch proptools.StringDefault(ab.properties.Payload_type, "image") {
|
||||||
|
@@ -4205,6 +4205,27 @@ func TestApexWithJniLibs(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApexMutatorsDontRunIfDisabled(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
`, func(fs map[string][]byte, config android.Config) {
|
||||||
|
delete(config.Targets, android.Android)
|
||||||
|
config.AndroidCommonTarget = android.Target{}
|
||||||
|
})
|
||||||
|
|
||||||
|
if expected, got := []string{""}, ctx.ModuleVariantsForTests("myapex"); !reflect.DeepEqual(expected, got) {
|
||||||
|
t.Errorf("Expected variants: %v, but got: %v", expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestApexWithJniLibs_Errors(t *testing.T) {
|
func TestApexWithJniLibs_Errors(t *testing.T) {
|
||||||
testApexError(t, `jni_libs: "xxx" is not a cc_library`, `
|
testApexError(t, `jni_libs: "xxx" is not a cc_library`, `
|
||||||
apex {
|
apex {
|
||||||
|
Reference in New Issue
Block a user