Merge branch 'main' into abseil_upgrade

pull/11622/head
Mike Kruskal 2 years ago committed by GitHub
commit 49761ed4f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      .github/workflows/ruby_install.yml
  2. 4
      kokoro/release/collect_all_artifacts.sh
  3. 60
      ruby/BUILD.bazel
  4. 63
      ruby/build_jruby_release.sh
  5. 88
      ruby/build_release.sh
  6. 2
      src/google/protobuf/compiler/cpp/helpers.cc
  7. 4
      src/google/protobuf/port_def.inc
  8. 1
      src/google/protobuf/port_undef.inc
  9. 2
      src/google/protobuf/repeated_field_unittest.cc
  10. 2
      src/google/protobuf/util/message_differencer.cc
  11. 2
      src/google/protobuf/util/message_differencer.h

@ -18,7 +18,16 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.6, 2.7, 3.0, 3.1, 3.2, jruby-9.2, jruby-9.3]
include:
- { ruby: 2.6, bazel: 6.0.0}
- { ruby: 2.7, bazel: 6.0.0}
- { ruby: 3.0, bazel: 6.0.0}
- { ruby: 3.1, bazel: 6.0.0}
- { ruby: 3.2, bazel: 6.0.0}
- { ruby: jruby-9.2, bazel: 6.0.0}
- { ruby: jruby-9.3, bazel: 6.0.0}
- { ruby: 2.6, bazel: 5.1.1}
- { ruby: jruby-9.2, bazel: 5.1.1}
steps:
- uses: actions/checkout@v2
@ -26,7 +35,7 @@ jobs:
run: |
sudo apt-get install -qy wget
mkdir $HOME/bin
wget -O $HOME/bin/bazel https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-linux-x86_64
wget -O $HOME/bin/bazel https://github.com/bazelbuild/bazel/releases/download/${{ matrix.bazel }}/bazel-${{ matrix.bazel }}-linux-x86_64
chmod a+x $HOME/bin/bazel
- name: Install git
run: |
@ -40,16 +49,16 @@ jobs:
with:
submodules: recursive
- name: Build cruby gem
run: $HOME/bin/bazel run ruby:release
run: $HOME/bin/bazel build ruby:release
if: ${{ !contains(matrix.ruby, 'jruby') }}
- name: Install cruby gem
run: gem install bazel-bin/ruby/release.runfiles/com_google_protobuf/tmp/google-protobuf-*
run: gem install bazel-bin/ruby/google-protobuf-*
if: ${{ !contains(matrix.ruby, 'jruby') }}
- name: Build jruby gem
run: $HOME/bin/bazel run ruby:jruby_release
run: $HOME/bin/bazel build ruby:jruby_release
if: ${{ contains(matrix.ruby, 'jruby') }}
- name: Install jruby gem
run: gem install bazel-bin/ruby/jruby_release.runfiles/com_google_protobuf/tmp/google-protobuf-*
run: gem install bazel-bin/ruby/google-protobuf-*
if: ${{ contains(matrix.ruby, 'jruby') }}
- name: Test installation
run: |

@ -57,6 +57,10 @@ sudo rm -f /etc/apt/sources.list.d/cuda.list
sudo apt update
sudo apt-get install -y nuget
# Copy WKT protos to csharp directory.
mkdir -p src/google/protobuf
cp ../src/google/protobuf/*.proto src/google/protobuf/
nuget pack Google.Protobuf.Tools.nuspec
# Copy the nupkg to the output artifacts

@ -4,6 +4,7 @@
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_ruby//ruby:defs.bzl", "ruby_library")
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
load("//:protobuf.bzl", "internal_ruby_proto_library")
load("//conformance:defs.bzl", "conformance_test")
load("//:protobuf_version.bzl", "PROTOBUF_RUBY_VERSION")
@ -20,27 +21,44 @@ ruby_library(
],
)
sh_binary(
# Note: these can be greatly simplified using inline_sh_binary in Bazel 6,
# but doesn't work prior to that due to https://github.com/bazelbuild/bazel/issues/15043.
# Instead, we need to manually copy all of the srcs into gendir from a genrule.
genrule(
name = "jruby_release",
data = [
srcs = [
"//ruby/lib/google:copy_jar",
"//ruby/lib/google:dist_files",
"//:well_known_ruby_protos",
"google-protobuf.gemspec",
],
srcs = [
"build_jruby_release.sh",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
outs = ["google-protobuf-"+PROTOBUF_RUBY_VERSION+"-java.gem"],
cmd = """
set -eux
mkdir tmp
for src in $(SRCS); do
cp --parents -L "$$src" tmp
done
for wkt in $(execpaths //:well_known_ruby_protos); do
mv "tmp/$$wkt" "tmp/ruby/lib/google/protobuf/"
done
mv "tmp/$(execpath //ruby/lib/google:copy_jar)" "tmp/ruby/lib/google"
cd tmp/ruby
chmod -R 777 ./
gem build google-protobuf.gemspec
cd ../..
mv tmp/ruby/google-protobuf-*.gem $@
""",
tags = ["manual"],
target_compatible_with = select({
"@rules_ruby//ruby/runtime:config_jruby": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
)
sh_binary(
genrule(
name = "release",
data = [
srcs = [
"@utf8_range//:utf8_range_srcs",
"@utf8_range//:LICENSE",
"//:well_known_ruby_protos",
@ -48,16 +66,34 @@ sh_binary(
"//ruby/lib/google:dist_files",
"google-protobuf.gemspec",
],
srcs = [
"build_release.sh",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
outs = ["google-protobuf-"+PROTOBUF_RUBY_VERSION+".gem"],
cmd = """
set -eux
mkdir tmp
for src in $(SRCS); do
cp --parents -L "$$src" "tmp"
done
mkdir -p "tmp/ruby/ext/google/protobuf_c/third_party/utf8_range"
for utf in $(execpaths @utf8_range//:utf8_range_srcs) $(execpath @utf8_range//:LICENSE); do
mv "tmp/$$utf" "tmp/ruby/ext/google/protobuf_c/third_party/utf8_range"
done
for wkt in $(execpaths //:well_known_ruby_protos); do
mv "tmp/$$wkt" "tmp/ruby/lib/google/protobuf/"
done
cd tmp/ruby
chmod -R 777 ./
gem build google-protobuf.gemspec
cd ../..
mv tmp/ruby/google-protobuf-*.gem $@
""",
tags = ["manual"],
target_compatible_with = select({
"@rules_ruby//ruby/runtime:config_ruby": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
)
################################################################################
# Tests
################################################################################

@ -1,63 +0,0 @@
#!/bin/bash
# This file should be executed with jruby
set -ex
# --- begin runfiles.bash initialization ---
# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
set -euo pipefail
if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
if [[ -f "$0.runfiles_manifest" ]]; then
export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.runfiles/MANIFEST" ]]; then
export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
export RUNFILES_DIR="$0.runfiles"
fi
fi
if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
"$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
else
echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
exit 1
fi
# --- end runfiles.bash initialization ---
# Make a temporary directory and move to it to do all packaging work
mkdir -p tmp
cd tmp
# Move all generated files to lib/google/protobuf
mkdir -p lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/any_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/api_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/descriptor_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/duration_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/empty_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/field_mask_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/source_context_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/struct_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/timestamp_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/type_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/wrappers_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf_java.jar)" lib/google
# Move all source files to the correct location
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf.rb)" lib/google
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/descriptor_dsl.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/message_exts.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/repeated_field.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/well_known_types.rb)" lib/google/protobuf
# Move gemspec file to current directory
cp "$(rlocation com_google_protobuf/ruby/google.protobuf.gemspec)" .
# Make all files global readable/writable/executable
chmod -R 777 ./
# Build gem
gem build google-protobuf.gemspec

@ -1,88 +0,0 @@
#!/bin/bash
# This file should be executed with ruby
set -ex
# --- begin runfiles.bash initialization ---
# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
set -euo pipefail
if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
if [[ -f "$0.runfiles_manifest" ]]; then
export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
elif [[ -f "$0.runfiles/MANIFEST" ]]; then
export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
export RUNFILES_DIR="$0.runfiles"
fi
fi
if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
"$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
else
echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
exit 1
fi
# --- end runfiles.bash initialization ---
# rvm use ruby-3.0
# Make a temporary directory and move to it to do all packaging work
mkdir -p tmp
cd tmp
# Move all generated files to lib/google/protobuf
mkdir -p lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/any_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/api_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/descriptor_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/duration_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/empty_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/field_mask_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/source_context_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/struct_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/timestamp_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/type_pb.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/src/google/protobuf/wrappers_pb.rb)" lib/google/protobuf
# Move all utf-8 files to ext/google/protobuf_c/third_party/utf8_range
UTF8_DIR=ext/google/protobuf_c/third_party/utf8_range
mkdir -p $UTF8_DIR
cp "$(rlocation utf8_range/LICENSE)" $UTF8_DIR/LICENSE
cp "$(rlocation utf8_range/naive.c)" $UTF8_DIR
cp "$(rlocation utf8_range/range2-neon.c)" $UTF8_DIR
cp "$(rlocation utf8_range/range2-sse.c)" $UTF8_DIR
cp "$(rlocation utf8_range/utf8_range.h)" $UTF8_DIR
# Move all source files to the correct location
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/convert.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/convert.h)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/defs.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/defs.h)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/extconf.rb)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/map.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/map.h)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/message.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/message.h)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/protobuf.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/protobuf.h)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/repeated_field.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/repeated_field.h)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/ruby-upb.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/ruby-upb.h)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/ext/google/protobuf_c/wrap_memcpy.c)" ext/google/protobuf_c
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf.rb)" lib/google
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/descriptor_dsl.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/message_exts.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/repeated_field.rb)" lib/google/protobuf
cp "$(rlocation com_google_protobuf/ruby/lib/google/protobuf/well_known_types.rb)" lib/google/protobuf
# Move gemspec file to current directory
cp "$(rlocation com_google_protobuf/ruby/google.protobuf.gemspec)" .
# Make all files global readable/writable/executable
chmod -R 777 ./
# Build gem
gem build google-protobuf.gemspec

@ -1424,8 +1424,6 @@ bool GetBootstrapBasename(const Options& options, absl::string_view basename,
"net/proto2/compiler/proto/plugin"},
{"net/proto2/compiler/proto/profile",
"net/proto2/compiler/proto/profile_bootstrap"},
{"third_party/protobuf/extension_declaration",
"third_party/protobuf/extension_declaration_bootstrap"},
};
auto iter = bootstrap_mapping->find(basename);
if (iter == bootstrap_mapping->end()) {

@ -208,10 +208,6 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
// Owner: mordberg@
#define PROTOBUF_FUTURE_MAP_PAIR_UPGRADE 1
// Used to remove the RTTI checks for `DefaultFieldComparator`.
// Owner: kfm@
#define PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR 1
// Used to remove the manipulation of cleared elements in RepeatedPtrField.
// Owner: mkruskal@
#define PROTOBUF_FUTURE_REMOVE_CLEARED_API 1

@ -118,7 +118,6 @@
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
#undef PROTOBUF_FUTURE_BREAKING_CHANGES
#undef PROTOBUF_FUTURE_MAP_PAIR_UPGRADE
#undef PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR
#undef PROTOBUF_FUTURE_REMOVE_CLEARED_API
#endif

@ -1398,7 +1398,7 @@ TEST(RepeatedPtrField, ClearedElements) {
EXPECT_EQ(field.ClearedCount(), 1);
EXPECT_EQ(field.Add(), original);
EXPECT_EQ(field.ClearedCount(), 0);
PROTOBUF_IGNORE_DEPRECATION_STOP
PROTOBUF_IGNORE_DEPRECATION_STOP
#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API
}

@ -347,14 +347,12 @@ void MessageDifferencer::set_field_comparator(FieldComparator* comparator) {
field_comparator_.base = comparator;
}
#ifdef PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR
void MessageDifferencer::set_field_comparator(
DefaultFieldComparator* comparator) {
GOOGLE_ABSL_CHECK(comparator) << "Field comparator can't be NULL.";
field_comparator_kind_ = kFCDefault;
field_comparator_.default_impl = comparator;
}
#endif // PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR
void MessageDifferencer::set_message_field_comparison(
MessageFieldComparison comparison) {

@ -553,9 +553,7 @@ class PROTOBUF_EXPORT MessageDifferencer {
// Note that this method must be called before Compare for the comparator to
// be used.
void set_field_comparator(FieldComparator* comparator);
#ifdef PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR
void set_field_comparator(DefaultFieldComparator* comparator);
#endif // PROTOBUF_FUTURE_REMOVE_DEFAULT_FIELD_COMPARATOR
// DEPRECATED. Pass a DefaultFieldComparator instance instead.
// Sets the fraction and margin for the float comparison of a given field.

Loading…
Cancel
Save