bp2build: convert paths/module refs to Bazel label
This currently expands all globs, still need to support converting glob
syntax.
Test: go build_conversion_test
Test: GENERATE_BAZEL_FILES=true m nothing
Test: m nothing
Bug: 165114590
Change-Id: If7b26e8e663d17566fad9614ca87a8da1f095284
diff --git a/android/filegroup.go b/android/filegroup.go
index 3d1bbc5..7a6cc4f 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -29,7 +29,7 @@
// https://docs.bazel.build/versions/master/be/general.html#filegroup
type bazelFilegroupAttributes struct {
Name *string
- Srcs []string
+ Srcs bazel.LabelList
}
type bazelFilegroup struct {
@@ -52,15 +52,18 @@
// TODO: Create helper functions to avoid this boilerplate.
func FilegroupBp2Build(ctx TopDownMutatorContext) {
- if m, ok := ctx.Module().(*fileGroup); ok {
- name := "__bp2build__" + m.base().BaseModuleName()
- ctx.CreateModule(BazelFileGroupFactory, &bazelFilegroupAttributes{
- Name: proptools.StringPtr(name),
- Srcs: m.properties.Srcs,
- }, &bazel.BazelTargetModuleProperties{
- Rule_class: "filegroup",
- })
+ fg, ok := ctx.Module().(*fileGroup)
+ if !ok {
+ return
}
+
+ name := "__bp2build__" + fg.base().BaseModuleName()
+ ctx.CreateModule(BazelFileGroupFactory, &bazelFilegroupAttributes{
+ Name: proptools.StringPtr(name),
+ Srcs: BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs),
+ }, &bazel.BazelTargetModuleProperties{
+ Rule_class: "filegroup",
+ })
}
type fileGroupProperties struct {