| # Copyright 2021 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| load("@rules_cc//cc:cc_library.bzl", "cc_library") |
| load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") |
| load("//pw_build:compatibility.bzl", "host_backend_alias", "incompatible_with_mcu") |
| load("//pw_build:pw_facade.bzl", "pw_facade") |
| load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| licenses(["notice"]) |
| |
| # TODO: pwbug.dev/328679085 - Remove this alias. |
| cc_library( |
| name = "facade", |
| deps = [ |
| ":assert.facade", |
| ":check.facade", |
| ], |
| ) |
| |
| label_flag( |
| name = "backend", |
| build_setting_default = ":unspecified_backend", |
| deprecation = "This label flag is no longer depended on by anything and will be removed soon.", |
| tags = ["manual"], |
| ) |
| |
| host_backend_alias( |
| name = "unspecified_backend", |
| backend = "//pw_assert_basic", |
| ) |
| |
| label_flag( |
| name = "backend_impl", |
| build_setting_default = "//pw_assert_basic:impl", |
| # For internal tooling: go/build-cleaner/troubleshooting-faq#keep-dep |
| tags = ["keep_dep"], |
| ) |
| |
| pw_facade( |
| name = "check", |
| hdrs = [ |
| "public/pw_assert/check.h", |
| "public/pw_assert/internal/check_impl.h", |
| "public/pw_assert/short.h", |
| ], |
| backend = ":check_backend", |
| strip_include_prefix = "public", |
| tags = ["noclangtidy"], |
| deps = [ |
| ":config", |
| "//pw_numeric:checked_arithmetic", |
| "//pw_preprocessor", |
| ], |
| ) |
| |
| label_flag( |
| name = "check_backend", |
| build_setting_default = ":unspecified_check_backend", |
| ) |
| |
| host_backend_alias( |
| name = "unspecified_check_backend", |
| backend = ":print_and_abort_check_backend", |
| ) |
| |
| label_flag( |
| name = "check_backend_impl", |
| build_setting_default = ":unspecified_check_backend_impl", |
| ) |
| |
| host_backend_alias( |
| name = "unspecified_check_backend_impl", |
| backend = "@rules_cc//:empty_lib", |
| ) |
| |
| pw_facade( |
| name = "assert", |
| hdrs = [ |
| "public/pw_assert/assert.h", |
| ], |
| backend = ":assert_backend", |
| strip_include_prefix = "public", |
| tags = ["noclangtidy"], |
| deps = [":config"], |
| ) |
| |
| label_flag( |
| name = "assert_backend", |
| build_setting_default = ":unspecified_assert_backend", |
| ) |
| |
| alias( |
| name = "unspecified_assert_backend", |
| actual = select({ |
| # Default backend for MCU build. |
| "@platforms//os:none": ":assert_compatibility_backend", |
| # Default backend for host build. |
| "//conditions:default": ":print_and_abort_assert_backend", |
| }), |
| ) |
| |
| label_flag( |
| name = "assert_backend_impl", |
| build_setting_default = "@rules_cc//:empty_lib", |
| ) |
| |
| cc_library( |
| name = "config", |
| hdrs = ["public/pw_assert/config.h"], |
| strip_include_prefix = "public", |
| deps = [":config_override"], |
| ) |
| |
| label_flag( |
| name = "config_override", |
| build_setting_default = "//pw_build:default_module_config", |
| ) |
| |
| cc_library( |
| name = "libc_assert", |
| hdrs = [ |
| "libc_assert_public_overrides/assert.h", |
| "libc_assert_public_overrides/cassert", |
| ], |
| strip_include_prefix = "libc_assert_public_overrides", |
| deps = [ |
| ":libc_assert_impl", |
| ], |
| ) |
| |
| cc_library( |
| name = "libc_assert_impl", |
| hdrs = [ |
| "public/pw_assert/internal/libc_assert.h", |
| ], |
| strip_include_prefix = "public", |
| visibility = ["//visibility:private"], |
| deps = [ |
| ":assert", |
| "//pw_preprocessor", |
| ], |
| ) |
| |
| cc_library( |
| name = "assert_compatibility_backend", |
| hdrs = [ |
| "assert_compatibility_public_overrides/pw_assert_backend/assert_backend.h", |
| ], |
| strip_include_prefix = "assert_compatibility_public_overrides", |
| deps = ["//pw_preprocessor"], |
| ) |
| |
| cc_library( |
| name = "print_and_abort", |
| hdrs = ["public/pw_assert/internal/print_and_abort.h"], |
| strip_include_prefix = "public", |
| visibility = ["//visibility:private"], |
| deps = [":config"], |
| ) |
| |
| cc_library( |
| name = "print_and_abort_assert_backend", |
| hdrs = ["print_and_abort_assert_public_overrides/pw_assert_backend/assert_backend.h"], |
| strip_include_prefix = "print_and_abort_assert_public_overrides", |
| deps = [ |
| ":config", |
| ":print_and_abort", |
| ], |
| ) |
| |
| cc_library( |
| name = "print_and_abort_check_backend", |
| hdrs = ["print_and_abort_check_public_overrides/pw_assert_backend/check_backend.h"], |
| strip_include_prefix = "print_and_abort_check_public_overrides", |
| deps = [":print_and_abort"], |
| ) |
| |
| cc_library( |
| name = "print_and_abort_assert_and_check_backend", |
| deps = [ |
| ":print_and_abort_assert_backend", |
| ":print_and_abort_check_backend", |
| ], |
| ) |
| |
| pw_cc_test( |
| name = "assert_facade_test", |
| srcs = [ |
| "assert_facade_test.cc", |
| "assert_test.cc", |
| "fake_backend.cc", |
| "public/pw_assert/internal/check_impl.h", |
| "pw_assert_test/fake_backend.h", |
| ], |
| has_nc_test = True, |
| tags = ["noclangtidy"], |
| deps = [ |
| ":assert", |
| ":config", |
| ":facade", |
| "//pw_preprocessor", |
| "//pw_result", |
| "//pw_span", |
| "//pw_status", |
| "//pw_string:builder", |
| ], |
| ) |
| |
| pw_cc_test( |
| name = "assert_backend_compile_test", |
| srcs = [ |
| "assert_backend_compile_test.cc", |
| "assert_backend_compile_test_c.c", |
| ], |
| deps = [ |
| ":assert", |
| ":check", |
| "//pw_status", |
| ], |
| ) |
| |
| # DOCSTAG: [contributing-docs-examples] |
| pw_cc_test( |
| name = "examples", |
| srcs = ["examples.cc"], |
| deps = [":check"], |
| ) |
| |
| sphinx_docs_library( |
| name = "docs", |
| srcs = [ |
| "BUILD.bazel", |
| "BUILD.gn", |
| "CMakeLists.txt", |
| "assert_test.cc", |
| "backends.rst", |
| "docs.rst", |
| "examples.cc", |
| ], |
| prefix = "pw_assert/", |
| target_compatible_with = incompatible_with_mcu(), |
| ) |
| # DOCSTAG: [contributing-docs-examples] |