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