Skip to content

Commit

Permalink
Add protoc-gen-validate 1.0.4.bcr.1 (#3420)
Browse files Browse the repository at this point in the history
This fixes compatibility with more recent versions of rules_python.
  • Loading branch information
mering authored Dec 14, 2024
1 parent 497e581 commit 08b05bb
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 1 deletion.
87 changes: 87 additions & 0 deletions modules/protoc-gen-validate/1.0.4.bcr.1/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
module(
name = "protoc-gen-validate",
version = "1.0.4.bcr.1",
compatibility_level = 1,
repo_name = "com_envoyproxy_protoc_gen_validate",
)

bazel_dep(
name = "bazel_skylib",
version = "1.4.2",
)
bazel_dep(
name = "gazelle",
version = "0.33.0",
repo_name = "bazel_gazelle",
)
bazel_dep(
name = "protobuf",
version = "23.1",
repo_name = "com_google_protobuf",
)
bazel_dep(
name = "re2",
version = "2021-09-01",
repo_name = "com_googlesource_code_re2",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "rules_go",
version = "0.42.0",
repo_name = "io_bazel_rules_go",
)
bazel_dep(
name = "rules_java",
version = "5.5.0",
)
bazel_dep(
name = "rules_proto",
version = "5.3.0-21.7",
)
bazel_dep(
name = "rules_python",
version = "0.40.0",
)
# -- bazel_dep definitions -- #

go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.21.1")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_iancoleman_strcase",
"com_github_lyft_protoc_gen_star_v2",
"org_golang_google_protobuf",
"org_golang_x_net",
)

PYTHON_VERSIONS = [
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
]
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
[
python.toolchain(
is_default = python_version == PYTHON_VERSIONS[-1],
python_version = python_version,
)
for python_version in PYTHON_VERSIONS
]
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
[
pip.parse(
hub_name = "pgv_pip_deps",
python_version = python_version,
requirements_lock = "//python:requirements.txt",
)
for python_version in PYTHON_VERSIONS
]
use_repo(pip, "pgv_pip_deps")
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
--- a/MODULE.bazel
+++ a/MODULE.bazel
@@ -0,0 +1,87 @@
+module(
+ name = "protoc-gen-validate",
+ version = "1.0.4.bcr.1",
+ compatibility_level = 1,
+ repo_name = "com_envoyproxy_protoc_gen_validate",
+)
+
+bazel_dep(
+ name = "bazel_skylib",
+ version = "1.4.2",
+)
+bazel_dep(
+ name = "gazelle",
+ version = "0.33.0",
+ repo_name = "bazel_gazelle",
+)
+bazel_dep(
+ name = "protobuf",
+ version = "23.1",
+ repo_name = "com_google_protobuf",
+)
+bazel_dep(
+ name = "re2",
+ version = "2021-09-01",
+ repo_name = "com_googlesource_code_re2",
+)
+bazel_dep(
+ name = "rules_cc",
+ version = "0.0.9",
+)
+bazel_dep(
+ name = "rules_go",
+ version = "0.42.0",
+ repo_name = "io_bazel_rules_go",
+)
+bazel_dep(
+ name = "rules_java",
+ version = "5.5.0",
+)
+bazel_dep(
+ name = "rules_proto",
+ version = "5.3.0-21.7",
+)
+bazel_dep(
+ name = "rules_python",
+ version = "0.40.0",
+)
+# -- bazel_dep definitions -- #
+
+go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
+go_sdk.download(version = "1.21.1")
+
+go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
+go_deps.from_file(go_mod = "//:go.mod")
+use_repo(
+ go_deps,
+ "com_github_iancoleman_strcase",
+ "com_github_lyft_protoc_gen_star_v2",
+ "org_golang_google_protobuf",
+ "org_golang_x_net",
+)
+
+PYTHON_VERSIONS = [
+ "3.9",
+ "3.10",
+ "3.11",
+ "3.12",
+ "3.13",
+]
+python = use_extension("@rules_python//python/extensions:python.bzl", "python")
+[
+ python.toolchain(
+ is_default = python_version == PYTHON_VERSIONS[-1],
+ python_version = python_version,
+ )
+ for python_version in PYTHON_VERSIONS
+]
+pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
+[
+ pip.parse(
+ hub_name = "pgv_pip_deps",
+ python_version = python_version,
+ requirements_lock = "//python:requirements.txt",
+ )
+ for python_version in PYTHON_VERSIONS
+]
+use_repo(pip, "pgv_pip_deps")
67 changes: 67 additions & 0 deletions modules/protoc-gen-validate/1.0.4.bcr.1/patches/pgv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
diff --git a/python/BUILD b/python/BUILD
index bf99c5f..268e4ad 100644
--- a/python/BUILD
+++ b/python/BUILD
@@ -3,6 +3,7 @@ load("@pgv_pip_deps//:requirements.bzl", "all_requirements")

exports_files([
"requirements.in",
+ "requirements.txt",
"setup.cfg",
])

diff --git a/python/requirements.txt b/python/requirements.txt
new file mode 100644
index 0000000..866d40b
--- /dev/null
+++ b/python/requirements.txt
@@ -0,0 +1,20 @@
+#
+# This file is autogenerated by pip-compile with Python 3.11
+# by the following command:
+#
+# pip-compile --output-file=requirements.txt requirements.in
+#
+astunparse==1.6.3
+ # via -r requirements.in
+jinja2==3.1.3
+ # via -r requirements.in
+markupsafe==2.1.5
+ # via jinja2
+protobuf==5.26.0
+ # via -r requirements.in
+six==1.16.0
+ # via astunparse
+validate-email==1.3
+ # via -r requirements.in
+wheel==0.43.0
+ # via astunparse
\ No newline at end of file
diff --git a/templates/cc/register.go b/templates/cc/register.go
index da773fc..dc0ae35 100644
--- a/templates/cc/register.go
+++ b/templates/cc/register.go
@@ -117,6 +117,10 @@ func CcFilePath(f pgs.File, ctx pgsgo.Context, tpl *template.Template) *pgs.File
func (fns CCFuncs) methodName(name interface{}) string {
nameStr := fmt.Sprintf("%s", name)
switch nameStr {
+ case "concept":
+ return "concept_"
+ case "requires":
+ return "requires_"
case "const":
return "const_"
case "inline":
diff --git a/validate/BUILD b/validate/BUILD
index a9d38c5..203beb4 100644
--- a/validate/BUILD
+++ b/validate/BUILD
@@ -28,7 +28,7 @@ cc_proto_library(
py_proto_library(
name = "validate_py",
srcs = ["validate.proto"],
- deps = ["@com_google_protobuf//:protobuf_python"],
+ deps = [],
)

go_proto_library(
20 changes: 20 additions & 0 deletions modules/protoc-gen-validate/1.0.4.bcr.1/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
matrix:
platform:
- debian10
- ubuntu2004
- windows
bazel:
- 7.x
- 8.x
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
bazel: ${{ bazel }}
build_flags:
- '--cxxopt=-std=c++14'
build_targets:
- '@protoc-gen-validate//bazel/go:pgv_plugin_go'
- '@protoc-gen-validate//validate:cc_validate'
- '@protoc-gen-validate//validate:go_default_library'
- '@protoc-gen-validate//validate:validate_proto'
10 changes: 10 additions & 0 deletions modules/protoc-gen-validate/1.0.4.bcr.1/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"url": "https://github.com/bufbuild/protoc-gen-validate/archive/refs/tags/v1.0.4.tar.gz",
"integrity": "sha256-kuKcIVBnXOlUyWW8qlWcqURwS3VxFTPP4DzlQdz1od0=",
"strip_prefix": "protoc-gen-validate-1.0.4",
"patches": {
"pgv.patch": "sha256-8RM92CCvSC1q8Wri8FgdcsZ0lXvb6mj2mDFqWEcgWvg=",
"module_dot_bazel.patch": "sha256-NfxGXYRoeXS7HjIGuXwaqptugPFEvYFDXiJCyu7zt08="
},
"patch_strip": 1
}
3 changes: 2 additions & 1 deletion modules/protoc-gen-validate/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"github:bufbuild/protoc-gen-validate"
],
"versions": [
"1.0.4"
"1.0.4",
"1.0.4.bcr.1"
],
"yanked_versions": {}
}

0 comments on commit 08b05bb

Please sign in to comment.