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