blob: 9f841df05d8f1e9b0235cca0c213fbdd3ccaaf4b [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 = [
Alex Perrycb7da4b2019-08-28 19:35:56 -070055 "//aos:configuration",
56 "//aos:configuration_fbs",
57 "//aos:flatbuffers",
Austin Schuha1654ed2019-01-27 17:24:54 -080058 "//aos/time",
Alex Perrycb7da4b2019-08-28 19:35:56 -070059 "@com_github_google_flatbuffers//:flatbuffers",
60 ],
61)
62
Austin Schuh6b9c4152019-11-29 12:45:24 -080063cc_library(
64 name = "ping_lib",
65 srcs = [
66 "ping_lib.cc",
67 ],
68 hdrs = [
69 "ping_lib.h",
70 ],
71 deps = [
72 ":event_loop",
73 ":ping_fbs",
74 ":pong_fbs",
75 "//aos:json_to_flatbuffer",
76 "@com_github_google_glog//:glog",
77 ],
78)
79
Alex Perrycb7da4b2019-08-28 19:35:56 -070080cc_binary(
81 name = "ping",
82 srcs = [
83 "ping.cc",
84 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -080085 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070086 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -080087 ":ping_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -070088 ":shm_event_loop",
89 "//aos:configuration",
90 "//aos:init",
91 "//aos:json_to_flatbuffer",
92 "@com_github_google_glog//:glog",
93 ],
94)
95
Austin Schuh6b9c4152019-11-29 12:45:24 -080096aos_config(
97 name = "pingpong_config",
98 src = "config.fb.json",
99 flatbuffers = [
100 ":ping_fbs",
101 ":pong_fbs",
102 ],
103)
104
105cc_library(
106 name = "pong_lib",
107 srcs = [
108 "pong_lib.cc",
109 ],
110 hdrs = [
111 "pong_lib.h",
112 ],
113 deps = [
114 ":event_loop",
115 ":ping_fbs",
116 ":pong_fbs",
117 "@com_github_google_glog//:glog",
118 ],
119)
120
Alex Perrycb7da4b2019-08-28 19:35:56 -0700121cc_binary(
122 name = "pong",
123 srcs = [
124 "pong.cc",
125 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800126 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700127 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -0800128 ":ping_fbs",
129 ":pong_fbs",
130 ":pong_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700131 ":shm_event_loop",
132 "//aos:configuration",
133 "//aos:init",
134 "//aos:json_to_flatbuffer",
135 "@com_github_google_glog//:glog",
Austin Schuha1654ed2019-01-27 17:24:54 -0800136 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800137)
138
Austin Schuh6b9c4152019-11-29 12:45:24 -0800139cc_test(
140 name = "pingpong_test",
141 srcs = ["pingpong_test.cc"],
142 data = [":pingpong_config.json"],
143 deps = [
144 ":ping_lib",
145 ":pong_lib",
146 ":simulated_event_loop",
147 "//aos:configuration",
148 "//aos:flatbuffers",
149 "//aos/testing:googletest",
150 ],
151)
152
Parker Schuhe4a70d62017-12-27 20:10:20 -0800153cc_library(
Austin Schuhe4106142019-12-01 18:19:53 -0800154 name = "timing_statistics",
155 srcs = ["timing_statistics.cc"],
156 hdrs = ["timing_statistics.h"],
157 deps = [
158 ":event_loop_fbs",
159 "//aos:configuration",
160 "@com_github_google_glog//:glog",
161 ],
162)
163
164cc_test(
165 name = "timing_statistics_test",
166 srcs = ["timing_statistics_test.cc"],
167 deps = [
168 ":timing_statistics",
169 "//aos:configuration",
170 "//aos:flatbuffers",
171 "//aos/testing:googletest",
172 ],
173)
174
175cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700176 name = "shm_event_loop",
177 srcs = ["shm_event_loop.cc"],
178 hdrs = ["shm_event_loop.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800179 visibility = ["//visibility:public"],
180 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700181 ":epoll",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700182 ":event_loop",
183 ":test_message_fbs",
184 "//aos:realtime",
185 "//aos/ipc_lib:lockless_queue",
186 "//aos/ipc_lib:signalfd",
Austin Schuh52d325c2019-06-23 18:59:06 -0700187 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800188 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800189)
190
191cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700192 name = "shm_event_loop_test",
193 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700194 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800195 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700196 ":event_loop_param_test",
197 ":shm_event_loop",
198 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800199 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800200)
201
202cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700203 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800204 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700205 srcs = ["event_loop_param_test.cc"],
206 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800207 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700208 ":event_loop",
209 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800210 "//aos/testing:googletest",
211 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800212)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800213
214cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700215 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700216 srcs = ["simulated_event_loop_test.cc"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800217 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700218 ":event_loop_param_test",
Austin Schuh7267c532019-05-19 19:55:53 -0700219 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800220 "//aos/testing:googletest",
221 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800222)
223
224cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700225 name = "simulated_event_loop",
Austin Schuh82c0c822019-05-27 19:55:20 -0700226 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700227 srcs = [
228 "event_scheduler.cc",
229 "simulated_event_loop.cc",
230 ],
231 hdrs = [
232 "event_scheduler.h",
233 "simulated_event_loop.h",
234 ],
Austin Schuh7267c532019-05-19 19:55:53 -0700235 visibility = ["//visibility:public"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800236 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700237 ":event_loop",
238 "//aos/ipc_lib:index",
Austin Schuh52d325c2019-06-23 18:59:06 -0700239 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700240 "@com_google_absl//absl/container:btree",
Austin Schuha1654ed2019-01-27 17:24:54 -0800241 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800242)
Austin Schuhe309d2a2019-11-29 13:25:21 -0800243
244flatbuffer_cc_library(
245 name = "logger_fbs",
246 srcs = ["logger.fbs"],
247 gen_reflections = 1,
248 includes = [
249 "//aos:configuration_fbs_includes",
250 ],
251)
252
253cc_library(
254 name = "logger",
255 srcs = ["logger.cc"],
256 hdrs = ["logger.h"],
257 deps = [
258 ":event_loop",
259 ":logger_fbs",
260 "//aos:flatbuffer_merge",
261 "//aos/time",
262 "@com_github_google_flatbuffers//:flatbuffers",
263 "@com_google_absl//absl/container:inlined_vector",
264 "@com_google_absl//absl/strings",
265 ],
266)
267
268cc_test(
269 name = "logger_test",
270 srcs = ["logger_test.cc"],
271 data = ["pingpong_config.json"],
272 deps = [
273 ":logger",
274 ":ping_lib",
275 ":pong_lib",
276 ":simulated_event_loop",
277 "//aos/testing:googletest",
278 ],
279)