summaryrefslogtreecommitdiff
path: root/python/binary.go
diff options
context:
space:
mode:
author Liz Kammer <eakammer@google.com> 2021-12-01 10:09:34 -0500
committer Liz Kammer <eakammer@google.com> 2021-12-01 10:14:49 -0500
commit46fb7aba4dd84a1960a94a53b6b561197f722ae2 (patch)
treeca827ae7f7f40c96cf74a19cd1c04e084805f49c /python/binary.go
parent7c721018bba97bd2134b35ca8b851478530f2953 (diff)
Support empty strings in bp2build
Previously, could not set an empty string as a value of an attribute; however, this is necessary in some cases. To not unnecessarily create an empty string, use string pointers for attributes rather than strings. Test: go test bp2build tests Change-Id: I03b3a3567452d455246d22d81f86c317d06b7c39
Diffstat (limited to 'python/binary.go')
-rw-r--r--python/binary.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/python/binary.go b/python/binary.go
index bf6167c3c..af02de63d 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -35,10 +35,10 @@ func registerPythonBinaryComponents(ctx android.RegistrationContext) {
}
type bazelPythonBinaryAttributes struct {
- Main string
+ Main *string
Srcs bazel.LabelListAttribute
Deps bazel.LabelListAttribute
- Python_version string
+ Python_version *string
}
func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
@@ -52,12 +52,12 @@ func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
return
}
- var main string
+ var main *string
for _, propIntf := range m.GetProperties() {
if props, ok := propIntf.(*BinaryProperties); ok {
// main is optional.
if props.Main != nil {
- main = *props.Main
+ main = props.Main
break
}
}
@@ -69,13 +69,13 @@ func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
// under Bionic.
py3Enabled := proptools.BoolDefault(m.properties.Version.Py3.Enabled, false)
py2Enabled := proptools.BoolDefault(m.properties.Version.Py2.Enabled, false)
- var python_version string
+ var python_version *string
if py3Enabled && py2Enabled {
panic(fmt.Errorf(
"error for '%s' module: bp2build's python_binary_host converter does not support "+
"converting a module that is enabled for both Python 2 and 3 at the same time.", m.Name()))
} else if py2Enabled {
- python_version = "PY2"
+ python_version = &pyVersion2
} else {
// do nothing, since python_version defaults to PY3.
}