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/bp2build/build_conversion.go b/bp2build/build_conversion.go
index 1fa3e06..2c293ea 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -16,6 +16,7 @@
import (
"android/soong/android"
+ "android/soong/bazel"
"fmt"
"reflect"
"strconv"
@@ -177,7 +178,7 @@
panic(fmt.Errorf("Unknown code-generation mode: %s", codegenMode))
}
- buildFileToTargets[ctx.ModuleDir(m)] = append(buildFileToTargets[dir], t)
+ buildFileToTargets[dir] = append(buildFileToTargets[dir], t)
})
return buildFileToTargets
}
@@ -349,6 +350,13 @@
ret += makeIndent(indent)
ret += "]"
case reflect.Struct:
+ if labels, ok := propertyValue.Interface().(bazel.LabelList); ok {
+ // TODO(b/165114590): convert glob syntax
+ return prettyPrint(reflect.ValueOf(labels.Includes), indent)
+ } else if label, ok := propertyValue.Interface().(bazel.Label); ok {
+ return fmt.Sprintf("%q", label.Label), nil
+ }
+
ret = "{\n"
// Sort and print the struct props by the key.
structProps := extractStructProperties(propertyValue, indent)