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") |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 18 | import("$dir_pw_chrono/backend.gni") |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 19 | import("$dir_pw_docgen/docs.gni") |
Prashanth Swaminathan | 49a4a82 | 2021-01-12 18:41:52 -0800 | [diff] [blame] | 20 | import("$dir_pw_log/backend.gni") |
Prashanth Swaminathan | 5ef2aa2 | 2020-11-10 09:57:46 -0800 | [diff] [blame] | 21 | import("$dir_pw_protobuf_compiler/proto.gni") |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 22 | import("$dir_pw_unit_test/test.gni") |
Wyatt Hepler | d49f8fe | 2020-10-15 10:13:47 -0700 | [diff] [blame] | 23 | |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 24 | config("default_config") { |
| 25 | include_dirs = [ "public" ] |
| 26 | } |
| 27 | |
Alexei Frolov | 5152d43 | 2020-01-17 14:15:01 -0800 | [diff] [blame] | 28 | pw_facade("pw_log") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 29 | backend = pw_log_BACKEND |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 30 | public_configs = [ ":default_config" ] |
| 31 | public = [ |
| 32 | "public/pw_log/levels.h", |
| 33 | "public/pw_log/log.h", |
Wyatt Hepler | 9a5d64e | 2020-08-06 12:36:11 -0700 | [diff] [blame] | 34 | "public/pw_log/options.h", |
Wyatt Hepler | 0cdb1a3 | 2021-03-05 14:16:13 -0800 | [diff] [blame] | 35 | "public/pw_log/short.h", |
| 36 | "public/pw_log/shorter.h", |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 37 | ] |
Ewout van Bekkum | eac9440 | 2021-05-07 16:58:42 -0700 | [diff] [blame] | 38 | |
Ewout van Bekkum | 38f20f7 | 2021-05-12 13:18:22 -0700 | [diff] [blame] | 39 | require_link_deps = [ ":impl" ] |
Ewout van Bekkum | eac9440 | 2021-05-07 16:58:42 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 42 | pw_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 Bekkum | eac9440 | 2021-05-07 16:58:42 -0700 | [diff] [blame] | 55 | # 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. |
| 65 | group("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 Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | pw_test_group("tests") { |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 75 | tests = [ |
| 76 | ":basic_log_test", |
| 77 | ":proto_utils_test", |
| 78 | ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 79 | } |
| 80 | |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 81 | pw_test("basic_log_test") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 82 | enable_if = pw_log_BACKEND != "" |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 83 | deps = [ |
| 84 | ":pw_log", |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 85 | dir_pw_preprocessor, |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 86 | pw_log_BACKEND, |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 87 | ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 88 | |
Wyatt Hepler | 68fde05 | 2020-05-13 14:43:03 -0700 | [diff] [blame] | 89 | sources = [ |
| 90 | "basic_log_test.cc", |
| 91 | "basic_log_test_plain_c.c", |
| 92 | ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 93 | } |
| 94 | |
Prashanth Swaminathan | 8015cec | 2021-06-04 10:00:40 -0700 | [diff] [blame] | 95 | pw_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 Swaminathan | 5ef2aa2 | 2020-11-10 09:57:46 -0800 | [diff] [blame] | 106 | pw_proto_library("protos") { |
Wyatt Hepler | 76c3a5c | 2021-05-26 09:57:11 -0700 | [diff] [blame] | 107 | sources = [ "log.proto" ] |
| 108 | prefix = "pw_log/proto" |
Wyatt Hepler | 0d4c916 | 2021-05-26 09:27:22 -0700 | [diff] [blame] | 109 | deps = [ "$dir_pw_tokenizer:proto" ] |
Prashanth Swaminathan | 5ef2aa2 | 2020-11-10 09:57:46 -0800 | [diff] [blame] | 110 | } |
| 111 | |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 112 | pw_doc_group("docs") { |
Wyatt Hepler | 0d4c916 | 2021-05-26 09:27:22 -0700 | [diff] [blame] | 113 | sources = [ |
| 114 | "docs.rst", |
| 115 | "protobuf.rst", |
| 116 | ] |
| 117 | inputs = [ "log.proto" ] |
Keir Mierle | af5e358 | 2019-12-30 13:11:05 -0800 | [diff] [blame] | 118 | } |