blob: 79200bdf532b1f31ff44b5702a3c4795e9e7ad2a [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",
64 ],
65)
66
Austin Schuh6b9c4152019-11-29 12:45:24 -080067cc_library(
68 name = "ping_lib",
69 srcs = [
70 "ping_lib.cc",
71 ],
72 hdrs = [
73 "ping_lib.h",
74 ],
75 deps = [
76 ":event_loop",
77 ":ping_fbs",
78 ":pong_fbs",
79 "//aos:json_to_flatbuffer",
80 "@com_github_google_glog//:glog",
81 ],
82)
83
Alex Perrycb7da4b2019-08-28 19:35:56 -070084cc_binary(
85 name = "ping",
86 srcs = [
87 "ping.cc",
88 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -080089 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070090 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -080091 ":ping_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -070092 ":shm_event_loop",
93 "//aos:configuration",
94 "//aos:init",
95 "//aos:json_to_flatbuffer",
96 "@com_github_google_glog//:glog",
97 ],
98)
99
Austin Schuh6b9c4152019-11-29 12:45:24 -0800100aos_config(
Austin Schuh39788ff2019-12-01 18:22:57 -0800101 name = "config",
102 src = "aos.json",
103 flatbuffers = [
104 ":event_loop_fbs",
105 ],
106)
107
108aos_config(
Austin Schuh6b9c4152019-11-29 12:45:24 -0800109 name = "pingpong_config",
Austin Schuh39788ff2019-12-01 18:22:57 -0800110 src = "pingpong.json",
Austin Schuh6b9c4152019-11-29 12:45:24 -0800111 flatbuffers = [
112 ":ping_fbs",
113 ":pong_fbs",
114 ],
Austin Schuh39788ff2019-12-01 18:22:57 -0800115 deps = [":config"],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800116)
117
Austin Schuh15649d62019-12-28 16:36:38 -0800118aos_config(
119 name = "multinode_pingpong_config",
120 src = "multinode_pingpong.json",
121 flatbuffers = [
122 ":ping_fbs",
123 ":pong_fbs",
Austin Schuhe84c3ed2019-12-14 15:29:48 -0800124 "//aos/network:message_bridge_client_fbs",
125 "//aos/network:message_bridge_server_fbs",
Austin Schuh15649d62019-12-28 16:36:38 -0800126 ],
127 deps = [":config"],
128)
129
Austin Schuh6b9c4152019-11-29 12:45:24 -0800130cc_library(
131 name = "pong_lib",
132 srcs = [
133 "pong_lib.cc",
134 ],
135 hdrs = [
136 "pong_lib.h",
137 ],
138 deps = [
139 ":event_loop",
140 ":ping_fbs",
141 ":pong_fbs",
142 "@com_github_google_glog//:glog",
143 ],
144)
145
Alex Perrycb7da4b2019-08-28 19:35:56 -0700146cc_binary(
147 name = "pong",
148 srcs = [
149 "pong.cc",
150 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800151 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700152 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -0800153 ":ping_fbs",
154 ":pong_fbs",
155 ":pong_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700156 ":shm_event_loop",
157 "//aos:configuration",
158 "//aos:init",
159 "//aos:json_to_flatbuffer",
160 "@com_github_google_glog//:glog",
Austin Schuha1654ed2019-01-27 17:24:54 -0800161 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800162)
163
Austin Schuh6b9c4152019-11-29 12:45:24 -0800164cc_test(
165 name = "pingpong_test",
166 srcs = ["pingpong_test.cc"],
167 data = [":pingpong_config.json"],
168 deps = [
169 ":ping_lib",
170 ":pong_lib",
171 ":simulated_event_loop",
172 "//aos:configuration",
173 "//aos:flatbuffers",
174 "//aos/testing:googletest",
175 ],
176)
177
Parker Schuhe4a70d62017-12-27 20:10:20 -0800178cc_library(
Austin Schuhe4106142019-12-01 18:19:53 -0800179 name = "timing_statistics",
180 srcs = ["timing_statistics.cc"],
181 hdrs = ["timing_statistics.h"],
182 deps = [
183 ":event_loop_fbs",
184 "//aos:configuration",
185 "@com_github_google_glog//:glog",
186 ],
187)
188
189cc_test(
190 name = "timing_statistics_test",
191 srcs = ["timing_statistics_test.cc"],
192 deps = [
193 ":timing_statistics",
194 "//aos:configuration",
195 "//aos:flatbuffers",
196 "//aos/testing:googletest",
197 ],
198)
199
200cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700201 name = "shm_event_loop",
202 srcs = ["shm_event_loop.cc"],
203 hdrs = ["shm_event_loop.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800204 visibility = ["//visibility:public"],
205 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700206 ":epoll",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700207 ":event_loop",
Austin Schuh39788ff2019-12-01 18:22:57 -0800208 ":event_loop_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700209 ":test_message_fbs",
Austin Schuh39788ff2019-12-01 18:22:57 -0800210 ":timing_statistics",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700211 "//aos:realtime",
212 "//aos/ipc_lib:lockless_queue",
213 "//aos/ipc_lib:signalfd",
Austin Schuh32fd5a72019-12-01 22:20:26 -0800214 "//aos/stl_mutex",
Austin Schuh52d325c2019-06-23 18:59:06 -0700215 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800216 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800217)
218
219cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700220 name = "shm_event_loop_test",
221 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700222 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800223 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700224 ":event_loop_param_test",
225 ":shm_event_loop",
226 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800227 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800228)
229
230cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700231 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800232 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700233 srcs = ["event_loop_param_test.cc"],
234 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800235 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700236 ":event_loop",
237 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800238 "//aos/testing:googletest",
239 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800240)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800241
242cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700243 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700244 srcs = ["simulated_event_loop_test.cc"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800245 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700246 ":event_loop_param_test",
Austin Schuh7267c532019-05-19 19:55:53 -0700247 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800248 "//aos/testing:googletest",
249 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800250)
251
252cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700253 name = "simulated_event_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700254 srcs = [
255 "event_scheduler.cc",
256 "simulated_event_loop.cc",
257 ],
258 hdrs = [
259 "event_scheduler.h",
260 "simulated_event_loop.h",
261 ],
Austin Schuh7267c532019-05-19 19:55:53 -0700262 visibility = ["//visibility:public"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800263 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700264 ":event_loop",
265 "//aos/ipc_lib:index",
Austin Schuh52d325c2019-06-23 18:59:06 -0700266 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700267 "@com_google_absl//absl/container:btree",
Austin Schuha1654ed2019-01-27 17:24:54 -0800268 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800269)