[Bazel] Fix gen_reflections for flatbuffers_ts_library (#7981)

If you used flatbuffers_ts_library with gen_reflections = True then it
attempted to use the flat-file compiler rather than flatc itself.

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
James Kuszmaul 2023-05-31 11:07:37 -07:00 committed by GitHub
parent 85088a196d
commit 204473cdb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -87,6 +87,7 @@ def flatbuffer_library_public(
optionally a Fileset([reflection_name]) with all generated reflection
binaries.
"""
reflection_include_paths = include_paths
if include_paths == None:
include_paths = default_include_paths(flatc_path)
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
@ -124,13 +125,16 @@ def flatbuffer_library_public(
**kwargs
)
if reflection_name:
if reflection_include_paths == None:
reflection_include_paths = default_include_paths(TRUE_FLATC_PATH)
reflection_include_paths_cmd = ["-I %s" % (s) for s in reflection_include_paths]
reflection_genrule_cmd = " ".join([
"SRCS=($(SRCS));",
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
"$(location %s)" % (TRUE_FLATC_PATH),
"-b --schema",
" ".join(flatc_args),
" ".join(include_paths_cmd),
" ".join(reflection_include_paths_cmd),
language_flag,
output_directory,
"$$f;",

View File

@ -10,5 +10,6 @@ genrule(
flatbuffer_ts_library(
name = "reflection_ts_fbs",
srcs = [":reflection.fbs"],
gen_reflections = True,
visibility = ["//visibility:public"],
)