Wyatt Hepler | 0cdb1a3 | 2021-03-05 14:16:13 -0800 | [diff] [blame] | 1 | # Copyright 2021 The Pigweed Authors |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 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 | |
Armando Montanez | fb3d3fb | 2020-06-09 18:12:12 -0700 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 17 | import("$dir_pw_build/facade.gni") |
Armando Montanez | e221d84 | 2021-11-17 17:27:41 -0800 | [diff] [blame] | 18 | import("$dir_pw_build/module_config.gni") |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 19 | import("$dir_pw_chrono/backend.gni") |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 20 | import("$dir_pw_docgen/docs.gni") |
Prashanth Swaminathan | 49a4a82 | 2021-01-12 18:41:52 -0800 | [diff] [blame] | 21 | import("$dir_pw_log/backend.gni") |
Prashanth Swaminathan | 5ef2aa2 | 2020-11-10 09:57:46 -0800 | [diff] [blame] | 22 | import("$dir_pw_protobuf_compiler/proto.gni") |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 23 | import("$dir_pw_unit_test/test.gni") |
Wyatt Hepler | d49f8fe | 2020-10-15 10:13:47 -0700 | [diff] [blame] | 24 | |
Armando Montanez | e221d84 | 2021-11-17 17:27:41 -0800 | [diff] [blame] | 25 | declare_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 Bekkum | a4fed72 | 2022-02-25 18:18:44 -0800 | [diff] [blame] | 30 | |
| 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 Montanez | e221d84 | 2021-11-17 17:27:41 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | config("public_include_path") { |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 37 | include_dirs = [ "public" ] |
Armando Montanez | e221d84 | 2021-11-17 17:27:41 -0800 | [diff] [blame] | 38 | visibility = [ ":*" ] |
| 39 | } |
| 40 | |
| 41 | pw_source_set("config") { |
| 42 | public = [ "public/pw_log/config.h" ] |
| 43 | public_configs = [ ":public_include_path" ] |
| 44 | public_deps = [ pw_log_CONFIG ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 45 | } |
| 46 | |
Alexei Frolov | 5152d43 | 2020-01-17 14:15:01 -0800 | [diff] [blame] | 47 | pw_facade("pw_log") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 48 | backend = pw_log_BACKEND |
Armando Montanez | e221d84 | 2021-11-17 17:27:41 -0800 | [diff] [blame] | 49 | public_configs = [ ":public_include_path" ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 50 | public = [ |
| 51 | "public/pw_log/levels.h", |
| 52 | "public/pw_log/log.h", |
Wyatt Hepler | 9a5d64e | 2020-08-06 12:36:11 -0700 | [diff] [blame] | 53 | "public/pw_log/options.h", |
Wyatt Hepler | 0cdb1a3 | 2021-03-05 14:16:13 -0800 | [diff] [blame] | 54 | "public/pw_log/short.h", |
| 55 | "public/pw_log/shorter.h", |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 56 | ] |
Armando Montanez | e221d84 | 2021-11-17 17:27:41 -0800 | [diff] [blame] | 57 | public_deps = [ ":config" ] |
Ewout van Bekkum | eac9440 | 2021-05-07 16:58:42 -0700 | [diff] [blame] | 58 | |
Ewout van Bekkum | 38f20f7 | 2021-05-12 13:18:22 -0700 | [diff] [blame] | 59 | require_link_deps = [ ":impl" ] |
Ewout van Bekkum | eac9440 | 2021-05-07 16:58:42 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Gwyneth Chen | c1b4c84 | 2023-10-16 19:16:13 +0000 | [diff] [blame] | 62 | pw_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 Bekkum | a4fed72 | 2022-02-25 18:18:44 -0800 | [diff] [blame] | 68 | pw_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 Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 85 | pw_source_set("proto_utils") { |
Armando Montanez | e221d84 | 2021-11-17 17:27:41 -0800 | [diff] [blame] | 86 | public_configs = [ ":public_include_path" ] |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 87 | public = [ "public/pw_log/proto_utils.h" ] |
| 88 | public_deps = [ |
| 89 | ":pw_log.facade", |
| 90 | "$dir_pw_bytes", |
Carlos Chinchilla | 72285b2 | 2022-02-25 18:00:03 -0800 | [diff] [blame] | 91 | "$dir_pw_log:protos.pwpb", |
Carlos Chinchilla | a5b131c | 2021-11-12 16:31:17 -0800 | [diff] [blame] | 92 | "$dir_pw_log_tokenized:metadata", |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 93 | "$dir_pw_result", |
Wyatt Hepler | 1c974a1 | 2022-06-24 19:22:42 +0000 | [diff] [blame] | 94 | dir_pw_span, |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 95 | ] |
Carlos Chinchilla | 72285b2 | 2022-02-25 18:00:03 -0800 | [diff] [blame] | 96 | deps = [ "$dir_pw_protobuf" ] |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 97 | sources = [ "proto_utils.cc" ] |
| 98 | } |
| 99 | |
Ewout van Bekkum | eac9440 | 2021-05-07 16:58:42 -0700 | [diff] [blame] | 100 | # 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. |
| 110 | group("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 Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | pw_test_group("tests") { |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 120 | tests = [ |
| 121 | ":basic_log_test", |
Ewout van Bekkum | a4fed72 | 2022-02-25 18:18:44 -0800 | [diff] [blame] | 122 | ":glog_adapter_test", |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 123 | ":proto_utils_test", |
| 124 | ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 125 | } |
| 126 | |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 127 | pw_test("basic_log_test") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 128 | enable_if = pw_log_BACKEND != "" |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 129 | deps = [ |
| 130 | ":pw_log", |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 131 | dir_pw_preprocessor, |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 132 | pw_log_BACKEND, |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 133 | ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 134 | |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 135 | sources = [ |
| 136 | "basic_log_test.cc", |
| 137 | "basic_log_test_plain_c.c", |
| 138 | ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 139 | } |
| 140 | |
Ewout van Bekkum | a4fed72 | 2022-02-25 18:18:44 -0800 | [diff] [blame] | 141 | pw_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 Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 150 | pw_test("proto_utils_test") { |
| 151 | enable_if = pw_log_BACKEND != "" |
| 152 | deps = [ |
| 153 | ":proto_utils", |
| 154 | ":pw_log.facade", |
Ewout van Bekkum | 56bf168 | 2022-05-16 14:19:31 -0700 | [diff] [blame] | 155 | "$dir_pw_containers", |
Carlos Chinchilla | 72285b2 | 2022-02-25 18:00:03 -0800 | [diff] [blame] | 156 | "$dir_pw_log:protos.pwpb", |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 157 | "$dir_pw_preprocessor", |
| 158 | "$dir_pw_protobuf", |
Carlos Chinchilla | 5463664 | 2021-10-19 17:18:16 -0700 | [diff] [blame] | 159 | "$dir_pw_protobuf:bytes_utils", |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 160 | ] |
| 161 | sources = [ "proto_utils_test.cc" ] |
| 162 | } |
| 163 | |
Prashanth Swaminathan | 5ef2aa2 | 2020-11-10 09:57:46 -0800 | [diff] [blame] | 164 | pw_proto_library("protos") { |
Wyatt Hepler | 76c3a5c | 2021-05-26 09:57:11 -0700 | [diff] [blame] | 165 | sources = [ "log.proto" ] |
| 166 | prefix = "pw_log/proto" |
Carlos Chinchilla | bc1e7b2 | 2021-11-03 20:27:20 -0700 | [diff] [blame] | 167 | deps = [ |
| 168 | "$dir_pw_protobuf:common_protos", |
| 169 | "$dir_pw_tokenizer:proto", |
| 170 | ] |
Carlos Chinchilla | 07c5ed9 | 2023-05-03 21:03:27 +0000 | [diff] [blame] | 171 | python_package = "py" |
Prashanth Swaminathan | 5ef2aa2 | 2020-11-10 09:57:46 -0800 | [diff] [blame] | 172 | } |
| 173 | |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 174 | pw_doc_group("docs") { |
Wyatt Hepler | 0d4c916 | 2021-05-26 09:27:22 -0700 | [diff] [blame] | 175 | sources = [ |
| 176 | "docs.rst", |
| 177 | "protobuf.rst", |
Gwyneth Chen | c1b4c84 | 2023-10-16 19:16:13 +0000 | [diff] [blame] | 178 | "tokenized_args.rst", |
Wyatt Hepler | 0d4c916 | 2021-05-26 09:27:22 -0700 | [diff] [blame] | 179 | ] |
Wyatt Hepler | 1d22124 | 2021-09-07 15:42:21 -0700 | [diff] [blame] | 180 | inputs = [ |
| 181 | "example_layer_diagram.svg", |
| 182 | "log.proto", |
| 183 | ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 184 | } |