# Copyright 2021 The Pigweed Authors # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. import("//build_overrides/pigweed.gni") import("$dir_pw_async2/backend.gni") import("$dir_pw_bloat/bloat.gni") import("$dir_pw_build/python.gni") import("$dir_pw_build/target_types.gni") import("$dir_pw_docgen/docs.gni") import("$dir_pw_fuzzer/fuzz_test.gni") import("$dir_pw_unit_test/test.gni") config("default_config") { include_dirs = [ "public" ] } group("pw_hdlc") { public_deps = [ ":decoder", ":encoded_size", ":encoder", ] } pw_source_set("common") { public_configs = [ ":default_config" ] public = [ "public/pw_hdlc/internal/protocol.h" ] public_deps = [ dir_pw_varint ] visibility = [ ":*" ] } pw_source_set("encoded_size") { public_configs = [ ":default_config" ] public = [ "public/pw_hdlc/encoded_size.h" ] public_deps = [ ":common", "$dir_pw_bytes", "$dir_pw_span", "$dir_pw_varint", ] } pw_source_set("decoder") { public_configs = [ ":default_config" ] public = [ "public/pw_hdlc/decoder.h" ] sources = [ "decoder.cc" ] public_deps = [ ":common", dir_pw_bytes, dir_pw_checksum, dir_pw_result, dir_pw_span, dir_pw_status, ] deps = [ dir_pw_log ] friend = [ ":*" ] } pw_source_set("encoder") { public_configs = [ ":default_config" ] public = [ "public/pw_hdlc/encoder.h" ] sources = [ "encoder.cc" ] public_deps = [ ":common", dir_pw_bytes, dir_pw_checksum, dir_pw_span, dir_pw_status, dir_pw_stream, ] deps = [ ":encoded_size" ] friend = [ ":*" ] } pw_source_set("rpc_channel_output") { public_configs = [ ":default_config" ] public = [ "public/pw_hdlc/rpc_channel.h" ] public_deps = [ ":pw_hdlc", "$dir_pw_rpc:server", dir_pw_span, ] } pw_source_set("default_addresses") { public_configs = [ ":default_config" ] public = [ "public/pw_hdlc/default_addresses.h" ] } pw_source_set("packet_parser") { public_configs = [ ":default_config" ] public = [ "public/pw_hdlc/wire_packet_parser.h" ] sources = [ "wire_packet_parser.cc" ] public_deps = [ ":pw_hdlc", "$dir_pw_router:packet_parser", ] deps = [ dir_pw_bytes, dir_pw_checksum, ] } # A backend for pw_rpc's `system_server` that sends and receives HDLC-framed RPC # packets over pw_sys_io. # # Warning: This system server is polling and blocking, so it's not # production-ready. This exists for simplifying initial bringup/testing, and # should not be used in any performance-sensitive application. pw_source_set("hdlc_sys_io_system_server") { deps = [ "$dir_pw_hdlc:decoder", "$dir_pw_hdlc:default_addresses", "$dir_pw_hdlc:rpc_channel_output", "$dir_pw_rpc/system_server:facade", "$dir_pw_stream:sys_io_stream", dir_pw_log, ] sources = [ "hdlc_sys_io_system_server.cc" ] } pw_source_set("router") { public_configs = [ ":default_config" ] public_deps = [ ":decoder", "$dir_pw_async2:dispatcher", "$dir_pw_async2:poll", "$dir_pw_containers:vector", "$dir_pw_multibuf:allocator", dir_pw_channel, dir_pw_multibuf, dir_pw_status, ] deps = [ ":encoder", "$dir_pw_multibuf:stream", dir_pw_log, dir_pw_result, dir_pw_stream, ] public = [ "public/pw_hdlc/router.h" ] sources = [ "router.cc" ] } pw_test("router_test") { enable_if = pw_async2_DISPATCHER_BACKEND != "" deps = [ ":router", "$dir_pw_allocator:testing", "$dir_pw_async2:pend_func_task", "$dir_pw_channel:forwarding_channel", "$dir_pw_channel:loopback_channel", "$dir_pw_multibuf:simple_allocator", ] sources = [ "router_test.cc" ] } pw_test_group("tests") { tests = [ ":encoded_size_test", ":encoder_test", ":decoder_test", ":router_test", ":rpc_channel_test", ":wire_packet_parser_test", ] group_deps = [ "$dir_pw_preprocessor:tests", "$dir_pw_status:tests", "$dir_pw_stream:tests", ] } pw_test("encoded_size_test") { deps = [ ":pw_hdlc", "$dir_pw_bytes", "$dir_pw_result", "$dir_pw_stream", "$dir_pw_varint", ] sources = [ "encoded_size_test.cc" ] # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. configs = [ "$dir_pw_build:conversion_warnings" ] } pw_test("encoder_test") { deps = [ ":pw_hdlc" ] sources = [ "encoder_test.cc" ] # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. configs = [ "$dir_pw_build:conversion_warnings" ] } pw_python_action("generate_decoder_test") { outputs = [ "$target_gen_dir/generated_decoder_test.cc" ] script = "py/decode_test.py" args = [ "--generate-cc-test" ] + rebase_path(outputs, root_build_dir) python_deps = [ "$dir_pw_build/py", "py", ] } pw_fuzz_test("decoder_test") { deps = [ ":pw_hdlc" ] source_gen_deps = [ ":generate_decoder_test" ] sources = [ "decoder_test.cc" ] # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. configs = [ "$dir_pw_build:conversion_warnings" ] } pw_test("rpc_channel_test") { deps = [ ":pw_hdlc", ":rpc_channel_output", ] sources = [ "rpc_channel_test.cc" ] # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. configs = [ "$dir_pw_build:conversion_warnings" ] } pw_test("wire_packet_parser_test") { deps = [ ":packet_parser", dir_pw_bytes, ] sources = [ "wire_packet_parser_test.cc" ] # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. configs = [ "$dir_pw_build:conversion_warnings" ] } pw_size_diff("size_report") { title = "HDLC sizes" binaries = [ { target = "size_report:full" base = "size_report:base" label = "HDLC encode and decode" }, { target = "size_report:full_crc" base = "size_report:base_crc" label = "HDLC encode and decode, ignoring CRC and varint" }, ] } pw_doc_group("docs") { sources = [ "api.rst", "design.rst", "docs.rst", "guide.rst", "router.rst", "rpc_example/docs.rst", "size.rst", ] inputs = [ "py/pw_hdlc/decode.py", "py/pw_hdlc/encode.py", ] report_deps = [ ":size_report" ] }