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