Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 1 | # Copyright 2020 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 | |
Armando Montanez | fb3d3fb | 2020-06-09 18:12:12 -0700 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 17 | import("$dir_pw_build/facade.gni") |
| 18 | import("$dir_pw_docgen/docs.gni") |
| 19 | import("$dir_pw_unit_test/test.gni") |
Wyatt Hepler | d49f8fe | 2020-10-15 10:13:47 -0700 | [diff] [blame] | 20 | |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 21 | declare_args() { |
| 22 | # Backend for the pw_assert module. |
| 23 | pw_assert_BACKEND = "" |
| 24 | } |
| 25 | |
Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 26 | config("default_config") { |
| 27 | include_dirs = [ "public" ] |
| 28 | } |
| 29 | |
| 30 | pw_facade("pw_assert") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 31 | backend = pw_assert_BACKEND |
Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 32 | public_configs = [ ":default_config" ] |
Keir Mierle | d1211ed | 2020-04-03 13:20:46 -0700 | [diff] [blame] | 33 | public = [ |
Wyatt Hepler | a59998f | 2021-03-19 14:35:10 -0700 | [diff] [blame^] | 34 | "public/pw_assert/check.h", |
| 35 | "public/pw_assert/internal/check_impl.h", |
| 36 | "public/pw_assert/short.h", |
Keir Mierle | d1211ed | 2020-04-03 13:20:46 -0700 | [diff] [blame] | 37 | ] |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 38 | public_deps = [ |
| 39 | dir_pw_preprocessor, |
| 40 | |
Wyatt Hepler | a59998f | 2021-03-19 14:35:10 -0700 | [diff] [blame^] | 41 | # Also expose assert.h to all users of pw_assert. |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 42 | ":light", |
| 43 | ] |
Wyatt Hepler | a59998f | 2021-03-19 14:35:10 -0700 | [diff] [blame^] | 44 | |
| 45 | # TODO(pwbug/350): Allow assert.h to include check.h for backwards |
| 46 | # compatibility. Remove this when projects have migrated. |
| 47 | allow_circular_includes_from = [ ":light" ] |
| 48 | deps = [ ":light" ] |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | # Provide a way include "pw_assert/light.h" without depending on the full |
| 52 | # assert facade. This enables relying on light asserts from low-level headers |
| 53 | # like polyfill or span that might trigger circular includes due to the |
| 54 | # backend. |
| 55 | # |
| 56 | # See the docs for more discussion around where to use which assert system. |
| 57 | pw_source_set("light") { |
| 58 | public_configs = [ ":default_config" ] |
| 59 | public = [ |
Wyatt Hepler | a59998f | 2021-03-19 14:35:10 -0700 | [diff] [blame^] | 60 | "public/pw_assert/assert.h", |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 61 | "public/pw_assert/light.h", |
| 62 | |
| 63 | # Needed for PW_ASSERT_ENABLE_DEBUG. Note that depending on :pw_assert to |
| 64 | # get options.h won't work here since it will trigger the circular include |
| 65 | # problem that light asserts are designed to solve. |
| 66 | "public/pw_assert/options.h", |
| 67 | ] |
Wyatt Hepler | dd3e881 | 2020-09-29 11:14:28 -0700 | [diff] [blame] | 68 | public_deps = [ dir_pw_preprocessor ] |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | # Note: While this is technically a test, doesn't verify any of the output and |
| 72 | # is more of a compile test. The results can be visually verified if desired. |
| 73 | pw_test("light_test") { |
| 74 | configs = [ ":default_config" ] |
| 75 | sources = [ "light_test.cc" ] |
| 76 | deps = [ ":pw_assert" ] |
Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | pw_test_group("tests") { |
Armando Montanez | ceb66f5 | 2020-06-04 12:56:38 -0700 | [diff] [blame] | 80 | tests = [ |
| 81 | ":assert_backend_compile_test", |
| 82 | ":assert_facade_test", |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 83 | ":light_test", |
Armando Montanez | ceb66f5 | 2020-06-04 12:56:38 -0700 | [diff] [blame] | 84 | ] |
Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 85 | } |
| 86 | |
Keir Mierle | 8d2a84f | 2020-04-14 22:00:00 -0700 | [diff] [blame] | 87 | # The assert facade test doesn't require a backend since a fake one is |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 88 | # provided. However, since this doesn't depend on the backend it re-includes |
Keir Mierle | 8d2a84f | 2020-04-14 22:00:00 -0700 | [diff] [blame] | 89 | # the facade headers. |
| 90 | pw_test("assert_facade_test") { |
| 91 | configs = [ ":default_config" ] # For internal/assert_impl.h |
| 92 | sources = [ |
| 93 | "assert_facade_test.cc", |
| 94 | "fake_backend.cc", |
Wyatt Hepler | a59998f | 2021-03-19 14:35:10 -0700 | [diff] [blame^] | 95 | "public/pw_assert/internal/check_impl.h", |
Keir Mierle | 8d2a84f | 2020-04-14 22:00:00 -0700 | [diff] [blame] | 96 | "pw_assert_test/fake_backend.h", |
| 97 | ] |
Keir Mierle | 854adec | 2020-09-03 14:07:19 -0700 | [diff] [blame] | 98 | deps = [ |
| 99 | ":light", |
| 100 | dir_pw_status, |
| 101 | ] |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 102 | |
| 103 | # TODO(frolv): Fix this test on the QEMU target. |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 104 | enable_if = pw_build_EXECUTABLE_TARGET_TYPE != "lm3s6965evb_executable" |
Keir Mierle | 8d2a84f | 2020-04-14 22:00:00 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Armando Montanez | ceb66f5 | 2020-06-04 12:56:38 -0700 | [diff] [blame] | 107 | pw_test("assert_backend_compile_test") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 108 | enable_if = pw_assert_BACKEND != "" |
Armando Montanez | ceb66f5 | 2020-06-04 12:56:38 -0700 | [diff] [blame] | 109 | deps = [ |
| 110 | ":pw_assert", |
Keir Mierle | 0fa7f7d | 2020-05-07 12:34:00 -0700 | [diff] [blame] | 111 | dir_pw_status, |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 112 | pw_assert_BACKEND, |
Armando Montanez | ceb66f5 | 2020-06-04 12:56:38 -0700 | [diff] [blame] | 113 | ] |
| 114 | sources = [ |
Armando Montanez | ceb66f5 | 2020-06-04 12:56:38 -0700 | [diff] [blame] | 115 | "assert_backend_compile_test.cc", |
Michael Spang | a99220e | 2020-06-11 20:07:16 -0400 | [diff] [blame] | 116 | "assert_backend_compile_test_c.c", |
Armando Montanez | ceb66f5 | 2020-06-04 12:56:38 -0700 | [diff] [blame] | 117 | ] |
Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | pw_doc_group("docs") { |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 121 | sources = [ "docs.rst" ] |
Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 122 | } |