scentini | 664f927 | 2018-08-28 14:10:46 +0200 | [diff] [blame] | 1 | """Creates config_setting that allows selecting based on 'compiler' value.""" |
| 2 | |
Yannic | f0cb9cd | 2020-02-13 22:04:14 +0100 | [diff] [blame] | 3 | def create_compiler_config_setting(name, value, visibility = None): |
scentini | 664f927 | 2018-08-28 14:10:46 +0200 | [diff] [blame] | 4 | # The "do_not_use_tools_cpp_compiler_present" attribute exists to |
| 5 | # distinguish between older versions of Bazel that do not support |
| 6 | # "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do. |
| 7 | # In the future, the only way to select on the compiler will be through |
| 8 | # flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can |
| 9 | # be removed. |
| 10 | if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"): |
| 11 | native.config_setting( |
| 12 | name = name, |
| 13 | flag_values = { |
| 14 | "@bazel_tools//tools/cpp:compiler": value, |
| 15 | }, |
Yannic | f0cb9cd | 2020-02-13 22:04:14 +0100 | [diff] [blame] | 16 | visibility = visibility, |
scentini | 664f927 | 2018-08-28 14:10:46 +0200 | [diff] [blame] | 17 | ) |
| 18 | else: |
| 19 | native.config_setting( |
| 20 | name = name, |
| 21 | values = {"compiler": value}, |
Yannic | f0cb9cd | 2020-02-13 22:04:14 +0100 | [diff] [blame] | 22 | visibility = visibility, |
scentini | 664f927 | 2018-08-28 14:10:46 +0200 | [diff] [blame] | 23 | ) |