blob: ea83668bcd4fad8f86ff40f28c3b85861780ea19 [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 Kuszmaulac2b6b42021-03-07 22:38:06 -080082 "//frc971/control_loops/drivetrain:down_estimator_plotter",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -080083 "//frc971/control_loops/drivetrain:drivetrain_plotter",
milind upadhyay9bd381d2021-01-23 13:44:13 -080084 "//frc971/control_loops/drivetrain:robot_state_plotter",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080085 "//frc971/wpilib:imu_plotter",
Austin Schuh7d63eab2021-03-06 20:15:02 -080086 "//y2020/control_loops/superstructure:accelerator_plotter",
87 "//y2020/control_loops/superstructure:finisher_plotter",
Austin Schuh2efe1682021-03-06 22:47:15 -080088 "//y2020/control_loops/superstructure:hood_plotter",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080089 ],
90)
91
92rollup_bundle(
93 name = "plot_index_bundle",
94 enable_code_splitting = False,
95 entry_point = "plot_index.ts",
96 target_compatible_with = ["@platforms//os:linux"],
97 deps = [
98 ":plot_index",
99 ],
100)
101
102filegroup(
103 name = "plotter_files",
104 srcs = [
105 "index.html",
106 "plot_index_bundle.min.js",
107 ],
108)
109
110sh_binary(
111 name = "web_plotter",
112 srcs = ["web_plotter.sh"],
113 data = [
114 ":plotter_files",
115 "//aos/network:log_web_proxy_main",
116 ],
117 target_compatible_with = ["@platforms//os:linux"],
118)
119
120sh_binary(
121 name = "live_web_plotter_demo",
122 srcs = ["live_web_plotter_demo.sh"],
123 data = [
124 ":plotter_files",
125 "//aos/network:web_proxy_main",
126 "//aos/network/www:test_config",
127 ],
128 target_compatible_with = ["@platforms//os:linux"],
129)
James Kuszmaul48671362020-12-24 13:54:16 -0800130
131flatbuffer_cc_library(
132 name = "plot_data_fbs",
133 srcs = [
134 "plot_data.fbs",
135 ],
136 gen_reflections = 1,
137 target_compatible_with = ["@platforms//os:linux"],
138)
139
140flatbuffer_ts_library(
141 name = "plot_data_ts_fbs",
142 srcs = [
143 "plot_data.fbs",
144 ],
145 target_compatible_with = ["@platforms//os:linux"],
146)
147
148ts_library(
149 name = "plot_data_utils",
150 srcs = ["plot_data_utils.ts"],
151 visibility = ["//visibility:public"],
152 deps = [
153 ":plot_data_ts_fbs",
154 "//aos:configuration_ts_fbs",
155 "//aos/network/www:aos_plotter",
156 "//aos/network/www:plotter",
157 "//aos/network/www:proxy",
158 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
159 ],
160)
161
162aos_config(
163 name = "plotter",
164 src = "plotter_config.json",
165 flatbuffers = [":plot_data_fbs"],
166 target_compatible_with = ["@platforms//os:linux"],
167 deps = ["//aos/events:config"],
168)
169
170cc_library(
171 name = "in_process_plotter",
172 srcs = ["in_process_plotter.cc"],
173 hdrs = ["in_process_plotter.h"],
174 copts = [
175 "-DWEBRTC_POSIX",
176 ],
177 deps = [
178 ":plot_data_fbs",
179 "//aos/events:simulated_event_loop",
180 "//aos/network:web_proxy",
181 ],
182)
183
184cc_binary(
185 name = "in_process_plotter_demo",
186 srcs = ["in_process_plotter_demo.cc"],
187 copts = [
188 "-DWEBRTC_POSIX",
189 ],
190 data = [
191 ":plotter",
192 ":plotter_files",
193 ],
194 # Tagged manual until we either get the linker working with the current
195 # WebRTC implementation or we get a new implementation.
196 tags = ["manual"],
197 deps = [
198 ":in_process_plotter",
199 "//aos:init",
200 ],
201)