Skip to content

Commit

Permalink
support protobuf 28.x (#67)
Browse files Browse the repository at this point in the history
* support protobuf 28.x
  • Loading branch information
oathdruid authored Oct 24, 2024
1 parent f90da51 commit b73e30e
Show file tree
Hide file tree
Showing 16 changed files with 9,712 additions and 32 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
fail-fast: false
matrix:
compiler: [{name: gcc, flag: --action_env=CC=gcc-14}, {name: clang, flag: --action_env=CC=clang-18}]
mode: [{name: dbg, flag: --compilation_mode=dbg}, {name: opt, flag: --compilation_mode=opt}]
std: [{name: c++20, flag: --cxxopt=-std=c++20}, {name: c++14, flag: --cxxopt=-std=c++14}]
stdlib: [{name: stdlibc++}, {name: libc++, flag: --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++}]
feature: [{name: asan, flag: --config=asan}, {name: tsan, flag: --features=tsan}]
Expand All @@ -21,21 +22,21 @@ jobs:
- std: {name: c++14}
feature: {name: tsan}
runs-on: ubuntu-24.04
name: basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}
name: basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: bazel-disk
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
restore-keys: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
restore-keys: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-
- run: sudo apt install libc++-18-dev libc++abi-18-dev
- 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/...
- 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/...
- uses: actions/cache/save@v4
if: always()
with:
path: bazel-disk
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}

arenastring:
strategy:
Expand All @@ -61,7 +62,7 @@ jobs:
key: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-${{github.sha}}
restore-keys: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-
- run: sudo apt install libc++-18-dev libc++abi-18-dev
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '27.5.arenastring'/" MODULE.bazel
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '28.3.arenastring'/" MODULE.bazel
- 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/...
- uses: actions/cache/save@v4
if: always()
Expand All @@ -78,6 +79,7 @@ jobs:
path: bazel-disk
key: bazel-disk-c++14-coroutine-${{github.sha}}
restore-keys: bazel-disk-c++14-coroutine-
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '27.5'/" MODULE.bazel
- 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/...
- uses: actions/cache/save@v4
if: always()
Expand Down
9 changes: 4 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ module(

################################################################################
# LOWER BOUND dependency versions.
# Bzlmod follows MVS:
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
# Bzlmod follows MVS: https://bazel.build/external/module
# Thus the highest version in their module graph is resolved.
bazel_dep(name = 'abseil-cpp', version = '20220623.1', repo_name = 'com_google_absl')
bazel_dep(name = 'bazel_skylib', version = '1.0.3')
bazel_dep(name = 'boost.preprocessor', version = '1.83.0')
bazel_dep(name = 'boost.preprocessor', version = '1.83.0.bcr.1')
bazel_dep(name = 'boost.spirit', version = '1.83.0')
bazel_dep(name = 'protobuf', version = '3.19.6', repo_name = 'com_google_protobuf')
################################################################################

################################################################################
# test only dependency
single_version_override(module_name = 'abseil-cpp', version = '20240722.0')
single_version_override(module_name = 'protobuf', version = '27.5')
single_version_override(module_name = 'protobuf', version = '28.3')
bazel_dep(name = 'googletest', version = '1.15.2', repo_name = 'com_google_googletest', dev_dependency = True)
bazel_dep(name = 'platforms', version = '0.0.10', dev_dependency = True)
bazel_dep(name = 'rules_cc', version = '0.0.9', dev_dependency = True)
bazel_dep(name = 'rules_cc', version = '0.0.13', dev_dependency = True)
bazel_dep(name = 'rules_cuda', version = '0.2.3', dev_dependency = True)

# cuda toolchain
Expand Down
8 changes: 8 additions & 0 deletions example/bcr-presubmit/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cc_binary(
name = 'example',
srcs = ['example.cpp'],
deps = [
'@babylon//:future',
'@babylon//:logging',
],
)
5 changes: 5 additions & 0 deletions example/bcr-presubmit/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bazel_dep(name = 'babylon')
local_path_override(
module_name = 'babylon',
path = '../..',
)
23 changes: 23 additions & 0 deletions example/bcr-presubmit/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "babylon/future.h"
#include "babylon/logging/logger.h"

#include <thread>
#include <vector>

int main() {
::babylon::CountDownLatch<> latch(10);
auto future = latch.get_future();
::std::vector<::std::thread> threads;
for (size_t i = 0; i < 10; ++i) {
threads.emplace_back([&, i]() {
BABYLON_LOG(INFO) << "finish " << i;
latch.count_down();
});
}
future.get();
BABYLON_LOG(INFO) << "finish all";
for (auto& thread : threads) {
thread.join();
}
return 0;
}
83 changes: 83 additions & 0 deletions registry/modules/protobuf/28.3.arenastring/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
# https://github.com/protocolbuffers/protobuf/issues/14313

module(
name = "protobuf",
version = "28.3.arenastring", # Automatically updated on release
compatibility_level = 1,
repo_name = "com_google_protobuf",
)

# LOWER BOUND dependency versions.
# Bzlmod follows MVS:
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
# Thus the highest version in their module graph is resolved.
bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "jsoncpp", version = "1.9.5")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
bazel_dep(name = "rules_java", version = "5.3.5")
bazel_dep(name = "rules_jvm_external", version = "5.1")
bazel_dep(name = "rules_pkg", version = "0.7.0")
bazel_dep(name = "rules_python", version = "0.28.0")
bazel_dep(name = "rules_rust", version = "0.45.1")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "zlib", version = "1.3.1")

# TODO: remove after toolchain types are moved to protobuf
bazel_dep(name = "rules_proto", version = "4.0.0")

SUPPORTED_PYTHON_VERSIONS = [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
[
python.toolchain(
is_default = python_version == SUPPORTED_PYTHON_VERSIONS[-1],
python_version = python_version,
)
for python_version in SUPPORTED_PYTHON_VERSIONS
]
use_repo(python, system_python = "python_{}".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")))
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
[
pip.parse(
hub_name = "pip_deps",
python_version = python_version,
requirements_lock = "//python:requirements.txt",
)
for python_version in SUPPORTED_PYTHON_VERSIONS
]
use_repo(pip, "pip_deps")

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2021")
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
crate.spec(
package = "googletest",
version = ">0.0.0",
)
crate.spec(
package = "paste",
version = ">=1",
)
crate.from_specs()
use_repo(crate, crate_index = "crates")

bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest", dev_dependency = True)
bazel_dep(name = "rules_ruby", dev_dependency = True)
archive_override(
module_name = "rules_ruby",
urls = ["https://github.com/protocolbuffers/rules_ruby/archive/b7f3e9756f3c45527be27bc38840d5a1ba690436.tar.gz"],
strip_prefix = "rules_ruby-b7f3e9756f3c45527be27bc38840d5a1ba690436",
integrity = "sha256-RNo21X/p9slOdF912FLprLnxvZHMXBTxaUDGFmm2bx8=",
patches = ["third_party/rules_ruby.patch"],
patch_strip = 1,
)
Loading

0 comments on commit b73e30e

Please sign in to comment.