Lee Mracek | 3e16a86 | 2019-01-24 11:15:36 -0500 | [diff] [blame] | 1 | package(default_visibility = ["//visibility:public"]) |
| 2 | |
James Kuszmaul | 5f5e123 | 2020-12-22 20:58:00 -0800 | [diff] [blame] | 3 | load("@npm_bazel_typescript//:defs.bzl", "ts_library") |
James Kuszmaul | 61a971f | 2020-01-01 15:06:18 -0800 | [diff] [blame] | 4 | load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") |
James Kuszmaul | 5f5e123 | 2020-12-22 20:58:00 -0800 | [diff] [blame] | 5 | load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "rollup_bundle") |
James Kuszmaul | 4867136 | 2020-12-24 13:54:16 -0800 | [diff] [blame] | 6 | load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library") |
| 7 | load("//aos:config.bzl", "aos_config") |
James Kuszmaul | 61a971f | 2020-01-01 15:06:18 -0800 | [diff] [blame] | 8 | |
Lee Mracek | 3e16a86 | 2019-01-24 11:15:36 -0500 | [diff] [blame] | 9 | py_library( |
| 10 | name = "python_init", |
| 11 | srcs = ["__init__.py"], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 12 | target_compatible_with = ["@platforms//os:linux"], |
Lee Mracek | 3e16a86 | 2019-01-24 11:15:36 -0500 | [diff] [blame] | 13 | deps = ["//frc971:python_init"], |
| 14 | ) |
James Kuszmaul | 7daef36 | 2019-12-31 18:28:17 -0800 | [diff] [blame] | 15 | |
| 16 | cc_binary( |
| 17 | name = "py_log_reader.so", |
| 18 | srcs = ["py_log_reader.cc"], |
| 19 | linkshared = True, |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 20 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | 7daef36 | 2019-12-31 18:28:17 -0800 | [diff] [blame] | 21 | deps = [ |
| 22 | "//aos:configuration", |
| 23 | "//aos:json_to_flatbuffer", |
| 24 | "//aos/events:shm_event_loop", |
| 25 | "//aos/events:simulated_event_loop", |
Austin Schuh | b06f03b | 2021-02-17 22:00:37 -0800 | [diff] [blame] | 26 | "//aos/events/logging:log_reader", |
James Kuszmaul | 7daef36 | 2019-12-31 18:28:17 -0800 | [diff] [blame] | 27 | "@com_github_google_glog//:glog", |
Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame] | 28 | "@python_repo//:python3.7_lib", |
James Kuszmaul | 7daef36 | 2019-12-31 18:28:17 -0800 | [diff] [blame] | 29 | ], |
| 30 | ) |
| 31 | |
| 32 | py_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 Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 39 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | 7daef36 | 2019-12-31 18:28:17 -0800 | [diff] [blame] | 40 | deps = ["//aos:configuration_fbs_python"], |
| 41 | ) |
James Kuszmaul | 61a971f | 2020-01-01 15:06:18 -0800 | [diff] [blame] | 42 | |
| 43 | py_proto_library( |
| 44 | name = "plot_config_proto", |
| 45 | srcs = ["plot_config.proto"], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 46 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | 61a971f | 2020-01-01 15:06:18 -0800 | [diff] [blame] | 47 | ) |
| 48 | |
| 49 | py_binary( |
| 50 | name = "plot", |
| 51 | srcs = ["plot.py"], |
| 52 | data = [ |
| 53 | ":py_log_reader.so", |
| 54 | ] + glob(["plot_configs/**"]), |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 55 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | 61a971f | 2020-01-01 15:06:18 -0800 | [diff] [blame] | 56 | deps = [ |
| 57 | ":plot_config_proto", |
| 58 | ":python_init", |
| 59 | "@matplotlib_repo//:matplotlib3", |
| 60 | ], |
| 61 | ) |
James Kuszmaul | 469fd4e | 2020-01-01 15:49:10 -0800 | [diff] [blame] | 62 | |
| 63 | py_test( |
| 64 | name = "plot_test", |
| 65 | srcs = ["plot_test.py"], |
| 66 | data = [ |
| 67 | "@sample_logfile//file", |
| 68 | ], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 69 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | 469fd4e | 2020-01-01 15:49:10 -0800 | [diff] [blame] | 70 | deps = [":plot"], |
| 71 | ) |
James Kuszmaul | 5f5e123 | 2020-12-22 20:58:00 -0800 | [diff] [blame] | 72 | |
| 73 | ts_library( |
| 74 | name = "plot_index", |
| 75 | srcs = ["plot_index.ts"], |
| 76 | target_compatible_with = ["@platforms//os:linux"], |
| 77 | deps = [ |
James Kuszmaul | 4867136 | 2020-12-24 13:54:16 -0800 | [diff] [blame] | 78 | ":plot_data_utils", |
James Kuszmaul | 5f5e123 | 2020-12-22 20:58:00 -0800 | [diff] [blame] | 79 | "//aos:configuration_ts_fbs", |
| 80 | "//aos/network/www:demo_plot", |
| 81 | "//aos/network/www:proxy", |
James Kuszmaul | c4ae11c | 2020-12-26 16:26:58 -0800 | [diff] [blame] | 82 | "//frc971/control_loops/drivetrain:drivetrain_plotter", |
milind upadhyay | 9bd381d | 2021-01-23 13:44:13 -0800 | [diff] [blame] | 83 | "//frc971/control_loops/drivetrain:robot_state_plotter", |
James Kuszmaul | 5f5e123 | 2020-12-22 20:58:00 -0800 | [diff] [blame] | 84 | "//frc971/wpilib:imu_plotter", |
Austin Schuh | 7d63eab | 2021-03-06 20:15:02 -0800 | [diff] [blame^] | 85 | "//y2020/control_loops/superstructure:accelerator_plotter", |
| 86 | "//y2020/control_loops/superstructure:finisher_plotter", |
James Kuszmaul | 5f5e123 | 2020-12-22 20:58:00 -0800 | [diff] [blame] | 87 | ], |
| 88 | ) |
| 89 | |
| 90 | rollup_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 | |
| 100 | filegroup( |
| 101 | name = "plotter_files", |
| 102 | srcs = [ |
| 103 | "index.html", |
| 104 | "plot_index_bundle.min.js", |
| 105 | ], |
| 106 | ) |
| 107 | |
| 108 | sh_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 | |
| 118 | sh_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 Kuszmaul | 4867136 | 2020-12-24 13:54:16 -0800 | [diff] [blame] | 128 | |
| 129 | flatbuffer_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 | |
| 138 | flatbuffer_ts_library( |
| 139 | name = "plot_data_ts_fbs", |
| 140 | srcs = [ |
| 141 | "plot_data.fbs", |
| 142 | ], |
| 143 | target_compatible_with = ["@platforms//os:linux"], |
| 144 | ) |
| 145 | |
| 146 | ts_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 | |
| 160 | aos_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 | |
| 168 | cc_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 | |
| 182 | cc_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 | ) |