Eugene Kliuchnikov | 4b2b2d4 | 2019-04-12 13:57:42 +0200 | [diff] [blame] | 1 | # Copyright 2018 Google Inc. All Rights Reserved. |
| 2 | # |
| 3 | # Distributed under MIT license. |
| 4 | # See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
| 5 | |
| 6 | """Creates config_setting that allows selecting based on 'compiler' value.""" |
| 7 | |
| 8 | def create_msvc_config(): |
| 9 | # The "do_not_use_tools_cpp_compiler_present" attribute exists to |
| 10 | # distinguish between older versions of Bazel that do not support |
| 11 | # "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do. |
| 12 | # In the future, the only way to select on the compiler will be through |
| 13 | # flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can |
| 14 | # be removed. |
| 15 | if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"): |
| 16 | native.config_setting( |
| 17 | name = "msvc", |
| 18 | flag_values = { |
| 19 | "@bazel_tools//tools/cpp:compiler": "msvc-cl", |
| 20 | }, |
| 21 | visibility = ["//visibility:public"], |
| 22 | ) |
| 23 | else: |
| 24 | native.config_setting( |
| 25 | name = "msvc", |
| 26 | values = {"compiler": "msvc-cl"}, |
| 27 | visibility = ["//visibility:public"], |
| 28 | ) |