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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/target_types.gni") 18import("$dir_pw_docgen/docs.gni") 19import("$dir_pw_protobuf_compiler/proto.gni") 20import("$dir_pw_third_party/nanopb/nanopb.gni") 21import("$dir_pw_unit_test/test.gni") 22import("config.gni") 23 24config("public_include_path") { 25 include_dirs = [ "public" ] 26 visibility = [ ":*" ] 27} 28 29config("backend_config") { 30 include_dirs = [ "public_overrides" ] 31} 32 33pw_source_set("config") { 34 public_deps = [ pw_trace_CONFIG ] 35 public_configs = [ ":public_include_path" ] 36 public = [ "public/pw_trace_tokenized/config.h" ] 37} 38 39pw_test_group("tests") { 40 tests = [ 41 ":trace_tokenized_test", 42 ":tokenized_trace_buffer_test", 43 ":tokenized_trace_buffer_log_test", 44 ] 45} 46 47pw_source_set("pw_trace_tokenized") { 48 public_configs = [ 49 ":backend_config", 50 ":public_include_path", 51 ] 52 public_deps = [ 53 ":config", 54 ":core", 55 "$dir_pw_tokenizer", 56 ] 57 if (pw_trace_tokenizer_time != "") { 58 deps = [ "$pw_trace_tokenizer_time" ] 59 } 60 61 public = [ "public_overrides/pw_trace_backend/trace_backend.h" ] 62} 63 64pw_test("trace_tokenized_test") { 65 enable_if = pw_trace_tokenizer_time != "" 66 deps = [ 67 ":core", 68 "$dir_pw_trace", 69 ] 70 71 sources = [ "trace_test.cc" ] 72} 73 74config("trace_buffer_size") { 75 defines = [ "PW_TRACE_BUFFER_SIZE_BYTES=${pw_trace_tokenized_BUFFER_SIZE}" ] 76} 77 78pw_proto_library("trace_rpc_service_proto") { 79 sources = [ "pw_trace_protos/trace_rpc.proto" ] 80 inputs = [ "pw_trace_protos/trace_rpc.options" ] 81} 82 83pw_source_set("trace_rpc_service") { 84 public_configs = [ ":public_include_path" ] 85 public_deps = [ ":trace_rpc_service_proto.nanopb_rpc" ] 86 deps = [ 87 ":core", 88 ":tokenized_trace_buffer", 89 "$dir_pw_log", 90 "$dir_pw_trace", 91 ] 92 sources = [ 93 "public/pw_trace_tokenized/trace_rpc_service_nanopb.h", 94 "trace_rpc_service_nanopb.cc", 95 ] 96} 97 98pw_source_set("tokenized_trace_buffer") { 99 deps = [ ":core" ] 100 public_deps = [ 101 ":config", 102 "$dir_pw_ring_buffer", 103 "$dir_pw_tokenizer", 104 "$dir_pw_varint", 105 ] 106 sources = [ "trace_buffer.cc" ] 107 public_configs = [ 108 ":public_include_path", 109 ":trace_buffer_size", 110 ] 111 public = [ "public/pw_trace_tokenized/trace_buffer.h" ] 112} 113 114pw_test("tokenized_trace_buffer_test") { 115 enable_if = pw_trace_tokenizer_time != "" 116 deps = [ 117 ":tokenized_trace_buffer", 118 "$dir_pw_trace", 119 ] 120 121 sources = [ "trace_buffer_test.cc" ] 122} 123 124pw_source_set("tokenized_trace_buffer_log") { 125 deps = [ 126 "$dir_pw_base64", 127 "$dir_pw_log", 128 "$dir_pw_string", 129 ] 130 public_deps = [ ":tokenized_trace_buffer" ] 131 sources = [ "trace_buffer_log.cc" ] 132 public = [ "public/pw_trace_tokenized/trace_buffer_log.h" ] 133} 134 135pw_test("tokenized_trace_buffer_log_test") { 136 enable_if = pw_trace_tokenizer_time != "" 137 deps = [ 138 ":tokenized_trace_buffer_log", 139 "$dir_pw_trace", 140 ] 141 sources = [ "trace_buffer_log_test.cc" ] 142} 143 144pw_source_set("fake_trace_time") { 145 deps = [ ":core" ] 146 sources = [ "fake_trace_time.cc" ] 147} 148 149pw_source_set("host_trace_time") { 150 deps = [ ":core" ] 151 sources = [ "host_trace_time.cc" ] 152} 153 154pw_source_set("core") { 155 public_configs = [ 156 ":backend_config", 157 ":public_include_path", 158 ] 159 public_deps = [ 160 "$dir_pw_status", 161 "$dir_pw_tokenizer", 162 ] 163 deps = [ 164 ":config", 165 "$dir_pw_assert", 166 "$dir_pw_ring_buffer", 167 "$dir_pw_trace:facade", 168 "$dir_pw_varint", 169 ] 170 public = [ 171 "public/pw_trace_tokenized/internal/trace_tokenized_internal.h", 172 "public/pw_trace_tokenized/trace_callback.h", 173 "public/pw_trace_tokenized/trace_tokenized.h", 174 ] 175 sources = [ "trace.cc" ] 176 visibility = [ ":*" ] 177} 178 179pw_doc_group("docs") { 180 sources = [ "docs.rst" ] 181} 182 183config("trace_example_config") { 184 include_dirs = [ "example/public" ] 185} 186 187pw_source_set("trace_example_to_file") { 188 deps = [ ":pw_trace_tokenized" ] 189 public_configs = [ ":trace_example_config" ] 190 public = [ "example/public/pw_trace_tokenized/example/trace_to_file.h" ] 191} 192 193# Builds trace examples 194pw_executable("trace_tokenized_example_basic") { 195 deps = [ 196 ":trace_example_to_file", 197 "$dir_pw_log", 198 "$dir_pw_trace", 199 "$dir_pw_trace:trace_sample_app", 200 ] 201 sources = [ "example/basic.cc" ] 202} 203 204pw_executable("trace_tokenized_example_trigger") { 205 deps = [ 206 ":trace_example_to_file", 207 "$dir_pw_log", 208 "$dir_pw_trace", 209 "$dir_pw_trace:trace_sample_app", 210 ] 211 sources = [ "example/trigger.cc" ] 212} 213 214pw_executable("trace_tokenized_example_filter") { 215 deps = [ 216 ":trace_example_to_file", 217 "$dir_pw_log", 218 "$dir_pw_trace", 219 "$dir_pw_trace:trace_sample_app", 220 ] 221 sources = [ "example/filter.cc" ] 222} 223 224if (dir_pw_third_party_nanopb == "") { 225 group("trace_tokenized_example_rpc") { 226 } 227} else { 228 pw_executable("trace_tokenized_example_rpc") { 229 sources = [ "example/rpc.cc" ] 230 deps = [ 231 ":trace_rpc_service", 232 "$dir_pw_hdlc", 233 "$dir_pw_log", 234 "$dir_pw_rpc:server", 235 "$dir_pw_rpc/system_server", 236 "$dir_pw_trace", 237 "$dir_pw_trace:trace_sample_app", 238 ] 239 } 240} 241