blob: 2b8c54c612ebd6acb1add05adeab26e364ea98ad [file] [log] [blame]
Lee Mracek3e16a862019-01-24 11:15:36 -05001package(default_visibility = ["//visibility:public"])
2
James Kuszmaul5f5e1232020-12-22 20:58:00 -08003load("@npm_bazel_typescript//:defs.bzl", "ts_library")
James Kuszmaul61a971f2020-01-01 15:06:18 -08004load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
James Kuszmaul5f5e1232020-12-22 20:58:00 -08005load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "rollup_bundle")
James Kuszmaul48671362020-12-24 13:54:16 -08006load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library")
7load("//aos:config.bzl", "aos_config")
James Kuszmaul61a971f2020-01-01 15:06:18 -08008
Lee Mracek3e16a862019-01-24 11:15:36 -05009py_library(
10 name = "python_init",
11 srcs = ["__init__.py"],
Philipp Schraderdada1072020-11-24 11:34:46 -080012 target_compatible_with = ["@platforms//os:linux"],
Lee Mracek3e16a862019-01-24 11:15:36 -050013 deps = ["//frc971:python_init"],
14)
James Kuszmaul7daef362019-12-31 18:28:17 -080015
16cc_binary(
17 name = "py_log_reader.so",
18 srcs = ["py_log_reader.cc"],
19 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -080020 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul7daef362019-12-31 18:28:17 -080021 deps = [
22 "//aos:configuration",
23 "//aos:json_to_flatbuffer",
24 "//aos/events:shm_event_loop",
25 "//aos/events:simulated_event_loop",
Austin Schuhb06f03b2021-02-17 22:00:37 -080026 "//aos/events/logging:log_reader",
James Kuszmaul7daef362019-12-31 18:28:17 -080027 "@com_github_google_glog//:glog",
Austin Schuh085eab92020-11-26 13:54:51 -080028 "@python_repo//:python3.7_lib",
James Kuszmaul7daef362019-12-31 18:28:17 -080029 ],
30)
31
32py_test(
33 name = "log_reader_test",
34 srcs = ["log_reader_test.py"],
35 data = [
36 ":py_log_reader.so",
37 "@sample_logfile//file",
38 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080039 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul7daef362019-12-31 18:28:17 -080040 deps = ["//aos:configuration_fbs_python"],
41)
James Kuszmaul61a971f2020-01-01 15:06:18 -080042
43py_proto_library(
44 name = "plot_config_proto",
45 srcs = ["plot_config.proto"],
Philipp Schraderdada1072020-11-24 11:34:46 -080046 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul61a971f2020-01-01 15:06:18 -080047)
48
49py_binary(
50 name = "plot",
51 srcs = ["plot.py"],
52 data = [
53 ":py_log_reader.so",
54 ] + glob(["plot_configs/**"]),
Philipp Schraderdada1072020-11-24 11:34:46 -080055 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul61a971f2020-01-01 15:06:18 -080056 deps = [
57 ":plot_config_proto",
58 ":python_init",
59 "@matplotlib_repo//:matplotlib3",
60 ],
61)
James Kuszmaul469fd4e2020-01-01 15:49:10 -080062
63py_test(
64 name = "plot_test",
65 srcs = ["plot_test.py"],
66 data = [
67 "@sample_logfile//file",
68 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080069 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul469fd4e2020-01-01 15:49:10 -080070 deps = [":plot"],
71)
James Kuszmaul5f5e1232020-12-22 20:58:00 -080072
73ts_library(
74 name = "plot_index",
75 srcs = ["plot_index.ts"],
76 target_compatible_with = ["@platforms//os:linux"],
77 deps = [
James Kuszmaul48671362020-12-24 13:54:16 -080078 ":plot_data_utils",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080079 "//aos:configuration_ts_fbs",
80 "//aos/network/www:demo_plot",
81 "//aos/network/www:proxy",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -080082 "//frc971/control_loops/drivetrain:drivetrain_plotter",
milind upadhyay9bd381d2021-01-23 13:44:13 -080083 "//frc971/control_loops/drivetrain:robot_state_plotter",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080084 "//frc971/wpilib:imu_plotter",
Austin Schuh7d63eab2021-03-06 20:15:02 -080085 "//y2020/control_loops/superstructure:accelerator_plotter",
86 "//y2020/control_loops/superstructure:finisher_plotter",
Austin Schuh2efe1682021-03-06 22:47:15 -080087 "//y2020/control_loops/superstructure:hood_plotter",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080088 ],
89)
90
91rollup_bundle(
92 name = "plot_index_bundle",
93 enable_code_splitting = False,
94 entry_point = "plot_index.ts",
95 target_compatible_with = ["@platforms//os:linux"],
96 deps = [
97 ":plot_index",
98 ],
99)
100
101filegroup(
102 name = "plotter_files",
103 srcs = [
104 "index.html",
105 "plot_index_bundle.min.js",
106 ],
107)
108
109sh_binary(
110 name = "web_plotter",
111 srcs = ["web_plotter.sh"],
112 data = [
113 ":plotter_files",
114 "//aos/network:log_web_proxy_main",
115 ],
116 target_compatible_with = ["@platforms//os:linux"],
117)
118
119sh_binary(
120 name = "live_web_plotter_demo",
121 srcs = ["live_web_plotter_demo.sh"],
122 data = [
123 ":plotter_files",
124 "//aos/network:web_proxy_main",
125 "//aos/network/www:test_config",
126 ],
127 target_compatible_with = ["@platforms//os:linux"],
128)
James Kuszmaul48671362020-12-24 13:54:16 -0800129
130flatbuffer_cc_library(
131 name = "plot_data_fbs",
132 srcs = [
133 "plot_data.fbs",
134 ],
135 gen_reflections = 1,
136 target_compatible_with = ["@platforms//os:linux"],
137)
138
139flatbuffer_ts_library(
140 name = "plot_data_ts_fbs",
141 srcs = [
142 "plot_data.fbs",
143 ],
144 target_compatible_with = ["@platforms//os:linux"],
145)
146
147ts_library(
148 name = "plot_data_utils",
149 srcs = ["plot_data_utils.ts"],
150 visibility = ["//visibility:public"],
151 deps = [
152 ":plot_data_ts_fbs",
153 "//aos:configuration_ts_fbs",
154 "//aos/network/www:aos_plotter",
155 "//aos/network/www:plotter",
156 "//aos/network/www:proxy",
157 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
158 ],
159)
160
161aos_config(
162 name = "plotter",
163 src = "plotter_config.json",
164 flatbuffers = [":plot_data_fbs"],
165 target_compatible_with = ["@platforms//os:linux"],
166 deps = ["//aos/events:config"],
167)
168
169cc_library(
170 name = "in_process_plotter",
171 srcs = ["in_process_plotter.cc"],
172 hdrs = ["in_process_plotter.h"],
173 copts = [
174 "-DWEBRTC_POSIX",
175 ],
176 deps = [
177 ":plot_data_fbs",
178 "//aos/events:simulated_event_loop",
179 "//aos/network:web_proxy",
180 ],
181)
182
183cc_binary(
184 name = "in_process_plotter_demo",
185 srcs = ["in_process_plotter_demo.cc"],
186 copts = [
187 "-DWEBRTC_POSIX",
188 ],
189 data = [
190 ":plotter",
191 ":plotter_files",
192 ],
193 # Tagged manual until we either get the linker working with the current
194 # WebRTC implementation or we get a new implementation.
195 tags = ["manual"],
196 deps = [
197 ":in_process_plotter",
198 "//aos:init",
199 ],
200)