blob: 66962294d0913e018052b531b232104eb173b414 [file] [log] [blame]
Abseil Team02687952018-07-12 10:34:29 -07001#
2# Copyright 2018 The Abseil Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
nik727338b70432019-03-08 10:27:53 -05008# https://www.apache.org/licenses/LICENSE-2.0
Abseil Team02687952018-07-12 10:34:29 -07009#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Abseil Team02687952018-07-12 10:34:29 -070015
16"""Creates config_setting that allows selecting based on 'compiler' value."""
17
18def create_llvm_config(name, visibility):
Abseil Team88a152a2019-03-08 14:06:50 -080019 # The "do_not_use_tools_cpp_compiler_present" attribute exists to
20 # distinguish between older versions of Bazel that do not support
21 # "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do.
22 # In the future, the only way to select on the compiler will be through
23 # flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
24 # be removed.
25 if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
26 native.config_setting(
27 name = name,
28 flag_values = {
29 "@bazel_tools//tools/cpp:compiler": "llvm",
30 },
31 visibility = visibility,
32 )
33 else:
34 native.config_setting(
35 name = name,
36 values = {"compiler": "llvm"},
37 visibility = visibility,
38 )