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
diff --git a/cc/bp2build.go b/cc/bp2build.go
index eabd814..888c3ba 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -388,7 +388,15 @@
}
cStdVal, cppStdVal = maybeReplaceGnuToC(gnu_extensions, cStdVal, cppStdVal)
- return &cStdVal, &cppStdVal
+ var c_std_prop, cpp_std_prop *string
+ if cStdVal != "" {
+ c_std_prop = &cStdVal
+ }
+ if cppStdVal != "" {
+ cpp_std_prop = &cppStdVal
+ }
+
+ return c_std_prop, cpp_std_prop
}
// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.