blob: 10b806869b8d186f30bf9f8cca7ecd9543cd6aba [file] [log] [blame]
rosica80442862018-05-28 05:59:33 -07001# Copyright 2018 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Rule that allows select() to differentiate between compilers."""
16
John Cater86e2db72022-02-10 23:27:21 -080017load("//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
rosica80442862018-05-28 05:59:33 -070018
19def _compiler_flag_impl(ctx):
vladmos20a042f2018-06-01 04:51:21 -070020 toolchain = find_cpp_toolchain(ctx)
21 return [config_common.FeatureFlagInfo(value = toolchain.compiler)]
rosica80442862018-05-28 05:59:33 -070022
23compiler_flag = rule(
24 implementation = _compiler_flag_impl,
25 attrs = {
vladmos20a042f2018-06-01 04:51:21 -070026 "_cc_toolchain": attr.label(default = Label("//tools/cpp:current_cc_toolchain")),
27 },
John Cater86e2db72022-02-10 23:27:21 -080028 toolchains = use_cpp_toolchain(),
jcater5672d5d2020-10-01 06:27:58 -070029 incompatible_use_toolchain_transition = True,
rosica80442862018-05-28 05:59:33 -070030)