diff --git a/.bazeliskrc b/.bazeliskrc index bd4a535..e0d5ba7 100644 --- a/.bazeliskrc +++ b/.bazeliskrc @@ -1 +1 @@ -USE_BAZEL_VERSION=5.4.1 +USE_BAZEL_VERSION=8.0.0 diff --git a/.bazelrc b/.bazelrc index a0ddfd7..7d76b03 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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 diff --git a/.gitignore b/.gitignore index 47760a1..831d332 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vs .vscode bazel-* +MODULE.bazel.lock diff --git a/BUILD.bazel b/BUILD.bazel index 2e84638..3b60939 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", ], ) @@ -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", diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..74da336 --- /dev/null +++ b/MODULE.bazel @@ -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") diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..e69de29 diff --git a/WORKSPACE.bazel b/WORKSPACE.bzlmod similarity index 79% rename from WORKSPACE.bazel rename to WORKSPACE.bzlmod index a14d0a6..7cbe729 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bzlmod @@ -1,5 +1,3 @@ -workspace(name = "stout") - load("//bazel:repos.bzl", "repos") repos(external = False) diff --git a/bazel/deps.bzl b/bazel/deps.bzl index c1f1680..795e1a5 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -2,8 +2,6 @@ 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. @@ -11,8 +9,6 @@ def deps(repo_mapping = {}): Args: repo_mapping (str): {}. """ - boost_deps() - picojson_deps( repo_mapping = repo_mapping, ) @@ -20,5 +16,3 @@ def deps(repo_mapping = {}): rapidjson_deps( repo_mapping = repo_mapping, ) - - protobuf_deps() diff --git a/bazel/repos.bzl b/bazel/repos.bzl index cee9262..fc96c08 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -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", @@ -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 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..9cbff04 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", @@ -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", ], ) diff --git a/tests/flags/BUILD.bazel b/tests/flags/BUILD.bazel index 71a100e..1fca25f 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("@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", @@ -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", ], @@ -44,6 +45,7 @@ cc_test( deps = [ ":test_proto_library", "//:flags", + "@com_google_protobuf//:time_util", "@gtest//:gtest_main", ], )