blob: 50a5263f224586c3b36624da7b824090bd26d342 [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",
48 "event_loop_tmpl.h",
49 ],
Austin Schuha1654ed2019-01-27 17:24:54 -080050 hdrs = [
Alex Perrycb7da4b2019-08-28 19:35:56 -070051 "event_loop.h",
Austin Schuha1654ed2019-01-27 17:24:54 -080052 ],
53 visibility = ["//visibility:public"],
54 deps = [
Austin Schuh39788ff2019-12-01 18:22:57 -080055 ":event_loop_fbs",
56 ":timing_statistics",
Alex Perrycb7da4b2019-08-28 19:35:56 -070057 "//aos:configuration",
58 "//aos:configuration_fbs",
59 "//aos:flatbuffers",
Austin Schuha1654ed2019-01-27 17:24:54 -080060 "//aos/time",
Austin Schuh39788ff2019-12-01 18:22:57 -080061 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -070062 "@com_github_google_flatbuffers//:flatbuffers",
63 ],
64)
65
Austin Schuh6b9c4152019-11-29 12:45:24 -080066cc_library(
67 name = "ping_lib",
68 srcs = [
69 "ping_lib.cc",
70 ],
71 hdrs = [
72 "ping_lib.h",
73 ],
74 deps = [
75 ":event_loop",
76 ":ping_fbs",
77 ":pong_fbs",
78 "//aos:json_to_flatbuffer",
79 "@com_github_google_glog//:glog",
80 ],
81)
82
Alex Perrycb7da4b2019-08-28 19:35:56 -070083cc_binary(
84 name = "ping",
85 srcs = [
86 "ping.cc",
87 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -080088 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070089 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -080090 ":ping_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -070091 ":shm_event_loop",
92 "//aos:configuration",
93 "//aos:init",
94 "//aos:json_to_flatbuffer",
95 "@com_github_google_glog//:glog",
96 ],
97)
98
Austin Schuh6b9c4152019-11-29 12:45:24 -080099aos_config(
Austin Schuh39788ff2019-12-01 18:22:57 -0800100 name = "config",
101 src = "aos.json",
102 flatbuffers = [
103 ":event_loop_fbs",
104 ],
105)
106
107aos_config(
Austin Schuh6b9c4152019-11-29 12:45:24 -0800108 name = "pingpong_config",
Austin Schuh39788ff2019-12-01 18:22:57 -0800109 src = "pingpong.json",
Austin Schuh6b9c4152019-11-29 12:45:24 -0800110 flatbuffers = [
111 ":ping_fbs",
112 ":pong_fbs",
113 ],
Austin Schuh39788ff2019-12-01 18:22:57 -0800114 deps = [":config"],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800115)
116
117cc_library(
118 name = "pong_lib",
119 srcs = [
120 "pong_lib.cc",
121 ],
122 hdrs = [
123 "pong_lib.h",
124 ],
125 deps = [
126 ":event_loop",
127 ":ping_fbs",
128 ":pong_fbs",
129 "@com_github_google_glog//:glog",
130 ],
131)
132
Alex Perrycb7da4b2019-08-28 19:35:56 -0700133cc_binary(
134 name = "pong",
135 srcs = [
136 "pong.cc",
137 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800138 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700139 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -0800140 ":ping_fbs",
141 ":pong_fbs",
142 ":pong_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700143 ":shm_event_loop",
144 "//aos:configuration",
145 "//aos:init",
146 "//aos:json_to_flatbuffer",
147 "@com_github_google_glog//:glog",
Austin Schuha1654ed2019-01-27 17:24:54 -0800148 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800149)
150
Austin Schuh6b9c4152019-11-29 12:45:24 -0800151cc_test(
152 name = "pingpong_test",
153 srcs = ["pingpong_test.cc"],
154 data = [":pingpong_config.json"],
155 deps = [
156 ":ping_lib",
157 ":pong_lib",
158 ":simulated_event_loop",
159 "//aos:configuration",
160 "//aos:flatbuffers",
161 "//aos/testing:googletest",
162 ],
163)
164
Parker Schuhe4a70d62017-12-27 20:10:20 -0800165cc_library(
Austin Schuhe4106142019-12-01 18:19:53 -0800166 name = "timing_statistics",
167 srcs = ["timing_statistics.cc"],
168 hdrs = ["timing_statistics.h"],
169 deps = [
170 ":event_loop_fbs",
171 "//aos:configuration",
172 "@com_github_google_glog//:glog",
173 ],
174)
175
176cc_test(
177 name = "timing_statistics_test",
178 srcs = ["timing_statistics_test.cc"],
179 deps = [
180 ":timing_statistics",
181 "//aos:configuration",
182 "//aos:flatbuffers",
183 "//aos/testing:googletest",
184 ],
185)
186
187cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700188 name = "shm_event_loop",
189 srcs = ["shm_event_loop.cc"],
190 hdrs = ["shm_event_loop.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800191 visibility = ["//visibility:public"],
192 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700193 ":epoll",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700194 ":event_loop",
Austin Schuh39788ff2019-12-01 18:22:57 -0800195 ":event_loop_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700196 ":test_message_fbs",
Austin Schuh39788ff2019-12-01 18:22:57 -0800197 ":timing_statistics",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700198 "//aos:realtime",
199 "//aos/ipc_lib:lockless_queue",
200 "//aos/ipc_lib:signalfd",
Austin Schuh52d325c2019-06-23 18:59:06 -0700201 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800202 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800203)
204
205cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700206 name = "shm_event_loop_test",
207 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700208 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800209 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700210 ":event_loop_param_test",
211 ":shm_event_loop",
212 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800213 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800214)
215
216cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700217 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800218 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700219 srcs = ["event_loop_param_test.cc"],
220 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800221 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700222 ":event_loop",
223 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800224 "//aos/testing:googletest",
225 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800226)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800227
228cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700229 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700230 srcs = ["simulated_event_loop_test.cc"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800231 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700232 ":event_loop_param_test",
Austin Schuh7267c532019-05-19 19:55:53 -0700233 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800234 "//aos/testing:googletest",
235 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800236)
237
238cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700239 name = "simulated_event_loop",
Austin Schuh82c0c822019-05-27 19:55:20 -0700240 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700241 srcs = [
242 "event_scheduler.cc",
243 "simulated_event_loop.cc",
244 ],
245 hdrs = [
246 "event_scheduler.h",
247 "simulated_event_loop.h",
248 ],
Austin Schuh7267c532019-05-19 19:55:53 -0700249 visibility = ["//visibility:public"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800250 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700251 ":event_loop",
252 "//aos/ipc_lib:index",
Austin Schuh52d325c2019-06-23 18:59:06 -0700253 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700254 "@com_google_absl//absl/container:btree",
Austin Schuha1654ed2019-01-27 17:24:54 -0800255 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800256)
Austin Schuhe309d2a2019-11-29 13:25:21 -0800257
258flatbuffer_cc_library(
259 name = "logger_fbs",
260 srcs = ["logger.fbs"],
261 gen_reflections = 1,
262 includes = [
263 "//aos:configuration_fbs_includes",
264 ],
265)
266
267cc_library(
268 name = "logger",
269 srcs = ["logger.cc"],
270 hdrs = ["logger.h"],
271 deps = [
272 ":event_loop",
273 ":logger_fbs",
274 "//aos:flatbuffer_merge",
275 "//aos/time",
276 "@com_github_google_flatbuffers//:flatbuffers",
277 "@com_google_absl//absl/container:inlined_vector",
278 "@com_google_absl//absl/strings",
279 ],
280)
281
282cc_test(
283 name = "logger_test",
284 srcs = ["logger_test.cc"],
285 data = ["pingpong_config.json"],
286 deps = [
287 ":logger",
288 ":ping_lib",
289 ":pong_lib",
290 ":simulated_event_loop",
291 "//aos/testing:googletest",
292 ],
293)