diff --git a/.bazeliskrc b/.bazeliskrc index bd4a535..89b6466 100644 --- a/.bazeliskrc +++ b/.bazeliskrc @@ -1 +1 @@ -USE_BAZEL_VERSION=5.4.1 +USE_BAZEL_VERSION=6.5.0 diff --git a/.bazelrc b/.bazelrc index a0ddfd7..b19922f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,9 +1,8 @@ # Specific Bazel build/test options. +build:macos --cxxopt='-std=c++17' --host_cxxopt='-std=c++17' -build:macos --cxxopt='-std=c++17' +build:linux --cxxopt='-std=c++17' --host_cxxopt='-std=c++17' -build:linux --cxxopt='-std=c++17' - -build:windows --cxxopt="/std:c++17" +build:windows --cxxopt="/std:c++17" --host_cxxopt='/std:c++17' build --enable_platform_specific_config diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index e6caeb2..47a4218 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,4 +1,4 @@ -# Workflow for building and testing flags on macOS and Ubuntu. +# Workflow for building and testing stout on macOS and Ubuntu. name: Build and Run all tests # We use action's triggers 'push' and 'pull_request'. @@ -31,6 +31,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: + # TODO: CI on Windows is disabled at the moment, because building + # Protobuf with MSVC and Bazel is not well-supported (#80). Re-enable + # once we have a better build story on Windows. os: ["macos-latest", "ubuntu-latest"] defaults: run: diff --git a/BUILD.bazel b/BUILD.bazel index 2e84638..5fc910d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -49,6 +49,7 @@ cc_library( "@com_github_google_glog//:glog", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", + "@com_google_protobuf//:duration_cc_proto", ], ) diff --git a/bazel/deps.bzl b/bazel/deps.bzl index c1f1680..8502806 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -1,5 +1,6 @@ """Dependency specific initialization for stout.""" +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 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") @@ -21,4 +22,13 @@ def deps(repo_mapping = {}): repo_mapping = repo_mapping, ) + # Needed because protobuf_deps brings rules_python 0.26.0 which is broken: + # https://github.com/bazelbuild/rules_python/issues/1543 + http_archive( + name = "rules_python", + sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036", + strip_prefix = "rules_python-0.25.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz", + ) + protobuf_deps() diff --git a/bazel/repos.bzl b/bazel/repos.bzl index 02946dc..d21e564 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -35,10 +35,12 @@ def repos(external = True, 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, + sha256 = "f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3", + strip_prefix = "abseil-cpp-20240722.0", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20240722.0.tar.gz", + "https://github.com/abseil/abseil-cpp/archive/20240722.0.tar.gz", + ], ) maybe( @@ -81,12 +83,11 @@ def repos(external = True, repo_mapping = {}): maybe( http_archive, name = "com_google_protobuf", - strip_prefix = "protobuf-3.19.1", + sha256 = "008a11cc56f9b96679b4c285fd05f46d317d685be3ab524b2a310be0fbad987e", + strip_prefix = "protobuf-29.3", 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", + "https://github.com/protocolbuffers/protobuf/archive/v29.3.tar.gz", ], - sha256 = "87407cd28e7a9c95d9f61a098a53cf031109d451a7763e7dd1253abf8b4df422", repo_mapping = repo_mapping, ) diff --git a/include/stout/flags/flags.cc b/include/stout/flags/flags.cc index 843dba9..4ac28dc 100644 --- a/include/stout/flags/flags.cc +++ b/include/stout/flags/flags.cc @@ -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; diff --git a/include/stout/flags/v1/BUILD.bazel b/include/stout/flags/v1/BUILD.bazel index 527dcd2..5fd61d9 100644 --- a/include/stout/flags/v1/BUILD.bazel +++ b/include/stout/flags/v1/BUILD.bazel @@ -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", diff --git a/tests/flags/BUILD.bazel b/tests/flags/BUILD.bazel index 71a100e..381f3f3 100644 --- a/tests/flags/BUILD.bazel +++ b/tests/flags/BUILD.bazel @@ -1,5 +1,6 @@ -load("@rules_cc//cc:defs.bzl", "cc_proto_library", "cc_test") -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") +load("@rules_cc//cc:defs.bzl", "cc_test") proto_library( name = "test_proto", @@ -44,6 +45,7 @@ cc_test( deps = [ ":test_proto_library", "//:flags", + "@com_google_protobuf//:time_util", "@gtest//:gtest_main", ], )