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/module_config.gni")
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_log/backend.gni")
21import("$dir_pw_tokenizer/backend.gni")
22import("$dir_pw_unit_test/test.gni")
23
24declare_args() {
25  # The build target that overrides the default configuration options for this
26  # module. This should point to a source set that provides defines through a
27  # public config (which may -include a file or add defines directly).
28  pw_log_tokenized_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
29}
30
31config("public_includes") {
32  include_dirs = [ "public" ]
33  visibility = [ ":*" ]
34}
35
36config("backend_config") {
37  include_dirs = [ "public_overrides" ]
38  visibility = [ ":*" ]
39}
40
41# This target provides the log_tokenized.h header, which implements the pw_log
42# backend.
43#
44# This target depends on the pw_tokenizer facade target
45# (dir_pw_tokenizer:global_handler_with_payload.facade) to avoid circular
46# dependencies. The dependency graph for pw_log_tokenized is the following:
47#
48#   pw_log:facade <---   :pw_log_tokenized
49#        ^            \      ^       ^
50#        |             \    /         \
51#   -> pw_log -> :log_backend --> pw_tokenizer:global_handler_with_payload
52#
53pw_source_set("pw_log_tokenized") {
54  public_configs = [ ":public_includes" ]
55  public_deps = [
56    "$dir_pw_log:facade",
57    "$dir_pw_tokenizer:global_handler_with_payload.facade",
58    dir_pw_preprocessor,
59    pw_log_tokenized_CONFIG,
60  ]
61  public = [
62    "public/pw_log_tokenized/config.h",
63    "public/pw_log_tokenized/log_tokenized.h",
64  ]
65}
66
67# This target provides the backend for pw_log.
68pw_source_set("log_backend") {
69  public_configs = [ ":backend_config" ]
70  public_deps = [ ":pw_log_tokenized" ]
71  public = [ "public_overrides/pw_log_backend/log_backend.h" ]
72  deps = [ "$dir_pw_tokenizer:global_handler_with_payload" ]
73}
74
75# This target provides a backend for pw_tokenizer that encodes tokenized logs as
76# Base64, encodes them into HDLC frames, and writes them over sys_io.
77pw_source_set("base64_over_hdlc") {
78  public_configs = [ ":public_includes" ]
79  public = [ "public/pw_log_tokenized/base64_over_hdlc.h" ]
80  sources = [ "base64_over_hdlc.cc" ]
81  deps = [
82    "$dir_pw_hdlc:encoder",
83    "$dir_pw_stream:sys_io_stream",
84    "$dir_pw_tokenizer:base64",
85    "$dir_pw_tokenizer:global_handler_with_payload.facade",
86  ]
87}
88
89pw_test_group("tests") {
90  tests = [ ":log_tokenized_test" ]
91}
92
93pw_test("log_tokenized_test") {
94  sources = [ "test.cc" ]
95  deps = [ ":pw_log_tokenized" ]
96}
97
98pw_doc_group("docs") {
99  sources = [ "docs.rst" ]
100  other_deps = [ "py" ]
101}
102