diff --git a/.bazeliskrc b/.bazeliskrc index a77e0c8..89b6466 100644 --- a/.bazeliskrc +++ b/.bazeliskrc @@ -1,2 +1 @@ -USE_BAZEL_VERSION=7.7.0 - +USE_BAZEL_VERSION=6.5.0 diff --git a/.bazelrc b/.bazelrc index 8ff7832..b19922f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,6 +1,3 @@ -# Disable Bazel modules (for now). -common --enable_bzlmod=false - # Specific Bazel build/test options. build:macos --cxxopt='-std=c++17' --host_cxxopt='-std=c++17' diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index a95cdc1..bdabe67 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -2,11 +2,7 @@ workspace(name = "com_github_3rdparty_stout") load("//bazel:repos.bzl", "repos") -repos() - -load("@rules_python//python:repositories.bzl", "py_repositories") - -py_repositories() +repos(external = False) load("//bazel:deps.bzl", "deps") diff --git a/bazel/deps.bzl b/bazel/deps.bzl index fb9e29a..8502806 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -1,16 +1,34 @@ """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") load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") -def deps(): - """Propagate all dependencies.""" +def deps(repo_mapping = {}): + """Propagate all dependencies. + + Args: + repo_mapping (str): {}. + """ boost_deps() - picojson_deps() + picojson_deps( + repo_mapping = repo_mapping, + ) + + rapidjson_deps( + repo_mapping = repo_mapping, + ) - rapidjson_deps() + # 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 62126e6..d21e564 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -15,28 +15,21 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//3rdparty/bazel-rules-picojson:repos.bzl", picojson_repos = "repos") load("//3rdparty/bazel-rules-rapidjson:repos.bzl", rapidjson_repos = "repos") -def repos(): - """Adds repositories/archives needed by stout.""" - picojson_repos() +def repos(external = True, repo_mapping = {}): + """Adds repositories/archives needed by stout - rapidjson_repos() - - maybe( - http_archive, - name = "rules_python", - sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07", - strip_prefix = "rules_python-1.0.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz", + Args: + external: whether or not we're invoking this function as though + though we're an external dependency + repo_mapping: passed through to all other functions that expect/use + repo_mapping, e.g., 'git_repository' + """ + picojson_repos( + repo_mapping = repo_mapping, ) - maybe( - http_archive, - name = "com_google_protobuf", - sha256 = "955ef3235be41120db4d367be81efe6891c9544b3a71194d80c3055865b26e09", - strip_prefix = "protobuf-29.5", - urls = [ - "https://github.com/protocolbuffers/protobuf/archive/v29.5.tar.gz", - ], + rapidjson_repos( + repo_mapping = repo_mapping, ) maybe( @@ -82,9 +75,20 @@ def repos(): maybe( http_archive, name = "com_github_google_glog", - sha256 = "c17d85c03ad9630006ef32c7be7c65656aba2e7e2fbfc82226b7e680c771fc88", - strip_prefix = "glog-0.7.1", - urls = ["https://github.com/google/glog/archive/v0.7.1.zip"], + url = "https://github.com/google/glog/archive/refs/tags/v0.5.0.tar.gz", + sha256 = "eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5", + strip_prefix = "glog-0.5.0", + ) + + maybe( + http_archive, + name = "com_google_protobuf", + sha256 = "008a11cc56f9b96679b4c285fd05f46d317d685be3ab524b2a310be0fbad987e", + strip_prefix = "protobuf-29.3", + urls = [ + "https://github.com/protocolbuffers/protobuf/archive/v29.3.tar.gz", + ], + repo_mapping = repo_mapping, ) # Copied and then modified to use the latest 'commit' and 'shallow_since' @@ -113,3 +117,12 @@ def repos(): "Move-Item -Path support/bazel/WORKSPACE.bazel -Destination WORKSPACE.bazel", ], ) + + if external: + maybe( + git_repository, + name = "com_github_3rdparty_stout", + commit = "67e6b9b08f340e223b741130815d97cf20296c08", + remote = "https://github.com/3rdparty/stout", + shallow_since = "1637367065 -0800", + ) diff --git a/include/stout/flags/flags.h b/include/stout/flags/flags.h index 565453d..6ebab99 100644 --- a/include/stout/flags/flags.h +++ b/include/stout/flags/flags.h @@ -218,7 +218,7 @@ class ParserBuilder { std::move(help), [f = std::forward(f)](google::protobuf::Message& message) { return f( - *google::protobuf::DynamicCastMessage(&message)); + *google::protobuf::DynamicCastToGenerated(&message)); }); return *this; @@ -291,7 +291,7 @@ class ParserBuilder { google::protobuf::Message& message) { return f( value, - *google::protobuf::DynamicCastMessage(&message)); + *google::protobuf::DynamicCastToGenerated(&message)); }; return true; } else {