Skip to content

Initial bzlmod support #88

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

Merged
merged 2 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
common --noenable_bzlmod --enable_workspace
common --enable_bzlmod --noenable_workspace

build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
build --cxxopt=-fsized-deallocation
Expand Down
47 changes: 47 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2023-2025 Buf Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# DO NOT EDIT MODULE.bazel - Edit MODULE.bazel.tmpl instead, then run make generate.

module(name = "protovalidate-cc")

bazel_dep(name = "re2", version = "2024-07-02.bcr.1", repo_name = "com_googlesource_code_re2")

bazel_dep(name = "protobuf", version = "29.2", repo_name = "com_google_protobuf")

bazel_dep(name = "rules_proto", version = "7.1.0")

bazel_dep(name = "rules_buf", version = "0.3.0")

bazel_dep(name = "googletest", version = "1.16.0.bcr.1", repo_name = "com_google_googletest")

bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")

bazel_dep(name = "cel-cpp", repo_name = "com_google_cel_cpp")

archive_override(
module_name = "cel-cpp",
strip_prefix = "cel-cpp-0.11.0",
patches=[
"@protovalidate-cc//deps:patches/cel_cpp/0001-Allow-message-field-access-using-index-operator.patch",
"@protovalidate-cc//deps:patches/cel_cpp/0002-Add-missing-include-for-absl-StrCat.patch",
"@protovalidate-cc//deps:patches/cel_cpp/0003-Fix-build-on-Windows-MSVC.patch",
],
patch_args=["-p1"],
urls = [
"https://github.com/google/cel-cpp/archive/v0.11.0.tar.gz"
]
)

bazel_dep(name = "protovalidate", version = "0.10.4", repo_name = "com_github_bufbuild_protovalidate")
770 changes: 770 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions MODULE.bazel.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2023-2025 Buf Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# DO NOT EDIT MODULE.bazel - Edit MODULE.bazel.tmpl instead, then run make generate.

module(name = "protovalidate-cc")

bazel_dep(name = "re2", version = "2024-07-02.bcr.1", repo_name = "com_googlesource_code_re2")

bazel_dep(name = "protobuf", version = "{{protobuf.meta.version}}", repo_name = "com_google_protobuf")

bazel_dep(name = "rules_proto", version = "7.1.0")

bazel_dep(name = "rules_buf", version = "0.3.0")

bazel_dep(name = "googletest", version = "1.16.0.bcr.1", repo_name = "com_google_googletest")

bazel_dep(name = "abseil-cpp", version = "{{absl.meta.version}}", repo_name = "com_google_absl")

bazel_dep(name = "cel-cpp", repo_name = "com_google_cel_cpp")

archive_override(
module_name = "cel-cpp",
strip_prefix = "cel-cpp-{{cel_cpp.meta.version}}",
patches=[
"@protovalidate-cc//deps:patches/cel_cpp/0001-Allow-message-field-access-using-index-operator.patch",
"@protovalidate-cc//deps:patches/cel_cpp/0002-Add-missing-include-for-absl-StrCat.patch",
"@protovalidate-cc//deps:patches/cel_cpp/0003-Fix-build-on-Windows-MSVC.patch",
],
patch_args=["-p1"],
urls = [
"https://github.com/google/cel-cpp/archive/v{{cel_cpp.meta.version}}.tar.gz"
]
)

bazel_dep(name = "protovalidate", version = "{{protovalidate.meta.version}}", repo_name = "com_github_bufbuild_protovalidate")
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ clean: ## Delete intermediate build artifacts
git clean -Xdf

.PHONY: generate
generate: generate-license ## Regenerate code and license headers
generate: generate-bzlmod generate-license ## Regenerate code and license headers

.PHONY: test
test: generate ## Run all unit tests
Expand All @@ -49,6 +49,12 @@ conformance: $(BIN)/protovalidate-conformance
$(BAZEL) build -c opt //buf/validate/conformance:runner_main && \
$(BIN)/protovalidate-conformance bazel-bin/buf/validate/conformance/runner_main $(ARGS)

.PHONY: generate-bzlmod
generate-bzlmod: ## Generate MODULE.bazel file from template
<MODULE.bazel.tmpl >MODULE.bazel \
jq -nrR --argjson json "$$(<./deps/shared_deps.json)" \
'inputs | gsub("\\{\\{(?<v>[^}]+)\\}\\}"; .v | split(".") as $$path | reduce $$path[] as $$key ($$json; .[$$key]) | tostring)'

.PHONY: generate-license
generate-license: $(BIN)/license-header ## Generate license headers for files
@# We want to operate on a list of modified and new files, excluding
Expand Down
Empty file added WORKSPACE.bzlmod
Empty file.
1 change: 1 addition & 0 deletions bazel/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ cc_library(
patches=[
"@com_github_bufbuild_protovalidate_cc//deps:patches/cel_cpp/0001-Allow-message-field-access-using-index-operator.patch",
"@com_github_bufbuild_protovalidate_cc//deps:patches/cel_cpp/0002-Add-missing-include-for-absl-StrCat.patch",
"@com_github_bufbuild_protovalidate_cc//deps:patches/cel_cpp/0003-Fix-build-on-Windows-MSVC.patch",
],
patch_args=["-p1"],
),
Expand Down
2 changes: 1 addition & 1 deletion buf/validate/validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ absl::Status Validator::ValidateMessage(
const auto* constraints_or = factory_->GetMessageConstraints(message.GetDescriptor());
if (constraints_or == nullptr) {
return absl::NotFoundError(
"constraints not loaded for message: " + message.GetDescriptor()->full_name());
absl::StrCat("constraints not loaded for message: ", message.GetDescriptor()->full_name()));
}
if (!constraints_or->ok()) {
return constraints_or->status();
Expand Down
Loading