| def declare_flag_choices(flag, choices): |
| """Declares a `config_setting` for each known choice for the provided flag. |
| The name of each config setting uses the name of the `config_setting` is: |
| [flag label name]_[choice] |
| This can be used with select_choice() to map `config_setting`s to values. |
| flag: The flag that guides the declared `config_setting`s. |
| pkg: The package that declare_flag_choices() was declared in. |
| choice_map: A mapping of distinct choices to |
| flag_name = flag.split(":")[1] |
| name = "{}_{}".format(flag_name, choice), |
| flag_values = {flag: choice}, |
| def flag_choice(flag, pkg, choice_map): |
| """Creates a `select()` based on choices declared by `declare_choices()`. |
| flag: The flag that guides the select. |
| pkg: The package that `declare_flag_choices()` was called in. |
| choice_map: A mapping of distinct choices to the final intended value. |
| for choice, val in choice_map.items() |