blob: fb0f35677ff8c73afd342c9e1622341ee8c7d7c8 [file] [log] [blame]
Alex Perrycb7da4b2019-08-28 19:35:56 -07001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
Austin Schuh6b9c4152019-11-29 12:45:24 -08002load("//aos:config.bzl", "aos_config")
Alex Perrycb7da4b2019-08-28 19:35:56 -07003
4package(default_visibility = ["//visibility:public"])
5
6flatbuffer_cc_library(
7 name = "test_message_fbs",
8 srcs = ["test_message.fbs"],
9 gen_reflections = 1,
10)
11
12flatbuffer_cc_library(
Austin Schuhe4106142019-12-01 18:19:53 -080013 name = "event_loop_fbs",
14 srcs = ["event_loop.fbs"],
15 gen_reflections = 1,
16 includes = [
17 "//aos:configuration_fbs_includes",
18 ],
19)
20
21flatbuffer_cc_library(
Austin Schuh6b9c4152019-11-29 12:45:24 -080022 name = "ping_fbs",
23 srcs = ["ping.fbs"],
24 gen_reflections = 1,
25)
26
27flatbuffer_cc_library(
28 name = "pong_fbs",
29 srcs = ["pong.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070030 gen_reflections = 1,
31)
32
Parker Schuhe4a70d62017-12-27 20:10:20 -080033cc_library(
Austin Schuh6b6dfa52019-06-12 20:16:20 -070034 name = "epoll",
35 srcs = ["epoll.cc"],
36 hdrs = ["epoll.h"],
Austin Schuh20b2b082019-09-11 20:42:56 -070037 visibility = ["//visibility:public"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -070038 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -070039 "//aos/time",
Austin Schuhf257f3c2019-10-27 21:00:43 -070040 "@com_github_google_glog//:glog",
Austin Schuh6b6dfa52019-06-12 20:16:20 -070041 ],
42)
43
44cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -070045 name = "event_loop",
Austin Schuh54cf95f2019-11-29 13:14:18 -080046 srcs = [
47 "event_loop.cc",
Austin Schuh7d87b672019-12-01 20:23:49 -080048 "event_loop_event.h",
Austin Schuh54cf95f2019-11-29 13:14:18 -080049 "event_loop_tmpl.h",
50 ],
Austin Schuha1654ed2019-01-27 17:24:54 -080051 hdrs = [
Alex Perrycb7da4b2019-08-28 19:35:56 -070052 "event_loop.h",
Austin Schuha1654ed2019-01-27 17:24:54 -080053 ],
54 visibility = ["//visibility:public"],
55 deps = [
Austin Schuh39788ff2019-12-01 18:22:57 -080056 ":event_loop_fbs",
57 ":timing_statistics",
Alex Perrycb7da4b2019-08-28 19:35:56 -070058 "//aos:configuration",
59 "//aos:configuration_fbs",
60 "//aos:flatbuffers",
Austin Schuha1654ed2019-01-27 17:24:54 -080061 "//aos/time",
Austin Schuh39788ff2019-12-01 18:22:57 -080062 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -070063 "@com_github_google_flatbuffers//:flatbuffers",
Brian Silverman0fc69932020-01-24 21:54:02 -080064 "@com_google_absl//absl/container:btree",
Alex Perrycb7da4b2019-08-28 19:35:56 -070065 ],
66)
67
Austin Schuh6b9c4152019-11-29 12:45:24 -080068cc_library(
69 name = "ping_lib",
70 srcs = [
71 "ping_lib.cc",
72 ],
73 hdrs = [
74 "ping_lib.h",
75 ],
76 deps = [
77 ":event_loop",
78 ":ping_fbs",
79 ":pong_fbs",
80 "//aos:json_to_flatbuffer",
81 "@com_github_google_glog//:glog",
82 ],
83)
84
Alex Perrycb7da4b2019-08-28 19:35:56 -070085cc_binary(
86 name = "ping",
87 srcs = [
88 "ping.cc",
89 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -080090 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070091 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -080092 ":ping_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -070093 ":shm_event_loop",
94 "//aos:configuration",
95 "//aos:init",
96 "//aos:json_to_flatbuffer",
97 "@com_github_google_glog//:glog",
98 ],
99)
100
Austin Schuh6b9c4152019-11-29 12:45:24 -0800101aos_config(
Austin Schuh39788ff2019-12-01 18:22:57 -0800102 name = "config",
103 src = "aos.json",
104 flatbuffers = [
105 ":event_loop_fbs",
106 ],
107)
108
109aos_config(
Austin Schuh6b9c4152019-11-29 12:45:24 -0800110 name = "pingpong_config",
Austin Schuh39788ff2019-12-01 18:22:57 -0800111 src = "pingpong.json",
Austin Schuh6b9c4152019-11-29 12:45:24 -0800112 flatbuffers = [
113 ":ping_fbs",
114 ":pong_fbs",
115 ],
Austin Schuh39788ff2019-12-01 18:22:57 -0800116 deps = [":config"],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800117)
118
Austin Schuh15649d62019-12-28 16:36:38 -0800119aos_config(
120 name = "multinode_pingpong_config",
121 src = "multinode_pingpong.json",
122 flatbuffers = [
123 ":ping_fbs",
124 ":pong_fbs",
Austin Schuhe84c3ed2019-12-14 15:29:48 -0800125 "//aos/network:message_bridge_client_fbs",
126 "//aos/network:message_bridge_server_fbs",
Austin Schuh15649d62019-12-28 16:36:38 -0800127 ],
128 deps = [":config"],
129)
130
Austin Schuh6b9c4152019-11-29 12:45:24 -0800131cc_library(
132 name = "pong_lib",
133 srcs = [
134 "pong_lib.cc",
135 ],
136 hdrs = [
137 "pong_lib.h",
138 ],
139 deps = [
140 ":event_loop",
141 ":ping_fbs",
142 ":pong_fbs",
143 "@com_github_google_glog//:glog",
144 ],
145)
146
Alex Perrycb7da4b2019-08-28 19:35:56 -0700147cc_binary(
148 name = "pong",
149 srcs = [
150 "pong.cc",
151 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800152 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700153 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -0800154 ":ping_fbs",
155 ":pong_fbs",
156 ":pong_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700157 ":shm_event_loop",
158 "//aos:configuration",
159 "//aos:init",
160 "//aos:json_to_flatbuffer",
161 "@com_github_google_glog//:glog",
Austin Schuha1654ed2019-01-27 17:24:54 -0800162 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800163)
164
Austin Schuh6b9c4152019-11-29 12:45:24 -0800165cc_test(
166 name = "pingpong_test",
167 srcs = ["pingpong_test.cc"],
168 data = [":pingpong_config.json"],
169 deps = [
170 ":ping_lib",
171 ":pong_lib",
172 ":simulated_event_loop",
173 "//aos:configuration",
174 "//aos:flatbuffers",
175 "//aos/testing:googletest",
176 ],
177)
178
Parker Schuhe4a70d62017-12-27 20:10:20 -0800179cc_library(
Austin Schuhe4106142019-12-01 18:19:53 -0800180 name = "timing_statistics",
181 srcs = ["timing_statistics.cc"],
182 hdrs = ["timing_statistics.h"],
183 deps = [
184 ":event_loop_fbs",
185 "//aos:configuration",
186 "@com_github_google_glog//:glog",
187 ],
188)
189
190cc_test(
191 name = "timing_statistics_test",
192 srcs = ["timing_statistics_test.cc"],
193 deps = [
194 ":timing_statistics",
195 "//aos:configuration",
196 "//aos:flatbuffers",
197 "//aos/testing:googletest",
198 ],
199)
200
201cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700202 name = "shm_event_loop",
203 srcs = ["shm_event_loop.cc"],
204 hdrs = ["shm_event_loop.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800205 visibility = ["//visibility:public"],
206 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700207 ":epoll",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700208 ":event_loop",
Austin Schuh39788ff2019-12-01 18:22:57 -0800209 ":event_loop_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700210 ":test_message_fbs",
Austin Schuh39788ff2019-12-01 18:22:57 -0800211 ":timing_statistics",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700212 "//aos:realtime",
213 "//aos/ipc_lib:lockless_queue",
214 "//aos/ipc_lib:signalfd",
Austin Schuh32fd5a72019-12-01 22:20:26 -0800215 "//aos/stl_mutex",
Austin Schuh52d325c2019-06-23 18:59:06 -0700216 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800217 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800218)
219
220cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700221 name = "shm_event_loop_test",
222 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700223 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800224 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700225 ":event_loop_param_test",
226 ":shm_event_loop",
227 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800228 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800229)
230
231cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700232 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800233 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700234 srcs = ["event_loop_param_test.cc"],
235 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800236 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700237 ":event_loop",
238 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800239 "//aos/testing:googletest",
240 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800241)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800242
243cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700244 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700245 srcs = ["simulated_event_loop_test.cc"],
Austin Schuh898f4972020-01-11 17:21:25 -0800246 data = ["multinode_pingpong_config.json"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800247 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700248 ":event_loop_param_test",
Austin Schuh898f4972020-01-11 17:21:25 -0800249 ":ping_lib",
250 ":pong_lib",
Austin Schuh7267c532019-05-19 19:55:53 -0700251 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800252 "//aos/testing:googletest",
253 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800254)
255
256cc_library(
Austin Schuhe1dafe42020-01-06 21:12:03 -0800257 name = "simple_channel",
258 srcs = ["simple_channel.cc"],
259 hdrs = ["simple_channel.h"],
260 deps = [
261 "//aos:configuration_fbs",
262 "@com_github_google_flatbuffers//:flatbuffers",
263 "@com_github_google_glog//:glog",
264 "@com_google_absl//absl/strings",
265 ],
266)
267
268cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700269 name = "simulated_event_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700270 srcs = [
271 "event_scheduler.cc",
272 "simulated_event_loop.cc",
Austin Schuh898f4972020-01-11 17:21:25 -0800273 "simulated_network_bridge.cc",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700274 ],
275 hdrs = [
276 "event_scheduler.h",
277 "simulated_event_loop.h",
Austin Schuh898f4972020-01-11 17:21:25 -0800278 "simulated_network_bridge.h",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700279 ],
Austin Schuh7267c532019-05-19 19:55:53 -0700280 visibility = ["//visibility:public"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800281 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700282 ":event_loop",
Austin Schuhe1dafe42020-01-06 21:12:03 -0800283 ":simple_channel",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700284 "//aos/ipc_lib:index",
Austin Schuh52d325c2019-06-23 18:59:06 -0700285 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700286 "@com_google_absl//absl/container:btree",
Austin Schuha1654ed2019-01-27 17:24:54 -0800287 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800288)