1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://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, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14"""Helpers for expressing compiler-specific build file logic.""" 15 16def if_compiler_is_clang(then, *, otherwise): 17 return select({ 18 "//pw_toolchain/cc/current_toolchain:compiler_is_clang": then, 19 "@rules_cc//cc/compiler:clang": then, 20 "//conditions:default": otherwise, 21 }) 22 23def if_compiler_is_gcc(then, *, otherwise): 24 return select({ 25 "//pw_toolchain/cc/current_toolchain:compiler_is_gcc": then, 26 "@rules_cc//cc/compiler:gcc": then, 27 "//conditions:default": otherwise, 28 }) 29 30def if_linker_is_clang(then, *, otherwise): 31 return select({ 32 "//pw_toolchain/cc/current_toolchain:linker_is_clang": then, 33 "@rules_cc//cc/compiler:clang": then, 34 "//conditions:default": otherwise, 35 }) 36 37def if_linker_is_gcc(then, *, otherwise): 38 return select({ 39 "//pw_toolchain/cc/current_toolchain:linker_is_gcc": then, 40 "@rules_cc//cc/compiler:gcc": then, 41 "//conditions:default": otherwise, 42 }) 43