Skip to content

Commit

Permalink
Update flatbuffers (bazelbuild#3629)
Browse files Browse the repository at this point in the history
Backporting fix google/flatbuffers#8492.
  • Loading branch information
mering authored Jan 21, 2025
1 parent 4e6dcbd commit ded2414
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 1 deletion.
73 changes: 73 additions & 0 deletions modules/flatbuffers/24.3.25.bcr.1/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module(
name = "flatbuffers",
version = "24.3.25.bcr.1",
compatibility_level = 1,
repo_name = "com_github_google_flatbuffers",
)

bazel_dep(
name = "aspect_bazel_lib",
version = "1.40.0",
)
bazel_dep(
name = "aspect_rules_esbuild",
version = "0.15.0",
)
bazel_dep(
name = "aspect_rules_js",
version = "1.34.1",
)
bazel_dep(
name = "aspect_rules_ts",
version = "1.4.5",
)
bazel_dep(
name = "grpc",
version = "1.48.1",
repo_name = "com_github_grpc_grpc",
)
bazel_dep(
name = "platforms",
version = "0.0.7",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "rules_go",
version = "0.41.0",
repo_name = "io_bazel_rules_go",
)
bazel_dep(
name = "rules_nodejs",
version = "5.8.3",
)
bazel_dep(
name = "rules_swift",
version = "1.2.0",
repo_name = "build_bazel_rules_swift",
)
# -- bazel_dep definitions -- #

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
use_repo(node, "nodejs_linux_amd64")

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")

non_module_dependencies = use_extension("//:extensions.bzl", "non_module_dependencies", dev_dependency = True)
use_repo(
non_module_dependencies,
"bazel_linux_x86_64",
)
1 change: 1 addition & 0 deletions modules/flatbuffers/24.3.25.bcr.1/overlay/MODULE.bazel
16 changes: 16 additions & 0 deletions modules/flatbuffers/24.3.25.bcr.1/overlay/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

def _non_module_dependencies_impl(_ctx):
http_file(
name = "bazel_linux_x86_64",
downloaded_file_path = "bazel",
executable = True,
sha256 = "e78fc3394deae5408d6f49a15c7b1e615901969ecf6e50d55ef899996b0b8458",
urls = [
"https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64",
],
)

non_module_dependencies = module_extension(
implementation = _non_module_dependencies_impl,
)
108 changes: 108 additions & 0 deletions modules/flatbuffers/24.3.25.bcr.1/patches/bzlmod.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
diff --git a/build_defs.bzl b/build_defs.bzl
index fff23544..24d2c37e 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -7,13 +7,13 @@ Rules for building C++ flatbuffers with Bazel.

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

-TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc"
+TRUE_FLATC_PATH = "@flatbuffers//:flatc"

DEFAULT_INCLUDE_PATHS = [
"./",
"$(GENDIR)",
"$(BINDIR)",
- "$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers",
+ "$(execpath @flatbuffers//:flatc).runfiles/flatbuffers",
]

def default_include_paths(flatc_path):
@@ -21,7 +21,7 @@ def default_include_paths(flatc_path):
"./",
"$(GENDIR)",
"$(BINDIR)",
- "$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path),
+ "$(execpath %s).runfiles/flatbuffers" % (flatc_path),
]

DEFAULT_FLATC_ARGS = [
@@ -47,7 +47,7 @@ def flatbuffer_library_public(
compatible_with = None,
restricted_to = None,
target_compatible_with = None,
- flatc_path = "@com_github_google_flatbuffers//:flatc",
+ flatc_path = "@flatbuffers//:flatc",
output_to_bindir = False,
tools = None,
extra_env = None,
@@ -262,8 +262,8 @@ def flatbuffer_cc_library(
"-parse_headers",
],
deps = [
- "@com_github_google_flatbuffers//:runtime_cc",
- "@com_github_google_flatbuffers//:flatbuffers",
+ "@flatbuffers//:runtime_cc",
+ "@flatbuffers//:flatbuffers",
] + deps,
includes = cc_include_paths,
compatible_with = compatible_with,
diff --git a/tests/ts/bazel_repository_test_dir/BUILD.bazel b/tests/ts/bazel_repository_test_dir/BUILD.bazel
index f6b01c5e..7f4c7d2d 100644
--- a/tests/ts/bazel_repository_test_dir/BUILD.bazel
+++ b/tests/ts/bazel_repository_test_dir/BUILD.bazel
@@ -1,13 +1,13 @@
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
-load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
+load("@flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

npm_link_package(
name = "node_modules/flatbuffers",
- src = "@com_github_google_flatbuffers//ts:flatbuffers",
+ src = "@flatbuffers//ts:flatbuffers",
)

flatbuffer_ts_library(
diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel
index 9bd9f4be..b902c438 100644
--- a/ts/BUILD.bazel
+++ b/ts/BUILD.bazel
@@ -66,7 +66,7 @@ sh_binary(
name = "compile_flat_file",
srcs = ["compile_flat_file.sh"],
data = [
- "@com_github_google_flatbuffers//:flatc",
+ "@flatbuffers//:flatc",
"@nodejs_linux_amd64//:node_bin",
],
# We just depend directly on the linux amd64 nodejs binary, so only support
diff --git a/ts/compile_flat_file.sh b/ts/compile_flat_file.sh
index 43e0c391..e3c783b8 100755
--- a/ts/compile_flat_file.sh
+++ b/ts/compile_flat_file.sh
@@ -16,7 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
# --- end runfiles.bash initialization v2 ---
set -eu
runfiles_export_envvars
-FLATC=$(rlocation com_github_google_flatbuffers/flatc)
+FLATC=$(rlocation flatbuffers/flatc)
TS_FILE=$(${FLATC} $@ | grep "Entry point.*generated" | grep -o "bazel-out.*ts")
export PATH="$(rlocation nodejs_linux_amd64/bin/nodejs/bin):${PATH}"
${ESBUILD_BIN} ${TS_FILE} --format=cjs --bundle --outfile="${OUTPUT_FILE}" --external:flatbuffers --log-level=warning
diff --git a/typescript.bzl b/typescript.bzl
index 63c1218c..807a8dee 100644
--- a/typescript.bzl
+++ b/typescript.bzl
@@ -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 = "@flatbuffers//ts:compile_flat_file",
toolchains = ["@aspect_rules_esbuild//esbuild:resolved_toolchain"],
tools = ["@aspect_rules_esbuild//esbuild:resolved_toolchain"],
)
21 changes: 21 additions & 0 deletions modules/flatbuffers/24.3.25.bcr.1/patches/runtime_headers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/BUILD.bazel b/BUILD.bazel
index 436ca59a..98990f8a 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -121,15 +121,7 @@ filegroup(
# Library used by flatbuffer_cc_library rules.
cc_library(
name = "runtime_cc",
- hdrs = [
- "include/flatbuffers/base.h",
- "include/flatbuffers/flatbuffers.h",
- "include/flatbuffers/flexbuffers.h",
- "include/flatbuffers/stl_emulation.h",
- "include/flatbuffers/util.h",
- "include/flatbuffers/vector.h",
- "include/flatbuffers/verifier.h",
- ],
+ hdrs = ["//:public_headers"],
linkstatic = 1,
strip_include_prefix = "/include",
)
40 changes: 40 additions & 0 deletions modules/flatbuffers/24.3.25.bcr.1/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
matrix:
bazel:
- 6.x
- 7.x
- 8.x
tasks:
ubuntu1804_test:
bazel: ${{ bazel }}
platform: ubuntu1804
environment:
CC: clang
SWIFT_VERSION: "5.5.3"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$PATH:$SWIFT_HOME/usr/bin"
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
build_targets:
- "@flatbuffers//:*"
ubuntu2004_test:
bazel: ${{ bazel }}
platform: ubuntu2004
environment:
CC: clang
SWIFT_VERSION: "5.5.3"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$PATH:$SWIFT_HOME/usr/bin"
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
build_targets:
- "@flatbuffers//:*"
macos_test:
bazel: ${{ bazel }}
platform: macos
build_targets:
- "@flatbuffers//:*"
14 changes: 14 additions & 0 deletions modules/flatbuffers/24.3.25.bcr.1/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"url": "https://github.com/google/flatbuffers/archive/refs/tags/v24.3.25.tar.gz",
"integrity": "sha256-QVfFys21lzfF1ifkesJrFA6e4osRAvgSs2Boqrcowe0=",
"strip_prefix": "flatbuffers-24.3.25",
"patches": {
"bzlmod.patch": "sha256-r4Ovp/aq1FsciYRae6OSXhnZT4R0X8VXc3AzF8Z4EfU=",
"runtime_headers.patch": "sha256-gAVDtkONBmgUFUItFArqBC1LBWI8ZoQJu4/A/i68NS0="
},
"patch_strip": 1,
"overlay": {
"MODULE.bazel": "sha256-fcXsRdkUk1Z55HdoxSfqvVkynR5DA986xF2hH8Oy4MA=",
"extensions.bzl": "sha256-MevVoimUuVuA+vFsKaQ4251YLPOo05D0l6iGN3Q+4sM="
}
}
73 changes: 73 additions & 0 deletions modules/flatbuffers/24.3.7.bcr.1/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module(
name = "flatbuffers",
version = "24.3.7.bcr.1",
compatibility_level = 1,
repo_name = "com_github_google_flatbuffers",
)

bazel_dep(
name = "aspect_bazel_lib",
version = "1.40.0",
)
bazel_dep(
name = "aspect_rules_esbuild",
version = "0.15.0",
)
bazel_dep(
name = "aspect_rules_js",
version = "1.34.1",
)
bazel_dep(
name = "aspect_rules_ts",
version = "1.4.5",
)
bazel_dep(
name = "grpc",
version = "1.48.1",
repo_name = "com_github_grpc_grpc",
)
bazel_dep(
name = "platforms",
version = "0.0.7",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "rules_go",
version = "0.41.0",
repo_name = "io_bazel_rules_go",
)
bazel_dep(
name = "rules_nodejs",
version = "5.8.3",
)
bazel_dep(
name = "rules_swift",
version = "1.2.0",
repo_name = "build_bazel_rules_swift",
)
# -- bazel_dep definitions -- #

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
use_repo(node, "nodejs_linux_amd64")

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")

non_module_dependencies = use_extension("//:extensions.bzl", "non_module_dependencies", dev_dependency = True)
use_repo(
non_module_dependencies,
"bazel_linux_x86_64",
)
1 change: 1 addition & 0 deletions modules/flatbuffers/24.3.7.bcr.1/overlay/MODULE.bazel
16 changes: 16 additions & 0 deletions modules/flatbuffers/24.3.7.bcr.1/overlay/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

def _non_module_dependencies_impl(_ctx):
http_file(
name = "bazel_linux_x86_64",
downloaded_file_path = "bazel",
executable = True,
sha256 = "e78fc3394deae5408d6f49a15c7b1e615901969ecf6e50d55ef899996b0b8458",
urls = [
"https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64",
],
)

non_module_dependencies = module_extension(
implementation = _non_module_dependencies_impl,
)
21 changes: 21 additions & 0 deletions modules/flatbuffers/24.3.7.bcr.1/patches/runtime_headers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/BUILD.bazel b/BUILD.bazel
index 436ca59a..98990f8a 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -121,15 +121,7 @@ filegroup(
# Library used by flatbuffer_cc_library rules.
cc_library(
name = "runtime_cc",
- hdrs = [
- "include/flatbuffers/base.h",
- "include/flatbuffers/flatbuffers.h",
- "include/flatbuffers/flexbuffers.h",
- "include/flatbuffers/stl_emulation.h",
- "include/flatbuffers/util.h",
- "include/flatbuffers/vector.h",
- "include/flatbuffers/verifier.h",
- ],
+ hdrs = ["//:public_headers"],
linkstatic = 1,
strip_include_prefix = "/include",
)
Loading

0 comments on commit ded2414

Please sign in to comment.