Skip to content

Commit

Permalink
pw_assert_trap: Split assert and check backends
Browse files Browse the repository at this point in the history
Bug: 350585010
Bug: 378564135
Change-Id: Ifcfc0b77127791c19078312fdd9700525873b2e7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/261633
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Ted Pudlik <[email protected]>
Reviewed-by: Dave Roth <[email protected]>
Lint: Lint 🤖 <[email protected]>
Docs-Not-Needed: Ted Pudlik <[email protected]>
  • Loading branch information
tpudlik authored and CQ Bot Account committed Jan 22, 2025
1 parent af05593 commit 72565bb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
66 changes: 33 additions & 33 deletions pw_assert_trap/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,6 @@ cc_library(
strip_include_prefix = "public",
)

# Note: to avoid circular dependencies, this target only includes the headers
# for pw_assert_trap. The source file and its dependencies are in the separate
# ":impl" target.
#
# If you point //pw_assert:check_backend and //pw_assert:assert_backend to
# //pw_assert_trap, then //pw_assert:check_backend_impl and
# //pw_assert:assert_backend_impl should point to //pw_assert_trap:impl.
cc_library(
name = "pw_assert_trap",
hdrs = [
"assert_public_overrides/pw_assert_backend/assert_backend.h",
"check_public_overrides/pw_assert_backend/check_backend.h",
"public/pw_assert_trap/assert_trap.h",
"public/pw_assert_trap/check_trap.h",
],
includes = [
"assert_public_overrides",
"check_public_overrides",
"public",
],
deps = [
":handler",
"//pw_assert:check.facade",
"//pw_preprocessor",
],
)

cc_library(
name = "handler",
hdrs = [
Expand Down Expand Up @@ -97,8 +70,20 @@ cc_library(
name = "assert_backend",
hdrs = [
"assert_public_overrides/pw_assert_backend/assert_backend.h",
"public/pw_assert_trap/assert_tokenized.h",
],
strip_include_prefix = "assert_public_overrides",
deps = [
":assert_backend_private",
],
)

cc_library(
name = "assert_backend_private",
hdrs = [
"public/pw_assert_trap/assert_trap.h",
],
strip_include_prefix = "public",
visibility = ["//visibility:private"],
deps = [
":handler",
],
Expand All @@ -108,8 +93,20 @@ cc_library(
name = "check_backend",
hdrs = [
"check_public_overrides/pw_assert_backend/check_backend.h",
"public/pw_assert_trap/check_tokenized.h",
],
strip_include_prefix = "check_public_overrides",
deps = [
":check_backend_private",
],
)

cc_library(
name = "check_backend_private",
hdrs = [
"public/pw_assert_trap/check_trap.h",
],
strip_include_prefix = "public",
visibility = ["//visibility:private"],
deps = [
":handler",
],
Expand Down Expand Up @@ -144,12 +141,15 @@ pw_cc_test(
srcs = [
"trap_handler_test.cc",
],
# TODO: https://pwbug.dev/351889230 - this fails when trap is the used
# as the system assert backend, so disable and only run manually.
tags = ["manual"],
# TODO: https://pwbug.dev/351889230 - this test will fail to build on any
# platform that sets the pw_assert backend to //pw_assert_trap. To be safe,
# disable it for any MCU platform. But run it on the host, where the assert
# backend is pw_assert_basic.
target_compatible_with = incompatible_with_mcu(),
deps = [
":check_backend_private",
":impl_test",
":pw_assert_trap",
":message",
],
)

Expand Down
1 change: 0 additions & 1 deletion pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,6 @@ def owners_lint_checks(ctx: PresubmitContext):
INCLUDE_CHECK_EXCEPTIONS = (
# keep-sorted: start
"//pw_assert_log:check_and_assert_backend",
"//pw_assert_trap:pw_assert_trap",
"//pw_async2_basic:dispatcher",
"//pw_async2_epoll:dispatcher",
"//pw_async_basic:fake_dispatcher",
Expand Down
4 changes: 2 additions & 2 deletions targets/rp2040/transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ RP2_SYSTEM_FLAGS = FREERTOS_FLAGS | {
"@pico-sdk//bazel/config:PICO_STDIO_UART": True,
"@pico-sdk//bazel/config:PICO_STDIO_USB": True,
"@pico-sdk//bazel/config:PICO_TOOLCHAIN": "clang",
"@pigweed//pw_assert:assert_backend": str(Label("//pw_assert_trap")),
"@pigweed//pw_assert:assert_backend": str(Label("//pw_assert_trap:assert_backend")),
"@pigweed//pw_assert:assert_backend_impl": str(Label("//pw_assert_trap:impl")),
"@pigweed//pw_assert:check_backend": str(Label("//pw_assert_trap")),
"@pigweed//pw_assert:check_backend": str(Label("//pw_assert_trap:check_backend")),
"@pigweed//pw_assert:check_backend_impl": str(Label("//pw_assert_trap:impl")),
"@pigweed//pw_build:default_module_config": str(Label("//targets/rp2040:pigweed_module_config")),
"@pigweed//pw_cpu_exception:entry_backend": str(Label("//pw_cpu_exception_cortex_m:cpu_exception")),
Expand Down

0 comments on commit 72565bb

Please sign in to comment.