1# 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# 8# https://www.apache.org/licenses/LICENSE-2.0 9# 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. 15 16"""Creates config_setting that allows selecting based on 'compiler' value.""" 17 18def create_llvm_config(name, visibility): 19 # 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 ) 39