blob: d6397624e75ba825ec963aea6aabad2af48e82a0 [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")
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070018import("$dir_pw_chrono/backend.gni")
Keir Mierleaf5e3582019-12-30 13:11:05 -080019import("$dir_pw_docgen/docs.gni")
Prashanth Swaminathan49a4a822021-01-12 18:41:52 -080020import("$dir_pw_log/backend.gni")
Prashanth Swaminathan5ef2aa22020-11-10 09:57:46 -080021import("$dir_pw_protobuf_compiler/proto.gni")
Keir Mierleaf5e3582019-12-30 13:11:05 -080022import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070023
Keir Mierleaf5e3582019-12-30 13:11:05 -080024config("default_config") {
25 include_dirs = [ "public" ]
26}
27
Alexei Frolov5152d432020-01-17 14:15:01 -080028pw_facade("pw_log") {
Alexei Frolov4c0428a2020-06-10 10:46:04 -070029 backend = pw_log_BACKEND
Keir Mierleaf5e3582019-12-30 13:11:05 -080030 public_configs = [ ":default_config" ]
31 public = [
32 "public/pw_log/levels.h",
33 "public/pw_log/log.h",
Wyatt Hepler9a5d64e2020-08-06 12:36:11 -070034 "public/pw_log/options.h",
Wyatt Hepler0cdb1a32021-03-05 14:16:13 -080035 "public/pw_log/short.h",
36 "public/pw_log/shorter.h",
Keir Mierleaf5e3582019-12-30 13:11:05 -080037 ]
Ewout van Bekkumeac94402021-05-07 16:58:42 -070038
Ewout van Bekkum38f20f72021-05-12 13:18:22 -070039 require_link_deps = [ ":impl" ]
Ewout van Bekkumeac94402021-05-07 16:58:42 -070040}
41
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070042pw_source_set("proto_utils") {
43 public_configs = [ ":default_config" ]
44 public = [ "public/pw_log/proto_utils.h" ]
45 public_deps = [
46 ":pw_log.facade",
47 "$dir_pw_bytes",
48 "$dir_pw_log_tokenized",
49 "$dir_pw_result",
50 ]
51 deps = [ "$dir_pw_log:protos.pwpb" ]
52 sources = [ "proto_utils.cc" ]
53}
54
Ewout van Bekkumeac94402021-05-07 16:58:42 -070055# pw_log is low-level and ubiquitous. Because of this, it can often cause
56# circular dependencies. This target collects dependencies from the backend that
57# cannot be used because they would cause circular deps.
58#
59# This group ("$dir_pw_log:impl") must listed in pw_build_LINK_DEPS if
60# pw_log_BACKEND is set.
61#
62# pw_log backends must provide their own "impl" target that collects their
63# actual dependencies. The backend "impl" group may be empty if everything can
64# go directly in the backend target without causing circular dependencies.
65group("impl") {
66 public_deps = []
67
68 if (pw_log_BACKEND != "") {
69 public_deps +=
70 [ get_label_info(pw_log_BACKEND, "label_no_toolchain") + ".impl" ]
71 }
Keir Mierleaf5e3582019-12-30 13:11:05 -080072}
73
74pw_test_group("tests") {
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070075 tests = [
76 ":basic_log_test",
77 ":proto_utils_test",
78 ]
Keir Mierleaf5e3582019-12-30 13:11:05 -080079}
80
Wyatt Hepler68fde052020-05-13 14:43:03 -070081pw_test("basic_log_test") {
Alexei Frolov4c0428a2020-06-10 10:46:04 -070082 enable_if = pw_log_BACKEND != ""
Wyatt Hepler68fde052020-05-13 14:43:03 -070083 deps = [
84 ":pw_log",
Wyatt Hepler68fde052020-05-13 14:43:03 -070085 dir_pw_preprocessor,
Alexei Frolov4c0428a2020-06-10 10:46:04 -070086 pw_log_BACKEND,
Wyatt Hepler68fde052020-05-13 14:43:03 -070087 ]
Keir Mierleaf5e3582019-12-30 13:11:05 -080088
Wyatt Hepler68fde052020-05-13 14:43:03 -070089 sources = [
90 "basic_log_test.cc",
91 "basic_log_test_plain_c.c",
92 ]
Keir Mierleaf5e3582019-12-30 13:11:05 -080093}
94
Prashanth Swaminathan8015cec2021-06-04 10:00:40 -070095pw_test("proto_utils_test") {
96 enable_if = pw_log_BACKEND != ""
97 deps = [
98 ":proto_utils",
99 ":pw_log.facade",
100 "$dir_pw_preprocessor",
101 "$dir_pw_protobuf",
102 ]
103 sources = [ "proto_utils_test.cc" ]
104}
105
Prashanth Swaminathan5ef2aa22020-11-10 09:57:46 -0800106pw_proto_library("protos") {
Wyatt Hepler76c3a5c2021-05-26 09:57:11 -0700107 sources = [ "log.proto" ]
108 prefix = "pw_log/proto"
Wyatt Hepler0d4c9162021-05-26 09:27:22 -0700109 deps = [ "$dir_pw_tokenizer:proto" ]
Prashanth Swaminathan5ef2aa22020-11-10 09:57:46 -0800110}
111
Keir Mierleaf5e3582019-12-30 13:11:05 -0800112pw_doc_group("docs") {
Wyatt Hepler0d4c9162021-05-26 09:27:22 -0700113 sources = [
114 "docs.rst",
115 "protobuf.rst",
116 ]
117 inputs = [ "log.proto" ]
Keir Mierleaf5e3582019-12-30 13:11:05 -0800118}