Skip to content

Commit b73e30e

Browse files
authored
support protobuf 28.x (#67)
* support protobuf 28.x
1 parent f90da51 commit b73e30e

File tree

16 files changed

+9712
-32
lines changed

16 files changed

+9712
-32
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
compiler: [{name: gcc, flag: --action_env=CC=gcc-14}, {name: clang, flag: --action_env=CC=clang-18}]
15+
mode: [{name: dbg, flag: --compilation_mode=dbg}, {name: opt, flag: --compilation_mode=opt}]
1516
std: [{name: c++20, flag: --cxxopt=-std=c++20}, {name: c++14, flag: --cxxopt=-std=c++14}]
1617
stdlib: [{name: stdlibc++}, {name: libc++, flag: --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++}]
1718
feature: [{name: asan, flag: --config=asan}, {name: tsan, flag: --features=tsan}]
@@ -21,21 +22,21 @@ jobs:
2122
- std: {name: c++14}
2223
feature: {name: tsan}
2324
runs-on: ubuntu-24.04
24-
name: basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}
25+
name: basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}
2526
steps:
2627
- uses: actions/checkout@v4
2728
- uses: actions/cache/restore@v4
2829
with:
2930
path: bazel-disk
30-
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
31-
restore-keys: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-
31+
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
32+
restore-keys: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-
3233
- run: sudo apt install libc++-18-dev libc++abi-18-dev
33-
- run: bazel test --compilation_mode=dbg --disk_cache=bazel-disk --verbose_failures --test_output=errors ${{matrix.compiler.flag}} ${{matrix.std.flag}} ${{matrix.stdlib.flag}} ${{matrix.feature.flag}} test/...
34+
- run: bazel test --disk_cache=bazel-disk --verbose_failures --test_output=errors ${{matrix.compiler.flag}} ${{matrix.mode.flag}} ${{matrix.std.flag}} ${{matrix.stdlib.flag}} ${{matrix.feature.flag}} test/...
3435
- uses: actions/cache/save@v4
3536
if: always()
3637
with:
3738
path: bazel-disk
38-
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
39+
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
3940

4041
arenastring:
4142
strategy:
@@ -61,7 +62,7 @@ jobs:
6162
key: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-${{github.sha}}
6263
restore-keys: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-
6364
- run: sudo apt install libc++-18-dev libc++abi-18-dev
64-
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '27.5.arenastring'/" MODULE.bazel
65+
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '28.3.arenastring'/" MODULE.bazel
6566
- run: bazel test --compilation_mode=opt --disk_cache=bazel-disk --verbose_failures --test_output=errors --config=asan --registry=https://bcr.bazel.build --registry=file://%workspace%/registry ${{matrix.compiler.flag}} ${{matrix.stdlib.flag}} ${{matrix.mutable.flag}} test/...
6667
- uses: actions/cache/save@v4
6768
if: always()
@@ -78,6 +79,7 @@ jobs:
7879
path: bazel-disk
7980
key: bazel-disk-c++14-coroutine-${{github.sha}}
8081
restore-keys: bazel-disk-c++14-coroutine-
82+
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '27.5'/" MODULE.bazel
8183
- run: bazel test --disk_cache=bazel-disk --verbose_failures --test_output=errors --action_env=CC=gcc-12 --cxxopt=-std=c++14 --cxxopt=-fcoroutines --cxxopt=-fconcepts test/...
8284
- uses: actions/cache/save@v4
8385
if: always()

MODULE.bazel

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ module(
66

77
################################################################################
88
# LOWER BOUND dependency versions.
9-
# Bzlmod follows MVS:
10-
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
9+
# Bzlmod follows MVS: https://bazel.build/external/module
1110
# Thus the highest version in their module graph is resolved.
1211
bazel_dep(name = 'abseil-cpp', version = '20220623.1', repo_name = 'com_google_absl')
1312
bazel_dep(name = 'bazel_skylib', version = '1.0.3')
14-
bazel_dep(name = 'boost.preprocessor', version = '1.83.0')
13+
bazel_dep(name = 'boost.preprocessor', version = '1.83.0.bcr.1')
1514
bazel_dep(name = 'boost.spirit', version = '1.83.0')
1615
bazel_dep(name = 'protobuf', version = '3.19.6', repo_name = 'com_google_protobuf')
1716
################################################################################
1817

1918
################################################################################
2019
# test only dependency
2120
single_version_override(module_name = 'abseil-cpp', version = '20240722.0')
22-
single_version_override(module_name = 'protobuf', version = '27.5')
21+
single_version_override(module_name = 'protobuf', version = '28.3')
2322
bazel_dep(name = 'googletest', version = '1.15.2', repo_name = 'com_google_googletest', dev_dependency = True)
2423
bazel_dep(name = 'platforms', version = '0.0.10', dev_dependency = True)
25-
bazel_dep(name = 'rules_cc', version = '0.0.9', dev_dependency = True)
24+
bazel_dep(name = 'rules_cc', version = '0.0.13', dev_dependency = True)
2625
bazel_dep(name = 'rules_cuda', version = '0.2.3', dev_dependency = True)
2726

2827
# cuda toolchain

example/bcr-presubmit/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cc_binary(
2+
name = 'example',
3+
srcs = ['example.cpp'],
4+
deps = [
5+
'@babylon//:future',
6+
'@babylon//:logging',
7+
],
8+
)

example/bcr-presubmit/MODULE.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bazel_dep(name = 'babylon')
2+
local_path_override(
3+
module_name = 'babylon',
4+
path = '../..',
5+
)

example/bcr-presubmit/example.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "babylon/future.h"
2+
#include "babylon/logging/logger.h"
3+
4+
#include <thread>
5+
#include <vector>
6+
7+
int main() {
8+
::babylon::CountDownLatch<> latch(10);
9+
auto future = latch.get_future();
10+
::std::vector<::std::thread> threads;
11+
for (size_t i = 0; i < 10; ++i) {
12+
threads.emplace_back([&, i]() {
13+
BABYLON_LOG(INFO) << "finish " << i;
14+
latch.count_down();
15+
});
16+
}
17+
future.get();
18+
BABYLON_LOG(INFO) << "finish all";
19+
for (auto& thread : threads) {
20+
thread.join();
21+
}
22+
return 0;
23+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
2+
# https://github.com/protocolbuffers/protobuf/issues/14313
3+
4+
module(
5+
name = "protobuf",
6+
version = "28.3.arenastring", # Automatically updated on release
7+
compatibility_level = 1,
8+
repo_name = "com_google_protobuf",
9+
)
10+
11+
# LOWER BOUND dependency versions.
12+
# Bzlmod follows MVS:
13+
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
14+
# Thus the highest version in their module graph is resolved.
15+
bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
16+
bazel_dep(name = "bazel_skylib", version = "1.4.1")
17+
bazel_dep(name = "jsoncpp", version = "1.9.5")
18+
bazel_dep(name = "rules_cc", version = "0.0.9")
19+
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
20+
bazel_dep(name = "rules_java", version = "5.3.5")
21+
bazel_dep(name = "rules_jvm_external", version = "5.1")
22+
bazel_dep(name = "rules_pkg", version = "0.7.0")
23+
bazel_dep(name = "rules_python", version = "0.28.0")
24+
bazel_dep(name = "rules_rust", version = "0.45.1")
25+
bazel_dep(name = "platforms", version = "0.0.8")
26+
bazel_dep(name = "zlib", version = "1.3.1")
27+
28+
# TODO: remove after toolchain types are moved to protobuf
29+
bazel_dep(name = "rules_proto", version = "4.0.0")
30+
31+
SUPPORTED_PYTHON_VERSIONS = [
32+
"3.8",
33+
"3.9",
34+
"3.10",
35+
"3.11",
36+
"3.12",
37+
]
38+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
39+
[
40+
python.toolchain(
41+
is_default = python_version == SUPPORTED_PYTHON_VERSIONS[-1],
42+
python_version = python_version,
43+
)
44+
for python_version in SUPPORTED_PYTHON_VERSIONS
45+
]
46+
use_repo(python, system_python = "python_{}".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")))
47+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
48+
[
49+
pip.parse(
50+
hub_name = "pip_deps",
51+
python_version = python_version,
52+
requirements_lock = "//python:requirements.txt",
53+
)
54+
for python_version in SUPPORTED_PYTHON_VERSIONS
55+
]
56+
use_repo(pip, "pip_deps")
57+
58+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
59+
rust.toolchain(edition = "2021")
60+
use_repo(rust, "rust_toolchains")
61+
register_toolchains("@rust_toolchains//:all")
62+
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
63+
crate.spec(
64+
package = "googletest",
65+
version = ">0.0.0",
66+
)
67+
crate.spec(
68+
package = "paste",
69+
version = ">=1",
70+
)
71+
crate.from_specs()
72+
use_repo(crate, crate_index = "crates")
73+
74+
bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest", dev_dependency = True)
75+
bazel_dep(name = "rules_ruby", dev_dependency = True)
76+
archive_override(
77+
module_name = "rules_ruby",
78+
urls = ["https://github.com/protocolbuffers/rules_ruby/archive/b7f3e9756f3c45527be27bc38840d5a1ba690436.tar.gz"],
79+
strip_prefix = "rules_ruby-b7f3e9756f3c45527be27bc38840d5a1ba690436",
80+
integrity = "sha256-RNo21X/p9slOdF912FLprLnxvZHMXBTxaUDGFmm2bx8=",
81+
patches = ["third_party/rules_ruby.patch"],
82+
patch_strip = 1,
83+
)

0 commit comments

Comments
 (0)