• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
8def 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 = "clang-cl",
18      flag_values = {
19          "@bazel_tools//tools/cpp:compiler": "clang-cl",
20      },
21      visibility = ["//visibility:public"],
22    )
23    native.config_setting(
24      name = "msvc",
25      flag_values = {
26          "@bazel_tools//tools/cpp:compiler": "msvc-cl",
27      },
28      visibility = ["//visibility:public"],
29    )
30  else:
31    native.config_setting(
32      name = "clang-cl",
33      values = {"compiler": "clang-cl"},
34      visibility = ["//visibility:public"],
35    )
36    native.config_setting(
37      name = "msvc",
38      values = {"compiler": "msvc-cl"},
39      visibility = ["//visibility:public"],
40    )
41