1# Copyright 2021 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( 16 "//pw_build:pigweed.bzl", 17 "pw_cc_test", 18 "pw_facade", 19) 20 21package(default_visibility = ["//visibility:public"]) 22 23licenses(["notice"]) 24 25# TODO: pwbug.dev/328679085 - Remove this alias. 26alias( 27 name = "facade", 28 actual = ":pw_assert.facade", 29) 30 31pw_facade( 32 name = "pw_assert", 33 hdrs = [ 34 "public/pw_assert/assert.h", 35 "public/pw_assert/check.h", 36 "public/pw_assert/internal/check_impl.h", 37 "public/pw_assert/short.h", 38 ], 39 backend = ":backend", 40 includes = [ 41 "public", 42 ], 43 deps = [ 44 ":config", 45 "//pw_preprocessor", 46 ], 47) 48 49label_flag( 50 name = "backend", 51 build_setting_default = ":backend_multiplexer", 52) 53 54label_flag( 55 name = "backend_impl", 56 build_setting_default = ":backend_impl_multiplexer", 57 # For internal tooling: go/build-cleaner/troubleshooting-faq#keep-dep 58 tags = ["keep_dep"], 59) 60 61cc_library( 62 name = "config", 63 hdrs = ["public/pw_assert/config.h"], 64 includes = ["public"], 65 deps = [":config_override"], 66) 67 68label_flag( 69 name = "config_override", 70 build_setting_default = "//pw_build:default_module_config", 71) 72 73cc_library( 74 name = "libc_assert", 75 hdrs = [ 76 "libc_assert_public_overrides/assert.h", 77 "libc_assert_public_overrides/cassert", 78 "public/pw_assert/internal/libc_assert.h", 79 ], 80 includes = [ 81 "libc_assert_public_overrides", 82 "public", 83 ], 84 deps = [ 85 "//pw_assert", 86 "//pw_preprocessor", 87 ], 88) 89 90cc_library( 91 name = "assert_compatibility_backend", 92 hdrs = [ 93 "assert_compatibility_public_overrides/pw_assert_backend/assert_backend.h", 94 ], 95 includes = ["assert_compatibility_public_overrides"], 96 deps = ["//pw_preprocessor"], 97) 98 99cc_library( 100 name = "print_and_abort", 101 hdrs = ["public/pw_assert/internal/print_and_abort.h"], 102 includes = ["public"], 103 visibility = ["//visibility:private"], 104 deps = [":config"], 105) 106 107cc_library( 108 name = "print_and_abort_assert_backend", 109 hdrs = ["print_and_abort_assert_public_overrides/pw_assert_backend/assert_backend.h"], 110 includes = ["print_and_abort_assert_public_overrides"], 111 deps = [ 112 ":config", 113 ":print_and_abort", 114 ], 115) 116 117cc_library( 118 name = "print_and_abort_check_backend", 119 hdrs = 120 ["print_and_abort_check_public_overrides/pw_assert_backend/check_backend.h"], 121 includes = ["print_and_abort_check_public_overrides"], 122 deps = [":print_and_abort"], 123) 124 125cc_library( 126 name = "print_and_abort_assert_and_check_backend", 127 deps = [ 128 ":print_and_abort_assert_backend", 129 ":print_and_abort_check_backend", 130 ], 131) 132 133cc_library( 134 name = "backend_multiplexer", 135 visibility = ["@pigweed//targets:__pkg__"], 136 deps = [ 137 "@pigweed//pw_assert_basic", 138 ], 139) 140 141alias( 142 name = "backend_impl_multiplexer", 143 actual = "@pigweed//pw_assert_basic:impl", 144 visibility = ["@pigweed//targets:__pkg__"], 145) 146 147pw_cc_test( 148 name = "assert_facade_test", 149 srcs = [ 150 "assert_facade_test.cc", 151 "assert_test.cc", 152 "fake_backend.cc", 153 "public/pw_assert/internal/check_impl.h", 154 "pw_assert_test/fake_backend.h", 155 ], 156 deps = [ 157 ":facade", 158 "//pw_assert", 159 "//pw_compilation_testing:negative_compilation_testing", 160 "//pw_preprocessor", 161 "//pw_span", 162 "//pw_status", 163 "//pw_string", 164 "//pw_unit_test", 165 ], 166) 167 168pw_cc_test( 169 name = "assert_backend_compile_test", 170 srcs = [ 171 "assert_backend_compile_test.cc", 172 "assert_backend_compile_test_c.c", 173 ], 174 deps = [ 175 "//pw_assert", 176 "//pw_status", 177 "//pw_unit_test", 178 ], 179) 180