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/bp2build/testing.go b/bp2build/testing.go
index 1f0ada2..2e59999 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -136,11 +136,7 @@
String_list_prop: m.props.String_list_prop,
}
- name := "__bp2build__" + m.Name()
- props := bazel.BazelTargetModuleProperties{
- Name: &name,
- Rule_class: "custom",
- }
+ props := bazel.NewBazelTargetModuleProperties(m.Name(), "custom", "")
ctx.CreateBazelTargetModule(customBazelModuleFactory, props, attrs)
}
@@ -157,28 +153,25 @@
baseName := m.Name()
attrs := &customBazelModuleAttributes{}
- myLibraryName := "__bp2build__" + baseName
- myLibraryProps := bazel.BazelTargetModuleProperties{
- Name: &myLibraryName,
- Rule_class: "my_library",
- Bzl_load_location: "//build/bazel/rules:rules.bzl",
- }
+ myLibraryProps := bazel.NewBazelTargetModuleProperties(
+ baseName,
+ "my_library",
+ "//build/bazel/rules:rules.bzl",
+ )
ctx.CreateBazelTargetModule(customBazelModuleFactory, myLibraryProps, attrs)
- protoLibraryName := "__bp2build__" + baseName + "_proto_library_deps"
- protoLibraryProps := bazel.BazelTargetModuleProperties{
- Name: &protoLibraryName,
- Rule_class: "proto_library",
- Bzl_load_location: "//build/bazel/rules:proto.bzl",
- }
+ protoLibraryProps := bazel.NewBazelTargetModuleProperties(
+ baseName+"_proto_library_deps",
+ "proto_library",
+ "//build/bazel/rules:proto.bzl",
+ )
ctx.CreateBazelTargetModule(customBazelModuleFactory, protoLibraryProps, attrs)
- myProtoLibraryName := "__bp2build__" + baseName + "_my_proto_library_deps"
- myProtoLibraryProps := bazel.BazelTargetModuleProperties{
- Name: &myProtoLibraryName,
- Rule_class: "my_proto_library",
- Bzl_load_location: "//build/bazel/rules:proto.bzl",
- }
+ myProtoLibraryProps := bazel.NewBazelTargetModuleProperties(
+ baseName+"_my_proto_library_deps",
+ "my_proto_library",
+ "//build/bazel/rules:proto.bzl",
+ )
ctx.CreateBazelTargetModule(customBazelModuleFactory, myProtoLibraryProps, attrs)
}
}