in tools/migration/crosstool_to_starlark_lib.go [773:820]
func parseFlagGroup(flagGroup *crosstoolpb.CToolchain_FlagGroup, depth int) (string, error) {
var res []string
if len(flagGroup.GetFlag()) != 0 {
res = append(res, "flags = "+makeStringArr(flagGroup.GetFlag(), depth+1, true))
}
if flagGroup.GetIterateOver() != "" {
res = append(res, fmt.Sprintf("iterate_over = \"%s\"", flagGroup.GetIterateOver()))
}
if len(flagGroup.GetFlagGroup()) != 0 {
flagGroupString, err := parseFlagGroups(flagGroup.GetFlagGroup(), depth+1)
if err != nil {
return "", err
}
res = append(res, "flag_groups = "+flagGroupString)
}
if len(flagGroup.GetExpandIfAllAvailable()) > 1 {
return "", errors.New("Flag group must not have more than one 'expand_if_all_available' field")
}
if len(flagGroup.GetExpandIfAllAvailable()) != 0 {
res = append(res,
fmt.Sprintf(
"expand_if_available = \"%s\"",
flagGroup.GetExpandIfAllAvailable()[0]))
}
if len(flagGroup.GetExpandIfNoneAvailable()) > 1 {
return "", errors.New("Flag group must not have more than one 'expand_if_none_available' field")
}
if len(flagGroup.GetExpandIfNoneAvailable()) != 0 {
res = append(res,
fmt.Sprintf(
"expand_if_not_available = \"%s\"",
flagGroup.GetExpandIfNoneAvailable()[0]))
}
if flagGroup.GetExpandIfTrue() != "" {
res = append(res, fmt.Sprintf("expand_if_true = \"%s\"",
flagGroup.GetExpandIfTrue()))
}
if flagGroup.GetExpandIfFalse() != "" {
res = append(res, fmt.Sprintf("expand_if_false = \"%s\"",
flagGroup.GetExpandIfFalse()))
}
if flagGroup.GetExpandIfEqual() != nil {
res = append(res,
"expand_if_equal = "+parseVariableWithValue(
flagGroup.GetExpandIfEqual(), depth+1))
}
return createObject("flag_group", res, depth), nil
}