| # 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/module_config.gni") |
| import("$dir_pw_build/python.gni") |
| import("$dir_pw_build/python_action.gni") |
| import("$dir_pw_build/target_types.gni") |
| import("$dir_pw_docgen/docs.gni") |
| import("$dir_pw_protobuf_compiler/proto.gni") |
| import("$dir_pw_third_party/nanopb/nanopb.gni") |
| import("$dir_pw_unit_test/test.gni") |
| |
| declare_args() { |
| # The build target that overrides the default configuration options for this |
| # module. This should point to a source set that provides defines through a |
| # public config (which may -include a file or add defines directly). |
| pw_rpc_CONFIG = pw_build_DEFAULT_MODULE_CONFIG |
| } |
| |
| config("public_include_path") { |
| include_dirs = [ "public" ] |
| visibility = [ ":*" ] |
| } |
| |
| pw_source_set("config") { |
| sources = [ "public/pw_rpc/internal/config.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ pw_rpc_CONFIG ] |
| visibility = [ "./*" ] |
| friend = [ "./*" ] |
| } |
| |
| pw_source_set("server") { |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ ":common" ] |
| deps = [ dir_pw_log ] |
| public = [ |
| "public/pw_rpc/server.h", |
| "public/pw_rpc/server_context.h", |
| "public/pw_rpc/service.h", |
| ] |
| sources = [ |
| "public/pw_rpc/internal/call.h", |
| "public/pw_rpc/internal/hash.h", |
| "public/pw_rpc/internal/method.h", |
| "public/pw_rpc/internal/method_lookup.h", |
| "public/pw_rpc/internal/method_union.h", |
| "public/pw_rpc/internal/responder.h", |
| "public/pw_rpc/internal/server.h", |
| "responder.cc", |
| "server.cc", |
| "service.cc", |
| ] |
| friend = [ "./*" ] |
| } |
| |
| pw_source_set("client") { |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ ":common" ] |
| deps = [ dir_pw_log ] |
| public = [ |
| "public/pw_rpc/client.h", |
| "public/pw_rpc/internal/base_client_call.h", |
| ] |
| sources = [ |
| "base_client_call.cc", |
| "client.cc", |
| ] |
| } |
| |
| pw_source_set("client_server") { |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ |
| ":client", |
| ":server", |
| ] |
| public = [ "public/pw_rpc/client_server.h" ] |
| sources = [ "client_server.cc" ] |
| } |
| |
| # Classes shared by the server and client. |
| pw_source_set("common") { |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ |
| ":protos.pwpb", |
| "$dir_pw_containers:intrusive_list", |
| dir_pw_assert, |
| dir_pw_bytes, |
| dir_pw_status, |
| ] |
| deps = [ dir_pw_log ] |
| public = [ "public/pw_rpc/channel.h" ] |
| sources = [ |
| "channel.cc", |
| "packet.cc", |
| "public/pw_rpc/internal/channel.h", |
| "public/pw_rpc/internal/method_type.h", |
| "public/pw_rpc/internal/packet.h", |
| ] |
| friend = [ "./*" ] |
| } |
| |
| pw_source_set("synchronized_channel_output") { |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ |
| ":common", |
| "$dir_pw_sync:lock_annotations", |
| "$dir_pw_sync:mutex", |
| ] |
| public = [ "public/pw_rpc/synchronized_channel_output.h" ] |
| } |
| |
| pw_source_set("test_utils") { |
| public = [ |
| "public/pw_rpc/internal/test_method.h", |
| "pw_rpc_private/fake_channel_output.h", |
| "pw_rpc_private/internal_test_utils.h", |
| "pw_rpc_private/method_impl_tester.h", |
| ] |
| sources = [ "fake_channel_output.cc" ] |
| public_configs = [ |
| ":public_include_path", |
| ":private_includes", |
| ] |
| public_deps = [ |
| ":client", |
| ":server", |
| dir_pw_assert, |
| dir_pw_bytes, |
| ] |
| visibility = [ "./*" ] |
| } |
| |
| config("private_includes") { |
| include_dirs = [ "." ] |
| visibility = [ ":*" ] |
| } |
| |
| pw_proto_library("protos") { |
| sources = [ |
| "echo.proto", |
| "internal/packet.proto", |
| ] |
| inputs = [ "echo.options" ] |
| python_package = "py" |
| prefix = "pw_rpc" |
| } |
| |
| pw_doc_group("docs") { |
| sources = [ "docs.rst" ] |
| inputs = [ |
| "echo.proto", |
| "internal/packet.proto", |
| ] |
| group_deps = [ |
| "nanopb:docs", |
| "py:docs", |
| ] |
| report_deps = [ ":server_size" ] |
| } |
| |
| pw_size_report("server_size") { |
| title = "Pigweed RPC server size report" |
| |
| binaries = [ |
| { |
| target = "size_report:server_only" |
| base = "size_report:base" |
| label = "Server by itself" |
| }, |
| ] |
| |
| if (dir_pw_third_party_nanopb != "") { |
| binaries += [ |
| { |
| target = "size_report:server_with_echo_service" |
| base = "size_report:base_with_nanopb" |
| label = "Server with a registered nanopb EchoService" |
| }, |
| ] |
| } |
| } |
| |
| pw_test_group("tests") { |
| tests = [ |
| ":base_client_call_test", |
| ":channel_test", |
| ":client_test", |
| ":client_server_test", |
| ":ids_test", |
| ":packet_test", |
| ":responder_test", |
| ":server_test", |
| ":service_test", |
| ] |
| group_deps = [ |
| "nanopb:tests", |
| "raw:tests", |
| ] |
| } |
| |
| pw_proto_library("test_protos") { |
| sources = [ "pw_rpc_test_protos/test.proto" ] |
| inputs = [ "pw_rpc_test_protos/test.options" ] |
| visibility = [ "./*" ] |
| } |
| |
| pw_test("responder_test") { |
| deps = [ |
| ":server", |
| ":test_utils", |
| ] |
| sources = [ "responder_test.cc" ] |
| } |
| |
| pw_test("channel_test") { |
| deps = [ |
| ":server", |
| ":test_utils", |
| ] |
| sources = [ "channel_test.cc" ] |
| } |
| |
| pw_python_action("generate_ids_test") { |
| outputs = [ "$target_gen_dir/generated_ids_test.cc" ] |
| |
| script = "py/tests/ids_test.py" |
| args = [ "--generate-cc-test" ] + rebase_path(outputs, root_build_dir) |
| python_deps = [ |
| "$dir_pw_build/py", |
| "py", |
| ] |
| } |
| |
| pw_test("ids_test") { |
| deps = [ |
| ":generate_ids_test", |
| ":server", |
| ] |
| sources = get_target_outputs(":generate_ids_test") |
| } |
| |
| pw_test("packet_test") { |
| deps = [ |
| ":server", |
| dir_pw_bytes, |
| dir_pw_protobuf, |
| ] |
| sources = [ "packet_test.cc" ] |
| } |
| |
| pw_test("service_test") { |
| deps = [ |
| ":protos.pwpb", |
| ":server", |
| dir_pw_assert, |
| ] |
| sources = [ "service_test.cc" ] |
| } |
| |
| pw_test("client_test") { |
| deps = [ |
| ":client", |
| ":test_utils", |
| ] |
| sources = [ "client_test.cc" ] |
| } |
| |
| pw_test("client_server_test") { |
| deps = [ |
| ":client_server", |
| ":test_utils", |
| "raw:method_union", |
| ] |
| sources = [ "client_server_test.cc" ] |
| } |
| |
| pw_test("base_client_call_test") { |
| deps = [ |
| ":client", |
| ":test_utils", |
| ] |
| sources = [ "base_client_call_test.cc" ] |
| } |
| |
| pw_test("server_test") { |
| deps = [ |
| ":protos.pwpb", |
| ":server", |
| ":test_utils", |
| dir_pw_assert, |
| ] |
| sources = [ "server_test.cc" ] |
| } |