aboutsummaryrefslogtreecommitdiff
path: root/pw_rpc/CMakeLists.txt
blob: 7d5b2cf475676415d8aded3c84bce5d545f53e32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright 2020 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.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake)

if(NOT "${dir_pw_third_party_nanopb}" STREQUAL "")
  add_subdirectory(nanopb)
endif()

add_subdirectory(raw)
add_subdirectory(system_server)

pw_add_module_library(pw_rpc.server
  SOURCES
    call.cc
    endpoint.cc
    server.cc
    server_call.cc
    service.cc
  PUBLIC_DEPS
    pw_rpc.common
  PRIVATE_DEPS
    pw_log
)
if(Zephyr_FOUND AND CONFIG_PIGWEED_RPC_SERVER)
  zephyr_link_libraries(pw_rpc.server)
endif()

pw_add_module_library(pw_rpc.client
  SOURCES
    client.cc
    client_call.cc
  PUBLIC_DEPS
    pw_rpc.common
    pw_result
  PRIVATE_DEPS
    pw_log
)
if(Zephyr_FOUND AND CONFIG_PIGWEED_RPC_CLIENT)
  zephyr_link_libraries(pw_rpc.client)
endif()

pw_add_module_library(pw_rpc.client_server
  SOURCES
    client_server.cc
  PUBLIC_DEPS
    pw_rpc.client
    pw_rpc.server
)
if(Zephyr_FOUND AND CONFIG_PIGWEED_RPC_CLIENT_SERVER)
  zephyr_link_libraries(pw_rpc.client_server)
endif()

pw_add_module_library(pw_rpc.common
  SOURCES
    channel.cc
    channel_list.cc
    packet.cc
  PUBLIC_DEPS
    pw_assert
    pw_bytes
    pw_containers
    pw_function
    pw_span
    pw_status
    pw_sync.lock_annotations
    pw_rpc.protos.pwpb
  PRIVATE_DEPS
    pw_log
)
if(Zephyr_FOUND AND CONFIG_PIGWEED_RPC_COMMON)
  zephyr_link_libraries(pw_rpc.common)
endif()

if (NOT "${pw_sync.mutex_BACKEND}" STREQUAL "pw_sync.mutex.NO_BACKEND_SET" AND
    NOT "${pw_sync.mutex_BACKEND}" STREQUAL "")
  target_link_libraries(pw_rpc.common PUBLIC pw_sync.mutex)
endif()

pw_add_module_library(pw_rpc.test_utils
  SOURCES
    fake_channel_output.cc
  PUBLIC_DEPS
    pw_assert
    pw_bytes
    pw_rpc.client
    pw_rpc.server
)
target_include_directories(pw_rpc.test_utils PUBLIC .)

pw_proto_library(pw_rpc.protos
  SOURCES
    internal/packet.proto
    echo.proto
  INPUTS
    echo.options
  PREFIX
    pw_rpc
)

pw_proto_library(pw_rpc.test_protos
  SOURCES
    pw_rpc_test_protos/test.proto
)

pw_auto_add_module_tests(pw_rpc
  PRIVATE_DEPS
    pw_rpc.client
    pw_rpc.server
)