Skip to content

Commit 2823100

Browse files
authored
Merge branch 'protocolbuffers:main' into improve-performance-repeated-packed-fixed-field
2 parents e5c3514 + 913f7b0 commit 2823100

File tree

154 files changed

+2673
-3877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+2673
-3877
lines changed

.github/workflows/test_release_branches.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
branch: [25.x, 28.x, 29.x]
16+
branch: [25.x, 29.x]
1717
runs-on: ubuntu-latest
1818
permissions:
1919
actions: write

.github/workflows/test_upb.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,24 @@ jobs:
264264
- name: Install Protobuf Test Wheel
265265
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
266266
run: pip install -vvv --no-index --find-links wheels protobuftests
267-
- name: Run the unit tests
267+
- name: Run legacy unit tests
268268
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
269+
# Legacy upb tests use a "test wrapper" and get installed under pb_unit_tests.
269270
run: |
270-
TESTS=$(pip show -f protobuftests | grep pb_unit_tests.*py$ | sed 's,/,.,g' | sed 's,\\,.,g' | sed -E 's,.py$,,g')
271-
for test in $TESTS; do
271+
PB_UNIT_TESTS=$(pip show -f protobuftests | grep pb_unit_tests.*py$ | sed 's,/,.,g' | sed 's,\\,.,g' | sed -E 's,.py$,,g')
272+
for test in $PB_UNIT_TESTS; do
272273
python -m unittest -v $test
273274
done
275+
- name: Run unit tests
276+
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
277+
# Newer upb tests are in the standard google.protobuf.internal path.
278+
# We will eventually make this into a wildcard rule once all tests
279+
# have been migrated to be compatible with upb.
280+
run: |
281+
TESTS=(message_test message_factory_test descriptor_test proto_builder_test)
282+
for test in ${TESTS[@]}; do
283+
python -m unittest -v google.protobuf.internal.${test}
284+
done
274285
275286
test_pure_python_wheels:
276287
name: Test Pure Python Wheels
@@ -299,8 +310,13 @@ jobs:
299310
python -m venv env
300311
source env/bin/activate
301312
echo "VIRTUAL ENV:" $VIRTUAL_ENV
302-
- name: Install numpy
303-
run: pip install numpy
313+
- name: Download Requirements
314+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 #4.1.8
315+
with:
316+
name: requirements
317+
path: requirements
318+
- name: Install requirements
319+
run: pip install -r requirements/requirements.txt
304320
- name: Install Protobuf Wheels
305321
run: pip install -vvv --no-index --find-links wheels protobuf protobuftests
306322
- name: Run the unit tests

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ ruby/tests/multi_level_nesting_test_pb.rb
176176
ruby/tests/service_test_pb.rb
177177
ruby/tests/test_import_proto2_pb.rb
178178
ruby/tests/test_ruby_package_proto2_pb.rb
179+
ruby/tests/basic_test_features_pb.rb
180+
ruby/tests/generated_code_editions_pb.rb
181+
ruby/tests/repeated_field_test_pb.rb
182+
ruby/tests/stress_pb.rb
183+
ruby/tests/utf8_pb.rb
179184
ruby/compatibility_tests/v3.0.0/protoc
180185
ruby/compatibility_tests/v3.0.0/tests/generated_code_pb.rb
181186
ruby/compatibility_tests/v3.0.0/tests/test_import_pb.rb

MODULE.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use_repo(
5858
system_python = "python_{}".format(SUPPORTED_PYTHON_VERSIONS[-1].replace(".", "_")),
5959
)
6060

61-
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
61+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True)
6262

6363
[
6464
pip.parse(
@@ -71,7 +71,7 @@ pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
7171

7272
use_repo(pip, "pip_deps")
7373

74-
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
74+
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate", dev_dependency = True)
7575
crate.spec(
7676
package = "googletest",
7777
version = ">0.0.0",
@@ -83,7 +83,7 @@ crate.spec(
8383
crate.from_specs()
8484
use_repo(crate, crate_index = "crates")
8585

86-
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
86+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven", dev_dependency = True)
8787
maven.install(
8888
name = "protobuf_maven",
8989
artifacts = [
@@ -112,6 +112,12 @@ use_repo(maven, "protobuf_maven")
112112
bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True, repo_name = "com_google_googletest")
113113
bazel_dep(name = "rules_buf", version = "0.3.0", dev_dependency = True)
114114
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
115+
bazel_dep(
116+
name = "abseil-py",
117+
version = "2.1.0",
118+
dev_dependency = True,
119+
repo_name = "com_google_absl_py",
120+
)
115121

116122
# rules_proto are needed for @com_google_protobuf_v25.0 used in //compatibility/... tests
117123
bazel_dep(name = "rules_proto", version = "4.0.0", dev_dependency = True)

WORKSPACE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ load("@pip_deps//:requirements.bzl", "install_deps")
193193

194194
install_deps()
195195

196+
http_archive(
197+
name = "com_google_absl_py",
198+
sha256 = "8a3d0830e4eb4f66c4fa907c06edf6ce1c719ced811a12e26d9d3162f8471758",
199+
strip_prefix = "abseil-py-2.1.0",
200+
urls = [
201+
"https://github.com/abseil/abseil-py/archive/refs/tags/v2.1.0.tar.gz",
202+
],
203+
)
204+
196205
http_archive(
197206
name = "rules_fuzzing",
198207
patch_args = ["-p1"],

cmake/dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(rules_shell-version "0.2.0")
3030
set(googletest-version "1.14.0")
3131
set(rules_buf-version "0.3.0")
3232
set(rules_testing-version "0.6.0")
33+
set(abseil-py-version "2.1.0")
3334
set(rules_proto-version "4.0.0")
3435

3536

cmake/dependencies_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def register_toolchains(self, *args):
9090
def use_repo(self, *args, **kwargs):
9191
pass
9292

93-
def use_extension(self, *args):
93+
def use_extension(self, *args, **kwargs):
9494
return ExtensionFunctions()
9595

9696

cmake/install.cmake

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ set(protobuf_HEADERS
9393
${descriptor_proto_proto_srcs}
9494
${plugin_proto_proto_srcs}
9595
${java_features_proto_proto_srcs}
96+
${go_features_proto_proto_srcs}
9697
)
9798
if (protobuf_BUILD_LIBUPB)
9899
list(APPEND protobuf_HEADERS ${libupb_hdrs})
@@ -105,14 +106,22 @@ if (protobuf_BUILD_LIBUPB)
105106
COMPONENT protobuf-headers
106107
)
107108
endif ()
109+
set(protobuf_STRIP_PREFIXES
110+
"/src"
111+
"/java/core/src/main/resources"
112+
"/go"
113+
"/"
114+
)
108115
foreach(_header ${protobuf_HEADERS})
109-
string(FIND ${_header} "${protobuf_SOURCE_DIR}/src" _find_src)
110-
string(FIND ${_header} "${protobuf_SOURCE_DIR}" _find_nosrc)
111-
if (_find_src GREATER -1)
112-
set(_from_dir "${protobuf_SOURCE_DIR}/src")
113-
elseif (_find_nosrc GREATER -1)
114-
set(_from_dir "${protobuf_SOURCE_DIR}")
115-
endif()
116+
foreach(_strip_prefix ${protobuf_STRIP_PREFIXES})
117+
string(FIND ${_header} "${protobuf_SOURCE_DIR}${_strip_prefix}" _find_src)
118+
if(_find_src GREATER -1)
119+
set(_from_dir "${protobuf_SOURCE_DIR}${_strip_prefix}")
120+
break()
121+
endif()
122+
endforeach()
123+
message(${_from_dir} "-" ${_header})
124+
116125
# Escape _from_dir for regex special characters in the directory name.
117126
string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" _from_dir_regexp "${_from_dir}")
118127
# On some platforms `_form_dir` ends up being just "protobuf", which can

conformance/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Copyright (c) 2024, Google LLC
2+
# All rights reserved.
3+
#
4+
# Use of this source code is governed by a BSD-style
5+
# license that can be found in the LICENSE file or at
6+
# https://developers.google.com/open-source/licenses/bsd
7+
18
# Conformance testing for Protobuf.
29

310
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "objc_library")

conformance/text_format_failure_list_python.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# This is the list of text format conformance tests that are known to fail right
22
# now.
33
# TODO: These should be fixed.
4-
Required.*.TextFormatInput.FloatFieldNoNegativeOctal # Should have failed to parse, but didn't.
5-
Required.*.TextFormatInput.FloatFieldNoOctal # Should have failed to parse, but didn't.
64
Required.*.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput # Output was not equivalent to reference message: modified: optional_bytes: "\007\010\014\n\r\t\013?\\\'\"" -> "\007\010\014\n\r\t
75
Required.*.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput # Output was not equivalent to reference message: modified: optional_bytes: "\007\010\014\n\r\t\013?\\\'\"" -> "\007\010\014\n\r\t
86
Required.*.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput # Output was not equivalent to reference message: modified: optional_string: "\007\010\014\n\r\t\013?\\\'\"" -> "\007\010\014\n\r\

0 commit comments

Comments
 (0)