Initial web proxy commit
Change-Id: I28481433e5609d9c819a1a2bce69fa9d096691a2
diff --git a/third_party/flatbuffers/BUILD b/third_party/flatbuffers/BUILD
index 492f158..05553e1 100644
--- a/third_party/flatbuffers/BUILD
+++ b/third_party/flatbuffers/BUILD
@@ -237,3 +237,8 @@
srcs = glob(["python/flatbuffers/*.py"]),
imports = ["python/"],
)
+
+filegroup(
+ name = "flatjs",
+ srcs = ["js/flatbuffers.js"],
+)
diff --git a/third_party/flatbuffers/build_defs.bzl b/third_party/flatbuffers/build_defs.bzl
index da61852..2ddc65b 100644
--- a/third_party/flatbuffers/build_defs.bzl
+++ b/third_party/flatbuffers/build_defs.bzl
@@ -4,6 +4,7 @@
"""
Rules for building C++ flatbuffers with Bazel.
"""
+load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
flatc_path = "@com_github_google_flatbuffers//:flatc"
@@ -26,6 +27,14 @@
"--gen-name-strings",
]
+DEFAULT_FLATC_TS_ARGS = [
+ "--gen-all",
+ "--no-fb-import",
+ "--no-ts-reexport",
+ "--reflect-names",
+ "--reflect-types",
+]
+
def flatbuffer_library_public(
name,
srcs,
@@ -293,3 +302,40 @@
imports = ["."],
deps = ["@com_github_google_flatbuffers//:flatpy"],
)
+
+def flatbuffer_ts_library(
+ name,
+ srcs,
+ compatible_with = None,
+ includes = [],
+ include_paths = DEFAULT_INCLUDE_PATHS,
+ flatc_args = DEFAULT_FLATC_TS_ARGS,
+ visibility = None,
+ srcs_filegroup_visibility = None):
+ """Generates a ts_library rule for a given flatbuffer definition.
+
+ Args:
+ name: Name of the generated ts_library rule.
+ srcs: Source .fbs file(s).
+ """
+ srcs_lib = "%s_srcs" % (name)
+ outs = ["%s_generated.ts" % (s.replace(".fbs", "").split("/")[-1]) for s in srcs]
+ flatbuffer_library_public(
+ name = srcs_lib,
+ srcs = srcs,
+ outs = outs,
+ language_flag = "--ts",
+ includes = includes,
+ include_paths = include_paths,
+ flatc_args = flatc_args,
+ compatible_with = compatible_with,
+ )
+ ts_library(
+ name = name,
+ srcs = outs,
+ visibility = visibility,
+ compatible_with = compatible_with,
+ deps = [
+ "@npm//@types",
+ ],
+ )