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 15load("@rules_cc//cc:cc_library.bzl", "cc_library") 16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") 17load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 18load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary") 19load("//pw_build:pw_facade.bzl", "pw_facade") 20load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 21 22package( 23 default_visibility = ["//visibility:public"], 24 features = ["-layering_check"], 25) 26 27licenses(["notice"]) 28 29# TODO: pwbug.dev/328679085 - Remove this alias once no-one uses it. 30alias( 31 name = "facade", 32 actual = ":pw_trace.facade", 33) 34 35pw_facade( 36 name = "pw_trace", 37 hdrs = [ 38 "public/pw_trace/internal/trace_internal.h", 39 "public/pw_trace/trace.h", 40 ], 41 backend = ":backend", 42 strip_include_prefix = "public", 43 tags = ["noclangtidy"], 44 deps = [ 45 "//pw_preprocessor", 46 ], 47) 48 49label_flag( 50 name = "backend", 51 build_setting_default = ":null", 52) 53 54cc_library( 55 name = "null", 56 hdrs = [ 57 "public/pw_trace/internal/null.h", 58 "public_overrides/pw_trace_backend/trace_backend.h", 59 ], 60 includes = [ 61 "public", 62 "public_overrides", 63 ], 64 tags = ["noclangtidy"], 65 deps = [ 66 ":pw_trace.facade", 67 "//pw_preprocessor", 68 ], 69) 70 71pw_cc_test( 72 name = "trace_backend_compile_test", 73 srcs = [ 74 "trace_backend_compile_test.cc", 75 "trace_backend_compile_test_c.c", 76 ], 77 deps = [ 78 ":pw_trace", 79 "//pw_preprocessor", 80 ], 81) 82 83pw_cc_test( 84 name = "trace_facade_test", 85 srcs = [ 86 "pw_trace_test/fake_backend.h", 87 "pw_trace_test/public_overrides/pw_trace_backend/trace_backend.h", 88 "trace_facade_test.cc", 89 ], 90 includes = [ 91 "pw_trace_test", 92 "pw_trace_test/public_overrides", 93 ], 94 tags = ["noclangtidy"], 95 deps = [ 96 ":pw_trace", 97 "//pw_preprocessor", 98 ], 99) 100 101pw_cc_test( 102 name = "trace_zero_facade_test", 103 srcs = [ 104 "pw_trace_zero/public_overrides/pw_trace_backend/trace_backend.h", 105 "trace_backend_compile_test.cc", 106 "trace_backend_compile_test_c.c", 107 ], 108 includes = [ 109 "pw_trace_zero", 110 "pw_trace_zero/public_overrides", 111 ], 112 deps = [ 113 ":pw_trace.facade", 114 "//pw_preprocessor", 115 ], 116) 117 118cc_library( 119 name = "trace_null_test", 120 testonly = True, 121 srcs = [ 122 "trace_null_test.cc", 123 "trace_null_test_c.c", 124 ], 125 deps = [ 126 ":null", 127 ":pw_trace", 128 "//pw_preprocessor", 129 "//pw_unit_test", 130 ], 131) 132 133cc_library( 134 name = "pw_trace_sample_app", 135 srcs = ["example/sample_app.cc"], 136 hdrs = ["example/public/pw_trace/example/sample_app.h"], 137 includes = ["example/public"], 138 # TODO: b/258071921 - fails to link on rp2040 with missing 139 # std::this_thread::__sleep_for symbol 140 target_compatible_with = incompatible_with_mcu(), 141 deps = [ 142 "//pw_ring_buffer", 143 "//pw_trace", 144 ], 145) 146 147pw_cc_binary( 148 name = "trace_example_basic", 149 srcs = ["example/basic.cc"], 150 # TODO: b/258071921 - fails to link on rp2040 with missing 151 # std::this_thread::__sleep_for symbol 152 target_compatible_with = incompatible_with_mcu(), 153 deps = [ 154 ":pw_trace_sample_app", 155 "//pw_log", 156 ], 157) 158 159sphinx_docs_library( 160 name = "docs", 161 srcs = [ 162 "backends.rst", 163 "docs.rst", 164 ], 165 prefix = "pw_trace/", 166 target_compatible_with = incompatible_with_mcu(), 167) 168