blob: dfad4ffb31a68c327fa7fc121ff29f25c71706d6 [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
118cc_library(
119 name = "pong_lib",
120 srcs = [
121 "pong_lib.cc",
122 ],
123 hdrs = [
124 "pong_lib.h",
125 ],
126 deps = [
127 ":event_loop",
128 ":ping_fbs",
129 ":pong_fbs",
130 "@com_github_google_glog//:glog",
131 ],
132)
133
Alex Perrycb7da4b2019-08-28 19:35:56 -0700134cc_binary(
135 name = "pong",
136 srcs = [
137 "pong.cc",
138 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800139 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700140 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -0800141 ":ping_fbs",
142 ":pong_fbs",
143 ":pong_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700144 ":shm_event_loop",
145 "//aos:configuration",
146 "//aos:init",
147 "//aos:json_to_flatbuffer",
148 "@com_github_google_glog//:glog",
Austin Schuha1654ed2019-01-27 17:24:54 -0800149 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800150)
151
Austin Schuh6b9c4152019-11-29 12:45:24 -0800152cc_test(
153 name = "pingpong_test",
154 srcs = ["pingpong_test.cc"],
155 data = [":pingpong_config.json"],
156 deps = [
157 ":ping_lib",
158 ":pong_lib",
159 ":simulated_event_loop",
160 "//aos:configuration",
161 "//aos:flatbuffers",
162 "//aos/testing:googletest",
163 ],
164)
165
Parker Schuhe4a70d62017-12-27 20:10:20 -0800166cc_library(
Austin Schuhe4106142019-12-01 18:19:53 -0800167 name = "timing_statistics",
168 srcs = ["timing_statistics.cc"],
169 hdrs = ["timing_statistics.h"],
170 deps = [
171 ":event_loop_fbs",
172 "//aos:configuration",
173 "@com_github_google_glog//:glog",
174 ],
175)
176
177cc_test(
178 name = "timing_statistics_test",
179 srcs = ["timing_statistics_test.cc"],
180 deps = [
181 ":timing_statistics",
182 "//aos:configuration",
183 "//aos:flatbuffers",
184 "//aos/testing:googletest",
185 ],
186)
187
188cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700189 name = "shm_event_loop",
190 srcs = ["shm_event_loop.cc"],
191 hdrs = ["shm_event_loop.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800192 visibility = ["//visibility:public"],
193 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700194 ":epoll",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700195 ":event_loop",
Austin Schuh39788ff2019-12-01 18:22:57 -0800196 ":event_loop_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700197 ":test_message_fbs",
Austin Schuh39788ff2019-12-01 18:22:57 -0800198 ":timing_statistics",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700199 "//aos:realtime",
200 "//aos/ipc_lib:lockless_queue",
201 "//aos/ipc_lib:signalfd",
Austin Schuh32fd5a72019-12-01 22:20:26 -0800202 "//aos/stl_mutex",
Austin Schuh52d325c2019-06-23 18:59:06 -0700203 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800204 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800205)
206
207cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700208 name = "shm_event_loop_test",
209 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700210 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800211 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700212 ":event_loop_param_test",
213 ":shm_event_loop",
214 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800215 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800216)
217
218cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700219 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800220 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700221 srcs = ["event_loop_param_test.cc"],
222 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800223 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700224 ":event_loop",
225 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800226 "//aos/testing:googletest",
227 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800228)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800229
230cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700231 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700232 srcs = ["simulated_event_loop_test.cc"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800233 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700234 ":event_loop_param_test",
Austin Schuh7267c532019-05-19 19:55:53 -0700235 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800236 "//aos/testing:googletest",
237 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800238)
239
240cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700241 name = "simulated_event_loop",
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)