blob: 45e947b8bc6818427f431b2078d09f3411fb7131 [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_binary(
10 name = "plot_action",
11 srcs = [
James Kuszmaul41fa78a2019-12-14 20:53:14 -080012 "logentry.py",
Austin Schuh8e17be92019-12-24 09:32:11 -080013 "logreader.py",
14 "plot_action.py",
15 "plotter.py",
Lee Mracek3e16a862019-01-24 11:15:36 -050016 ],
17 legacy_create_init = False,
Philipp Schraderdada1072020-11-24 11:34:46 -080018 target_compatible_with = ["@platforms//os:linux"],
Lee Mracek3e16a862019-01-24 11:15:36 -050019 deps = [
20 ":python_init",
James Kuszmaul910f92b2020-01-01 15:30:38 -080021 "@matplotlib_repo//:matplotlib2.7",
Lee Mracek3e16a862019-01-24 11:15:36 -050022 ],
23)
24
25py_library(
26 name = "python_init",
27 srcs = ["__init__.py"],
Philipp Schraderdada1072020-11-24 11:34:46 -080028 target_compatible_with = ["@platforms//os:linux"],
Lee Mracek3e16a862019-01-24 11:15:36 -050029 deps = ["//frc971:python_init"],
30)
James Kuszmaul7daef362019-12-31 18:28:17 -080031
32cc_binary(
33 name = "py_log_reader.so",
34 srcs = ["py_log_reader.cc"],
35 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -080036 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul7daef362019-12-31 18:28:17 -080037 deps = [
38 "//aos:configuration",
39 "//aos:json_to_flatbuffer",
40 "//aos/events:shm_event_loop",
41 "//aos/events:simulated_event_loop",
42 "//aos/events/logging:logger",
43 "@com_github_google_glog//:glog",
44 "@python_repo//:python3.5_lib",
45 ],
46)
47
48py_test(
49 name = "log_reader_test",
50 srcs = ["log_reader_test.py"],
51 data = [
52 ":py_log_reader.so",
53 "@sample_logfile//file",
54 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080055 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul7daef362019-12-31 18:28:17 -080056 deps = ["//aos:configuration_fbs_python"],
57)
James Kuszmaul61a971f2020-01-01 15:06:18 -080058
59py_proto_library(
60 name = "plot_config_proto",
61 srcs = ["plot_config.proto"],
Philipp Schraderdada1072020-11-24 11:34:46 -080062 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul61a971f2020-01-01 15:06:18 -080063)
64
65py_binary(
66 name = "plot",
67 srcs = ["plot.py"],
68 data = [
69 ":py_log_reader.so",
70 ] + glob(["plot_configs/**"]),
Philipp Schraderdada1072020-11-24 11:34:46 -080071 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul61a971f2020-01-01 15:06:18 -080072 deps = [
73 ":plot_config_proto",
74 ":python_init",
75 "@matplotlib_repo//:matplotlib3",
76 ],
77)
James Kuszmaul469fd4e2020-01-01 15:49:10 -080078
79py_test(
80 name = "plot_test",
81 srcs = ["plot_test.py"],
82 data = [
83 "@sample_logfile//file",
84 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080085 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul469fd4e2020-01-01 15:49:10 -080086 deps = [":plot"],
87)
James Kuszmaul5f5e1232020-12-22 20:58:00 -080088
89ts_library(
90 name = "plot_index",
91 srcs = ["plot_index.ts"],
92 target_compatible_with = ["@platforms//os:linux"],
93 deps = [
James Kuszmaul48671362020-12-24 13:54:16 -080094 ":plot_data_utils",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080095 "//aos:configuration_ts_fbs",
96 "//aos/network/www:demo_plot",
97 "//aos/network/www:proxy",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -080098 "//frc971/control_loops/drivetrain:drivetrain_plotter",
milind upadhyay9bd381d2021-01-23 13:44:13 -080099 "//frc971/control_loops/drivetrain:robot_state_plotter",
James Kuszmaul5f5e1232020-12-22 20:58:00 -0800100 "//frc971/wpilib:imu_plotter",
101 ],
102)
103
104rollup_bundle(
105 name = "plot_index_bundle",
106 enable_code_splitting = False,
107 entry_point = "plot_index.ts",
108 target_compatible_with = ["@platforms//os:linux"],
109 deps = [
110 ":plot_index",
111 ],
112)
113
114filegroup(
115 name = "plotter_files",
116 srcs = [
117 "index.html",
118 "plot_index_bundle.min.js",
119 ],
120)
121
122sh_binary(
123 name = "web_plotter",
124 srcs = ["web_plotter.sh"],
125 data = [
126 ":plotter_files",
127 "//aos/network:log_web_proxy_main",
128 ],
129 target_compatible_with = ["@platforms//os:linux"],
130)
131
132sh_binary(
133 name = "live_web_plotter_demo",
134 srcs = ["live_web_plotter_demo.sh"],
135 data = [
136 ":plotter_files",
137 "//aos/network:web_proxy_main",
138 "//aos/network/www:test_config",
139 ],
140 target_compatible_with = ["@platforms//os:linux"],
141)
James Kuszmaul48671362020-12-24 13:54:16 -0800142
143flatbuffer_cc_library(
144 name = "plot_data_fbs",
145 srcs = [
146 "plot_data.fbs",
147 ],
148 gen_reflections = 1,
149 target_compatible_with = ["@platforms//os:linux"],
150)
151
152flatbuffer_ts_library(
153 name = "plot_data_ts_fbs",
154 srcs = [
155 "plot_data.fbs",
156 ],
157 target_compatible_with = ["@platforms//os:linux"],
158)
159
160ts_library(
161 name = "plot_data_utils",
162 srcs = ["plot_data_utils.ts"],
163 visibility = ["//visibility:public"],
164 deps = [
165 ":plot_data_ts_fbs",
166 "//aos:configuration_ts_fbs",
167 "//aos/network/www:aos_plotter",
168 "//aos/network/www:plotter",
169 "//aos/network/www:proxy",
170 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
171 ],
172)
173
174aos_config(
175 name = "plotter",
176 src = "plotter_config.json",
177 flatbuffers = [":plot_data_fbs"],
178 target_compatible_with = ["@platforms//os:linux"],
179 deps = ["//aos/events:config"],
180)
181
182cc_library(
183 name = "in_process_plotter",
184 srcs = ["in_process_plotter.cc"],
185 hdrs = ["in_process_plotter.h"],
186 copts = [
187 "-DWEBRTC_POSIX",
188 ],
189 deps = [
190 ":plot_data_fbs",
191 "//aos/events:simulated_event_loop",
192 "//aos/network:web_proxy",
193 ],
194)
195
196cc_binary(
197 name = "in_process_plotter_demo",
198 srcs = ["in_process_plotter_demo.cc"],
199 copts = [
200 "-DWEBRTC_POSIX",
201 ],
202 data = [
203 ":plotter",
204 ":plotter_files",
205 ],
206 # Tagged manual until we either get the linker working with the current
207 # WebRTC implementation or we get a new implementation.
208 tags = ["manual"],
209 deps = [
210 ":in_process_plotter",
211 "//aos:init",
212 ],
213)