blob: 3b3fb5243e9a999aba003b00e0cdbbe175cecfe8 [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",
37 srcs = ["event_loop_tmpl.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -080038 hdrs = [
Alex Perrycb7da4b2019-08-28 19:35:56 -070039 "event_loop.h",
Austin Schuha1654ed2019-01-27 17:24:54 -080040 ],
41 visibility = ["//visibility:public"],
42 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -070043 "//aos:configuration",
44 "//aos:configuration_fbs",
45 "//aos:flatbuffers",
Austin Schuha1654ed2019-01-27 17:24:54 -080046 "//aos/time",
Alex Perrycb7da4b2019-08-28 19:35:56 -070047 "@com_github_google_flatbuffers//:flatbuffers",
48 ],
49)
50
Austin Schuh6b9c4152019-11-29 12:45:24 -080051cc_library(
52 name = "ping_lib",
53 srcs = [
54 "ping_lib.cc",
55 ],
56 hdrs = [
57 "ping_lib.h",
58 ],
59 deps = [
60 ":event_loop",
61 ":ping_fbs",
62 ":pong_fbs",
63 "//aos:json_to_flatbuffer",
64 "@com_github_google_glog//:glog",
65 ],
66)
67
Alex Perrycb7da4b2019-08-28 19:35:56 -070068cc_binary(
69 name = "ping",
70 srcs = [
71 "ping.cc",
72 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -080073 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070074 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -080075 ":ping_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -070076 ":shm_event_loop",
77 "//aos:configuration",
78 "//aos:init",
79 "//aos:json_to_flatbuffer",
80 "@com_github_google_glog//:glog",
81 ],
82)
83
Austin Schuh6b9c4152019-11-29 12:45:24 -080084aos_config(
85 name = "pingpong_config",
86 src = "config.fb.json",
87 flatbuffers = [
88 ":ping_fbs",
89 ":pong_fbs",
90 ],
91)
92
93cc_library(
94 name = "pong_lib",
95 srcs = [
96 "pong_lib.cc",
97 ],
98 hdrs = [
99 "pong_lib.h",
100 ],
101 deps = [
102 ":event_loop",
103 ":ping_fbs",
104 ":pong_fbs",
105 "@com_github_google_glog//:glog",
106 ],
107)
108
Alex Perrycb7da4b2019-08-28 19:35:56 -0700109cc_binary(
110 name = "pong",
111 srcs = [
112 "pong.cc",
113 ],
Austin Schuh6b9c4152019-11-29 12:45:24 -0800114 data = ["pingpong_config.json"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700115 deps = [
Austin Schuh6b9c4152019-11-29 12:45:24 -0800116 ":ping_fbs",
117 ":pong_fbs",
118 ":pong_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700119 ":shm_event_loop",
120 "//aos:configuration",
121 "//aos:init",
122 "//aos:json_to_flatbuffer",
123 "@com_github_google_glog//:glog",
Austin Schuha1654ed2019-01-27 17:24:54 -0800124 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800125)
126
Austin Schuh6b9c4152019-11-29 12:45:24 -0800127cc_test(
128 name = "pingpong_test",
129 srcs = ["pingpong_test.cc"],
130 data = [":pingpong_config.json"],
131 deps = [
132 ":ping_lib",
133 ":pong_lib",
134 ":simulated_event_loop",
135 "//aos:configuration",
136 "//aos:flatbuffers",
137 "//aos/testing:googletest",
138 ],
139)
140
Parker Schuhe4a70d62017-12-27 20:10:20 -0800141cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700142 name = "shm_event_loop",
143 srcs = ["shm_event_loop.cc"],
144 hdrs = ["shm_event_loop.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800145 visibility = ["//visibility:public"],
146 deps = [
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700147 ":epoll",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700148 ":event_loop",
149 ":test_message_fbs",
150 "//aos:realtime",
151 "//aos/ipc_lib:lockless_queue",
152 "//aos/ipc_lib:signalfd",
Austin Schuh52d325c2019-06-23 18:59:06 -0700153 "//aos/util:phased_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800154 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800155)
156
157cc_test(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700158 name = "shm_event_loop_test",
159 srcs = ["shm_event_loop_test.cc"],
Austin Schuh6b6dfa52019-06-12 20:16:20 -0700160 shard_count = 5,
Austin Schuha1654ed2019-01-27 17:24:54 -0800161 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700162 ":event_loop_param_test",
163 ":shm_event_loop",
164 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800165 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800166)
167
168cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700169 name = "event_loop_param_test",
Austin Schuha1654ed2019-01-27 17:24:54 -0800170 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700171 srcs = ["event_loop_param_test.cc"],
172 hdrs = ["event_loop_param_test.h"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800173 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700174 ":event_loop",
175 ":test_message_fbs",
Austin Schuha1654ed2019-01-27 17:24:54 -0800176 "//aos/testing:googletest",
177 ],
Parker Schuhe4a70d62017-12-27 20:10:20 -0800178)
Neil Balchc8f41ed2018-01-20 22:06:53 -0800179
180cc_test(
Austin Schuh7267c532019-05-19 19:55:53 -0700181 name = "simulated_event_loop_test",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700182 srcs = ["simulated_event_loop_test.cc"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800183 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700184 ":event_loop_param_test",
Austin Schuh7267c532019-05-19 19:55:53 -0700185 ":simulated_event_loop",
Austin Schuha1654ed2019-01-27 17:24:54 -0800186 "//aos/testing:googletest",
187 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800188)
189
190cc_library(
Austin Schuh7267c532019-05-19 19:55:53 -0700191 name = "simulated_event_loop",
Austin Schuh82c0c822019-05-27 19:55:20 -0700192 testonly = True,
Alex Perrycb7da4b2019-08-28 19:35:56 -0700193 srcs = [
194 "event_scheduler.cc",
195 "simulated_event_loop.cc",
196 ],
197 hdrs = [
198 "event_scheduler.h",
199 "simulated_event_loop.h",
200 ],
Austin Schuh7267c532019-05-19 19:55:53 -0700201 visibility = ["//visibility:public"],
Austin Schuha1654ed2019-01-27 17:24:54 -0800202 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700203 ":event_loop",
204 "//aos/ipc_lib:index",
Austin Schuh52d325c2019-06-23 18:59:06 -0700205 "//aos/util:phased_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700206 "@com_google_absl//absl/container:btree",
Austin Schuha1654ed2019-01-27 17:24:54 -0800207 ],
Neil Balchc8f41ed2018-01-20 22:06:53 -0800208)