Add partial bp2build support for APEX targets (second try).
Test: Added unit test
Change-Id: Icbf0475251aac5d1f13bd35a18f90b6c70f3ae29
diff --git a/android/mutator.go b/android/mutator.go
index 365bf29..819dd0f 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -19,6 +19,7 @@
"fmt"
"reflect"
"strings"
+ "sync"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -229,6 +230,9 @@
var bp2buildDepsMutators = []RegisterMutatorFunc{}
var bp2buildMutators = map[string]RegisterMutatorFunc{}
+// See http://b/192523357
+var bp2buildLock sync.Mutex
+
// RegisterBp2BuildMutator registers specially crafted mutators for
// converting Blueprint/Android modules into special modules that can
// be code-generated into Bazel BUILD targets.
@@ -238,6 +242,9 @@
f := func(ctx RegisterMutatorsContext) {
ctx.TopDown(moduleType, m)
}
+ // Use a lock to avoid a concurrent map write if RegisterBp2BuildMutator is called in parallel
+ bp2buildLock.Lock()
+ defer bp2buildLock.Unlock()
bp2buildMutators[moduleType] = f
}