Clean up import of typescript reflection_generated
Importing it via org_frc971/... is cumbersome and has poor portability
when used from an external repository.
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
Change-Id: I3d4ab41b730fc56e6ee31bae7f2e2784fb0bd5a1
diff --git a/aos/network/www/aos_plotter.ts b/aos/network/www/aos_plotter.ts
index b7d8771..cd2e131 100644
--- a/aos/network/www/aos_plotter.ts
+++ b/aos/network/www/aos_plotter.ts
@@ -28,7 +28,7 @@
import {Connection} from 'org_frc971/aos/network/www/proxy';
import {SubscriberRequest, ChannelRequest, TransferMethod} from 'org_frc971/aos/network/web_proxy_generated';
import {Parser, Table} from 'org_frc971/aos/network/www/reflection'
-import {Schema} from 'org_frc971/external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {Schema} from 'flatbuffers_reflection/reflection_generated';
import {ByteBuffer} from 'flatbuffers';
export class TimestampedMessage {
diff --git a/aos/network/www/proxy.ts b/aos/network/www/proxy.ts
index cf8e972..0bda8b9 100644
--- a/aos/network/www/proxy.ts
+++ b/aos/network/www/proxy.ts
@@ -1,7 +1,7 @@
import {Builder, ByteBuffer, Offset} from 'flatbuffers';
import {Channel as ChannelFb, Configuration} from 'org_frc971/aos/configuration_generated';
import {ChannelRequest as ChannelRequestFb, ChannelState, MessageHeader, Payload, SdpType, SubscriberRequest, TransferMethod, WebSocketIce, WebSocketMessage, WebSocketSdp} from 'org_frc971/aos/network/web_proxy_generated';
-import {Schema} from 'org_frc971/external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {Schema} from 'flatbuffers_reflection/reflection_generated';
// There is one handler for each DataChannel, it maintains the state of
// multi-part messages and delegates to a callback when the message is fully
diff --git a/frc971/analysis/plot_data_utils.ts b/frc971/analysis/plot_data_utils.ts
index 230e370..80c4cca 100644
--- a/frc971/analysis/plot_data_utils.ts
+++ b/frc971/analysis/plot_data_utils.ts
@@ -5,7 +5,7 @@
import {ByteBuffer} from 'flatbuffers';
import {Plot, Point} from 'org_frc971/aos/network/www/plotter';
import {Connection} from 'org_frc971/aos/network/www/proxy';
-import {Schema} from 'org_frc971/external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {Schema} from 'flatbuffers_reflection/reflection_generated';
export function plotData(conn: Connection, parentDiv: Element) {
// Set up a selection box to allow the user to choose between plots to show.
diff --git a/frc971/wpilib/imu_plot_utils.ts b/frc971/wpilib/imu_plot_utils.ts
index 08b3c13..c4b516b 100644
--- a/frc971/wpilib/imu_plot_utils.ts
+++ b/frc971/wpilib/imu_plot_utils.ts
@@ -5,7 +5,7 @@
import {Point} from 'org_frc971/aos/network/www/plotter';
import {Table} from 'org_frc971/aos/network/www/reflection';
import {ByteBuffer} from 'flatbuffers';
-import {Schema} from 'org_frc971/external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {Schema} from 'flatbuffers_reflection/reflection_generated';
const FILTER_WINDOW_SIZE = 100;
diff --git a/third_party/flatbuffers/build_defs.bzl b/third_party/flatbuffers/build_defs.bzl
index cb50726..7eaa4d3 100644
--- a/third_party/flatbuffers/build_defs.bzl
+++ b/third_party/flatbuffers/build_defs.bzl
@@ -379,7 +379,8 @@
flatc_args = DEFAULT_FLATC_TS_ARGS,
visibility = None,
restricted_to = None,
- include_reflection = True):
+ include_reflection = True,
+ package_name = None):
"""Generates a ts_library rule for a given flatbuffer definition.
Args:
@@ -401,6 +402,7 @@
include_reflection: Optional, Whether to depend on the flatbuffer
reflection library automatically. Only really relevant for the
target that builds the reflection library itself.
+ package_name: Optional, Package name to use for the generated code.
"""
srcs_lib = "%s_srcs" % (name)
@@ -428,7 +430,7 @@
"SRCS=($(SRCS));",
"OUTS=($(OUTS));",
"for i in $${!SRCS[@]}; do",
- "sed 's/third_party\\/flatbuffers/external\\/com_github_google_flatbuffers/' $${SRCS[i]} > $${OUTS[i]};",
+ "sed \"s/'.*reflection\\/reflection_pregenerated/'flatbuffers_reflection\\/reflection_generated/\" $${SRCS[i]} > $${OUTS[i]};",
"sed -i 's/_pregenerated/_generated/' $${OUTS[i]};",
"done",
])
@@ -469,6 +471,7 @@
restricted_to = restricted_to,
target_compatible_with = target_compatible_with,
deps = [name + "_ts"],
+ package_name = package_name,
)
native.filegroup(
name = "%s_includes" % (name),
diff --git a/third_party/flatbuffers/reflection/BUILD.bazel b/third_party/flatbuffers/reflection/BUILD.bazel
index 7948e12..aa421db 100644
--- a/third_party/flatbuffers/reflection/BUILD.bazel
+++ b/third_party/flatbuffers/reflection/BUILD.bazel
@@ -8,6 +8,7 @@
flatbuffer_ts_library(
name = "reflection_ts_fbs",
+ package_name = "flatbuffers_reflection",
srcs = ["reflection.fbs"],
include_reflection = False,
visibility = ["//visibility:public"],
diff --git a/y2020/control_loops/drivetrain/localizer_plotter.ts b/y2020/control_loops/drivetrain/localizer_plotter.ts
index 9fe80de..b2120ef 100644
--- a/y2020/control_loops/drivetrain/localizer_plotter.ts
+++ b/y2020/control_loops/drivetrain/localizer_plotter.ts
@@ -6,7 +6,7 @@
import {Point} from 'org_frc971/aos/network/www/plotter';
import {Table} from 'org_frc971/aos/network/www/reflection';
import {ByteBuffer} from 'flatbuffers';
-import {Schema} from 'org_frc971/external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {Schema} from 'flatbuffers_reflection/reflection_generated';
const TIME = AosPlotter.TIME;
diff --git a/y2020/control_loops/superstructure/turret_plotter.ts b/y2020/control_loops/superstructure/turret_plotter.ts
index 2c3fb01..5cb15c6 100644
--- a/y2020/control_loops/superstructure/turret_plotter.ts
+++ b/y2020/control_loops/superstructure/turret_plotter.ts
@@ -7,7 +7,7 @@
import {Point} from 'org_frc971/aos/network/www/plotter';
import {Table} from 'org_frc971/aos/network/www/reflection';
import {ByteBuffer} from 'flatbuffers';
-import {Schema} from 'org_frc971/external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {Schema} from 'flatbuffers_reflection/reflection_generated';
import Connection = proxy.Connection;
diff --git a/y2022/vision/vision_plotter.ts b/y2022/vision/vision_plotter.ts
index 8b9fa7f..adbf900 100644
--- a/y2022/vision/vision_plotter.ts
+++ b/y2022/vision/vision_plotter.ts
@@ -4,7 +4,7 @@
import {BLUE, BROWN, CYAN, GREEN, PINK, RED, WHITE} from 'org_frc971/aos/network/www/colors';
import {Connection} from 'org_frc971/aos/network/www/proxy';
import {Table} from 'org_frc971/aos/network/www/reflection';
-import {Schema} from 'org_frc971/external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {Schema} from 'flatbuffers_reflection/reflection_generated';
import {TargetEstimate} from 'org_frc971/y2022/vision/target_estimate_generated';