Skip to content

Commit 7a06a83

Browse files
authored
1 parent 7a5f0ea commit 7a06a83

10 files changed

+380
-0
lines changed

modules/protobuf/25.5/MODULE.bazel

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
2+
# https://github.com/protocolbuffers/protobuf/issues/14313
3+
4+
module(
5+
name = "protobuf",
6+
version = "25.5",
7+
compatibility_level = 1,
8+
repo_name = "com_google_protobuf",
9+
)
10+
11+
# LOWER BOUND dependency versions.
12+
# Bzlmod follows MVS:
13+
# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
14+
# Thus the highest version in their module graph is resolved.
15+
bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
16+
bazel_dep(name = "bazel_skylib", version = "1.4.1")
17+
bazel_dep(name = "jsoncpp", version = "1.9.5")
18+
bazel_dep(name = "rules_cc", version = "0.0.9")
19+
bazel_dep(name = "rules_java", version = "4.0.0")
20+
bazel_dep(name = "rules_jvm_external", version = "5.1")
21+
bazel_dep(name = "rules_pkg", version = "0.7.0")
22+
bazel_dep(name = "rules_python", version = "0.10.2")
23+
bazel_dep(name = "platforms", version = "0.0.8")
24+
bazel_dep(name = "zlib", version = "1.2.11")
25+
26+
# TODO: remove after toolchain types are moved to protobuf
27+
bazel_dep(name = "rules_proto", version = "4.0.0")
28+
29+
# Do not take the effort to convert utf8_range to Bzlmod as this has been moved to protobuf/third_party
30+
# See https://github.com/protocolbuffers/utf8_range/commit/1d1ea7e3fedf482d4a12b473c1ed25fe0f371a45
31+
non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps")
32+
use_repo(non_module_deps, "utf8_range")
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/MODULE.bazel b/MODULE.bazel
2+
index 2d43e46df..ea70894de 100644
3+
--- a/MODULE.bazel
4+
+++ b/MODULE.bazel
5+
@@ -1,2 +1,26 @@
6+
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
7+
# https://github.com/protocolbuffers/protobuf/issues/14313
8+
+
9+
+module(
10+
+ name = "protobuf",
11+
+ version = "25.5",
12+
+ compatibility_level = 1,
13+
+)
14+
+
15+
+# LOWER BOUND dependency versions.
16+
+# Bzlmod follows MVS:
17+
+# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution
18+
+# Thus the highest version in their module graph is resolved.
19+
+bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1", repo_name = "com_google_absl")
20+
+bazel_dep(name = "bazel_skylib", version = "1.4.1")
21+
+bazel_dep(name = "jsoncpp", version = "1.9.5")
22+
+bazel_dep(name = "rules_cc", version = "0.0.9")
23+
+bazel_dep(name = "rules_java", version = "4.0.0")
24+
+bazel_dep(name = "rules_jvm_external", version = "5.1")
25+
+bazel_dep(name = "rules_pkg", version = "0.7.0")
26+
+bazel_dep(name = "rules_python", version = "0.10.2")
27+
+bazel_dep(name = "platforms", version = "0.0.8")
28+
+bazel_dep(name = "zlib", version = "1.2.11")
29+
+
30+
+# TODO: remove after toolchain types are moved to protobuf
31+
+bazel_dep(name = "rules_proto", version = "4.0.0")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel
2+
new file mode 100644
3+
index 000000000..7e7f44fb4
4+
--- /dev/null
5+
+++ b/examples/MODULE.bazel
6+
@@ -0,0 +1,10 @@
7+
+bazel_dep(name = "rules_cc", version = "0.0.1")
8+
+bazel_dep(name = "rules_proto", version = "4.0.0")
9+
+bazel_dep(name = "rules_java", version = "7.3.0")
10+
+bazel_dep(name = "rules_pkg", version = "0.7.0")
11+
+bazel_dep(name = "protobuf", repo_name = "com_google_protobuf")
12+
+
13+
+local_path_override(
14+
+ module_name = "protobuf",
15+
+ path = "..",
16+
+)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/protobuf.bzl b/protobuf.bzl
2+
index d96eeb4c9..cd10f01ec 100644
3+
--- a/protobuf.bzl
4+
+++ b/protobuf.bzl
5+
@@ -493,8 +493,8 @@ def internal_ruby_proto_library(
6+
srcs = [],
7+
deps = [],
8+
includes = ["."],
9+
- default_runtime = "@com_google_protobuf//ruby:protobuf",
10+
- protoc = "@com_google_protobuf//:protoc",
11+
+ default_runtime = "//ruby:protobuf",
12+
+ protoc = "//:protoc",
13+
testonly = None,
14+
visibility = ["//visibility:public"],
15+
**kwargs):
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git a/MODULE.bazel b/MODULE.bazel
2+
index ea70894de..37e49a5c6 100644
3+
--- a/MODULE.bazel
4+
+++ b/MODULE.bazel
5+
@@ -24,3 +24,8 @@ bazel_dep(name = "zlib", version = "1.2.11")
6+
7+
# TODO: remove after toolchain types are moved to protobuf
8+
bazel_dep(name = "rules_proto", version = "4.0.0")
9+
+
10+
+# Do not take the effort to convert utf8_range to Bzlmod as this has been moved to protobuf/third_party
11+
+# See https://github.com/protocolbuffers/utf8_range/commit/1d1ea7e3fedf482d4a12b473c1ed25fe0f371a45
12+
+non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps")
13+
+use_repo(non_module_deps, "utf8_range")
14+
diff --git a/non_module_deps.bzl b/non_module_deps.bzl
15+
new file mode 100644
16+
index 000000000..0b3c57229
17+
--- /dev/null
18+
+++ b/non_module_deps.bzl
19+
@@ -0,0 +1,19 @@
20+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
21+
+
22+
+def _github_archive(repo, commit, **kwargs):
23+
+ repo_name = repo.split("/")[-1]
24+
+ http_archive(
25+
+ urls = [repo + "/archive/" + commit + ".zip"],
26+
+ strip_prefix = repo_name + "-" + commit,
27+
+ **kwargs
28+
+ )
29+
+
30+
+def _non_module_deps_impl(ctx):
31+
+ _github_archive(
32+
+ name = "utf8_range",
33+
+ repo = "https://github.com/protocolbuffers/utf8_range",
34+
+ commit = "de0b4a8ff9b5d4c98108bdfe723291a33c52c54f",
35+
+ sha256 = "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702",
36+
+ )
37+
+
38+
+non_module_deps = module_extension(implementation = _non_module_deps_impl)
39+
\ No newline at end of file
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index 23efee4a3..1c7ff6ee7 100644
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -5,7 +5,7 @@ load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_librar
6+
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
7+
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
8+
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
9+
-load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library")
10+
+load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library")
11+
12+
licenses(["notice"])
13+
14+
@@ -150,17 +150,6 @@ filegroup(
15+
visibility = ["//visibility:public"],
16+
)
17+
18+
-internal_ruby_proto_library(
19+
- name = "well_known_ruby_protos",
20+
- srcs = [":well_known_protos"],
21+
- default_runtime = "",
22+
- includes = ["src"],
23+
- visibility = [
24+
- "//conformance:__pkg__",
25+
- "//ruby:__subpackages__",
26+
- ],
27+
-)
28+
-
29+
################################################################################
30+
# Protocol Buffers Compiler
31+
################################################################################
32+
@@ -525,33 +514,6 @@ internal_php_proto_library(
33+
],
34+
)
35+
36+
-internal_ruby_proto_library(
37+
- name = "test_messages_proto2_ruby_proto",
38+
- testonly = 1,
39+
- srcs = ["//src/google/protobuf:test_messages_proto2.proto"],
40+
- includes = ["src/google/protobuf"],
41+
- visibility = [
42+
- "//conformance:__pkg__",
43+
- "//ruby:__subpackages__",
44+
- ],
45+
-)
46+
-
47+
-internal_ruby_proto_library(
48+
- name = "test_messages_proto3_ruby_proto",
49+
- testonly = 1,
50+
- srcs = ["//src/google/protobuf:test_messages_proto3.proto"],
51+
- includes = [
52+
- "src/google/protobuf",
53+
- # The above must come first.
54+
- "src",
55+
- ],
56+
- visibility = [
57+
- "//conformance:__pkg__",
58+
- "//ruby:__subpackages__",
59+
- ],
60+
- deps = [":well_known_ruby_protos"],
61+
-)
62+
-
63+
filegroup(
64+
name = "bzl_srcs",
65+
srcs = glob(["**/*.bzl"]),
66+
diff --git a/conformance/BUILD.bazel b/conformance/BUILD.bazel
67+
index c4955042c..56a81c5aa 100644
68+
--- a/conformance/BUILD.bazel
69+
+++ b/conformance/BUILD.bazel
70+
@@ -2,7 +2,7 @@
71+
72+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "objc_library")
73+
load("@rules_ruby//ruby:defs.bzl", "ruby_binary")
74+
-load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library")
75+
+load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library")
76+
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
77+
load(
78+
"@rules_pkg//:mappings.bzl",
79+
diff --git a/protobuf.bzl b/protobuf.bzl
80+
index cd10f01ec..efc59e8bc 100644
81+
--- a/protobuf.bzl
82+
+++ b/protobuf.bzl
83+
@@ -2,7 +2,6 @@ load("@bazel_skylib//lib:versions.bzl", "versions")
84+
load("@rules_cc//cc:defs.bzl", "objc_library")
85+
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
86+
load("@rules_python//python:defs.bzl", "py_library")
87+
-load("@rules_ruby//ruby:defs.bzl", "ruby_library")
88+
89+
def _GetPath(ctx, path):
90+
if ctx.label.workspace_root:
91+
@@ -490,6 +489,7 @@ def internal_objc_proto_library(
92+
93+
def internal_ruby_proto_library(
94+
name,
95+
+ ruby_library,
96+
srcs = [],
97+
deps = [],
98+
includes = ["."],
99+
@@ -506,6 +506,7 @@ def internal_ruby_proto_library(
100+
101+
Args:
102+
name: the name of the ruby_proto_library.
103+
+ ruby_library: the ruby library rules to use.
104+
srcs: the .proto files to compile.
105+
deps: a list of dependency labels; must be a internal_ruby_proto_library.
106+
includes: a string indicating the include path of the .proto files.
107+
diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl
108+
index d055eed8c..c96090989 100644
109+
--- a/protobuf_deps.bzl
110+
+++ b/protobuf_deps.bzl
111+
@@ -109,14 +109,6 @@ def protobuf_deps():
112+
sha256 = "f9e4f6acf82449324d56669bda4bdb28b48688ad2990d8b39fa5b93ed39c9ad1",
113+
)
114+
115+
- if not native.existing_rule("rules_ruby"):
116+
- _github_archive(
117+
- name = "rules_ruby",
118+
- repo = "https://github.com/protocolbuffers/rules_ruby",
119+
- commit = "b7f3e9756f3c45527be27bc38840d5a1ba690436",
120+
- sha256 = "347927fd8de6132099fcdc58e8f7eab7bde4eb2fd424546b9cd4f1c6f8f8bad8",
121+
- )
122+
-
123+
if not native.existing_rule("rules_jvm_external"):
124+
_github_archive(
125+
name = "rules_jvm_external",
126+
diff --git a/ruby/BUILD.bazel b/ruby/BUILD.bazel
127+
index cc4b477ee..847c50fcf 100755
128+
--- a/ruby/BUILD.bazel
129+
+++ b/ruby/BUILD.bazel
130+
@@ -7,7 +7,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
131+
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
132+
load("@rules_ruby//ruby:defs.bzl", "ruby_library")
133+
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
134+
-load("//:protobuf.bzl", "internal_ruby_proto_library")
135+
+load("//ruby:defs.bzl", "internal_ruby_proto_library")
136+
load("//conformance:defs.bzl", "conformance_test")
137+
load("//:protobuf_version.bzl", "PROTOBUF_RUBY_VERSION")
138+
139+
diff --git a/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel b/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel
140+
index 34a539172..697f87699 100644
141+
--- a/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel
142+
+++ b/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel
143+
@@ -1,6 +1,6 @@
144+
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
145+
load("@rules_ruby//ruby:defs.bzl", "ruby_test")
146+
-load("//:protobuf.bzl", "internal_ruby_proto_library")
147+
+load("//ruby:defs.bzl", "internal_ruby_proto_library")
148+
149+
internal_ruby_proto_library(
150+
name = "test_ruby_protos",
151+
diff --git a/ruby/defs.bzl b/ruby/defs.bzl
152+
new file mode 100644
153+
index 000000000..e7610ad01
154+
--- /dev/null
155+
+++ b/ruby/defs.bzl
156+
@@ -0,0 +1,24 @@
157+
+"""Wrapper around internal_ruby_proto_library to supply our rules_ruby"""
158+
+
159+
+load("@rules_ruby//ruby:defs.bzl", "ruby_library")
160+
+load("//:protobuf.bzl", _internal_ruby_proto_library = "internal_ruby_proto_library")
161+
+
162+
+def internal_ruby_proto_library(
163+
+ name,
164+
+ **kwargs):
165+
+ """Bazel rule to create a Ruby protobuf library from proto source files
166+
+
167+
+ NOTE: the rule is only an internal workaround to generate protos. The
168+
+ interface may change and the rule may be removed when bazel has introduced
169+
+ the native rule.
170+
+
171+
+ Args:
172+
+ name: the name of the ruby_proto_library.
173+
+ **kwargs: other keyword arguments that are passed to ruby_library.
174+
+
175+
+ """
176+
+ _internal_ruby_proto_library(
177+
+ name,
178+
+ ruby_library,
179+
+ **kwargs
180+
+ )
181+
\ No newline at end of file
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/MODULE.bazel b/MODULE.bazel
2+
index 37e49a5c6..ede816afc 100644
3+
--- a/MODULE.bazel
4+
+++ b/MODULE.bazel
5+
@@ -5,6 +5,7 @@ module(
6+
name = "protobuf",
7+
version = "25.5",
8+
compatibility_level = 1,
9+
+ repo_name = "com_google_protobuf",
10+
)
11+
12+
# LOWER BOUND dependency versions.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
matrix:
2+
platform: ["debian10", "macos", "ubuntu2004", "windows"]
3+
bazel:
4+
- 7.x
5+
- 6.x
6+
7+
tasks:
8+
verify_targets:
9+
name: "Verify build targets"
10+
platform: ${{ platform }}
11+
bazel: ${{ bazel }}
12+
build_flags:
13+
- '--host_cxxopt=-std=c++14'
14+
- '--cxxopt=-std=c++14'
15+
build_targets:
16+
- '@protobuf//:protobuf'
17+
- '@protobuf//:protobuf_lite'
18+
- '@protobuf//:protoc'
19+
- '@protobuf//:test_messages_proto2_cc_proto'
20+
- '@protobuf//:test_messages_proto3_cc_proto'
21+
22+
bcr_test_module:
23+
module_path: "examples"
24+
matrix:
25+
platform: ["debian10", "macos", "ubuntu2004", "windows"]
26+
bazel:
27+
- 7.x
28+
- 6.x
29+
tasks:
30+
run_test_module:
31+
name: "Run test module"
32+
platform: ${{ platform }}
33+
bazel: ${{ bazel }}
34+
build_flags:
35+
- '--host_cxxopt=-std=c++14'
36+
- '--cxxopt=-std=c++14'
37+
- '--nocheck_visibility'
38+
build_targets:
39+
- "//..."

modules/protobuf/25.5/source.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"url": "https://github.com/protocolbuffers/protobuf/releases/download/v25.5/protobuf-25.5.tar.gz",
3+
"integrity": "sha256-PPfVsXxP8E/p8DgQTp0Mrm2gm4ziccE+RPisafUeTg8=",
4+
"strip_prefix": "protobuf-25.5",
5+
"patch_strip": 1,
6+
"patches": {
7+
"0001-Add-MODULE.bazel.patch": "sha256-v3aLq5ijyJP1ps8eA59v5YGHx4K2GuBVDvE5rXQljgA=",
8+
"0002-Examples-MODULE.bazel.patch": "sha256-k7d24FnGJcB+cnpmsmrzKO1FfE6r8gAYp13CDCvGUiM=",
9+
"0003-relative-labels.patch": "sha256-qafPK4p4WWgEFbzesFCghZVthul1KYq+hAz5T9sZOYQ=",
10+
"0004-Add-utf8_range-dependency.patch": "sha256-oghruhqg3b9LiQ/A4v6w2KjJLxS0pwOJSSetyIU5pNI=",
11+
"0005-Make-rules_ruby-a-dev-only-dependency.patch": "sha256-o3fv37+EXKESz1Kdq9en72kPzxZh4weCPR5laFOKSdw=",
12+
"0006-Add-repo_name.patch": "sha256-BOsh6WsbuyO+Wdm+VxGbGbKarQpRFjK25ImYCkQ0ggg="
13+
}
14+
}

modules/protobuf/metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"21.7",
105105
"23.1",
106106
"24.4",
107+
"25.5",
107108
"26.0",
108109
"26.0.bcr.1",
109110
"26.0.bcr.2",

0 commit comments

Comments
 (0)