1# Copyright 2021 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_bloat/bloat.gni")
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_sync/backend.gni")
21import("$dir_pw_unit_test/test.gni")
22
23config("public_include_path") {
24  include_dirs = [ "public" ]
25  visibility = [ ":*" ]
26}
27
28pw_source_set("static_router") {
29  public_configs = [ ":public_include_path" ]
30  public_deps = [
31    ":egress",
32    ":packet_parser",
33    "$dir_pw_sync:lock_annotations",
34    "$dir_pw_sync:mutex",
35    dir_pw_metric,
36  ]
37  public = [ "public/pw_router/static_router.h" ]
38  sources = [ "static_router.cc" ]
39}
40
41pw_source_set("egress") {
42  public_configs = [ ":public_include_path" ]
43  public = [ "public/pw_router/egress.h" ]
44  public_deps = [ dir_pw_bytes ]
45}
46
47pw_source_set("packet_parser") {
48  public_configs = [ ":public_include_path" ]
49  public = [ "public/pw_router/packet_parser.h" ]
50  public_deps = [ dir_pw_bytes ]
51}
52
53pw_source_set("egress_function") {
54  public_configs = [ ":public_include_path" ]
55  public = [ "public/pw_router/egress_function.h" ]
56  public_deps = [ ":egress" ]
57}
58
59pw_doc_group("docs") {
60  sources = [ "docs.rst" ]
61  # TODO(frolv): This size report can't currently be built as the docs target
62  # does not have a mutex backend.
63  # report_deps = [ ":static_router_size" ]
64}
65
66pw_test_group("tests") {
67  tests = [ ":static_router_test" ]
68}
69
70pw_test("static_router_test") {
71  deps = [
72    ":egress_function",
73    ":static_router",
74  ]
75  sources = [ "static_router_test.cc" ]
76  enable_if = pw_sync_MUTEX_BACKEND != ""
77}
78
79pw_size_report("static_router_size") {
80  title = "pw::router::StaticRouter size report"
81  binaries = [
82    {
83      target = "size_report:static_router_with_one_route"
84      base = "size_report:base"
85      label = "Static router with a single route"
86    },
87  ]
88}
89