blob: 754a29a9814fc280fcaf159025fd50e64eeae201 [file] [log] [blame]
# 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_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_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/pw_hdlc/internal/encoder.h",
]
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("pw_rpc") {
public_configs = [ ":default_config" ]
public = [ "public/pw_hdlc/rpc_packets.h" ]
sources = [ "rpc_packets.cc" ]
public_deps = [
":pw_hdlc",
"$dir_pw_rpc:server",
dir_pw_sys_io,
]
}
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:pw_rpc",
"$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_test_group("tests") {
tests = [
":encoder_test",
":decoder_test",
":rpc_channel_test",
":encoded_size_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" ]
}
pw_test("encoder_test") {
deps = [ ":pw_hdlc" ]
sources = [ "encoder_test.cc" ]
}
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_test("decoder_test") {
deps = [
":generate_decoder_test",
":pw_hdlc",
]
sources = [ "decoder_test.cc" ] + get_target_outputs(":generate_decoder_test")
}
pw_test("rpc_channel_test") {
deps = [
":pw_hdlc",
":rpc_channel_output",
]
sources = [ "rpc_channel_test.cc" ]
}
pw_test("wire_packet_parser_test") {
deps = [
":packet_parser",
dir_pw_bytes,
]
sources = [ "wire_packet_parser_test.cc" ]
}
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 = [
"docs.rst",
"rpc_example/docs.rst",
]
inputs = [
"py/pw_hdlc/decode.py",
"py/pw_hdlc/encode.py",
]
report_deps = [ ":size_report" ]
}