blob: 3377d67f88fd5c9fa42bb986b196b0cee63ececb [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 Schuh6b9c4152019-11-29 12:45:24 -080013 name = "ping_fbs",
14 srcs = ["ping.fbs"],
15 gen_reflections = 1,
16)
17
18flatbuffer_cc_library(
19 name = "pong_fbs",
20 srcs = ["pong.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070021 gen_reflections = 1,
22)
23
Parker Schuhe4a70d62017-12-27 20:10:20 -080024cc_library(
Austin Schuh6b6dfa52019-06-12 20:16:20 -070025 name = "epoll",
26 srcs = ["epoll.cc"],
27 hdrs = ["epoll.h"],
Austin Schuh20b2b082019-09-11 20:42:56 -070028 visibility = ["//visibility:public"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -070029 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -070030 "//aos/time",
Austin Schuhf257f3c2019-10-27 21:00:43 -070031 "@com_github_google_glog//:glog",
Austin Schuh6b6dfa52019-06-12 20:16:20 -070032 ],
33)
34
35cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -070036 name = "event_loop",
Austin Schuh54cf95f2019-11-29 13:14:18 -080037 srcs = [
38 "event_loop.cc",
39 "event_loop_tmpl.h",
40 ],
Austin Schuha1654ed2019-01-27 17:24:54 -080041 hdrs = [
Alex Perrycb7da4b2019-08-28 19:35:56 -070042 "event_loop.h",
Austin Schuha1654ed2019-01-27 17:24:54 -080043 ],
44 visibility = ["//visibility:public"],
45 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -070046 "//aos:configuration",
47 "//aos:configuration_fbs",
48 "//aos:flatbuffers",
Austin Schuha1654ed2019-01-27 17:24:54 -080049 "//aos/time",
Alex Perrycb7da4b2019-08-28 19:35:56 -070050 "@com_github_google_flatbuffers//:flatbuffers",
51 ],
52)
53
Austin Schuh6b9c4152019-11-29 12:45:24 -080054cc_library(
55 name = "ping_lib",
56 srcs = [
57 "ping_lib.cc",
58 ],
59 hdrs = [
60 "ping_lib.h",
61 ],
62 deps = [
63 ":event_loop",
64 ":ping_fbs",
65 ":pong_fbs",
66 "//aos:json_to_flatbuffer",
67 "@com_github_google_glog//:glog",
68 ],
69)
70
Alex Perrycb7da4b2019-08-28 19:35:56 -070071cc_binary(
72 name = "ping",
73 srcs = [
74 "ping.cc",
75 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -080076 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070077 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -080078 ":ping_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -070079 ":shm_event_loop",
80 "//aos:configuration",
81 "//aos:init",
82 "//aos:json_to_flatbuffer",
83 "@com_github_google_glog//:glog",
84 ],
85)
86
Austin Schuh6b9c4152019-11-29 12:45:24 -080087aos_config(
88 name = "pingpong_config",
89 src = "config.fb.json",
90 flatbuffers = [
91 ":ping_fbs",
92 ":pong_fbs",
93 ],
94)
95
96cc_library(
97 name = "pong_lib",
98 srcs = [
99 "pong_lib.cc",
100 ],
101 hdrs = [
102 "pong_lib.h",
103 ],
104 deps = [
105 ":event_loop",
106 ":ping_fbs",
107 ":pong_fbs",
108 "@com_github_google_glog//:glog",
109 ],
110)
111
Alex Perrycb7da4b2019-08-28 19:35:56 -0700112cc_binary(
113 name = "pong",
114 srcs = [
115 "pong.cc",
116 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800117 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700118 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -0800119 ":ping_fbs",
120 ":pong_fbs",
121 ":pong_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700122 ":shm_event_loop",
123 "//aos:configuration",
124 "//aos:init",
125 "//aos:json_to_flatbuffer",
126 "@com_github_google_glog//:glog",
Austin Schuha1654ed2019-01-27 17:24:54 -0800127 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800128)
129
Austin Schuh6b9c4152019-11-29 12:45:24 -0800130cc_test(
131 name = "pingpong_test",
132 srcs = ["pingpong_test.cc"],
133 data = [":pingpong_config.json"],
134 deps = [
135 ":ping_lib",
136 ":pong_lib",
137 ":simulated_event_loop",
138 "//aos:configuration",
139 "//aos:flatbuffers",
140 "//aos/testing:googletest",
141 ],
142)
143
Parker Schuhe4a70d62017-12-27 20:10:20 -0800144cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700145 name = "shm_event_loop",
146 srcs = ["shm_event_loop.cc"],
147 hdrs = ["shm_event_loop.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800148 visibility = ["//visibility:public"],
149 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700150 ":epoll",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700151 ":event_loop",
152 ":test_message_fbs",
153 "//aos:realtime",
154 "//aos/ipc_lib:lockless_queue",
155 "//aos/ipc_lib:signalfd",
Austin Schuh52d325c2019-06-23 18:59:06 -0700156 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800157 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800158)
159
160cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700161 name = "shm_event_loop_test",
162 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700163 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800164 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700165 ":event_loop_param_test",
166 ":shm_event_loop",
167 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800168 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800169)
170
171cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700172 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800173 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700174 srcs = ["event_loop_param_test.cc"],
175 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800176 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700177 ":event_loop",
178 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800179 "//aos/testing:googletest",
180 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800181)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800182
183cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700184 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700185 srcs = ["simulated_event_loop_test.cc"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800186 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700187 ":event_loop_param_test",
Austin Schuh7267c532019-05-19 19:55:53 -0700188 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800189 "//aos/testing:googletest",
190 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800191)
192
193cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700194 name = "simulated_event_loop",
Austin Schuh82c0c822019-05-27 19:55:20 -0700195 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700196 srcs = [
197 "event_scheduler.cc",
198 "simulated_event_loop.cc",
199 ],
200 hdrs = [
201 "event_scheduler.h",
202 "simulated_event_loop.h",
203 ],
Austin Schuh7267c532019-05-19 19:55:53 -0700204 visibility = ["//visibility:public"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800205 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700206 ":event_loop",
207 "//aos/ipc_lib:index",
Austin Schuh52d325c2019-06-23 18:59:06 -0700208 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700209 "@com_google_absl//absl/container:btree",
Austin Schuha1654ed2019-01-27 17:24:54 -0800210 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800211)
Austin Schuhe309d2a2019-11-29 13:25:21 -0800212
213flatbuffer_cc_library(
214 name = "logger_fbs",
215 srcs = ["logger.fbs"],
216 gen_reflections = 1,
217 includes = [
218 "//aos:configuration_fbs_includes",
219 ],
220)
221
222cc_library(
223 name = "logger",
224 srcs = ["logger.cc"],
225 hdrs = ["logger.h"],
226 deps = [
227 ":event_loop",
228 ":logger_fbs",
229 "//aos:flatbuffer_merge",
230 "//aos/time",
231 "@com_github_google_flatbuffers//:flatbuffers",
232 "@com_google_absl//absl/container:inlined_vector",
233 "@com_google_absl//absl/strings",
234 ],
235)
236
237cc_test(
238 name = "logger_test",
239 srcs = ["logger_test.cc"],
240 data = ["pingpong_config.json"],
241 deps = [
242 ":logger",
243 ":ping_lib",
244 ":pong_lib",
245 ":simulated_event_loop",
246 "//aos/testing:googletest",
247 ],
248)