blob: e61a294df87395d64f8b70dbe586d2318b52d9bc [file] [log] [blame]
Wyatt Hepler0cdb1a32021-03-05 14:16:13 -08001# Copyright 2021 The Pigweed Authors
Keir Mierleaf5e3582019-12-30 13:11:05 -08002#
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 Montanezfb3d3fb2020-06-09 18:12:12 -070015import("//build_overrides/pigweed.gni")
16
Keir Mierleaf5e3582019-12-30 13:11:05 -080017import("$dir_pw_build/facade.gni")
Armando Montaneze221d842021-11-17 17:27:41 -080018import("$dir_pw_build/module_config.gni")
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070019import("$dir_pw_chrono/backend.gni")
Keir Mierleaf5e3582019-12-30 13:11:05 -080020import("$dir_pw_docgen/docs.gni")
Prashanth Swaminathan49a4a822021-01-12 18:41:52 -080021import("$dir_pw_log/backend.gni")
Prashanth Swaminathan5ef2aa22020-11-10 09:57:46 -080022import("$dir_pw_protobuf_compiler/proto.gni")
Keir Mierleaf5e3582019-12-30 13:11:05 -080023import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070024
Armando Montaneze221d842021-11-17 17:27:41 -080025declare_args() {
26 # The build target that overrides the default configuration options for this
27 # module. This should point to a source set that provides defines through a
28 # public config (which may -include a file or add defines directly).
29 pw_log_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
Ewout van Bekkuma4fed722022-02-25 18:18:44 -080030
31 # The build target that overrides the default configuration options for the
32 # glog adapter portion of this module.
33 pw_log_GLOG_ADAPTER_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
Armando Montaneze221d842021-11-17 17:27:41 -080034}
35
36config("public_include_path") {
Keir Mierleaf5e3582019-12-30 13:11:05 -080037 include_dirs = [ "public" ]
Armando Montaneze221d842021-11-17 17:27:41 -080038 visibility = [ ":*" ]
39}
40
41pw_source_set("config") {
42 public = [ "public/pw_log/config.h" ]
43 public_configs = [ ":public_include_path" ]
44 public_deps = [ pw_log_CONFIG ]
Keir Mierleaf5e3582019-12-30 13:11:05 -080045}
46
Alexei Frolov5152d432020-01-17 14:15:01 -080047pw_facade("pw_log") {
Alexei Frolov4c0428a2020-06-10 10:46:04 -070048 backend = pw_log_BACKEND
Armando Montaneze221d842021-11-17 17:27:41 -080049 public_configs = [ ":public_include_path" ]
Keir Mierleaf5e3582019-12-30 13:11:05 -080050 public = [
51 "public/pw_log/levels.h",
52 "public/pw_log/log.h",
Wyatt Hepler9a5d64e2020-08-06 12:36:11 -070053 "public/pw_log/options.h",
Wyatt Hepler0cdb1a32021-03-05 14:16:13 -080054 "public/pw_log/short.h",
55 "public/pw_log/shorter.h",
Keir Mierleaf5e3582019-12-30 13:11:05 -080056 ]
Armando Montaneze221d842021-11-17 17:27:41 -080057 public_deps = [ ":config" ]
Ewout van Bekkumeac94402021-05-07 16:58:42 -070058
Ewout van Bekkum38f20f72021-05-12 13:18:22 -070059 require_link_deps = [ ":impl" ]
Ewout van Bekkumeac94402021-05-07 16:58:42 -070060}
61
Gwyneth Chenc1b4c842023-10-16 19:16:13 +000062pw_source_set("args") {
63 public_configs = [ ":public_include_path" ]
64 public_deps = [ dir_pw_tokenizer ]
65 public = [ "public/pw_log/tokenized_args.h" ]
66}
67
Ewout van Bekkuma4fed722022-02-25 18:18:44 -080068pw_source_set("glog_adapter") {
69 public_configs = [ ":public_include_path" ]
70 public = [
71 "public/pw_log/glog_adapter.h",
72 "public/pw_log/glog_adapter_config.h",
73 ]
74 public_deps = [
75 ":config",
76 "$dir_pw_assert",
77 "$dir_pw_log",
78 "$dir_pw_preprocessor",
79 "$dir_pw_string",
80 pw_log_GLOG_ADAPTER_CONFIG,
81 ]
82 sources = [ "public/pw_log/internal/glog_adapter.h" ]
83}
84
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070085pw_source_set("proto_utils") {
Armando Montaneze221d842021-11-17 17:27:41 -080086 public_configs = [ ":public_include_path" ]
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070087 public = [ "public/pw_log/proto_utils.h" ]
88 public_deps = [
89 ":pw_log.facade",
90 "$dir_pw_bytes",
Carlos Chinchilla72285b22022-02-25 18:00:03 -080091 "$dir_pw_log:protos.pwpb",
Carlos Chinchillaa5b131c2021-11-12 16:31:17 -080092 "$dir_pw_log_tokenized:metadata",
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070093 "$dir_pw_result",
Wyatt Hepler1c974a12022-06-24 19:22:42 +000094 dir_pw_span,
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070095 ]
Carlos Chinchilla72285b22022-02-25 18:00:03 -080096 deps = [ "$dir_pw_protobuf" ]
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070097 sources = [ "proto_utils.cc" ]
98}
99
Ewout van Bekkumeac94402021-05-07 16:58:42 -0700100# pw_log is low-level and ubiquitous. Because of this, it can often cause
101# circular dependencies. This target collects dependencies from the backend that
102# cannot be used because they would cause circular deps.
103#
104# This group ("$dir_pw_log:impl") must listed in pw_build_LINK_DEPS if
105# pw_log_BACKEND is set.
106#
107# pw_log backends must provide their own "impl" target that collects their
108# actual dependencies. The backend "impl" group may be empty if everything can
109# go directly in the backend target without causing circular dependencies.
110group("impl") {
111 public_deps = []
112
113 if (pw_log_BACKEND != "") {
114 public_deps +=
115 [ get_label_info(pw_log_BACKEND, "label_no_toolchain") + ".impl" ]
116 }
Keir Mierleaf5e3582019-12-30 13:11:05 -0800117}
118
119pw_test_group("tests") {
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -0700120 tests = [
121 ":basic_log_test",
Ewout van Bekkuma4fed722022-02-25 18:18:44 -0800122 ":glog_adapter_test",
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -0700123 ":proto_utils_test",
124 ]
Keir Mierleaf5e3582019-12-30 13:11:05 -0800125}
126
Wyatt Hepler68fde052020-05-13 14:43:03 -0700127pw_test("basic_log_test") {
Alexei Frolov4c0428a2020-06-10 10:46:04 -0700128 enable_if = pw_log_BACKEND != ""
Wyatt Hepler68fde052020-05-13 14:43:03 -0700129 deps = [
130 ":pw_log",
Wyatt Hepler68fde052020-05-13 14:43:03 -0700131 dir_pw_preprocessor,
Alexei Frolov4c0428a2020-06-10 10:46:04 -0700132 pw_log_BACKEND,
Wyatt Hepler68fde052020-05-13 14:43:03 -0700133 ]
Keir Mierleaf5e3582019-12-30 13:11:05 -0800134
Wyatt Hepler68fde052020-05-13 14:43:03 -0700135 sources = [
136 "basic_log_test.cc",
137 "basic_log_test_plain_c.c",
138 ]
Keir Mierleaf5e3582019-12-30 13:11:05 -0800139}
140
Ewout van Bekkuma4fed722022-02-25 18:18:44 -0800141pw_test("glog_adapter_test") {
142 enable_if = pw_log_BACKEND != ""
143 deps = [
144 ":glog_adapter",
145 pw_log_BACKEND,
146 ]
147 sources = [ "glog_adapter_test.cc" ]
148}
149
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -0700150pw_test("proto_utils_test") {
151 enable_if = pw_log_BACKEND != ""
152 deps = [
153 ":proto_utils",
154 ":pw_log.facade",
Ewout van Bekkum56bf1682022-05-16 14:19:31 -0700155 "$dir_pw_containers",
Carlos Chinchilla72285b22022-02-25 18:00:03 -0800156 "$dir_pw_log:protos.pwpb",
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -0700157 "$dir_pw_preprocessor",
158 "$dir_pw_protobuf",
Carlos Chinchilla54636642021-10-19 17:18:16 -0700159 "$dir_pw_protobuf:bytes_utils",
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -0700160 ]
161 sources = [ "proto_utils_test.cc" ]
162}
163
Prashanth Swaminathan5ef2aa22020-11-10 09:57:46 -0800164pw_proto_library("protos") {
Wyatt Hepler76c3a5c2021-05-26 09:57:11 -0700165 sources = [ "log.proto" ]
166 prefix = "pw_log/proto"
Carlos Chinchillabc1e7b22021-11-03 20:27:20 -0700167 deps = [
168 "$dir_pw_protobuf:common_protos",
169 "$dir_pw_tokenizer:proto",
170 ]
Carlos Chinchilla07c5ed92023-05-03 21:03:27 +0000171 python_package = "py"
Prashanth Swaminathan5ef2aa22020-11-10 09:57:46 -0800172}
173
Keir Mierleaf5e3582019-12-30 13:11:05 -0800174pw_doc_group("docs") {
Wyatt Hepler0d4c9162021-05-26 09:27:22 -0700175 sources = [
176 "docs.rst",
177 "protobuf.rst",
Gwyneth Chenc1b4c842023-10-16 19:16:13 +0000178 "tokenized_args.rst",
Wyatt Hepler0d4c9162021-05-26 09:27:22 -0700179 ]
Wyatt Hepler1d221242021-09-07 15:42:21 -0700180 inputs = [
181 "example_layer_diagram.svg",
182 "log.proto",
183 ]
Keir Mierleaf5e3582019-12-30 13:11:05 -0800184}