Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Bazel 8 #73

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
USE_BAZEL_VERSION=5.4.1
USE_BAZEL_VERSION=8.0.0
9 changes: 5 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Specific Bazel build/test options.

build:macos --cxxopt='-std=c++17'
# Enable both `MODULE.bazel` and `WORKSPACE.bzlmod`, not `WORKSPACE`.
common --enable_bzlmod
common --enable_workspace

# Specific Bazel build/test options.
build:macos --cxxopt='-std=c++17' --macos_minimum_os=10.15
build:linux --cxxopt='-std=c++17'

build:windows --cxxopt="/std:c++17"

build --enable_platform_specific_config
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vs
.vscode
bazel-*
MODULE.bazel.lock
14 changes: 7 additions & 7 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
"//include/stout/flags/v1:flag",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/time",
"@com_github_google_glog//:glog",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
"@com_google_protobuf//:duration_cc_proto",
],
)

Expand Down Expand Up @@ -89,11 +90,10 @@ cc_library(
"//:flags",
"//:notification",
"//:stateful-tally",
"@boost//:functional",
"@boost//:get_pointer",
"@boost//:lexical_cast",
"@boost//:uuid",
"@boost//:variant",
"@boost.functional//:boost.functional",
"@boost.lexical_cast//:boost.lexical_cast",
"@boost.uuid//:boost.uuid",
"@boost.variant//:boost.variant",
"@com_github_fmtlib_fmt//:fmt",
"@com_github_google_glog//:glog",
"@com_github_kazuho_picojson//:picojson",
Expand Down
14 changes: 14 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(name = "stout", version = "0.1")

bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.2")
bazel_dep(name = "protobuf", version = "29.2", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.1.0")

# TODO: We also depend on Boost ICL but that is not packaged for BCR yet.
bazel_dep(name = "boost.circular_buffer", version = "1.83.0.bcr.1")
bazel_dep(name = "boost.functional", version = "1.83.0.bcr.1")
bazel_dep(name = "boost.lexical_cast", version = "1.83.0.bcr.1")
bazel_dep(name = "boost.ptr_container", version = "1.83.0.bcr.1")
bazel_dep(name = "boost.range", version = "1.83.0.bcr.1")
bazel_dep(name = "boost.uuid", version = "1.83.0.bcr.1")
bazel_dep(name = "boost.variant", version = "1.83.0.bcr.1")
Empty file added WORKSPACE
Empty file.
2 changes: 0 additions & 2 deletions WORKSPACE.bazel → WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
workspace(name = "stout")

load("//bazel:repos.bzl", "repos")

repos(external = False)
Expand Down
6 changes: 0 additions & 6 deletions bazel/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@

load("@com_github_3rdparty_bazel_rules_picojson//bazel:deps.bzl", picojson_deps = "deps")
load("@com_github_3rdparty_bazel_rules_rapidjson//bazel:deps.bzl", rapidjson_deps = "deps")
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

def deps(repo_mapping = {}):
"""Propagate all dependencies.

Args:
repo_mapping (str): {}.
"""
boost_deps()

picojson_deps(
repo_mapping = repo_mapping,
)

rapidjson_deps(
repo_mapping = repo_mapping,
)

protobuf_deps()
29 changes: 0 additions & 29 deletions bazel/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ def repos(external = True, repo_mapping = {}):
repo_mapping = repo_mapping,
)

maybe(
http_archive,
name = "com_google_absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz"],
strip_prefix = "abseil-cpp-20211102.0",
sha256 = "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
repo_mapping = repo_mapping,
)

maybe(
git_repository,
name = "com_github_nelhage_rules_boost",
commit = "494ddf5db56580eb019479965fa2908ce6548385",
remote = "https://github.com/nelhage/rules_boost",
shallow_since = "1675669198 -0800",
)

maybe(
http_archive,
name = "com_github_gflags_gflags",
Expand All @@ -73,18 +56,6 @@ def repos(external = True, repo_mapping = {}):
strip_prefix = "glog-0.5.0",
)

maybe(
http_archive,
name = "com_google_protobuf",
strip_prefix = "protobuf-3.19.1",
urls = [
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz",
],
sha256 = "87407cd28e7a9c95d9f61a098a53cf031109d451a7763e7dd1253abf8b4df422",
repo_mapping = repo_mapping,
)

# Copied and then modified to use the latest 'commit' and 'shallow_since'
# rather than tracking the 'master' branch from:
# https://github.com/fmtlib/fmt/tree/master/support/bazel
Expand Down
14 changes: 7 additions & 7 deletions include/stout/flags/flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -678,19 +678,19 @@ void Parser::SetFieldMessageOrAggregateErrors(
// error for us to print out later.
struct ErrorCollector : public google::protobuf::io::ErrorCollector {
// TODO(artur): include also 'line' and 'column' for easier debugging.
void AddError(
void RecordError(
int /* line */,
int /* column */,
const std::string& message) override {
google::protobuf::io::ColumnNumber /* column */,
absl::string_view message) override {
error += message;
}

void AddWarning(
void RecordWarning(
int line,
int column,
const std::string& message) override {
google::protobuf::io::ColumnNumber column,
absl::string_view message) override {
// For now we treat all warnings as errors.
AddError(line, column, message);
RecordError(line, column, message);
}

std::string error;
Expand Down
6 changes: 3 additions & 3 deletions include/stout/flags/v1/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")

proto_library(
name = "flag_proto",
Expand All @@ -14,7 +14,7 @@ proto_library(
# proto_library rules of the source files importing them.
# A list of all @com_google_protobuf well known protos can
# seen with:
# `bazel query 'kind(proto_library, @com_google_protobuf//:all)'`
# `bazel query 'kind(.*, @com_google_protobuf//:all)'`
"@com_google_protobuf//:descriptor_proto",
],
)
Expand Down
8 changes: 5 additions & 3 deletions tests/flags/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library", "cc_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")

proto_library(
name = "test_proto",
Expand All @@ -15,7 +16,7 @@ proto_library(
# proto_library rules of the source files importing them.
# A list of all @com_google_protobuf well known protos can
# seen with:
# `bazel query 'kind(proto_library, @com_google_protobuf//:all)'`
# `bazel query 'kind(.*, @com_google_protobuf//:all)'`
"@com_google_protobuf//:duration_proto",
"//include/stout/flags/v1:flag_proto",
],
Expand Down Expand Up @@ -44,6 +45,7 @@ cc_test(
deps = [
":test_proto_library",
"//:flags",
"@com_google_protobuf//:time_util",
"@gtest//:gtest_main",
],
)