diff options
-rw-r--r-- | apex/apex.go | 11 | ||||
-rw-r--r-- | apex/apex_test.go | 21 |
2 files changed, 31 insertions, 1 deletions
diff --git a/apex/apex.go b/apex/apex.go index 07253c1c..dc6ae02b 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -845,10 +845,13 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { // Mark the direct and transitive dependencies of apex bundles so that they // can be built for the apex bundles. func apexDepsMutator(mctx android.TopDownMutatorContext) { + if !mctx.Module().Enabled() { + return + } var apexBundles []android.ApexInfo var directDep bool if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { - apexBundles = []android.ApexInfo{android.ApexInfo{ + apexBundles = []android.ApexInfo{{ ApexName: mctx.ModuleName(), MinSdkVersion: a.minSdkVersion(mctx), }} @@ -886,6 +889,9 @@ func inAnySdk(module android.Module) bool { // Create apex variations if a module is included in APEX(s). func apexMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { am.CreateApexVariations(mctx) } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { @@ -923,6 +929,9 @@ func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsIn } func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } if ab, ok := mctx.Module().(*apexBundle); ok { var variants []string switch proptools.StringDefault(ab.properties.Payload_type, "image") { diff --git a/apex/apex_test.go b/apex/apex_test.go index 2e5a2bdc..35a07c8c 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4085,6 +4085,27 @@ func TestSymlinksFromApexToSystem(t *testing.T) { ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file } +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 TestAppBundle(t *testing.T) { ctx, _ := testApex(t, ` apex { |