1# Copyright 2022 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 15load("@bazel_skylib//rules:common_settings.bzl", "string_flag") 16load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 17 18package(default_visibility = ["//visibility:public"]) 19 20licenses(["notice"]) 21 22# One specific flavor of duct tape for now. 23string_flag( 24 name = "cortex-m_toolchain_kind", 25 build_setting_default = "gcc", 26 values = [ 27 "clang", 28 "gcc", 29 ], 30) 31 32config_setting( 33 name = "use_clang_for_cortex-m", 34 flag_values = {":cortex-m_toolchain_kind": "clang"}, 35) 36 37alias( 38 name = "cortex-m_cc_toolchain", 39 actual = select({ 40 ":use_clang_for_cortex-m": "//pw_toolchain/arm_clang:arm_clang_toolchain_cortex-m", 41 "//conditions:default": "//pw_toolchain/arm_gcc:arm_gcc_toolchain_cortex-m", 42 }), 43) 44 45# This is an interim solution to allow flag-based toolchain selection. 46# Do not rely on this, as it is likely to change. 47toolchain( 48 name = "cc_toolchain_cortex-m0", 49 target_compatible_with = [ 50 "@pw_toolchain//constraints/arm_mcpu:cortex-m0", 51 ], 52 toolchain = ":cortex-m_cc_toolchain", 53 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", 54) 55 56toolchain( 57 name = "cc_toolchain_cortex-m0plus", 58 target_compatible_with = [ 59 "@pw_toolchain//constraints/arm_mcpu:cortex-m0plus", 60 ], 61 toolchain = ":cortex-m_cc_toolchain", 62 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", 63) 64 65toolchain( 66 name = "cc_toolchain_cortex-m33", 67 target_compatible_with = [ 68 "@pw_toolchain//constraints/arm_mcpu:cortex-m33", 69 ], 70 toolchain = ":cortex-m_cc_toolchain", 71 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", 72) 73 74cc_library( 75 name = "no_destructor", 76 hdrs = ["public/pw_toolchain/no_destructor.h"], 77 strip_include_prefix = "public", 78) 79 80pw_cc_test( 81 name = "no_destructor_test", 82 srcs = ["no_destructor_test.cc"], 83 deps = [ 84 ":no_destructor", 85 "//pw_assert", 86 "//pw_unit_test", 87 ], 88) 89 90cc_library( 91 name = "sibling_cast", 92 hdrs = ["public/pw_toolchain/internal/sibling_cast.h"], 93 strip_include_prefix = "public", 94 visibility = ["//:__subpackages__"], # Restrict to Pigweed 95 deps = ["//pw_compilation_testing:negative_compilation_testing"], 96) 97 98pw_cc_test( 99 name = "sibling_cast_test", 100 srcs = ["sibling_cast_test.cc"], 101 deps = [ 102 ":sibling_cast", 103 "//pw_unit_test", 104 ], 105) 106 107cc_library( 108 name = "wrap_abort", 109 srcs = ["wrap_abort.cc"], 110 linkopts = ["-Wl,--wrap=abort"], 111 deps = ["//pw_assert"], 112 alwayslink = 1, 113) 114 115filegroup( 116 name = "doxygen", 117 srcs = [ 118 "public/pw_toolchain/no_destructor.h", 119 ], 120) 121