blob: 2223955b17daccd7c8191937a0d1f54963b57b68 [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",
86 ],
87)
88
89rollup_bundle(
90 name = "plot_index_bundle",
91 enable_code_splitting = False,
92 entry_point = "plot_index.ts",
93 target_compatible_with = ["@platforms//os:linux"],
94 deps = [
95 ":plot_index",
96 ],
97)
98
99filegroup(
100 name = "plotter_files",
101 srcs = [
102 "index.html",
103 "plot_index_bundle.min.js",
104 ],
105)
106
107sh_binary(
108 name = "web_plotter",
109 srcs = ["web_plotter.sh"],
110 data = [
111 ":plotter_files",
112 "//aos/network:log_web_proxy_main",
113 ],
114 target_compatible_with = ["@platforms//os:linux"],
115)
116
117sh_binary(
118 name = "live_web_plotter_demo",
119 srcs = ["live_web_plotter_demo.sh"],
120 data = [
121 ":plotter_files",
122 "//aos/network:web_proxy_main",
123 "//aos/network/www:test_config",
124 ],
125 target_compatible_with = ["@platforms//os:linux"],
126)
James Kuszmaul48671362020-12-24 13:54:16 -0800127
128flatbuffer_cc_library(
129 name = "plot_data_fbs",
130 srcs = [
131 "plot_data.fbs",
132 ],
133 gen_reflections = 1,
134 target_compatible_with = ["@platforms//os:linux"],
135)
136
137flatbuffer_ts_library(
138 name = "plot_data_ts_fbs",
139 srcs = [
140 "plot_data.fbs",
141 ],
142 target_compatible_with = ["@platforms//os:linux"],
143)
144
145ts_library(
146 name = "plot_data_utils",
147 srcs = ["plot_data_utils.ts"],
148 visibility = ["//visibility:public"],
149 deps = [
150 ":plot_data_ts_fbs",
151 "//aos:configuration_ts_fbs",
152 "//aos/network/www:aos_plotter",
153 "//aos/network/www:plotter",
154 "//aos/network/www:proxy",
155 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
156 ],
157)
158
159aos_config(
160 name = "plotter",
161 src = "plotter_config.json",
162 flatbuffers = [":plot_data_fbs"],
163 target_compatible_with = ["@platforms//os:linux"],
164 deps = ["//aos/events:config"],
165)
166
167cc_library(
168 name = "in_process_plotter",
169 srcs = ["in_process_plotter.cc"],
170 hdrs = ["in_process_plotter.h"],
171 copts = [
172 "-DWEBRTC_POSIX",
173 ],
174 deps = [
175 ":plot_data_fbs",
176 "//aos/events:simulated_event_loop",
177 "//aos/network:web_proxy",
178 ],
179)
180
181cc_binary(
182 name = "in_process_plotter_demo",
183 srcs = ["in_process_plotter_demo.cc"],
184 copts = [
185 "-DWEBRTC_POSIX",
186 ],
187 data = [
188 ":plotter",
189 ":plotter_files",
190 ],
191 # Tagged manual until we either get the linker working with the current
192 # WebRTC implementation or we get a new implementation.
193 tags = ["manual"],
194 deps = [
195 ":in_process_plotter",
196 "//aos:init",
197 ],
198)