Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@ Rules for building C++ flatbuffers with Bazel.

load("@rules_cc//cc:defs.bzl", "cc_library")

TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc"
def repo_name(label):
if hasattr(label, "repo_name"): # Added in Bazel 7.1
return label.repo_name
else:
return "com_github_google_flatbuffers"

TRUE_FLATC_PATH = Label("//:flatc")

DEFAULT_INCLUDE_PATHS = [
"./",
"$(GENDIR)",
"$(BINDIR)",
"$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers",
"$(execpath %s).runfiles/%s" % (TRUE_FLATC_PATH, repo_name(TRUE_FLATC_PATH)),
]

def default_include_paths(flatc_path):
return [
"./",
"$(GENDIR)",
"$(BINDIR)",
"$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path),
"$(execpath %s).runfiles/%s" % (flatc_path, repo_name(flatc_path)),
]

DEFAULT_FLATC_ARGS = [
Expand All @@ -47,7 +53,7 @@ def flatbuffer_library_public(
compatible_with = None,
restricted_to = None,
target_compatible_with = None,
flatc_path = "@com_github_google_flatbuffers//:flatc",
flatc_path = None,
output_to_bindir = False,
tools = None,
extra_env = None,
Expand Down Expand Up @@ -87,6 +93,11 @@ def flatbuffer_library_public(
optionally a Fileset([reflection_name]) with all generated reflection
binaries.
"""
if flatc_path == None:
flatc_path = TRUE_FLATC_PATH
else:
flatc_path = native.package_relative_label(flatc_path)

reflection_include_paths = include_paths
if include_paths == None:
include_paths = default_include_paths(flatc_path)
Expand Down Expand Up @@ -262,8 +273,8 @@ def flatbuffer_cc_library(
"-parse_headers",
],
deps = [
"@com_github_google_flatbuffers//:runtime_cc",
"@com_github_google_flatbuffers//:flatbuffers",
Label("//:runtime_cc"),
Label("//:flatbuffers"),
] + deps,
includes = cc_include_paths,
compatible_with = compatible_with,
Expand Down
2 changes: 1 addition & 1 deletion ts/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sh_binary(
name = "compile_flat_file",
srcs = ["compile_flat_file.sh"],
data = [
"@com_github_google_flatbuffers//:flatc",
"//:flatc",
"@nodejs_linux_amd64//:node_bin",
],
# We just depend directly on the linux amd64 nodejs binary, so only support
Expand Down
2 changes: 1 addition & 1 deletion typescript.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def flatbuffer_ts_library(
reflection_name = reflection_name,
reflection_visibility = visibility,
target_compatible_with = target_compatible_with,
flatc_path = "@com_github_google_flatbuffers//ts:compile_flat_file",
flatc_path = Label("//ts:compile_flat_file"),
toolchains = ["@aspect_rules_esbuild//esbuild:resolved_toolchain"],
tools = ["@aspect_rules_esbuild//esbuild:resolved_toolchain"],
)
Expand Down
Loading