Skip to content

Commit 88f6e35

Browse files
committed
Update flatbuffers
Add fix for missing runtime headers.
1 parent 5d106ac commit 88f6e35

File tree

14 files changed

+442
-1
lines changed

14 files changed

+442
-1
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module(
2+
name = "flatbuffers",
3+
version = "24.3.25.bcr.1",
4+
compatibility_level = 1,
5+
repo_name = "com_github_google_flatbuffers",
6+
)
7+
8+
bazel_dep(
9+
name = "aspect_bazel_lib",
10+
version = "1.40.0",
11+
)
12+
bazel_dep(
13+
name = "aspect_rules_esbuild",
14+
version = "0.15.0",
15+
)
16+
bazel_dep(
17+
name = "aspect_rules_js",
18+
version = "1.34.1",
19+
)
20+
bazel_dep(
21+
name = "aspect_rules_ts",
22+
version = "1.4.5",
23+
)
24+
bazel_dep(
25+
name = "grpc",
26+
version = "1.48.1",
27+
repo_name = "com_github_grpc_grpc",
28+
)
29+
bazel_dep(
30+
name = "platforms",
31+
version = "0.0.7",
32+
)
33+
bazel_dep(
34+
name = "rules_cc",
35+
version = "0.0.9",
36+
)
37+
bazel_dep(
38+
name = "rules_go",
39+
version = "0.41.0",
40+
repo_name = "io_bazel_rules_go",
41+
)
42+
bazel_dep(
43+
name = "rules_nodejs",
44+
version = "5.8.3",
45+
)
46+
bazel_dep(
47+
name = "rules_swift",
48+
version = "1.2.0",
49+
repo_name = "build_bazel_rules_swift",
50+
)
51+
# -- bazel_dep definitions -- #
52+
53+
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
54+
npm.npm_translate_lock(
55+
name = "npm",
56+
npmrc = "//:.npmrc",
57+
pnpm_lock = "//:pnpm-lock.yaml",
58+
verify_node_modules_ignored = "//:.bazelignore",
59+
)
60+
use_repo(npm, "npm")
61+
62+
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
63+
use_repo(node, "nodejs_linux_amd64")
64+
65+
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
66+
rules_ts_ext.deps()
67+
use_repo(rules_ts_ext, "npm_typescript")
68+
69+
non_module_dependencies = use_extension("//:extensions.bzl", "non_module_dependencies", dev_dependency = True)
70+
use_repo(
71+
non_module_dependencies,
72+
"bazel_linux_x86_64",
73+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../MODULE.bazel
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
2+
3+
def _non_module_dependencies_impl(_ctx):
4+
http_file(
5+
name = "bazel_linux_x86_64",
6+
downloaded_file_path = "bazel",
7+
executable = True,
8+
sha256 = "e78fc3394deae5408d6f49a15c7b1e615901969ecf6e50d55ef899996b0b8458",
9+
urls = [
10+
"https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64",
11+
],
12+
)
13+
14+
non_module_dependencies = module_extension(
15+
implementation = _non_module_dependencies_impl,
16+
)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
diff --git a/build_defs.bzl b/build_defs.bzl
2+
index fff23544..24d2c37e 100644
3+
--- a/build_defs.bzl
4+
+++ b/build_defs.bzl
5+
@@ -7,13 +7,13 @@ Rules for building C++ flatbuffers with Bazel.
6+
7+
load("@rules_cc//cc:defs.bzl", "cc_library")
8+
9+
-TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc"
10+
+TRUE_FLATC_PATH = "@flatbuffers//:flatc"
11+
12+
DEFAULT_INCLUDE_PATHS = [
13+
"./",
14+
"$(GENDIR)",
15+
"$(BINDIR)",
16+
- "$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers",
17+
+ "$(execpath @flatbuffers//:flatc).runfiles/flatbuffers",
18+
]
19+
20+
def default_include_paths(flatc_path):
21+
@@ -21,7 +21,7 @@ def default_include_paths(flatc_path):
22+
"./",
23+
"$(GENDIR)",
24+
"$(BINDIR)",
25+
- "$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path),
26+
+ "$(execpath %s).runfiles/flatbuffers" % (flatc_path),
27+
]
28+
29+
DEFAULT_FLATC_ARGS = [
30+
@@ -47,7 +47,7 @@ def flatbuffer_library_public(
31+
compatible_with = None,
32+
restricted_to = None,
33+
target_compatible_with = None,
34+
- flatc_path = "@com_github_google_flatbuffers//:flatc",
35+
+ flatc_path = "@flatbuffers//:flatc",
36+
output_to_bindir = False,
37+
tools = None,
38+
extra_env = None,
39+
@@ -262,8 +262,8 @@ def flatbuffer_cc_library(
40+
"-parse_headers",
41+
],
42+
deps = [
43+
- "@com_github_google_flatbuffers//:runtime_cc",
44+
- "@com_github_google_flatbuffers//:flatbuffers",
45+
+ "@flatbuffers//:runtime_cc",
46+
+ "@flatbuffers//:flatbuffers",
47+
] + deps,
48+
includes = cc_include_paths,
49+
compatible_with = compatible_with,
50+
diff --git a/tests/ts/bazel_repository_test_dir/BUILD.bazel b/tests/ts/bazel_repository_test_dir/BUILD.bazel
51+
index f6b01c5e..7f4c7d2d 100644
52+
--- a/tests/ts/bazel_repository_test_dir/BUILD.bazel
53+
+++ b/tests/ts/bazel_repository_test_dir/BUILD.bazel
54+
@@ -1,13 +1,13 @@
55+
load("@aspect_rules_js//js:defs.bzl", "js_test")
56+
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
57+
-load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
58+
+load("@flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
59+
load("@npm//:defs.bzl", "npm_link_all_packages")
60+
61+
npm_link_all_packages(name = "node_modules")
62+
63+
npm_link_package(
64+
name = "node_modules/flatbuffers",
65+
- src = "@com_github_google_flatbuffers//ts:flatbuffers",
66+
+ src = "@flatbuffers//ts:flatbuffers",
67+
)
68+
69+
flatbuffer_ts_library(
70+
diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel
71+
index 9bd9f4be..b902c438 100644
72+
--- a/ts/BUILD.bazel
73+
+++ b/ts/BUILD.bazel
74+
@@ -66,7 +66,7 @@ sh_binary(
75+
name = "compile_flat_file",
76+
srcs = ["compile_flat_file.sh"],
77+
data = [
78+
- "@com_github_google_flatbuffers//:flatc",
79+
+ "@flatbuffers//:flatc",
80+
"@nodejs_linux_amd64//:node_bin",
81+
],
82+
# We just depend directly on the linux amd64 nodejs binary, so only support
83+
diff --git a/ts/compile_flat_file.sh b/ts/compile_flat_file.sh
84+
index 43e0c391..e3c783b8 100755
85+
--- a/ts/compile_flat_file.sh
86+
+++ b/ts/compile_flat_file.sh
87+
@@ -16,7 +16,7 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
88+
# --- end runfiles.bash initialization v2 ---
89+
set -eu
90+
runfiles_export_envvars
91+
-FLATC=$(rlocation com_github_google_flatbuffers/flatc)
92+
+FLATC=$(rlocation flatbuffers/flatc)
93+
TS_FILE=$(${FLATC} $@ | grep "Entry point.*generated" | grep -o "bazel-out.*ts")
94+
export PATH="$(rlocation nodejs_linux_amd64/bin/nodejs/bin):${PATH}"
95+
${ESBUILD_BIN} ${TS_FILE} --format=cjs --bundle --outfile="${OUTPUT_FILE}" --external:flatbuffers --log-level=warning
96+
diff --git a/typescript.bzl b/typescript.bzl
97+
index 63c1218c..807a8dee 100644
98+
--- a/typescript.bzl
99+
+++ b/typescript.bzl
100+
@@ -69,7 +69,7 @@ def flatbuffer_ts_library(
101+
reflection_name = reflection_name,
102+
reflection_visibility = visibility,
103+
target_compatible_with = target_compatible_with,
104+
- flatc_path = "@com_github_google_flatbuffers//ts:compile_flat_file",
105+
+ flatc_path = "@flatbuffers//ts:compile_flat_file",
106+
toolchains = ["@aspect_rules_esbuild//esbuild:resolved_toolchain"],
107+
tools = ["@aspect_rules_esbuild//esbuild:resolved_toolchain"],
108+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index 436ca59a..98990f8a 100644
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -121,15 +121,7 @@ filegroup(
6+
# Library used by flatbuffer_cc_library rules.
7+
cc_library(
8+
name = "runtime_cc",
9+
- hdrs = [
10+
- "include/flatbuffers/base.h",
11+
- "include/flatbuffers/flatbuffers.h",
12+
- "include/flatbuffers/flexbuffers.h",
13+
- "include/flatbuffers/stl_emulation.h",
14+
- "include/flatbuffers/util.h",
15+
- "include/flatbuffers/vector.h",
16+
- "include/flatbuffers/verifier.h",
17+
- ],
18+
+ hdrs = ["//:public_headers"],
19+
linkstatic = 1,
20+
strip_include_prefix = "/include",
21+
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
matrix:
3+
bazel:
4+
- 6.x
5+
- 7.x
6+
- 8.x
7+
tasks:
8+
ubuntu1804_test:
9+
bazel: ${{ bazel }}
10+
platform: ubuntu1804
11+
environment:
12+
CC: clang
13+
SWIFT_VERSION: "5.5.3"
14+
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
15+
PATH: "$PATH:$SWIFT_HOME/usr/bin"
16+
shell_commands:
17+
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
18+
- "mkdir $SWIFT_HOME"
19+
- "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"
20+
build_targets:
21+
- "@flatbuffers//:*"
22+
ubuntu2004_test:
23+
bazel: ${{ bazel }}
24+
platform: ubuntu2004
25+
environment:
26+
CC: clang
27+
SWIFT_VERSION: "5.5.3"
28+
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
29+
PATH: "$PATH:$SWIFT_HOME/usr/bin"
30+
shell_commands:
31+
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
32+
- "mkdir $SWIFT_HOME"
33+
- "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"
34+
build_targets:
35+
- "@flatbuffers//:*"
36+
macos_test:
37+
bazel: ${{ bazel }}
38+
platform: macos
39+
build_targets:
40+
- "@flatbuffers//:*"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"url": "https://github.com/google/flatbuffers/archive/refs/tags/v24.3.25.tar.gz",
3+
"integrity": "sha256-QVfFys21lzfF1ifkesJrFA6e4osRAvgSs2Boqrcowe0=",
4+
"strip_prefix": "flatbuffers-24.3.25",
5+
"patches": {
6+
"bzlmod.patch": "sha256-r4Ovp/aq1FsciYRae6OSXhnZT4R0X8VXc3AzF8Z4EfU=",
7+
"runtime_headers.patch": "sha256-gAVDtkONBmgUFUItFArqBC1LBWI8ZoQJu4/A/i68NS0="
8+
},
9+
"patch_strip": 1,
10+
"overlay": {
11+
"MODULE.bazel": "sha256-fcXsRdkUk1Z55HdoxSfqvVkynR5DA986xF2hH8Oy4MA=",
12+
"extensions.bzl": "sha256-MevVoimUuVuA+vFsKaQ4251YLPOo05D0l6iGN3Q+4sM="
13+
}
14+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module(
2+
name = "flatbuffers",
3+
version = "24.3.7.bcr.1",
4+
compatibility_level = 1,
5+
repo_name = "com_github_google_flatbuffers",
6+
)
7+
8+
bazel_dep(
9+
name = "aspect_bazel_lib",
10+
version = "1.40.0",
11+
)
12+
bazel_dep(
13+
name = "aspect_rules_esbuild",
14+
version = "0.15.0",
15+
)
16+
bazel_dep(
17+
name = "aspect_rules_js",
18+
version = "1.34.1",
19+
)
20+
bazel_dep(
21+
name = "aspect_rules_ts",
22+
version = "1.4.5",
23+
)
24+
bazel_dep(
25+
name = "grpc",
26+
version = "1.48.1",
27+
repo_name = "com_github_grpc_grpc",
28+
)
29+
bazel_dep(
30+
name = "platforms",
31+
version = "0.0.7",
32+
)
33+
bazel_dep(
34+
name = "rules_cc",
35+
version = "0.0.9",
36+
)
37+
bazel_dep(
38+
name = "rules_go",
39+
version = "0.41.0",
40+
repo_name = "io_bazel_rules_go",
41+
)
42+
bazel_dep(
43+
name = "rules_nodejs",
44+
version = "5.8.3",
45+
)
46+
bazel_dep(
47+
name = "rules_swift",
48+
version = "1.2.0",
49+
repo_name = "build_bazel_rules_swift",
50+
)
51+
# -- bazel_dep definitions -- #
52+
53+
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
54+
npm.npm_translate_lock(
55+
name = "npm",
56+
npmrc = "//:.npmrc",
57+
pnpm_lock = "//:pnpm-lock.yaml",
58+
verify_node_modules_ignored = "//:.bazelignore",
59+
)
60+
use_repo(npm, "npm")
61+
62+
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
63+
use_repo(node, "nodejs_linux_amd64")
64+
65+
rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)
66+
rules_ts_ext.deps()
67+
use_repo(rules_ts_ext, "npm_typescript")
68+
69+
non_module_dependencies = use_extension("//:extensions.bzl", "non_module_dependencies", dev_dependency = True)
70+
use_repo(
71+
non_module_dependencies,
72+
"bazel_linux_x86_64",
73+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../MODULE.bazel
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
2+
3+
def _non_module_dependencies_impl(_ctx):
4+
http_file(
5+
name = "bazel_linux_x86_64",
6+
downloaded_file_path = "bazel",
7+
executable = True,
8+
sha256 = "e78fc3394deae5408d6f49a15c7b1e615901969ecf6e50d55ef899996b0b8458",
9+
urls = [
10+
"https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-x86_64",
11+
],
12+
)
13+
14+
non_module_dependencies = module_extension(
15+
implementation = _non_module_dependencies_impl,
16+
)

0 commit comments

Comments
 (0)