bp2build: cc_library converter for //bionic/libdl:libdl_android
This CL contains the converter for libdl_android, a cc_library that
expands into a cc_shared_library and a regular cc_library.
Test: TH
Test: bp2build; bazel test //build/bazel/tests/...
Change-Id: If70641a538211b0d6b2aac0e4d0d06912318304d
diff --git a/bp2build/configurability.go b/bp2build/configurability.go
index b2b3379..97729df 100644
--- a/bp2build/configurability.go
+++ b/bp2build/configurability.go
@@ -69,20 +69,26 @@
return ret, err
}
- // Create the selects for arch specific values.
- selectMap, err := prettyPrintSelectMap(archSelects, "[]", indent)
+ // Convenience function to append selects components to an attribute value.
+ appendSelects := func(selectsData selects, defaultValue, s string) (string, error) {
+ selectMap, err := prettyPrintSelectMap(selectsData, defaultValue, indent)
+ if err != nil {
+ return "", err
+ }
+ if s != "" && selectMap != "" {
+ s += " + "
+ }
+ s += selectMap
+
+ return s, nil
+ }
+
+ ret, err = appendSelects(archSelects, "[]", ret)
if err != nil {
return "", err
}
- ret += selectMap
- // Create the selects for target os specific values.
- selectMap, err = prettyPrintSelectMap(osSelects, "[]", indent)
- if err != nil {
- return "", err
- }
- ret += selectMap
-
+ ret, err = appendSelects(osSelects, "[]", ret)
return ret, err
}
@@ -113,7 +119,7 @@
}
// Create the map.
- ret := " + select({\n"
+ ret := "select({\n"
ret += selects
// default condition comes last.
ret += fmt.Sprintf("%s\"%s\": %s,\n", makeIndent(indent+1), "//conditions:default", defaultValue)