bp2build: refactor BazelTargetModule naming boilerplate.

This CL replaces the "__bp2build__" name prefix boilerplate with a props
creation function, and centralizes the prefixing in there.

Test: TH
Test: soong tests
Change-Id: Ic963199ab60dcce0d3361abff111cfa9acd4c21b
diff --git a/android/mutator.go b/android/mutator.go
index 91753d1..c387193 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -16,7 +16,9 @@
 
 import (
 	"android/soong/bazel"
+	"fmt"
 	"reflect"
+	"strings"
 
 	"github.com/google/blueprint"
 	"github.com/google/blueprint/proptools"
@@ -513,6 +515,14 @@
 	factory ModuleFactory,
 	bazelProps bazel.BazelTargetModuleProperties,
 	attrs interface{}) BazelTargetModule {
+	if !strings.HasPrefix(*bazelProps.Name, bazel.BazelTargetModuleNamePrefix) {
+		panic(fmt.Errorf(
+			"bp2build error: the bazel target module name must start with '%s': %s",
+			bazel.BazelTargetModuleNamePrefix,
+			*bazelProps.Name,
+		))
+	}
+
 	return t.CreateModule(factory, &bazelProps, attrs).(BazelTargetModule)
 }