blob: 5aef05a263c3737dc7a072059b023d82b79635c0 [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 Schuh32fd5a72019-12-01 22:20:26 -0800201 "//aos/stl_mutex",
Austin Schuh52d325c2019-06-23 18:59:06 -0700202 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800203 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800204)
205
206cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700207 name = "shm_event_loop_test",
208 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700209 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800210 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700211 ":event_loop_param_test",
212 ":shm_event_loop",
213 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800214 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800215)
216
217cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700218 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800219 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700220 srcs = ["event_loop_param_test.cc"],
221 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800222 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700223 ":event_loop",
224 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800225 "//aos/testing:googletest",
226 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800227)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800228
229cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700230 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700231 srcs = ["simulated_event_loop_test.cc"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800232 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700233 ":event_loop_param_test",
Austin Schuh7267c532019-05-19 19:55:53 -0700234 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800235 "//aos/testing:googletest",
236 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800237)
238
239cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700240 name = "simulated_event_loop",
Austin Schuh82c0c822019-05-27 19:55:20 -0700241 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700242 srcs = [
243 "event_scheduler.cc",
244 "simulated_event_loop.cc",
245 ],
246 hdrs = [
247 "event_scheduler.h",
248 "simulated_event_loop.h",
249 ],
Austin Schuh7267c532019-05-19 19:55:53 -0700250 visibility = ["//visibility:public"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800251 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700252 ":event_loop",
253 "//aos/ipc_lib:index",
Austin Schuh52d325c2019-06-23 18:59:06 -0700254 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700255 "@com_google_absl//absl/container:btree",
Austin Schuha1654ed2019-01-27 17:24:54 -0800256 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800257)
Austin Schuhe309d2a2019-11-29 13:25:21 -0800258
259flatbuffer_cc_library(
260 name = "logger_fbs",
261 srcs = ["logger.fbs"],
262 gen_reflections = 1,
263 includes = [
264 "//aos:configuration_fbs_includes",
265 ],
266)
267
268cc_library(
269 name = "logger",
270 srcs = ["logger.cc"],
271 hdrs = ["logger.h"],
272 deps = [
273 ":event_loop",
274 ":logger_fbs",
275 "//aos:flatbuffer_merge",
276 "//aos/time",
277 "@com_github_google_flatbuffers//:flatbuffers",
278 "@com_google_absl//absl/container:inlined_vector",
279 "@com_google_absl//absl/strings",
280 ],
281)
282
283cc_test(
284 name = "logger_test",
285 srcs = ["logger_test.cc"],
286 data = ["pingpong_config.json"],
287 deps = [
288 ":logger",
289 ":ping_lib",
290 ":pong_lib",
291 ":simulated_event_loop",
292 "//aos/testing:googletest",
293 ],
294)