Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_assert / BUILD.gn
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
15 import("//build_overrides/pigweed.gni")
16
17 import("$dir_pw_build/facade.gni")
18 import("$dir_pw_docgen/docs.gni")
19 import("$dir_pw_unit_test/test.gni")
20
21 declare_args() {
22   # Backend for the pw_assert module.
23   pw_assert_BACKEND = ""
24 }
25
26 config("default_config") {
27   include_dirs = [ "public" ]
28 }
29
30 pw_facade("pw_assert") {
31   backend = pw_assert_BACKEND
32   public_configs = [ ":default_config" ]
33   public = [
34     "public/pw_assert/assert.h",
35     "public/pw_assert/internal/assert_impl.h",
36   ]
37   public_deps = [
38     dir_pw_preprocessor,
39
40     # Also expose light.h to all users of pw_assert.
41     ":light",
42   ]
43 }
44
45 # Provide a way include "pw_assert/light.h" without depending on the full
46 # assert facade. This enables relying on light asserts from low-level headers
47 # like polyfill or span that might trigger circular includes due to the
48 # backend.
49 #
50 # See the docs for more discussion around where to use which assert system.
51 pw_source_set("light") {
52   public_configs = [ ":default_config" ]
53   public = [
54     "public/pw_assert/light.h",
55
56     # Needed for PW_ASSERT_ENABLE_DEBUG. Note that depending on :pw_assert to
57     # get options.h won't work here since it will trigger the circular include
58     # problem that light asserts are designed to solve.
59     "public/pw_assert/options.h",
60   ]
61   public_deps = [ dir_pw_preprocessor ]
62 }
63
64 # Note: While this is technically a test, doesn't verify any of the output and
65 # is more of a compile test. The results can be visually verified if desired.
66 pw_test("light_test") {
67   configs = [ ":default_config" ]
68   sources = [ "light_test.cc" ]
69   deps = [ ":pw_assert" ]
70 }
71
72 pw_test_group("tests") {
73   tests = [
74     ":assert_backend_compile_test",
75     ":assert_facade_test",
76     ":light_test",
77   ]
78 }
79
80 # The assert facade test doesn't require a backend since a fake one is
81 # provided. However, since this doesn't depend on the backend it re-includes
82 # the facade headers.
83 pw_test("assert_facade_test") {
84   configs = [ ":default_config" ]  # For internal/assert_impl.h
85   sources = [
86     "assert_facade_test.cc",
87     "fake_backend.cc",
88     "public/pw_assert/internal/assert_impl.h",
89     "pw_assert_test/fake_backend.h",
90   ]
91   deps = [
92     ":light",
93     dir_pw_status,
94   ]
95
96   # TODO(frolv): Fix this test on the QEMU target.
97   enable_if = pw_build_EXECUTABLE_TARGET_TYPE != "lm3s6965evb_executable"
98 }
99
100 pw_test("assert_backend_compile_test") {
101   enable_if = pw_assert_BACKEND != ""
102   deps = [
103     ":pw_assert",
104     dir_pw_status,
105     pw_assert_BACKEND,
106   ]
107   sources = [
108     "assert_backend_compile_test.cc",
109     "assert_backend_compile_test_c.c",
110   ]
111 }
112
113 pw_doc_group("docs") {
114   sources = [ "docs.rst" ]
115 }