126fa459cSmrg# Copyright 2018 Google Inc. All Rights Reserved. 226fa459cSmrg# 326fa459cSmrg# Distributed under MIT license. 426fa459cSmrg# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 526fa459cSmrg 626fa459cSmrg"""Creates config_setting that allows selecting based on 'compiler' value.""" 726fa459cSmrg 826fa459cSmrgdef create_msvc_config(): 926fa459cSmrg # The "do_not_use_tools_cpp_compiler_present" attribute exists to 1026fa459cSmrg # distinguish between older versions of Bazel that do not support 1126fa459cSmrg # "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do. 1226fa459cSmrg # In the future, the only way to select on the compiler will be through 1326fa459cSmrg # flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can 1426fa459cSmrg # be removed. 1526fa459cSmrg if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"): 1626fa459cSmrg native.config_setting( 1726fa459cSmrg name = "msvc", 1826fa459cSmrg flag_values = { 1926fa459cSmrg "@bazel_tools//tools/cpp:compiler": "msvc-cl", 2026fa459cSmrg }, 2126fa459cSmrg visibility = ["//visibility:public"], 2226fa459cSmrg ) 2326fa459cSmrg else: 2426fa459cSmrg native.config_setting( 2526fa459cSmrg name = "msvc", 2626fa459cSmrg values = {"compiler": "msvc-cl"}, 2726fa459cSmrg visibility = ["//visibility:public"], 2826fa459cSmrg ) 29