Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into unset-by-index
Browse files Browse the repository at this point in the history
  • Loading branch information
Leprechaunz committed Jan 29, 2023
2 parents b3f94ba + a185a6e commit 529050b
Show file tree
Hide file tree
Showing 462 changed files with 17,048 additions and 9,472 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
- uses: codespell-project/actions-codespell@master
with:
check_filenames: true
skip: ./.git,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal,./.github/workflows/codespell.yml
ignore_words_list: "alow,alse,ba,chec,cleare,copyable,cloneable,dedup,dur,errorprone,falsy,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',ro,te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,streem,sur,falsy"
skip: ./.git,./third_party,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal,./.github/workflows/codespell.yml
ignore_words_list: "alow,alse,atleast,ba,chec,cleare,copyable,cloneable,dedup,dur,errorprone,falsy,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',ro,te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,streem,sur,falsy"
67 changes: 67 additions & 0 deletions .github/workflows/ruby_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Ruby Install Tests

on:
push:
branches:
- main
- '[0-9]+.x'
pull_request:
branches:
- main
- '[0-9]+.x'
workflow_dispatch:

jobs:
test_ruby_gems:
name: Test ruby gems
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
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
- name: Install bazel
run: |
sudo apt-get install -qy wget
mkdir $HOME/bin
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: |
sudo apt-get install -qy --no-install-recommends git
- name: Install ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build cruby gem
run: $HOME/bin/bazel build ruby:release
if: ${{ !contains(matrix.ruby, 'jruby') }}
- name: Install cruby gem
run: gem install bazel-bin/ruby/google-protobuf-*
if: ${{ !contains(matrix.ruby, 'jruby') }}
- name: Build jruby gem
run: $HOME/bin/bazel build ruby:jruby_release
if: ${{ contains(matrix.ruby, 'jruby') }}
- name: Install jruby gem
run: gem install bazel-bin/ruby/google-protobuf-*
if: ${{ contains(matrix.ruby, 'jruby') }}
- name: Test installation
run: |
bazel run //:protoc -- --proto_path=$GITHUB_WORKSPACE/src --proto_path=$GITHUB_WORKSPACE/ruby/tests --proto_path=$GITHUB_WORKSPACE/ruby --ruby_out=$GITHUB_WORKSPACE/ruby tests/test_import_proto2.proto
bazel run //:protoc -- --proto_path=$GITHUB_WORKSPACE/src --proto_path=$GITHUB_WORKSPACE/ruby/tests --proto_path=$GITHUB_WORKSPACE/ruby --ruby_out=$GITHUB_WORKSPACE/ruby tests/basic_test.proto
ruby ruby/tests/basic.rb
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
[submodule "third_party/abseil-cpp"]
path = third_party/abseil-cpp
url = https://github.com/abseil/abseil-cpp.git
branch = lts_2022_06_23
branch = lts_2023_01_24
[submodule "third_party/jsoncpp"]
path = third_party/jsoncpp
url = https://github.com/open-source-parsers/jsoncpp.git
[submodule "third_party/utf8_range"]
path = third_party/utf8_range
url = https://github.com/protocolbuffers/utf8_range.git
10 changes: 2 additions & 8 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* cpp_generated_lib_linked support is removed in protoc
* Reduced .pb.o object file size slightly by explicitly instantiating
InternalMetadata templates in the runtime.
* Add C++20 keywords guarded by PROTOBUF_FUTURE_CPP20_KEYWORDS
* Breaking change: Add C++20 reserved keywords.
* Fixed crash in ThreadLocalStorage for pre-C++17 compilers on 32-bit ARM.
* Clarified that JSON API non-OK statuses are not a stable API.
* Added a default implementation of MessageDifferencer::Reporter methods.
Expand All @@ -24,7 +24,7 @@
* Undefine the macro `linux` when compiling protobuf
* Reduce memory consumption of MessageSet parsing.
* Save code space by avoiding inlining of large-in-aggregate code-space MessageLite::~MessageLite destructor.
* Breaking change: delete Arena::Init
* Breaking change: Delete Arena::Init
* Make a PROTOBUF_POISON/UNPOISON to reduce noise in the source
* Put alignment functions in "arena_align.h"
* Split off `cleanup` arena functions into "arena_cleanup.h"
Expand Down Expand Up @@ -58,17 +58,11 @@
* Fixed Bug in proto3 java lite repeated enum fields. Failed to call copyOnWrite before modifying previously built message. Causes modification to already "built" messages that should be immutable.
* Fix Java reflection serialization of empty packed fields.
* Refactoring java full runtime to reuse sub-message builders and prepare to migrate parsing logic from parse constructor to builder.
* Fix TextFormat parser to build up recurring (but supposedly not repeated) sub-messages directly from text rather than building a new sub-message and merging the fully formed message into the existing field.
* Make message-type extensions merge from wire-format instead of building up instances and merging afterwards. This has much better performance.
* Change the Lite runtime to prefer merging from the wireformat into mutable messages rather than building up a new immutable object before merging. This way results in fewer allocations and copy operations.
* Move proto wireformat parsing functionality from the private "parsing constructor" to the Builder class.
* Refactoring java full runtime to reuse sub-message builders and prepare to migrate parsing logic from parse constructor to builder.
* Move proto wireformat parsing functionality from the private "parsing constructor" to the Builder class.
* Change the Lite runtime to prefer merging from the wireformat into mutable messages rather than building up a new immutable object before merging. This way results in fewer allocations and copy operations.
* Make message-type extensions merge from wire-format instead of building up instances and merging afterwards. This has much better performance.
* Fix TextFormat parser to build up recurring (but supposedly not repeated) sub-messages directly from text rather than building a new sub-message and merging the fully formed message into the existing field.
* Fix bug in nested builder caching logic where cleared sub-field builders would remain dirty after a clear and build in a parent layer. https://github.com/protocolbuffers/protobuf/issues/10624
* Performance test for TextFormat to verify fix for https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-h4h5-3hr4-j3g2

# Python
* Changes ordering of printed fields in .pyi files from lexicographic to the same ordering found in the proto descriptor.
Expand Down
29 changes: 8 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,6 @@ if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE)
get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY)
endif()

# Add C++14 flags
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CYGWIN)
string(REGEX_MATCH "-std=gnu\\+\\+([0-9]+)" _protobuf_CXX_STD "${CMAKE_CXX_FLAGS}")
endif()
if(NOT _protobuf_CXX_STD)
set(_protobuf_CXX_STD "${CMAKE_CXX_STANDARD}")
endif()
if(_protobuf_CXX_STD LESS "14")
message(FATAL_ERROR "Protocol Buffers requires at least C++14, but is configured for C++${_protobuf_CXX_STD}")
endif()
if(CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++${_protobuf_CXX_STD}")
else()
set(CMAKE_CXX_STANDARD ${_protobuf_CXX_STD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

# The Intel compiler isn't able to deal with noinline member functions of
# template classes defined in headers. As such it spams the output with
# warning #2196: routine is both "inline" and "noinline"
Expand Down Expand Up @@ -279,6 +258,9 @@ else (protobuf_BUILD_SHARED_LIBS)
endif()
endif (protobuf_BUILD_SHARED_LIBS)

# Export all symbols on Windows when building shared libraries
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

if (MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Build with multiple processes
Expand All @@ -289,6 +271,7 @@ if (MSVC)
# MSVC warning suppressions
add_compile_options(
/wd4065 # switch statement contains 'default' but no 'case' labels
/wd4146 # unary minus operator applied to unsigned type
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
/wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
Expand Down Expand Up @@ -340,6 +323,10 @@ endif (protobuf_UNICODE)
set(protobuf_ABSL_PROVIDER "module" CACHE STRING "Provider of absl library")
set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package")

if (protobuf_BUILD_TESTS)
include(${protobuf_SOURCE_DIR}/cmake/gtest.cmake)
endif (protobuf_BUILD_TESTS)

include(${protobuf_SOURCE_DIR}/cmake/abseil-cpp.cmake)

if (protobuf_BUILD_PROTOBUF_BINARIES)
Expand Down
8 changes: 8 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ http_archive(
load("//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps")
protobuf_deps()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
Expand Down
2 changes: 2 additions & 0 deletions build_defs/cpp_opts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
COPTS = select({
"//build_defs:config_msvc": [
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd4146", # unary minus operator applied to unsigned type
"/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
"/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
"/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
Expand All @@ -19,6 +20,7 @@ COPTS = select({
"-DHAVE_ZLIB",
"-Woverloaded-virtual",
"-Wno-sign-compare",
"-Wno-nonnull",
"-Werror",
],
})
Expand Down
11 changes: 11 additions & 0 deletions build_defs/upb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- upbc/bootstrap_compiler.bzl
+++ upbc/bootstrap_compiler.bzl
@@ -20,7 +20,7 @@ _upbc_base = "//upbc:protoc-gen-upb"

# begin:github_only
_is_google3 = False
-_extra_proto_path = "-Iexternal/com_google_protobuf/src "
+_extra_proto_path = "-Isrc "
# end:github_only

def _upbc(stage):
13 changes: 13 additions & 0 deletions cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ currently support CMake 3.5 and newer on both [Windows](#windows-builds) and
Most of the instructions will be given using CMake's command-line interface, but
the same actions can be performed using appropriate GUI tools.

# CMake Flags

## C++ Version

By default, CMake will use whatever C++ version is the system default. Since
protobuf requires C++14 or newer, sometimes you will need to explicitly override
this. For example, the following:

cmake . -DCMAKE_CXX_STANDARD=14
cmake --build

will build protobuf using C++14 (see [CXX_STANDARD](https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html#prop_tgt:CXX_STANDARD){.external} for all available options).

# Windows Builds

On Windows, you can build the project from *Command Prompt* and using an
Expand Down
24 changes: 19 additions & 5 deletions cmake/abseil-cpp.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Setup our dependency on Abseil.

set(ABSL_PROPAGATE_CXX_STD ON)
if(protobuf_BUILD_TESTS)
# Tell Abseil to build test-only helpers.
set(ABSL_BUILD_TEST_HELPERS ON)

# We depend on googletest too, so just tell Abseil to use the same one we've
# already setup.
set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
set(ABSL_FIND_GOOGLETEST OFF)
endif()

if(TARGET absl::strings)
# If Abseil is included already, skip including it.
Expand Down Expand Up @@ -33,11 +41,11 @@ if (BUILD_SHARED_LIBS AND MSVC)
# On MSVC Abseil is bundled into a single DLL.
set(protobuf_ABSL_USED_TARGETS abseil_dll)

# As a workaround for https://github.com/abseil/abseil-cpp/issues/1118,
# make sure ABSL_CONSUME_DLL gets set for all subsequent builds.
add_definitions(-DABSL_CONSUME_DLL)
set(protobuf_ABSL_USED_TEST_TARGETS abseil_test_dll)
else()
set(protobuf_ABSL_USED_TARGETS
absl::absl_check
absl::absl_log
absl::algorithm
absl::base
absl::bind_front
Expand All @@ -47,13 +55,16 @@ else()
absl::cord
absl::core_headers
absl::debugging
absl::die_if_null
absl::dynamic_annotations
absl::flags
absl::flat_hash_map
absl::flat_hash_set
absl::function_ref
absl::hash
absl::layout
absl::log_initialize
absl::log_severity
absl::memory
absl::node_hash_map
absl::node_hash_set
Expand All @@ -68,4 +79,7 @@ else()
absl::utility
absl::variant
)
endif ()
set(protobuf_ABSL_USED_TEST_TARGETS
absl::scoped_mock_log
)
endif ()
48 changes: 48 additions & 0 deletions cmake/gtest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF)

if (protobuf_USE_EXTERNAL_GTEST)
find_package(GTest REQUIRED)
else()
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt")
message(FATAL_ERROR
"Cannot find third_party/googletest directory that's needed to "
"build tests. If you use git, make sure you have cloned submodules:\n"
" git submodule update --init --recursive\n"
"If instead you want to skip tests, run cmake with:\n"
" cmake -Dprotobuf_BUILD_TESTS=OFF\n")
endif()

set(googlemock_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googlemock")
set(googletest_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googletest")
include_directories(
${googlemock_source_dir}
${googletest_source_dir}
${googletest_source_dir}/include
${googlemock_source_dir}/include
)

add_library(gmock ${protobuf_SHARED_OR_STATIC}
"${googlemock_source_dir}/src/gmock-all.cc"
"${googletest_source_dir}/src/gtest-all.cc"
)
if (protobuf_BUILD_SHARED_LIBS)
set_target_properties(gmock
PROPERTIES
COMPILE_DEFINITIONS
"GTEST_CREATE_SHARED_LIBRARY=1"
)
install(TARGETS gmock EXPORT protobuf-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc")
target_link_libraries(gmock_main gmock)

add_library(GTest::gmock ALIAS gmock)
add_library(GTest::gmock_main ALIAS gmock_main)
add_library(GTest::gtest ALIAS gmock)
add_library(GTest::gtest_main ALIAS gmock_main)
endif()
Loading

0 comments on commit 529050b

Please sign in to comment.