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