feat add protobuf for C++11
All checks were successful
linux-x64-gcc / linux-gcc (Release) (push) Successful in 47s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 10m42s

This commit is contained in:
tqcq 2024-03-13 18:11:02 +08:00
parent 4ea52bd2da
commit f8d2b051ee
753 changed files with 409279 additions and 2 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,351 @@
# Minimum CMake required
cmake_minimum_required(VERSION 3.5)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring...")
endif()
# CMake policies
cmake_policy(SET CMP0022 NEW)
# On MacOS use @rpath/ for target's install name prefix path
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif ()
# Clear VERSION variables when no VERSION is given to project()
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
# MSVC runtime library flags are selected by an abstraction.
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# Project
project(protobuf C CXX)
if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE)
if(CMAKE_PROJECT_NAME STREQUAL "protobuf")
get_filename_component(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
endif()
get_filename_component(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
get_filename_component(PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY)
endif()
# Add c++11 flags
if (CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
else()
set(CMAKE_CXX_STANDARD 11)
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"
# This silences that warning.
if (CMAKE_CXX_COMPILER_ID MATCHES Intel)
string(APPEND CMAKE_CXX_FLAGS " -diag-disable=2196")
endif()
# Options
option(protobuf_INSTALL "Install protobuf binaries and files" ON)
if(WITH_PROTOC)
set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE)
endif()
option(protobuf_BUILD_TESTS "Build tests" OFF)
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON)
option(protobuf_BUILD_LIBPROTOC "Build libprotoc" OFF)
option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" OFF)
if (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
else (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
endif (BUILD_SHARED_LIBS)
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
include(CMakeDependentOption)
cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
"NOT protobuf_BUILD_SHARED_LIBS" OFF)
set(protobuf_WITH_ZLIB_DEFAULT ON)
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
set(protobuf_DEBUG_POSTFIX "d"
CACHE STRING "Default debug postfix")
mark_as_advanced(protobuf_DEBUG_POSTFIX)
# User options
include(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake)
# Overrides for option dependencies
if (protobuf_BUILD_PROTOC_BINARIES OR protobuf_BUILD_TESTS)
set(protobuf_BUILD_LIBPROTOC ON)
endif ()
# Path to main configure script
set(protobuf_CONFIGURE_SCRIPT "${protobuf_SOURCE_DIR}/configure.ac")
# Parse configure script
set(protobuf_AC_INIT_REGEX
"^AC_INIT\\(\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\]\\)$")
file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_AC_INIT_LINE
LIMIT_COUNT 1 REGEX "^AC_INIT")
# Description
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\1"
protobuf_DESCRIPTION "${protobuf_AC_INIT_LINE}")
# Version
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2"
protobuf_VERSION_STRING "${protobuf_AC_INIT_LINE}")
# Contact
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3"
protobuf_CONTACT "${protobuf_AC_INIT_LINE}")
# Parse version tweaks
set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+)([-]rc[-]|\\.)?([0-9]*)$")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1"
protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2"
protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3"
protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\5"
protobuf_VERSION_PRERELEASE "${protobuf_VERSION_STRING}")
message(STATUS "${protobuf_VERSION_PRERELEASE}")
# Package version
set(protobuf_VERSION
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
if(protobuf_VERSION_PRERELEASE)
set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}")
else()
set(protobuf_VERSION "${protobuf_VERSION}.0")
endif()
message(STATUS "${protobuf_VERSION}")
if(protobuf_VERBOSE)
message(STATUS "Configuration script parsing status [")
message(STATUS " Description : ${protobuf_DESCRIPTION}")
message(STATUS " Version : ${protobuf_VERSION} (${protobuf_VERSION_STRING})")
message(STATUS " Contact : ${protobuf_CONTACT}")
message(STATUS "]")
endif()
add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)
if (protobuf_DISABLE_RTTI)
add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
"{
global:
main;
local:
*;
};")
# CheckLinkerFlag module available in CMake >=3.18.
if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18)
include(CheckLinkerFlag)
check_linker_flag(CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map protobuf_HAVE_LD_VERSION_SCRIPT)
else()
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
check_cxx_source_compiles("
int main() {
return 0;
}
" protobuf_HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endif()
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
find_package(Threads REQUIRED)
set(_protobuf_FIND_ZLIB)
if (protobuf_WITH_ZLIB)
find_package(ZLIB)
if (ZLIB_FOUND)
set(HAVE_ZLIB 1)
# FindZLIB module define ZLIB_INCLUDE_DIRS variable
# Set ZLIB_INCLUDE_DIRECTORIES for compatible
set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
# Using imported target if exists
if (TARGET ZLIB::ZLIB)
set(ZLIB_LIBRARIES ZLIB::ZLIB)
set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
endif (TARGET ZLIB::ZLIB)
else (ZLIB_FOUND)
set(HAVE_ZLIB 0)
# Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
# complain when we use them later.
set(ZLIB_INCLUDE_DIRECTORIES)
set(ZLIB_LIBRARIES)
endif (ZLIB_FOUND)
endif (protobuf_WITH_ZLIB)
if (HAVE_ZLIB)
add_definitions(-DHAVE_ZLIB)
endif (HAVE_ZLIB)
# We need to link with libatomic on systems that do not have builtin atomics, or
# don't have builtin support for 8 byte atomics
set(protobuf_LINK_LIBATOMIC false)
if (NOT MSVC)
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
check_cxx_source_compiles("
#include <atomic>
int main() {
return std::atomic<int64_t>{};
}
" protobuf_HAVE_BUILTIN_ATOMICS)
if (NOT protobuf_HAVE_BUILTIN_ATOMICS)
set(protobuf_LINK_LIBATOMIC true)
endif (NOT protobuf_HAVE_BUILTIN_ATOMICS)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endif (NOT MSVC)
if (protobuf_BUILD_SHARED_LIBS)
set(protobuf_SHARED_OR_STATIC "SHARED")
else (protobuf_BUILD_SHARED_LIBS)
set(protobuf_SHARED_OR_STATIC "STATIC")
# The CMAKE_<LANG>_FLAGS(_<BUILD_TYPE>)? is meant to be user controlled.
# Prior to CMake 3.15, the MSVC runtime library was pushed into the same flags
# making programmatic control difficult. Prefer the functionality in newer
# CMake versions when available.
if(${CMAKE_VERSION} VERSION_GREATER 3.15 OR ${CMAKE_VERSION} VERSION_EQUAL 3.15)
if (protobuf_MSVC_STATIC_RUNTIME)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
endif()
else()
# In case we are building static libraries, link also the runtime library statically
# so that MSVCR*.DLL is not required at runtime.
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
if (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
endif()
endif (protobuf_BUILD_SHARED_LIBS)
if (MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Build with multiple processes
add_definitions(/MP)
endif()
# Set source file and execution character sets to UTF-8
add_definitions(/utf-8)
# MSVC warning suppressions
add_definitions(
/wd4065 # switch statement contains 'default' but no 'case' labels
/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
/wd4305 # 'identifier' : truncation from 'type1' to 'type2'
/wd4307 # 'operator' : integral constant overflow
/wd4309 # 'conversion' : truncation of constant value
/wd4334 # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
/wd4355 # 'this' : used in base member initializer list
/wd4506 # no definition for inline function 'function'
/wd4800 # 'type' : forcing value to bool 'true' or 'false' (performance warning)
/wd4996 # The compiler encountered a deprecated declaration.
)
# Allow big object
add_definitions(/bigobj)
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
string(REPLACE "." "," protobuf_RC_FILEVERSION "${protobuf_VERSION}")
configure_file(${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in extract_includes.bat)
# Suppress linker warnings about files with no symbols defined.
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Configure Resource Compiler
enable_language(RC)
# use English language (0x409) in resource compiler
set(rc_flags "/l0x409")
# fix rc.exe invocations because of usage of add_definitions()
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_flags} <DEFINES> /fo<OBJECT> <SOURCE>")
endif()
# Generate the version.rc file used elsewhere.
configure_file(${protobuf_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
set(protobuf_version_rc_file ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
# Add the "lib" prefix for generated .lib outputs.
set(LIB_PREFIX lib)
else (MSVC)
# No version.rc file.
set(protobuf_version_rc_file)
# When building with "make", "lib" prefix will be added automatically by
# the build tool.
set(LIB_PREFIX)
endif (MSVC)
include_directories(
${ZLIB_INCLUDE_DIRECTORIES}
${protobuf_BINARY_DIR}
${protobuf_SOURCE_DIR}/src)
if (protobuf_UNICODE)
add_definitions(-DUNICODE -D_UNICODE)
endif (protobuf_UNICODE)
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake)
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf.cmake)
if (protobuf_BUILD_LIBPROTOC)
include(${protobuf_SOURCE_DIR}/cmake/libprotoc.cmake)
endif (protobuf_BUILD_LIBPROTOC)
if (protobuf_BUILD_PROTOC_BINARIES)
include(${protobuf_SOURCE_DIR}/cmake/protoc.cmake)
if (NOT DEFINED protobuf_PROTOC_EXE)
set(protobuf_PROTOC_EXE protoc)
endif (NOT DEFINED protobuf_PROTOC_EXE)
endif (protobuf_BUILD_PROTOC_BINARIES)
# Ensure we have a protoc executable if we need one
if (protobuf_BUILD_TESTS OR protobuf_BUILD_CONFORMANCE OR protobuf_BUILD_EXAMPLES)
if (NOT DEFINED protobuf_PROTOC_EXE)
find_program(protobuf_PROTOC_EXE protoc)
if (NOT protobuf_PROTOC_EXE)
message(FATAL "Build requires 'protoc' but binary not found and not building protoc.")
endif ()
endif ()
if(protobuf_VERBOSE)
message(STATUS "Using protoc : ${protobuf_PROTOC_EXE}")
endif(protobuf_VERBOSE)
endif ()
if (protobuf_BUILD_TESTS)
enable_testing()
include(${protobuf_SOURCE_DIR}/cmake/tests.cmake)
endif (protobuf_BUILD_TESTS)
if (protobuf_BUILD_CONFORMANCE)
include(${protobuf_SOURCE_DIR}/cmake/conformance.cmake)
endif (protobuf_BUILD_CONFORMANCE)
if (protobuf_INSTALL)
include(${protobuf_SOURCE_DIR}/cmake/install.cmake)
endif (protobuf_INSTALL)
if (protobuf_BUILD_EXAMPLES)
include(${protobuf_SOURCE_DIR}/cmake/examples.cmake)
endif (protobuf_BUILD_EXAMPLES)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring done")
endif(protobuf_VERBOSE)

View File

@ -0,0 +1,107 @@
This file contains a list of people who have made large contributions
to the public version of Protocol Buffers.
Original Protocol Buffers design and implementation:
Sanjay Ghemawat <sanjay@google.com>
Jeff Dean <jeff@google.com>
Daniel Dulitz <daniel@google.com>
Craig Silverstein
Paul Haahr <haahr@google.com>
Corey Anderson <corin@google.com>
(and many others)
Proto2 C++ and Java primary author:
Kenton Varda <kenton@google.com>
Proto2 Python primary authors:
Will Robinson <robinson@google.com>
Petar Petrov <petar@google.com>
Java Nano primary authors:
Brian Duff <bduff@google.com>
Tom Chao <chaot@google.com>
Max Cai <maxtroy@google.com>
Ulas Kirazci <ulas@google.com>
Large code contributions:
Jason Hsueh <jasonh@google.com>
Joseph Schorr <jschorr@google.com>
Wenbo Zhu <wenboz@google.com>
Large quantity of code reviews:
Scott Bruce <sbruce@google.com>
Frank Yellin
Neal Norwitz <nnorwitz@google.com>
Jeffrey Yasskin <jyasskin@google.com>
Ambrose Feinstein <ambrose@google.com>
Documentation:
Lisa Carey <lcarey@google.com>
Maven packaging:
Gregory Kick <gak@google.com>
Patch contributors:
Kevin Ko <kevin.s.ko@gmail.com>
* Small patch to handle trailing slashes in --proto_path flag.
Johan Euphrosine <proppy@aminche.com>
* Small patch to fix Python CallMethod().
Ulrich Kunitz <kune@deine-taler.de>
* Small optimizations to Python serialization.
Leandro Lucarella <llucax@gmail.com>
* VI syntax highlighting tweaks.
* Fix compiler to not make output executable.
Dilip Joseph <dilip.antony.joseph@gmail.com>
* Heuristic detection of sub-messages when printing unknown fields in
text format.
Brian Atkinson <nairb774@gmail.com>
* Added @Override annotation to generated Java code where appropriate.
Vincent Choinière <Choiniere.Vincent@hydro.qc.ca>
* Tru64 support.
Monty Taylor <monty.taylor@gmail.com>
* Solaris 10 + Sun Studio fixes.
Alek Storm <alek.storm@gmail.com>
* Slicing support for repeated scalar fields for the Python API.
Oleg Smolsky <oleg.smolsky@gmail.com>
* MS Visual Studio error format option.
* Detect unordered_map in stl_hash.m4.
Brian Olson <brianolson@google.com>
* gzip/zlib I/O support.
Michael Poole <mdpoole@troilus.org>
* Fixed warnings about generated constructors not explicitly initializing
all fields (only present with certain compiler settings).
* Added generation of field number constants.
Wink Saville <wink@google.com>
* Fixed initialization ordering problem in logging code.
Will Pierce <willp@nuclei.com>
* Small patch improving performance of in Python serialization.
Alexandre Vassalotti <alexandre@peadrop.com>
* Emacs mode for Protocol Buffers (editors/protobuf-mode.el).
Scott Stafford <scott.stafford@gmail.com>
* Added Swap(), SwapElements(), and RemoveLast() to Reflection interface.
Alexander Melnikov <alm@sibmail.ru>
* HPUX support.
Oliver Jowett <oliver.jowett@gmail.com>
* Detect whether zlib is new enough in configure script.
* Fixes for Solaris 10 32/64-bit confusion.
Evan Jones <evanj@mit.edu>
* Optimize Java serialization code when writing a small message to a stream.
* Optimize Java serialization of strings so that UTF-8 encoding happens only
once per string per serialization call.
* Clean up some Java warnings.
* Fix bug with permanent callbacks that delete themselves when run.
Michael Kucharski <m.kucharski@gmail.com>
* Added CodedInputStream.getTotalBytesRead().
Kacper Kowalik <xarthisius.kk@gmail.com>
* Fixed m4/acx_pthread.m4 problem for some Linux distributions.
William Orr <will@worrbase.com>
* Fixed detection of sched_yield on Solaris.
* Added atomicops for Solaris
Andrew Paprocki <andrew@ishiboo.com>
* Fixed minor IBM xlC compiler build issues
* Added atomicops for AIX (POWER)
Nipunn Koorapati <nipunn1313@gmail.com>
* Provide a type alias field ValueType on EnumTypeWrapper
* Match service argument names to abstract interface

View File

@ -0,0 +1,32 @@
Copyright 2008 Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Code generated by the Protocol Buffer compiler is owned by the owner
of the input file used when generating it. This code is not
standalone and requires a support library to be linked with it. This
support library is itself covered by the above license.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,84 @@
Protocol Buffers - Google's data interchange format
===================================================
Copyright 2008 Google Inc.
https://developers.google.com/protocol-buffers/
Overview
--------
Protocol Buffers (a.k.a., protobuf) are Google's language-neutral,
platform-neutral, extensible mechanism for serializing structured data. You
can find [protobuf's documentation on the Google Developers site](https://developers.google.com/protocol-buffers/).
This README file contains protobuf installation instructions. To install
protobuf, you need to install the protocol compiler (used to compile .proto
files) and the protobuf runtime for your chosen programming language.
Protocol Compiler Installation
------------------------------
The protocol compiler is written in C++. If you are using C++, please follow
the [C++ Installation Instructions](src/README.md) to install protoc along
with the C++ runtime.
For non-C++ users, the simplest way to install the protocol compiler is to
download a pre-built binary from our release page:
[https://github.com/protocolbuffers/protobuf/releases](https://github.com/protocolbuffers/protobuf/releases)
In the downloads section of each release, you can find pre-built binaries in
zip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary
as well as a set of standard .proto files distributed along with protobuf.
If you are looking for an old version that is not available in the release
page, check out the maven repo here:
[https://repo1.maven.org/maven2/com/google/protobuf/protoc/](https://repo1.maven.org/maven2/com/google/protobuf/protoc/)
These pre-built binaries are only provided for released versions. If you want
to use the github main version at HEAD, or you need to modify protobuf code,
or you are using C++, it's recommended to build your own protoc binary from
source.
If you would like to build protoc binary from source, see the [C++ Installation
Instructions](src/README.md).
Protobuf Runtime Installation
-----------------------------
Protobuf supports several different programming languages. For each programming
language, you can find instructions in the corresponding source directory about
how to install protobuf runtime for that specific language:
| Language | Source |
|--------------------------------------|-------------------------------------------------------------|
| C++ (include C++ runtime and protoc) | [src](src) |
| Java | [java](java) |
| Python | [python](python) |
| Objective-C | [objectivec](objectivec) |
| C# | [csharp](csharp) |
| Ruby | [ruby](ruby) |
| Go | [protocolbuffers/protobuf-go](https://github.com/protocolbuffers/protobuf-go)|
| PHP | [php](php) |
| Dart | [dart-lang/protobuf](https://github.com/dart-lang/protobuf) |
Quick Start
-----------
The best way to learn how to use protobuf is to follow the tutorials in our
developer guide:
https://developers.google.com/protocol-buffers/docs/tutorials
If you want to learn from code examples, take a look at the examples in the
[examples](examples) directory.
Documentation
-------------
The complete documentation for Protocol Buffers is available via the
web at:
https://developers.google.com/protocol-buffers/

View File

@ -0,0 +1,71 @@
workspace(name = "com_google_protobuf")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
local_repository(
name = "com_google_protobuf_examples",
path = "examples",
)
http_archive(
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
urls = [
"https://mirror.bazel.build/github.com/google/googletest/archive/release-1.10.0.tar.gz",
"https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
],
)
http_archive(
name = "com_github_google_benchmark",
sha256 = "2a778d821997df7d8646c9c59b8edb9a573a6e04c534c01892a40aa524a7b68c",
strip_prefix = "benchmark-bf585a2789e30585b4e3ce6baf11ef2750b54677",
urls = [
"https://github.com/google/benchmark/archive/bf585a2789e30585b4e3ce6baf11ef2750b54677.zip",
],
)
# Load common dependencies.
load("//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps")
protobuf_deps()
bind(
name = "python_headers",
actual = "//util/python:python_headers",
)
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
# For updating instructions, see:
# https://github.com/bazelbuild/rules_jvm_external#updating-maven_installjson
maven_install_json = "//:maven_install.json",
repositories = [
"https://repo1.maven.org/maven2",
"https://repo.maven.apache.org/maven2",
],
)
load("@maven//:defs.bzl", "pinned_maven_install")
pinned_maven_install()
# For `cc_proto_blacklist_test` and `build_test`.
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()
# For `kt_jvm_library`
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
kotlin_repositories()
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
upb_deps()

1258
3party/protobuf-3.21.12/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

271
3party/protobuf-3.21.12/ar-lib Executable file
View File

@ -0,0 +1,271 @@
#! /bin/sh
# Wrapper for Microsoft lib.exe
me=ar-lib
scriptversion=2019-07-04.01; # UTC
# Copyright (C) 2010-2021 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# func_error message
func_error ()
{
echo "$me: $1" 1>&2
exit 1
}
file_conv=
# func_file_conv build_file
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN* | MSYS*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv in
mingw)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin | msys)
file=`cygpath -m "$file" || echo "$file"`
;;
wine)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_at_file at_file operation archive
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
# for each of them.
# When interpreting the content of the @FILE, do NOT use func_file_conv,
# since the user would need to supply preconverted file names to
# binutils ar, at least for MinGW.
func_at_file ()
{
operation=$2
archive=$3
at_file_contents=`cat "$1"`
eval set x "$at_file_contents"
shift
for member
do
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
done
}
case $1 in
'')
func_error "no command. Try '$0 --help' for more information."
;;
-h | --h*)
cat <<EOF
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
Members may be specified in a file named with @FILE.
EOF
exit $?
;;
-v | --v*)
echo "$me, version $scriptversion"
exit $?
;;
esac
if test $# -lt 3; then
func_error "you must specify a program, an action and an archive"
fi
AR=$1
shift
while :
do
if test $# -lt 2; then
func_error "you must specify a program, an action and an archive"
fi
case $1 in
-lib | -LIB \
| -ltcg | -LTCG \
| -machine* | -MACHINE* \
| -subsystem* | -SUBSYSTEM* \
| -verbose | -VERBOSE \
| -wx* | -WX* )
AR="$AR $1"
shift
;;
*)
action=$1
shift
break
;;
esac
done
orig_archive=$1
shift
func_file_conv "$orig_archive"
archive=$file
# strip leading dash in $action
action=${action#-}
delete=
extract=
list=
quick=
replace=
index=
create=
while test -n "$action"
do
case $action in
d*) delete=yes ;;
x*) extract=yes ;;
t*) list=yes ;;
q*) quick=yes ;;
r*) replace=yes ;;
s*) index=yes ;;
S*) ;; # the index is always updated implicitly
c*) create=yes ;;
u*) ;; # TODO: don't ignore the update modifier
v*) ;; # TODO: don't ignore the verbose modifier
*)
func_error "unknown action specified"
;;
esac
action=${action#?}
done
case $delete$extract$list$quick$replace,$index in
yes,* | ,yes)
;;
yesyes*)
func_error "more than one action specified"
;;
*)
func_error "no action specified"
;;
esac
if test -n "$delete"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
for member
do
case $1 in
@*)
func_at_file "${1#@}" -REMOVE "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
;;
esac
done
elif test -n "$extract"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
if test $# -gt 0; then
for member
do
case $1 in
@*)
func_at_file "${1#@}" -EXTRACT "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
;;
esac
done
else
$AR -NOLOGO -LIST "$archive" | tr -d '\r' | sed -e 's/\\/\\\\/g' \
| while read member
do
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
done
fi
elif test -n "$quick$replace"; then
if test ! -f "$orig_archive"; then
if test -z "$create"; then
echo "$me: creating $orig_archive"
fi
orig_archive=
else
orig_archive=$archive
fi
for member
do
case $1 in
@*)
func_file_conv "${1#@}"
set x "$@" "@$file"
;;
*)
func_file_conv "$1"
set x "$@" "$file"
;;
esac
shift
shift
done
if test -n "$orig_archive"; then
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
else
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
fi
elif test -n "$list"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
$AR -NOLOGO -LIST "$archive" || exit $?
fi

View File

@ -0,0 +1,44 @@
#!/bin/sh
# Run this script to generate the configure script and other files that will
# be included in the distribution. These files are not checked in because they
# are automatically generated.
set -e
if [ ! -z "$@" ]; then
for argument in "$@"; do
case $argument in
# make curl silent
"-s")
curlopts="-s"
;;
esac
done
fi
# Check that we're being run from the right directory.
if test ! -f src/google/protobuf/stubs/common.h; then
cat >&2 << __EOF__
Could not find source code. Make sure you are running this script from the
root of the distribution tree.
__EOF__
exit 1
fi
set -ex
# The absence of a m4 directory in googletest causes autoreconf to fail when
# building under the CentOS docker image. It's a warning in regular build on
# Ubuntu/gLinux as well. (This is only needed if git submodules have been
# initialized, which is typically only needed for testing; see the installation
# instructions for details.)
if test -d third_party/googletest; then
mkdir -p third_party/googletest/m4
fi
# TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings.
autoreconf -f -i -Wall,no-obsolete
rm -rf autom4te.cache config.h.in~
exit 0

View File

@ -0,0 +1,664 @@
benchmarks_protoc_inputs_benchmark_wrapper = \
benchmarks.proto
benchmarks_protoc_inputs = \
datasets/google_message1/proto3/benchmark_message1_proto3.proto
benchmarks_protoc_inputs_proto2 = \
datasets/google_message1/proto2/benchmark_message1_proto2.proto \
datasets/google_message2/benchmark_message2.proto \
datasets/google_message3/benchmark_message3.proto \
datasets/google_message3/benchmark_message3_1.proto \
datasets/google_message3/benchmark_message3_2.proto \
datasets/google_message3/benchmark_message3_3.proto \
datasets/google_message3/benchmark_message3_4.proto \
datasets/google_message3/benchmark_message3_5.proto \
datasets/google_message3/benchmark_message3_6.proto \
datasets/google_message3/benchmark_message3_7.proto \
datasets/google_message3/benchmark_message3_8.proto \
datasets/google_message4/benchmark_message4.proto \
datasets/google_message4/benchmark_message4_1.proto \
datasets/google_message4/benchmark_message4_2.proto \
datasets/google_message4/benchmark_message4_3.proto
make_tmp_dir:
mkdir -p 'tmp/java/src/main/java'
touch make_tmp_dir
# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
# relative to srcdir, which may not be the same as the current directory when
# building out-of-tree.
protoc_middleman: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper)
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd/cpp --java_out=$$oldpwd/tmp/java/src/main/java --python_out=$$oldpwd/tmp $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) )
touch protoc_middleman
protoc_middleman2: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs_proto2) $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd/cpp --java_out=$$oldpwd/tmp/java/src/main/java --python_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2) )
touch protoc_middleman2
all_data = $$(find $$(cd $(srcdir) && pwd) -type f -name "dataset.*.pb" -not -path "$$(cd $(srcdir) && pwd)/tmp/*")
############# CPP RULES ##############
benchmarks_protoc_outputs = \
cpp/benchmarks.pb.cc \
cpp/datasets/google_message1/proto3/benchmark_message1_proto3.pb.cc
benchmarks_protoc_outputs_header = \
cpp/benchmarks.pb.h \
cpp/datasets/google_message1/proto3/benchmark_message1_proto3.pb.h
benchmarks_protoc_outputs_proto2_header = \
cpp/datasets/google_message1/proto2/benchmark_message1_proto2.pb.h \
cpp/datasets/google_message2/benchmark_message2.pb.h \
cpp/datasets/google_message3/benchmark_message3.pb.h \
cpp/datasets/google_message3/benchmark_message3_1.pb.h \
cpp/datasets/google_message3/benchmark_message3_2.pb.h \
cpp/datasets/google_message3/benchmark_message3_3.pb.h \
cpp/datasets/google_message3/benchmark_message3_4.pb.h \
cpp/datasets/google_message3/benchmark_message3_5.pb.h \
cpp/datasets/google_message3/benchmark_message3_6.pb.h \
cpp/datasets/google_message3/benchmark_message3_7.pb.h \
cpp/datasets/google_message3/benchmark_message3_8.pb.h \
cpp/datasets/google_message4/benchmark_message4.pb.h \
cpp/datasets/google_message4/benchmark_message4_1.pb.h \
cpp/datasets/google_message4/benchmark_message4_2.pb.h \
cpp/datasets/google_message4/benchmark_message4_3.pb.h
benchmarks_protoc_outputs_proto2 = \
cpp/datasets/google_message1/proto2/benchmark_message1_proto2.pb.cc \
cpp/datasets/google_message2/benchmark_message2.pb.cc \
cpp/datasets/google_message3/benchmark_message3.pb.cc \
cpp/datasets/google_message3/benchmark_message3_1.pb.cc \
cpp/datasets/google_message3/benchmark_message3_2.pb.cc \
cpp/datasets/google_message3/benchmark_message3_3.pb.cc \
cpp/datasets/google_message3/benchmark_message3_4.pb.cc \
cpp/datasets/google_message3/benchmark_message3_5.pb.cc \
cpp/datasets/google_message3/benchmark_message3_6.pb.cc \
cpp/datasets/google_message3/benchmark_message3_7.pb.cc \
cpp/datasets/google_message3/benchmark_message3_8.pb.cc \
cpp/datasets/google_message4/benchmark_message4.pb.cc \
cpp/datasets/google_message4/benchmark_message4_1.pb.cc \
cpp/datasets/google_message4/benchmark_message4_2.pb.cc \
cpp/datasets/google_message4/benchmark_message4_3.pb.cc
$(benchmarks_protoc_outputs): protoc_middleman
$(benchmarks_protoc_outputs_header): protoc_middleman
$(benchmarks_protoc_outputs_proto2): protoc_middleman2
$(benchmarks_protoc_outputs_proto2_header): protoc_middleman2
initialize_submodule:
oldpwd=`pwd`
cd $(top_srcdir) && git submodule update --init -r third_party/benchmark && cd third_party/benchmark \
&& cmake -DCMAKE_BUILD_TYPE=Release && make
cd $$oldpwd
touch initialize_submodule
$(top_srcdir)/third_party/benchmark/src/libbenchmark.a: initialize_submodule
AM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
bin_PROGRAMS = cpp-benchmark
cpp_benchmark_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
cpp_benchmark_SOURCES = cpp/cpp_benchmark.cc
cpp_benchmark_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(top_srcdir)/third_party/benchmark/include
# Explicit deps because BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_cpp" could fail if parallel enough.
# See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually
cpp/cpp_benchmark-cpp_benchmark.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
cpp/benchmark-cpp_benchmark.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
nodist_cpp_benchmark_SOURCES = \
$(benchmarks_protoc_outputs) \
$(benchmarks_protoc_outputs_proto2) \
$(benchmarks_protoc_outputs_proto2_header) \
$(benchmarks_protoc_outputs_header)
cpp: protoc_middleman protoc_middleman2 cpp-benchmark initialize_submodule
./cpp-benchmark $(all_data)
############ CPP RULES END ############
############# JAVA RULES ##############
java_benchmark_testing_files = \
java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java
javac_middleman: $(java_benchmark_testing_files) protoc_middleman protoc_middleman2
cp -r $(srcdir)/java tmp
mkdir -p tmp/java/lib
cp $(top_srcdir)/java/core/target/*.jar tmp/java/lib/protobuf-java.jar
cd tmp/java && mvn clean compile assembly:single -Dprotobuf.version=$(PACKAGE_VERSION) && cd ../..
@touch javac_middleman
java-benchmark: javac_middleman
@echo "Writing shortcut script java-benchmark..."
@echo '#! /bin/bash' > java-benchmark
@echo 'all_data=""' >> java-benchmark
@echo 'conf=()' >> java-benchmark
@echo 'data_files=""' >> java-benchmark
@echo 'for arg in $$@; do if [[ $${arg:0:1} == "-" ]]; then conf+=($$arg); else data_files+="$$arg,"; fi; done' >> java-benchmark
@echo 'java -cp '\"tmp/java/target/*:$(top_srcdir)/java/core/target/*:$(top_srcdir)/java/util/target/*\"" \\" >>java-benchmark
@echo ' com.google.caliper.runner.CaliperMain com.google.protobuf.ProtoCaliperBenchmark -i runtime '"\\" >> java-benchmark
@echo ' -b serializeToByteArray,serializeToMemoryStream,deserializeFromByteArray,deserializeFromMemoryStream '"\\" >> java-benchmark
@echo ' -DdataFile=$${data_files:0:-1} $${conf[*]}' >> java-benchmark
@chmod +x java-benchmark
java: protoc_middleman protoc_middleman2 java-benchmark
./java-benchmark $(all_data)
############# JAVA RULES END ##############
############# PYTHON RULES ##############
python_add_init: protoc_middleman protoc_middleman2
all_file=`find tmp -type f -regex '.*\.py'` && \
for file in $${all_file[@]}; do \
path="$${file%/*}"; \
while true; do \
touch "$$path/__init__.py" && chmod +x "$$path/__init__.py"; \
if [[ $$path != *"/"* ]]; then break; fi; \
path=$${path%/*}; \
done \
done
python_cpp_pkg_flags = `pkg-config --cflags --libs python3`
lib_LTLIBRARIES = libbenchmark_messages.la
libbenchmark_messages_la_SOURCES = python/python_benchmark_messages.cc
libbenchmark_messages_la_LIBADD = $(top_srcdir)/src/.libs/libprotobuf.la
libbenchmark_messages_la_LDFLAGS = -version-info 1:0:0 -export-dynamic
libbenchmark_messages_la_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp $(python_cpp_pkg_flags)
libbenchmark_messages_la-python_benchmark_messages.$(OBJEXT): $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header) $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2)
nodist_libbenchmark_messages_la_SOURCES = \
$(benchmarks_protoc_outputs) \
$(benchmarks_protoc_outputs_proto2) \
$(benchmarks_protoc_outputs_proto2_header) \
$(benchmarks_protoc_outputs_header)
python-pure-python-benchmark: python_add_init
@echo "Writing shortcut script python-pure-python-benchmark..."
@echo '#! /bin/bash' > python-pure-python-benchmark
@echo export LD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-pure-python-benchmark
@echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-pure-python-benchmark
@echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'python\' >> python-pure-python-benchmark
@echo cp $(srcdir)/python/py_benchmark.py tmp >> python-pure-python-benchmark
@echo python3 tmp/py_benchmark.py '$$@' >> python-pure-python-benchmark
@chmod +x python-pure-python-benchmark
python-cpp-reflection-benchmark: python_add_init
@echo "Writing shortcut script python-cpp-reflection-benchmark..."
@echo '#! /bin/bash' > python-cpp-reflection-benchmark
@echo export LD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-reflection-benchmark
@echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-reflection-benchmark
@echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'cpp\' >> python-cpp-reflection-benchmark
@echo cp $(srcdir)/python/py_benchmark.py tmp >> python-cpp-reflection-benchmark
@echo python3 tmp/py_benchmark.py '$$@' >> python-cpp-reflection-benchmark
@chmod +x python-cpp-reflection-benchmark
python-cpp-generated-code-benchmark: python_add_init libbenchmark_messages.la
@echo "Writing shortcut script python-cpp-generated-code-benchmark..."
@echo '#! /bin/bash' > python-cpp-generated-code-benchmark
@echo export LD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-generated-code-benchmark
@echo export DYLD_LIBRARY_PATH=$(top_srcdir)/src/.libs >> python-cpp-generated-code-benchmark
@echo export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=\'cpp\' >> python-cpp-generated-code-benchmark
@echo cp $(srcdir)/python/py_benchmark.py tmp >> python-cpp-generated-code-benchmark
@echo python3 tmp/py_benchmark.py --cpp_generated '$$@' >> python-cpp-generated-code-benchmark
@chmod +x python-cpp-generated-code-benchmark
python-pure-python: python-pure-python-benchmark
./python-pure-python-benchmark $(all_data)
python-cpp-reflection: python-cpp-reflection-benchmark
./python-cpp-reflection-benchmark $(all_data)
python-cpp-generated-code: python-cpp-generated-code-benchmark
./python-cpp-generated-code-benchmark $(all_data)
############# PYTHON RULES END ##############
############# GO RULES BEGIN ##############
benchmarks_protoc_inputs_proto2_message1 = \
datasets/google_message1/proto2/benchmark_message1_proto2.proto
benchmarks_protoc_inputs_proto2_message2 = \
datasets/google_message2/benchmark_message2.proto
benchmarks_protoc_inputs_proto2_message3 = \
datasets/google_message3/benchmark_message3.proto \
datasets/google_message3/benchmark_message3_1.proto \
datasets/google_message3/benchmark_message3_2.proto \
datasets/google_message3/benchmark_message3_3.proto \
datasets/google_message3/benchmark_message3_4.proto \
datasets/google_message3/benchmark_message3_5.proto \
datasets/google_message3/benchmark_message3_6.proto \
datasets/google_message3/benchmark_message3_7.proto \
datasets/google_message3/benchmark_message3_8.proto
benchmarks_protoc_inputs_proto2_message4 = \
datasets/google_message4/benchmark_message4.proto \
datasets/google_message4/benchmark_message4_1.proto \
datasets/google_message4/benchmark_message4_2.proto \
datasets/google_message4/benchmark_message4_3.proto
go_protoc_middleman: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs) $(benchmarks_protoc_inputs_proto2_message1) $(benchmarks_protoc_inputs_proto2_message2) $(benchmarks_protoc_inputs_proto2_message3) $(benchmarks_protoc_inputs_proto2_message4) $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_benchmark_wrapper) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message1) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message2) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message3) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message4) )
touch go_protoc_middleman
go-benchmark: go_protoc_middleman
@echo "Writing shortcut script go-benchmark..."
@echo '#! /bin/bash' > go-benchmark
@echo 'cd $(srcdir)/go' >> go-benchmark
@echo 'all_data=""' >> go-benchmark
@echo 'conf=()' >> go-benchmark
@echo 'data_files=()' >> go-benchmark
@echo 'for arg in $$@; do if [[ $${arg:0:1} == "-" ]]; then conf+=($$arg); else data_files+=("$$arg"); fi; done' >> go-benchmark
@echo 'go test -bench=. $${conf[*]} -- $${data_files[*]}' >> go-benchmark
@echo 'cd ..' >> go-benchmark
@chmod +x go-benchmark
go: go_protoc_middleman go-benchmark
./go-benchmark $(all_data)
############# GO RULES END ##############
############# GOGO RULES BEGIN ############
cpp_no_group_benchmarks_protoc_outputs_header = \
gogo/cpp_no_group/benchmarks.pb.h \
gogo/cpp_no_group/datasets/google_message1/proto3/benchmark_message1_proto3.pb.h
cpp_no_group_benchmarks_protoc_outputs = \
gogo/cpp_no_group/benchmarks.pb.cc \
gogo/cpp_no_group/datasets/google_message1/proto3/benchmark_message1_proto3.pb.cc
cpp_no_group_benchmarks_protoc_outputs_proto2_header = \
gogo/cpp_no_group/datasets/google_message1/proto2/benchmark_message1_proto2.pb.h \
gogo/cpp_no_group/datasets/google_message2/benchmark_message2.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_1.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_2.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_3.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_4.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_5.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_6.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_7.pb.h \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_8.pb.h \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4.pb.h \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4_1.pb.h \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4_2.pb.h \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4_3.pb.h
cpp_no_group_benchmarks_protoc_outputs_proto2 = \
gogo/cpp_no_group/datasets/google_message1/proto2/benchmark_message1_proto2.pb.cc \
gogo/cpp_no_group/datasets/google_message2/benchmark_message2.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_1.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_2.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_3.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_4.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_5.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_6.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_7.pb.cc \
gogo/cpp_no_group/datasets/google_message3/benchmark_message3_8.pb.cc \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4.pb.cc \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4_1.pb.cc \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4_2.pb.cc \
gogo/cpp_no_group/datasets/google_message4/benchmark_message4_3.pb.cc
$(cpp_no_group_benchmarks_protoc_outputs): cpp_no_group_protoc_middleman
$(cpp_no_group_benchmarks_protoc_outputs_header): cpp_no_group_protoc_middleman
$(cpp_no_group_benchmarks_protoc_outputs_proto2): cpp_no_group_protoc_middleman
$(cpp_no_group_benchmarks_protoc_outputs_proto2_header): cpp_no_group_protoc_middleman
generate_cpp_no_group_benchmark_code:
cp $(srcdir)/cpp/cpp_benchmark.cc gogo/cpp_no_group/cpp_benchmark.cc
sed -i -e "s/\#include \"datasets/\#include \"gogo\/cpp_no_group\/datasets/g" gogo/cpp_no_group/cpp_benchmark.cc
sed -i -e "s/\#include \"benchmarks.pb.h/\#include \"gogo\/cpp_no_group\/benchmarks.pb.h/g" gogo/cpp_no_group/cpp_benchmark.cc
touch generate_cpp_no_group_benchmark_code
bin_PROGRAMS += cpp-no-group-benchmark
cpp_no_group_benchmark_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
cpp_no_group_benchmark_SOURCES = gogo/cpp_no_group/cpp_benchmark.cc
cpp_no_group_benchmark_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/gogo/cpp_no_group -I$(top_srcdir)/third_party/benchmark/include
# Explicit deps because BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_cpp" could fail if parallel enough.
# See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually
gogo/cpp_no_group/cpp_no_group_benchmark-cpp_benchmark.$(OBJEXT): $(cpp_no_group_benchmarks_protoc_outputs) $(cpp_no_group_benchmarks_protoc_outputs_proto2) $(cpp_no_group_benchmarks_protoc_outputs_header) \
$(cpp_no_group_benchmarks_protoc_outputs_proto2_header) $(top_srcdir)/third_party/benchmark/src/libbenchmark.a generate_cpp_no_group_benchmark_code
gogo/cpp_no_group/cpp_benchmark.cc: generate_cpp_no_group_benchmark_code
nodist_cpp_no_group_benchmark_SOURCES = \
$(cpp_no_group_benchmarks_protoc_outputs_proto2) \
$(cpp_no_group_benchmarks_protoc_outputs) \
$(cpp_no_group_benchmarks_protoc_outputs_header) \
$(cpp_no_group_benchmarks_protoc_outputs_proto2_header)
cpp_no_group: cpp_no_group_protoc_middleman generate_gogo_data cpp-no-group-benchmark
./cpp-no-group-benchmark $(gogo_data)
gogo_proto_middleman: protoc-gen-gogoproto
mkdir -p "tmp/gogo_proto"
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I$(srcdir) -I$(top_srcdir) --plugin=protoc-gen-gogoproto --gogoproto_out=$$oldpwd/tmp/gogo_proto $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) )
touch gogo_proto_middleman
gogo_data = $$(for data in $(all_data); do echo "tmp/gogo_data$${data\#$(srcdir)}"; done | xargs)
generate_gogo_data: protoc_middleman protoc_middleman2 gogo-data-scrubber
mkdir -p `dirname $(gogo_data)`
./gogo-data-scrubber $(all_data) $(gogo_data)
touch generate_gogo_data
make_tmp_dir_gogo:
mkdir -p tmp/go_no_group/benchmark_code
mkdir -p tmp/gogofast/benchmark_code
mkdir -p tmp/gogofaster/benchmark_code
mkdir -p tmp/gogoslick/benchmark_code
touch make_tmp_dir_gogo
go_no_group_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_benchmark_wrapper) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message1) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message2) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message3) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --go_out=$$oldpwd/tmp/go_no_group $(benchmarks_protoc_inputs_proto2_message4) )
touch go_no_group_protoc_middleman
cpp_no_group_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_benchmark_wrapper) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message1) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message2) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message3) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --cpp_out=$$oldpwd/gogo/cpp_no_group $(benchmarks_protoc_inputs_proto2_message4) )
touch cpp_no_group_protoc_middleman
gogofast_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_benchmark_wrapper) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message1) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message2) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message3) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofast_out=$$oldpwd/tmp/gogofast $(benchmarks_protoc_inputs_proto2_message4) )
touch gogofast_protoc_middleman
gogofaster_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_benchmark_wrapper) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message1) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message2) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message3) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogofaster_out=$$oldpwd/tmp/gogofaster $(benchmarks_protoc_inputs_proto2_message4) )
touch gogofaster_protoc_middleman
gogoslick_protoc_middleman: make_tmp_dir_gogo $(top_srcdir)/src/protoc$(EXEEXT) gogo_proto_middleman $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_benchmark_wrapper) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message1) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message2) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message3) )
oldpwd=`pwd` && ( cd $(srcdir)/tmp/gogo_proto && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$$oldpwd/$(top_srcdir)/src --gogoslick_out=$$oldpwd/tmp/gogoslick $(benchmarks_protoc_inputs_proto2_message4) )
touch gogoslick_protoc_middleman
generate-gogo-benchmark-code:
@echo '#! /bin/bash' > generate-gogo-benchmark-code
@echo 'cp $(srcdir)/go/go_benchmark_test.go tmp/$$1/benchmark_code/$$1_benchmark1_test.go' >> generate-gogo-benchmark-code
@echo 'sed -i -e "s/\.\.\/tmp/../g" tmp/$$1/benchmark_code/$$1_benchmark1_test.go' >> generate-gogo-benchmark-code
@echo 'sed -i -e "s/b\.Run(\"\(.*\)\"/b.Run(\"\1\_$$1\"/g" tmp/$$1/benchmark_code/$$1_benchmark1_test.go' >> generate-gogo-benchmark-code
@echo 'if [[ $$2 == 1 ]]; then sed -i -e "s/github\.com\/golang/github.com\/gogo/g" tmp/$$1/benchmark_code/$$1_benchmark1_test.go; fi ' >> generate-gogo-benchmark-code
@chmod +x generate-gogo-benchmark-code
generate_all_gogo_benchmark_code: generate-gogo-benchmark-code make_tmp_dir_gogo
./generate-gogo-benchmark-code go_no_group 0
./generate-gogo-benchmark-code gogofast 1
./generate-gogo-benchmark-code gogofaster 1
./generate-gogo-benchmark-code gogoslick 1
gogo-benchmark:
@echo "Writing shortcut script gogo-benchmark..."
@echo '#! /bin/bash' > gogo-benchmark
@echo 'cd tmp/$$1/benchmark_code' >> gogo-benchmark
@echo 'shift' >> gogo-benchmark
@echo 'all_data=""' >> gogo-benchmark
@echo 'for data_file in $$@; do all_data="$$all_data ../../../$$data_file"; done' >> gogo-benchmark
@echo 'go test -bench=. -- $$all_data' >> gogo-benchmark
@echo 'cd ../..' >> gogo-benchmark
@chmod +x gogo-benchmark
go_no_group: go_no_group_protoc_middleman generate_gogo_data generate_all_gogo_benchmark_code gogo-benchmark
./gogo-benchmark go_no_group $(gogo_data)
gogofast: gogofast_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code
./gogo-benchmark gogofast $(gogo_data)
gogofaster: gogofaster_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code
./gogo-benchmark gogofaster $(gogo_data)
gogoslick: gogoslick_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code
./gogo-benchmark gogoslick $(gogo_data)
############# GOGO RULES END ############
############ UTIL RULES BEGIN ############
bin_PROGRAMS += protoc-gen-gogoproto gogo-data-scrubber protoc-gen-proto2_to_proto3 proto3-data-stripper
protoc_gen_gogoproto_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/src/libprotoc.la
protoc_gen_gogoproto_SOURCES = util/protoc-gen-gogoproto.cc
protoc_gen_gogoproto_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util
gogo_data_scrubber_LDADD = $(top_srcdir)/src/libprotobuf.la
gogo_data_scrubber_SOURCES = util/gogo_data_scrubber.cc
gogo_data_scrubber_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util
util/gogo_data_scrubber-gogo_data_scrubber.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header)
nodist_gogo_data_scrubber_SOURCES = \
$(benchmarks_protoc_outputs) \
$(benchmarks_protoc_outputs_proto2) \
$(benchmarks_protoc_outputs_proto2_header) \
$(benchmarks_protoc_outputs_header)
protoc_gen_proto2_to_proto3_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/src/libprotoc.la
protoc_gen_proto2_to_proto3_SOURCES = util/protoc-gen-proto2_to_proto3.cc
protoc_gen_proto2_to_proto3_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util
proto3_data_stripper_LDADD = $(top_srcdir)/src/libprotobuf.la
proto3_data_stripper_SOURCES = util/proto3_data_stripper.cc
proto3_data_stripper_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)/cpp -I$(srcdir)/util
util/proto3_data_stripper-proto3_data_stripper.$(OBJEXT): $(benchmarks_protoc_outputs) $(benchmarks_protoc_outputs_proto2) $(benchmarks_protoc_outputs_header) $(benchmarks_protoc_outputs_proto2_header)
nodist_proto3_data_stripper_SOURCES = \
$(benchmarks_protoc_outputs) \
$(benchmarks_protoc_outputs_proto2) \
$(benchmarks_protoc_outputs_proto2_header) \
$(benchmarks_protoc_outputs_header)
############ UTIL RULES END ############
############ PROTO3 PREPARATION BEGIN #############
proto3_proto_middleman: protoc-gen-proto2_to_proto3
mkdir -p "tmp/proto3_proto"
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I$(srcdir) -I$(top_srcdir) --plugin=protoc-gen-proto2_to_proto3 --proto2_to_proto3_out=$$oldpwd/tmp/proto3_proto $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) )
touch proto3_proto_middleman
full_srcdir = $$(cd $(srcdir) && pwd)
proto3_data = $$(for data in $(all_data); do echo $(full_srcdir)"/tmp/proto3_data$${data\#$(full_srcdir)}"; done | xargs)
generate_proto3_data: protoc_middleman protoc_middleman2 proto3-data-stripper
mkdir -p `dirname $(proto3_data)`
./proto3-data-stripper $(all_data) $(proto3_data)
touch generate_proto3_data
############ PROTO3 PREPARATION END #############
############ PHP RULES BEGIN #################
proto3_middleman_php: proto3_proto_middleman
mkdir -p "tmp/php"
oldpwd=`pwd` && ( cd tmp/proto3_proto && $$oldpwd/../src/protoc$(EXEEXT) -I$(srcdir) -I$(top_srcdir) --php_out=$$oldpwd/tmp/php $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) )
touch proto3_middleman_php
php-benchmark: proto3_middleman_php generate_proto3_data
mkdir -p "tmp/php/Google/Protobuf/Benchmark" && cp php/PhpBenchmark.php "tmp/php/Google/Protobuf/Benchmark"
cp php/autoload.php "tmp/php"
@echo "Writing shortcut script php-benchmark..."
@echo '#! /bin/bash' > php-benchmark
@echo 'export PROTOBUF_PHP_SRCDIR="$$(cd $(top_srcdir) && pwd)/php/src"' >> php-benchmark
@echo 'cd tmp/php' >> php-benchmark
@echo 'export CURRENT_DIR=$$(pwd)' >> php-benchmark
@echo 'php -d auto_prepend_file="autoload.php" -d include_path="$$(pwd)" Google/Protobuf/Benchmark/PhpBenchmark.php $$@' >> php-benchmark
@echo 'cd ../..' >> php-benchmark
@chmod +x php-benchmark
php: php-benchmark proto3_middleman_php
./php-benchmark --behavior_prefix="php" $(proto3_data)
php_c_extension:
cd $(top_srcdir)/php/ext/google/protobuf && phpize && ./configure CFLAGS='-O3' && make -j8
php-c-benchmark: proto3_middleman_php generate_proto3_data php_c_extension php_c_extension
mkdir -p "tmp/php/Google/Protobuf/Benchmark" && cp php/PhpBenchmark.php "tmp/php/Google/Protobuf/Benchmark"
cp php/autoload.php "tmp/php"
@echo "Writing shortcut script php-c-benchmark..."
@echo '#! /bin/bash' > php-c-benchmark
@echo 'export PROTOBUF_PHP_SRCDIR="$$(cd $(top_srcdir) && pwd)/php/src"' >> php-c-benchmark
@echo 'export PROTOBUF_PHP_EXTDIR="$$PROTOBUF_PHP_SRCDIR/../ext/google/protobuf/modules"' >> php-c-benchmark
@echo 'cd tmp/php' >> php-c-benchmark
@echo 'export CURRENT_DIR=$$(pwd)' >> php-c-benchmark
@echo 'php -d auto_prepend_file="autoload.php" -d include_path="$$(pwd)" -d extension="$$PROTOBUF_PHP_EXTDIR/protobuf.so" Google/Protobuf/Benchmark/PhpBenchmark.php $$@' >> php-c-benchmark
@echo 'cd ../..' >> php-c-benchmark
@chmod +x php-c-benchmark
php_c: php-c-benchmark proto3_middleman_php
./php-c-benchmark --behavior_prefix="php_c" $(proto3_data)
############ PHP RULES END #################
############ protobuf.js RULE BEGIN #############
pbjs_preparation:
mkdir -p tmp/protobuf.js
cd tmp/protobuf.js && git clone https://github.com/dcodeIO/protobuf.js.git && \
cd protobuf.js && npm install && npm run build
cd tmp/protobuf.js && npm install benchmark
cp protobuf.js/* tmp/protobuf.js
cp js/benchmark_suite.js tmp/protobuf.js
touch pbjs_preparation
pbjs_middleman: pbjs_preparation
export OLDDIR=$$(pwd) && cd tmp/protobuf.js && node generate_pbjs_files.js --target static-module --include_path=$$OLDDIR -o generated_bundle_code.js $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2)
touch pbjs_middleman
pbjs-benchmark: pbjs_middleman
@echo '#! /bin/bash' > pbjs-benchmark
@echo 'cd tmp/protobuf.js' >> pbjs-benchmark
@echo 'sed -i "s/protobufjs/.\/protobuf.js/g" generated_bundle_code.js' >> pbjs-benchmark
@echo 'env NODE_PATH=".:./node_modules:$$NODE_PATH" node protobufjs_benchmark.js $$@' >> pbjs-benchmark
@chmod +x pbjs-benchmark
pbjs: pbjs-benchmark
./pbjs-benchmark $(all_data)
############ protobuf.js RULE END #############
############ JS RULE BEGIN #############
js_preparation:
mkdir -p tmp/js
oldpwd=$$(pwd) && cd $(top_srcdir)/js && npm install && npm test
cd tmp/js && npm install benchmark
cp js/* tmp/js
touch js_preparation
js_middleman: js_preparation
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --js_out=import_style=commonjs,binary:$$oldpwd/tmp/js $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2))
touch js_middleman
js-benchmark: js_middleman
@echo '#! /bin/bash' > js-benchmark
@echo 'export TOP_JS_SRCDIR=$$(cd $(top_srcdir)/js && pwd)' >> js-benchmark
@echo 'cd tmp/js' >> js-benchmark
@echo 'env NODE_PATH="$$TOP_JS_SRCDIR:.:./node_modules:$$NODE_PATH" node --max-old-space-size=4096 js_benchmark.js $$@' >> js-benchmark
@chmod +x js-benchmark
js: js-benchmark
./js-benchmark $(all_data)
############ JS RULE END #############
EXTRA_DIST = \
$(benchmarks_protoc_inputs_benchmark_wrapper) \
$(benchmarks_protoc_inputs) \
$(benchmarks_protoc_inputs_proto2) \
google_size.proto
MAINTAINERCLEANFILES = \
Makefile.in
CLEANFILES = \
$(benchmarks_protoc_outputs) \
$(benchmarks_protoc_outputs_header) \
$(benchmarks_protoc_outputs_proto2) \
$(benchmarks_protoc_outputs_proto2_header) \
initialize_submodule \
make_tmp_dir \
protoc_middleman \
protoc_middleman2 \
javac_middleman \
java-benchmark \
python_cpp_proto_library \
python-pure-python-benchmark \
python-cpp-reflection-benchmark \
python-cpp-generated-code-benchmark \
go-benchmark \
go_protoc_middleman \
make_tmp_dir_gogo \
gogo_proto_middleman \
generate_gogo_data \
go_no_group_protoc_middleman \
go_no_group \
go-no-group-benchmark \
$(cpp_no_group_benchmarks_protoc_outputs_header) \
$(cpp_no_group_benchmarks_protoc_outputs) \
$(cpp_no_group_benchmarks_protoc_outputs_proto2_header) \
$(cpp_no_group_benchmarks_protoc_outputs_proto2) \
generate_all_gogo_benchmark_code \
generate-gogo-benchmark-code \
cpp_no_group_protoc_middleman \
generate_cpp_no_group_benchmark_code \
generate_gogo_benchmark_code \
gogofast_protoc_middleman \
gogofast \
gogofaster_protoc_middleman \
gogofaster \
gogoslick_protoc_middleman \
gogoslick \
gogo-benchmark \
gogo/cpp_no_group/cpp_benchmark.* \
proto3_proto_middleman \
generate_proto3_data \
php-benchmark \
php-c-benchmark \
proto3_middleman_php \
pbjs_preparation \
pbjs_middleman \
pbjs-benchmark \
js_preparation \
js_middleman \
js-benchmark
clean-local:
-rm -rf tmp/*

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,239 @@
# Protocol Buffers Benchmarks
This directory contains benchmarking schemas and data sets that you
can use to test a variety of performance scenarios against your
protobuf language runtime. If you are looking for performance
numbers of officially supported languages, see [Protobuf Performance](
https://github.com/protocolbuffers/protobuf/blob/main/docs/performance.md).
## Prerequisite
First, you need to follow the instruction in the root directory's README to
build your language's protobuf, then:
### CPP
You need to install [cmake](https://cmake.org/) before building the benchmark.
We are using [google/benchmark](https://github.com/google/benchmark) as the
benchmark tool for testing cpp. This will be automatically made during build the
cpp benchmark.
The cpp protobuf performance can be improved by linking with
[TCMalloc](https://google.github.io/tcmalloc).
### Java
We're using maven to build the java benchmarks, which is the same as to build
the Java protobuf. There're no other tools need to install. We're using
[google/caliper](https://github.com/google/caliper) as benchmark tool, which
can be automatically included by maven.
### Python
We're using python C++ API for testing the generated
CPP proto version of python protobuf, which is also a prerequisite for Python
protobuf cpp implementation. You need to install the correct version of Python
C++ extension package before run generated CPP proto version of Python
protobuf's benchmark. e.g. under Ubuntu, you need to
```
$ sudo apt-get install python-dev
$ sudo apt-get install python3-dev
```
And you also need to make sure `pkg-config` is installed.
### Go
Go protobufs are maintained at [github.com/golang/protobuf](
http://github.com/golang/protobuf). If not done already, you need to install the
toolchain and the Go protoc-gen-go plugin for protoc.
To install protoc-gen-go, run:
```
$ go get -u github.com/golang/protobuf/protoc-gen-go
$ export PATH=$PATH:$(go env GOPATH)/bin
```
The first command installs `protoc-gen-go` into the `bin` directory in your local `GOPATH`.
The second command adds the `bin` directory to your `PATH` so that `protoc` can locate the plugin later.
### PHP
PHP benchmark's requirement is the same as PHP protobuf's requirements. The benchmark will automatically
include PHP protobuf's src and build the c extension if required.
### Node.js
Node.js benchmark need [node](https://nodejs.org/en/)(higher than V6) and [npm](https://www.npmjs.com/) package manager installed. This benchmark is using the [benchmark](https://www.npmjs.com/package/benchmark) framework to test, which needn't to manually install. And another prerequisite is [protobuf js](https://github.com/protocolbuffers/protobuf/tree/main/js), which needn't to manually install either
### C#
The C# benchmark code is built as part of the main Google.Protobuf
solution. It requires the .NET Core SDK, and depends on
[BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet), which
will be downloaded automatically.
## Run instructions
To run all the benchmark dataset:
### Java:
First build the Java binary in the usual way with Maven:
```
$ cd java
$ mvn install
```
Assuming that completes successfully,
```
$ cd ../benchmarks
$ make java
```
### CPP:
```
$ make cpp
```
For linking with tcmalloc:
```
$ env LD_PRELOAD={directory to libtcmalloc.so} make cpp
```
### Python:
We have three versions of python protobuf implementation: pure python, cpp
reflection and cpp generated code. To run these version benchmark, you need to:
#### Pure Python:
```
$ make python-pure-python
```
#### CPP reflection:
```
$ make python-cpp-reflection
```
#### CPP generated code:
```
$ make python-cpp-generated-code
```
### Go
```
$ make go
```
### PHP
We have two version of php protobuf implementation: pure php, php with c extension. To run these version benchmark, you need to:
#### Pure PHP
```
$ make php
```
#### PHP with c extension
```
$ make php_c
```
### Node.js
```
$ make js
```
To run a specific dataset or run with specific options:
### Java:
```
$ make java-benchmark
$ ./java-benchmark $(specific generated dataset file name) [$(caliper options)]
```
### CPP:
```
$ make cpp-benchmark
$ ./cpp-benchmark $(specific generated dataset file name) [$(benchmark options)]
```
### Python:
For Python benchmark we have `--json` for outputting the json result
#### Pure Python:
```
$ make python-pure-python-benchmark
$ ./python-pure-python-benchmark [--json] $(specific generated dataset file name)
```
#### CPP reflection:
```
$ make python-cpp-reflection-benchmark
$ ./python-cpp-reflection-benchmark [--json] $(specific generated dataset file name)
```
#### CPP generated code:
```
$ make python-cpp-generated-code-benchmark
$ ./python-cpp-generated-code-benchmark [--json] $(specific generated dataset file name)
```
### Go:
```
$ make go-benchmark
$ ./go-benchmark $(specific generated dataset file name) [go testing options]
```
### PHP
#### Pure PHP
```
$ make php-benchmark
$ ./php-benchmark $(specific generated dataset file name)
```
#### PHP with c extension
```
$ make php-c-benchmark
$ ./php-c-benchmark $(specific generated dataset file name)
```
### Node.js
```
$ make js-benchmark
$ ./js-benchmark $(specific generated dataset file name)
```
### C#
From `csharp/src/Google.Protobuf.Benchmarks`, run:
```
$ dotnet run -c Release
```
We intend to add support for this within the makefile in due course.
## Benchmark datasets
Each data set is in the format of benchmarks.proto:
1. name is the benchmark dataset's name.
2. message_name is the benchmark's message type full name (including package and message name)
3. payload is the list of raw data.
The schema for the datasets is described in `benchmarks.proto`.
Benchmark likely want to run several benchmarks against each data set (parse,
serialize, possibly JSON, possibly using different APIs, etc).
We would like to add more data sets. In general we will favor data sets
that make the overall suite diverse without being too large or having
too many similar tests. Ideally everyone can run through the entire
suite without the test run getting too long.

View File

@ -0,0 +1,63 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto3";
package benchmarks;
option java_package = "com.google.protobuf.benchmarks";
message BenchmarkDataset {
// Name of the benchmark dataset. This should be unique across all datasets.
// Should only contain word characters: [a-zA-Z0-9_]
string name = 1;
// Fully-qualified name of the protobuf message for this dataset.
// It will be one of the messages defined benchmark_messages_proto2.proto
// or benchmark_messages_proto3.proto.
//
// Implementations that do not support reflection can implement this with
// an explicit "if/else" chain that lists every known message defined
// in those files.
string message_name = 2;
// The payload(s) for this dataset. They should be parsed or serialized
// in sequence, in a loop, ie.
//
// while (!benchmarkDone) { // Benchmark runner decides when to exit.
// for (i = 0; i < benchmark.payload.length; i++) {
// parse(benchmark.payload[i])
// }
// }
//
// This is intended to let datasets include a variety of data to provide
// potentially more realistic results than just parsing the same message
// over and over. A single message parsed repeatedly could yield unusually
// good branch prediction performance.
repeated bytes payload = 3;
}

View File

@ -0,0 +1,254 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <fstream>
#include <iostream>
#include "benchmark/benchmark.h"
#include "benchmarks.pb.h"
#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h"
#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h"
#include "datasets/google_message2/benchmark_message2.pb.h"
#include "datasets/google_message3/benchmark_message3.pb.h"
#include "datasets/google_message4/benchmark_message4.pb.h"
#define PREFIX "dataset."
#define SUFFIX ".pb"
using benchmarks::BenchmarkDataset;
using google::protobuf::Arena;
using google::protobuf::Descriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::Message;
using google::protobuf::MessageFactory;
class Fixture : public benchmark::Fixture {
public:
Fixture(const BenchmarkDataset& dataset, const std::string& suffix) {
for (int i = 0; i < dataset.payload_size(); i++) {
payloads_.push_back(dataset.payload(i));
}
const Descriptor* d =
DescriptorPool::generated_pool()->FindMessageTypeByName(
dataset.message_name());
if (!d) {
std::cerr << "Couldn't find message named '" << dataset.message_name()
<< "\n";
}
prototype_ = MessageFactory::generated_factory()->GetPrototype(d);
SetName((dataset.name() + suffix).c_str());
}
protected:
std::vector<std::string> payloads_;
const Message* prototype_;
};
class WrappingCounter {
public:
WrappingCounter(size_t limit) : value_(0), limit_(limit) {}
size_t Next() {
size_t ret = value_;
if (++value_ == limit_) {
value_ = 0;
}
return ret;
}
private:
size_t value_;
size_t limit_;
};
template <class T>
class ParseNewFixture : public Fixture {
public:
ParseNewFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_parse_new") {}
virtual void BenchmarkCase(benchmark::State& state) {
WrappingCounter i(payloads_.size());
size_t total = 0;
while (state.KeepRunning()) {
T m;
const std::string& payload = payloads_[i.Next()];
total += payload.size();
m.ParseFromString(payload);
}
state.SetBytesProcessed(total);
}
};
template <class T>
class ParseNewArenaFixture : public Fixture {
public:
ParseNewArenaFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_parse_newarena") {}
virtual void BenchmarkCase(benchmark::State& state) {
WrappingCounter i(payloads_.size());
size_t total = 0;
Arena arena;
while (state.KeepRunning()) {
arena.Reset();
Message* m = Arena::CreateMessage<T>(&arena);
const std::string& payload = payloads_[i.Next()];
total += payload.size();
m->ParseFromString(payload);
}
state.SetBytesProcessed(total);
}
};
template <class T>
class ParseReuseFixture : public Fixture {
public:
ParseReuseFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_parse_reuse") {}
virtual void BenchmarkCase(benchmark::State& state) {
T m;
WrappingCounter i(payloads_.size());
size_t total = 0;
while (state.KeepRunning()) {
const std::string& payload = payloads_[i.Next()];
total += payload.size();
m.ParseFromString(payload);
}
state.SetBytesProcessed(total);
}
};
template <class T>
class SerializeFixture : public Fixture {
public:
SerializeFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_serialize") {
for (size_t i = 0; i < payloads_.size(); i++) {
message_.push_back(new T);
message_.back()->ParseFromString(payloads_[i]);
}
}
~SerializeFixture() {
for (size_t i = 0; i < message_.size(); i++) {
delete message_[i];
}
}
virtual void BenchmarkCase(benchmark::State& state) {
size_t total = 0;
std::string str;
WrappingCounter i(payloads_.size());
while (state.KeepRunning()) {
str.clear();
message_[i.Next()]->SerializeToString(&str);
total += str.size();
}
state.SetBytesProcessed(total);
}
private:
std::vector<T*> message_;
};
std::string ReadFile(const std::string& name) {
std::ifstream file(name.c_str());
GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" << name <<
"', please make sure you are running "
"this command from the benchmarks/ "
"directory.\n";
return std::string((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
}
template <class T>
void RegisterBenchmarksForType(const BenchmarkDataset& dataset) {
::benchmark::internal::RegisterBenchmarkInternal(
new ParseNewFixture<T>(dataset));
::benchmark::internal::RegisterBenchmarkInternal(
new ParseReuseFixture<T>(dataset));
::benchmark::internal::RegisterBenchmarkInternal(
new ParseNewArenaFixture<T>(dataset));
::benchmark::internal::RegisterBenchmarkInternal(
new SerializeFixture<T>(dataset));
}
void RegisterBenchmarks(const std::string& dataset_bytes) {
BenchmarkDataset dataset;
GOOGLE_CHECK(dataset.ParseFromString(dataset_bytes));
if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") {
RegisterBenchmarksForType<benchmarks::proto3::GoogleMessage1>(dataset);
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") {
RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage1>(dataset);
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") {
RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage2>(dataset);
} else if (dataset.message_name() ==
"benchmarks.google_message3.GoogleMessage3") {
RegisterBenchmarksForType
<benchmarks::google_message3::GoogleMessage3>(dataset);
} else if (dataset.message_name() ==
"benchmarks.google_message4.GoogleMessage4") {
RegisterBenchmarksForType
<benchmarks::google_message4::GoogleMessage4>(dataset);
} else {
std::cerr << "Unknown message type: " << dataset.message_name();
exit(1);
}
}
int main(int argc, char *argv[]) {
::benchmark::Initialize(&argc, argv);
if (argc == 1) {
std::cerr << "Usage: ./cpp-benchmark <input data>" << std::endl;
std::cerr << "input data is in the format of \"benchmarks.proto\""
<< std::endl;
return 1;
} else {
for (int i = 1; i < argc; i++) {
RegisterBenchmarks(ReadFile(argv[i]));
}
}
::benchmark::RunSpecifiedBenchmarks();
}

View File

@ -0,0 +1,108 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Benchmark messages for proto2.
syntax = "proto2";
package benchmarks.proto2;
option java_package = "com.google.protobuf.benchmarks";
// This is the default, but we specify it here explicitly.
option optimize_for = SPEED;
option cc_enable_arenas = true;
message GoogleMessage1 {
required string field1 = 1;
optional string field9 = 9;
optional string field18 = 18;
optional bool field80 = 80 [default = false];
optional bool field81 = 81 [default = true];
required int32 field2 = 2;
required int32 field3 = 3;
optional int32 field280 = 280;
optional int32 field6 = 6 [default = 0];
optional int64 field22 = 22;
optional string field4 = 4;
repeated fixed64 field5 = 5;
optional bool field59 = 59 [default = false];
optional string field7 = 7;
optional int32 field16 = 16;
optional int32 field130 = 130 [default = 0];
optional bool field12 = 12 [default = true];
optional bool field17 = 17 [default = true];
optional bool field13 = 13 [default = true];
optional bool field14 = 14 [default = true];
optional int32 field104 = 104 [default = 0];
optional int32 field100 = 100 [default = 0];
optional int32 field101 = 101 [default = 0];
optional string field102 = 102;
optional string field103 = 103;
optional int32 field29 = 29 [default = 0];
optional bool field30 = 30 [default = false];
optional int32 field60 = 60 [default = -1];
optional int32 field271 = 271 [default = -1];
optional int32 field272 = 272 [default = -1];
optional int32 field150 = 150;
optional int32 field23 = 23 [default = 0];
optional bool field24 = 24 [default = false];
optional int32 field25 = 25 [default = 0];
optional GoogleMessage1SubMessage field15 = 15;
optional bool field78 = 78;
optional int32 field67 = 67 [default = 0];
optional int32 field68 = 68;
optional int32 field128 = 128 [default = 0];
optional string field129 = 129 [default = "xxxxxxxxxxxxxxxxxxxxx"];
optional int32 field131 = 131 [default = 0];
}
message GoogleMessage1SubMessage {
optional int32 field1 = 1 [default = 0];
optional int32 field2 = 2 [default = 0];
optional int32 field3 = 3 [default = 0];
optional string field15 = 15;
optional bool field12 = 12 [default = true];
optional int64 field13 = 13;
optional int64 field14 = 14;
optional int32 field16 = 16;
optional int32 field19 = 19 [default = 2];
optional bool field20 = 20 [default = true];
optional bool field28 = 28 [default = true];
optional fixed64 field21 = 21;
optional int32 field22 = 22;
optional bool field23 = 23 [default = false];
optional bool field206 = 206 [default = false];
optional fixed32 field203 = 203;
optional int32 field204 = 204;
optional string field205 = 205;
optional uint64 field207 = 207;
optional uint64 field300 = 300;
}

View File

@ -0,0 +1,108 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Benchmark messages for proto3.
syntax = "proto3";
package benchmarks.proto3;
option java_package = "com.google.protobuf.benchmarks";
// This is the default, but we specify it here explicitly.
option optimize_for = SPEED;
option cc_enable_arenas = true;
message GoogleMessage1 {
string field1 = 1;
string field9 = 9;
string field18 = 18;
bool field80 = 80;
bool field81 = 81;
int32 field2 = 2;
int32 field3 = 3;
int32 field280 = 280;
int32 field6 = 6;
int64 field22 = 22;
string field4 = 4;
repeated fixed64 field5 = 5;
bool field59 = 59;
string field7 = 7;
int32 field16 = 16;
int32 field130 = 130;
bool field12 = 12;
bool field17 = 17;
bool field13 = 13;
bool field14 = 14;
int32 field104 = 104;
int32 field100 = 100;
int32 field101 = 101;
string field102 = 102;
string field103 = 103;
int32 field29 = 29;
bool field30 = 30;
int32 field60 = 60;
int32 field271 = 271;
int32 field272 = 272;
int32 field150 = 150;
int32 field23 = 23;
bool field24 = 24;
int32 field25 = 25;
GoogleMessage1SubMessage field15 = 15;
bool field78 = 78;
int32 field67 = 67;
int32 field68 = 68;
int32 field128 = 128;
string field129 = 129;
int32 field131 = 131;
}
message GoogleMessage1SubMessage {
int32 field1 = 1;
int32 field2 = 2;
int32 field3 = 3;
string field15 = 15;
bool field12 = 12;
int64 field13 = 13;
int64 field14 = 14;
int32 field16 = 16;
int32 field19 = 19;
bool field20 = 20;
bool field28 = 28;
fixed64 field21 = 21;
int32 field22 = 22;
bool field23 = 23;
bool field206 = 206;
fixed32 field203 = 203;
int32 field204 = 204;
string field205 = 205;
uint64 field207 = 207;
uint64 field300 = 300;
}

View File

@ -0,0 +1,108 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
// Benchmark messages for proto2.
syntax = "proto2";
package benchmarks.proto2;
option java_package = "com.google.protobuf.benchmarks";
// This is the default, but we specify it here explicitly.
option optimize_for = SPEED;
option cc_enable_arenas = true;
message GoogleMessage2 {
optional string field1 = 1;
optional int64 field3 = 3;
optional int64 field4 = 4;
optional int64 field30 = 30;
optional bool field75 = 75 [default = false];
optional string field6 = 6;
optional bytes field2 = 2;
optional int32 field21 = 21 [default = 0];
optional int32 field71 = 71;
optional float field25 = 25;
optional int32 field109 = 109 [default = 0];
optional int32 field210 = 210 [default = 0];
optional int32 field211 = 211 [default = 0];
optional int32 field212 = 212 [default = 0];
optional int32 field213 = 213 [default = 0];
optional int32 field216 = 216 [default = 0];
optional int32 field217 = 217 [default = 0];
optional int32 field218 = 218 [default = 0];
optional int32 field220 = 220 [default = 0];
optional int32 field221 = 221 [default = 0];
optional float field222 = 222 [default = 0.0];
optional int32 field63 = 63;
repeated group Group1 = 10 {
required float field11 = 11;
optional float field26 = 26;
optional string field12 = 12;
optional string field13 = 13;
repeated string field14 = 14;
required uint64 field15 = 15;
optional int32 field5 = 5;
optional string field27 = 27;
optional int32 field28 = 28;
optional string field29 = 29;
optional string field16 = 16;
repeated string field22 = 22;
repeated int32 field73 = 73;
optional int32 field20 = 20 [default = 0];
optional string field24 = 24;
optional GoogleMessage2GroupedMessage field31 = 31;
}
repeated string field128 = 128;
optional int64 field131 = 131;
repeated string field127 = 127;
optional int32 field129 = 129;
repeated int64 field130 = 130;
optional bool field205 = 205 [default = false];
optional bool field206 = 206 [default = false];
}
message GoogleMessage2GroupedMessage {
optional float field1 = 1;
optional float field2 = 2;
optional float field3 = 3 [default = 0.0];
optional bool field4 = 4;
optional bool field5 = 5;
optional bool field6 = 6 [default = true];
optional bool field7 = 7 [default = false];
optional float field8 = 8;
optional bool field9 = 9;
optional float field10 = 10;
optional int64 field11 = 11;
}

View File

@ -0,0 +1,566 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message3;
import "datasets/google_message3/benchmark_message3_1.proto";
import "datasets/google_message3/benchmark_message3_2.proto";
import "datasets/google_message3/benchmark_message3_3.proto";
import "datasets/google_message3/benchmark_message3_4.proto";
import "datasets/google_message3/benchmark_message3_5.proto";
import "datasets/google_message3/benchmark_message3_7.proto";
import "datasets/google_message3/benchmark_message3_8.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message GoogleMessage3 {
optional .benchmarks.google_message3.Message37487 field37519 = 2;
optional .benchmarks.google_message3.Message36876 field37520 = 3;
optional .benchmarks.google_message3.Message13062 field37521 = 4;
optional .benchmarks.google_message3.Message952 field37522 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field37523 = 6;
optional .benchmarks.google_message3.UnusedEmptyMessage field37524 = 7;
optional .benchmarks.google_message3.UnusedEmptyMessage field37525 = 8;
optional .benchmarks.google_message3.UnusedEmptyMessage field37526 = 9;
optional .benchmarks.google_message3.UnusedEmptyMessage field37527 = 10;
optional .benchmarks.google_message3.UnusedEmptyMessage field37528 = 11;
optional .benchmarks.google_message3.UnusedEmptyMessage field37529 = 12;
optional .benchmarks.google_message3.UnusedEmptyMessage field37530 = 13;
optional .benchmarks.google_message3.UnusedEmptyMessage field37531 = 14;
optional .benchmarks.google_message3.UnusedEmptyMessage field37532 = 15;
optional .benchmarks.google_message3.UnusedEmptyMessage field37533 = 16;
}
message Message1327 {
repeated .benchmarks.google_message3.UnusedEmptyMessage field1369 = 1;
repeated .benchmarks.google_message3.Message1328 field1370 = 3;
repeated .benchmarks.google_message3.UnusedEmptyMessage field1371 = 5;
repeated .benchmarks.google_message3.UnusedEmptyMessage field1372 = 6;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message1327 field1373 = 23104162;
}
}
message Message3672 {
optional .benchmarks.google_message3.Enum3476 field3727 = 1;
optional int32 field3728 = 11;
optional int32 field3729 = 2;
repeated group Message3673 = 3 {
required .benchmarks.google_message3.Enum3476 field3738 = 4;
required int32 field3739 = 5;
}
repeated group Message3674 = 6 {
required .benchmarks.google_message3.Enum3476 field3740 = 7;
required int32 field3741 = 8;
}
optional bool field3732 = 9;
optional int32 field3733 = 10;
optional .benchmarks.google_message3.Enum3476 field3734 = 20;
optional int32 field3735 = 21;
optional .benchmarks.google_message3.UnusedEmptyMessage field3736 = 50;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message3672 field3737 = 3144435;
}
}
message Message3804 {
required int64 field3818 = 1;
required bool field3819 = 2;
repeated .benchmarks.google_message3.Enum3805 field3820 = 4;
optional int32 field3821 = 5;
optional bool field3822 = 6;
optional int64 field3823 = 7;
optional .benchmarks.google_message3.Enum3783 field3824 = 8;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message3804 field3825 = 59241828;
}
}
message Message6849 {
repeated .benchmarks.google_message3.Message6850 field6910 = 1;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message6849 field6911 = 107558455;
}
}
message Message6866 {
repeated .benchmarks.google_message3.Message6863 field6973 = 1;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message6866 field6974 = 22259060;
}
}
message Message6870 {
repeated .benchmarks.google_message3.Message6871 field6991 = 1;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message6870 field6992 = 90034652;
}
}
message Message7651 {
optional string field7685 = 1;
optional int64 field7686 = 2;
optional int64 field7687 = 3;
optional int64 field7688 = 4;
optional int32 field7689 = 5;
optional int32 field7690 = 6;
optional int32 field7691 = 7;
optional int32 field7692 = 8;
optional int32 field7693 = 9;
optional int32 field7694 = 10;
optional int32 field7695 = 11;
optional int32 field7696 = 12;
optional int32 field7697 = 13;
optional int32 field7698 = 14;
optional int32 field7699 = 15;
optional int32 field7700 = 16;
optional int32 field7701 = 17;
optional int32 field7702 = 18;
optional bool field7703 = 19;
repeated int32 field7704 = 20;
repeated int32 field7705 = 21;
repeated string field7706 = 22;
repeated string field7707 = 23;
optional .benchmarks.google_message3.UnusedEmptyMessage field7708 = 24;
optional int32 field7709 = 25;
optional int32 field7710 = 26;
optional int32 field7711 = 27;
optional int32 field7712 = 43;
optional int32 field7713 = 28;
optional int32 field7714 = 29;
repeated .benchmarks.google_message3.Message7547 field7715 = 30;
repeated .benchmarks.google_message3.Message7547 field7716 = 31;
repeated .benchmarks.google_message3.UnusedEmptyMessage field7717 = 32;
repeated string field7718 = 33;
repeated string field7719 = 34;
repeated .benchmarks.google_message3.Message7648 field7720 = 35;
optional bool field7721 = 36;
optional bool field7722 = 37;
optional bool field7723 = 38;
optional bool field7724 = 39;
optional .benchmarks.google_message3.UnusedEmptyMessage field7725 = 40;
optional .benchmarks.google_message3.UnusedEnum field7726 = 41;
optional .benchmarks.google_message3.Enum7654 field7727 = 42;
optional string field7728 = 44;
optional .benchmarks.google_message3.UnusedEmptyMessage field7729 = 45;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message7651 field7730 = 55876009;
}
}
message Message7864 {
optional string field7866 = 1;
optional string field7867 = 2;
repeated .benchmarks.google_message3.Message7865 field7868 = 5;
repeated .benchmarks.google_message3.Message7865 field7869 = 6;
repeated .benchmarks.google_message3.Message7865 field7870 = 7;
repeated .benchmarks.google_message3.UnusedEmptyMessage field7871 = 8;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message7864 field7872 = 44542730;
}
}
message Message7929 {
optional int64 field7942 = 1;
optional int64 field7943 = 4;
optional int64 field7944 = 5;
optional int64 field7945 = 12;
optional int64 field7946 = 13;
optional int64 field7947 = 18;
optional int64 field7948 = 6;
optional int64 field7949 = 7;
repeated .benchmarks.google_message3.Message7919 field7950 = 8;
repeated .benchmarks.google_message3.UnusedEmptyMessage field7951 = 20;
repeated .benchmarks.google_message3.Message7920 field7952 = 14;
repeated .benchmarks.google_message3.Message7921 field7953 = 15;
repeated .benchmarks.google_message3.Message7928 field7954 = 17;
optional int64 field7955 = 19;
optional bool field7956 = 2;
optional int64 field7957 = 3;
optional int64 field7958 = 9;
repeated .benchmarks.google_message3.UnusedEmptyMessage field7959 = 10;
repeated bytes field7960 = 11;
optional int64 field7961 = 16;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message7929 field7962 = 53392238;
}
}
message Message8508 {
repeated .benchmarks.google_message3.Message8511 field8517 = 8;
repeated .benchmarks.google_message3.Message8512 field8518 = 9;
repeated .benchmarks.google_message3.Message8513 field8519 = 11;
optional bool field8520 = 13;
optional .benchmarks.google_message3.Message8514 field8521 = 14;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8522 = 15;
repeated .benchmarks.google_message3.Message8515 field8523 = 16;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8524 = 17;
optional int64 field8525 = 1;
optional float field8526 = 2;
optional int64 field8527 = 3;
optional int64 field8528 = 4;
optional int32 field8529 = 5;
optional bytes field8530 = 6;
repeated bytes field8531 = 7;
optional bool field8532 = 10;
optional bytes field8533 = 12;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message8508 field8534 = 3811804;
}
}
message Message9122 {
optional float field9132 = 1;
optional float field9133 = 2;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message9122 field9134 = 120398939;
}
}
message Message10177 {
repeated .benchmarks.google_message3.Message10155 field10270 = 1;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message10177 field10271 = 26801105;
}
}
message Message10278 {
repeated int32 field10286 = 1 [packed = true];
repeated int32 field10287 = 2 [packed = true];
optional int32 field10288 = 3;
extend .benchmarks.google_message3.Message10155 {
optional .benchmarks.google_message3.Message10278 field10289 = 29374161;
}
}
message Message10323 {
repeated .benchmarks.google_message3.Message10320 field10360 = 1;
extend .benchmarks.google_message3.Message10155 {
optional .benchmarks.google_message3.Message10323 field10361 = 27922524;
}
}
message Message10324 {
repeated .benchmarks.google_message3.Message10322 field10362 = 1;
optional .benchmarks.google_message3.Message10321 field10363 = 2;
extend .benchmarks.google_message3.Message10155 {
optional .benchmarks.google_message3.Message10324 field10364 = 27832297;
}
}
message Message11990 {
repeated .benchmarks.google_message3.Message11988 field12030 = 1;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message11990 field12031 = 21265426;
}
}
message Message12691 {
optional string field12713 = 1;
optional int32 field12714 = 2;
optional .benchmarks.google_message3.Message12668 field12715 = 3;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message12691 field12716 = 28426536;
}
}
message Message12870 {
required int32 field12879 = 1;
optional int32 field12880 = 7;
required int32 field12881 = 2;
optional uint64 field12882 = 3;
optional string field12883 = 2001;
optional fixed64 field12884 = 4;
repeated fixed64 field12885 = 14;
optional int32 field12886 = 9;
optional int64 field12887 = 18;
repeated .benchmarks.google_message3.Message12870 field12888 = 8;
optional int32 field12889 = 5;
optional uint64 field12890 = 6;
optional int32 field12891 = 10;
optional int32 field12892 = 11;
optional double field12893 = 12;
optional .benchmarks.google_message3.Message12825 field12894 = 13;
optional double field12895 = 15;
optional string field12896 = 16;
optional .benchmarks.google_message3.Enum12871 field12897 = 17;
optional int32 field12898 = 19;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message12870 field12899 = 5447656;
}
}
message Message13154 {
required float field13164 = 1;
required float field13165 = 2;
extend .benchmarks.google_message3.Message13145 {
optional .benchmarks.google_message3.Message13154 field13166 = 47301086;
}
}
message Message16507 {
optional bool field16510 = 3;
optional bool field16511 = 4;
optional bool field16512 = 14;
repeated string field16513 = 5;
repeated string field16514 = 6;
optional string field16515 = 8;
repeated int32 field16516 = 9;
repeated int32 field16517 = 10;
optional int32 field16518 = 7;
optional string field16519 = 15;
repeated string field16520 = 11;
repeated .benchmarks.google_message3.UnusedEmptyMessage field16521 = 27;
repeated .benchmarks.google_message3.UnusedEmptyMessage field16522 = 22;
repeated .benchmarks.google_message3.UnusedEmptyMessage field16523 = 28;
optional string field16524 = 18;
optional int32 field16525 = 19;
optional int32 field16526 = 20;
optional .benchmarks.google_message3.UnusedEmptyMessage field16527 = 23;
optional bool field16528 = 24;
repeated string field16529 = 25;
optional double field16530 = 26;
optional .benchmarks.google_message3.Message16478 field16531 = 30;
optional bool field16532 = 31;
optional string field16533 = 32;
optional bool field16534 = 33;
optional bool field16535 = 35;
optional bool field16536 = 36;
optional bool field16537 = 37;
optional bool field16538 = 38;
optional bool field16539 = 39;
optional bool field16540 = 40;
repeated string field16541 = 41;
extensions 21 to 21;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message16507 field16542 = 5569941;
}
}
message Message16564 {
repeated .benchmarks.google_message3.Message16552 field16568 = 1;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message16564 field16569 = 25830030;
}
}
message Message16661 {
repeated .benchmarks.google_message3.Message16660 field16671 = 1;
repeated uint64 field16672 = 2;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message16661 field16673 = 31274398;
}
}
message Message16746 {
repeated .benchmarks.google_message3.Message16727 field16806 = 1;
optional bool field16807 = 2;
optional bool field16808 = 3;
repeated .benchmarks.google_message3.Message16725 field16809 = 4;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message16746 field16810 = 28406765;
}
}
message Message17786 {
repeated group Message17787 = 1 {
required int32 field18177 = 2;
required int32 field18178 = 3;
optional .benchmarks.google_message3.Message17783 field18179 = 4;
optional .benchmarks.google_message3.UnusedEmptyMessage field18180 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field18181 = 6;
repeated .benchmarks.google_message3.UnusedEmptyMessage field18182 = 8;
optional .benchmarks.google_message3.UnusedEmptyMessage field18183 = 9;
optional .benchmarks.google_message3.Message17726 field18184 = 10;
optional .benchmarks.google_message3.UnusedEmptyMessage field18185 = 11;
optional .benchmarks.google_message3.Message16945 field18186 = 102;
optional .benchmarks.google_message3.UnusedEmptyMessage field18187 = 12;
optional .benchmarks.google_message3.UnusedEmptyMessage field18188 = 13;
optional .benchmarks.google_message3.UnusedEmptyMessage field18189 = 7;
optional .benchmarks.google_message3.UnusedEmptyMessage field18190 = 100;
optional .benchmarks.google_message3.UnusedEmptyMessage field18191 = 101;
optional .benchmarks.google_message3.UnusedEmptyMessage field18192 = 14;
optional .benchmarks.google_message3.UnusedEmptyMessage field18193 = 19;
optional .benchmarks.google_message3.UnusedEmptyMessage field18194 = 22;
optional .benchmarks.google_message3.UnusedEmptyMessage field18195 = 24;
optional .benchmarks.google_message3.Enum16925 field18196 = 21;
optional bool field18197 = 18;
repeated .benchmarks.google_message3.UnusedEnum field18198 = 23;
optional .benchmarks.google_message3.UnusedEmptyMessage field18199 = 15;
optional string field18200 = 16;
optional string field18201 = 17;
optional bool field18202 = 99;
}
repeated .benchmarks.google_message3.Message17782 field18175 = 20;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message17786 field18176 = 11823055;
}
}
message Message22857 {
repeated .benchmarks.google_message3.Message22853 field22874 = 1;
extend .benchmarks.google_message3.Message10155 {
optional .benchmarks.google_message3.Message22857 field22875 = 67799715;
}
}
message Message24404 {
repeated group Message24405 = 1 {
required int32 field24686 = 2;
required int32 field24687 = 3;
optional .benchmarks.google_message3.Message24317 field24688 = 4;
optional .benchmarks.google_message3.UnusedEmptyMessage field24689 = 5;
optional .benchmarks.google_message3.Message24376 field24690 = 6;
optional .benchmarks.google_message3.Message24345 field24691 = 7;
optional .benchmarks.google_message3.UnusedEmptyMessage field24692 = 8;
optional .benchmarks.google_message3.Message24379 field24693 = 9;
optional .benchmarks.google_message3.UnusedEmptyMessage field24694 = 10;
optional .benchmarks.google_message3.UnusedEmptyMessage field24695 = 11;
optional .benchmarks.google_message3.Message24391 field24696 = 12;
optional .benchmarks.google_message3.UnusedEmptyMessage field24697 = 13;
optional .benchmarks.google_message3.UnusedEmptyMessage field24698 = 14;
optional .benchmarks.google_message3.UnusedEmptyMessage field24699 = 22;
optional .benchmarks.google_message3.UnusedEmptyMessage field24700 = 23;
optional .benchmarks.google_message3.UnusedEmptyMessage field24701 = 25;
optional .benchmarks.google_message3.Enum16925 field24702 = 18;
optional float field24703 = 20;
optional bool field24704 = 19;
repeated .benchmarks.google_message3.Enum16891 field24705 = 24;
optional .benchmarks.google_message3.UnusedEmptyMessage field24706 = 15;
optional string field24707 = 16;
optional string field24708 = 17;
optional float field24709 = 21;
optional bool field24710 = 26;
optional .benchmarks.google_message3.UnusedEnum field24711 = 27;
optional bool field24712 = 28;
optional .benchmarks.google_message3.UnusedEnum field24713 = 29;
optional bool field24714 = 31;
optional bool field24715 = 99;
optional int64 field24716 = 32;
}
optional .benchmarks.google_message3.Message24403 field24684 = 30;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message24404 field24685 = 9129287;
}
}
message Message27300 {
repeated .benchmarks.google_message3.UnusedEmptyMessage field27302 = 1;
optional string field27303 = 2;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message27300 field27304 = 24956467;
}
}
message Message27453 {
optional string field27459 = 15;
repeated string field27460 = 1;
repeated float field27461 = 6;
repeated int32 field27462 = 27;
repeated int32 field27463 = 28;
repeated .benchmarks.google_message3.Message27454 field27464 = 24;
repeated string field27465 = 2;
repeated float field27466 = 7;
repeated string field27467 = 22;
repeated string field27468 = 23;
optional string field27469 = 26;
repeated .benchmarks.google_message3.Message27357 field27470 = 8;
optional .benchmarks.google_message3.Message27360 field27471 = 16;
optional string field27472 = 25;
optional string field27473 = 11;
optional bool field27474 = 13;
optional bool field27475 = 14;
optional bool field27476 = 17;
optional .benchmarks.google_message3.UnusedEmptyMessage field27477 = 12;
optional bool field27478 = 34268945;
optional bool field27479 = 20;
optional string field27480 = 21;
optional .benchmarks.google_message3.UnusedEmptyMessage field27481 = 10;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message27453 field27482 = 8086204;
}
}
extend .benchmarks.google_message3.Message16945 {
optional string field17026 = 472;
repeated string field17027 = 818;
optional .benchmarks.google_message3.Message0 field17031 = 215;
repeated .benchmarks.google_message3.Message0 field17032 = 292;
repeated .benchmarks.google_message3.Message0 field17038 = 234;
repeated .benchmarks.google_message3.Message0 field17039 = 235;
optional .benchmarks.google_message3.Message0 field17042 = 246;
optional string field17043 = 224;
optional string field17044 = 225;
repeated string field17048 = 63;
repeated string field17049 = 64;
repeated .benchmarks.google_message3.Message0 field17052 = 233;
repeated .benchmarks.google_message3.Message0 field17053 = 66;
repeated string field17056 = 275;
optional string field17057 = 226;
repeated .benchmarks.google_message3.Message0 field17060 = 27;
repeated string field17073 = 75;
repeated .benchmarks.google_message3.Message0 field17076 = 77;
repeated string field17078 = 296;
repeated .benchmarks.google_message3.Message0 field17082 = 160;
repeated .benchmarks.google_message3.Message0 field17091 = 585;
repeated .benchmarks.google_message3.Message0 field17098 = 987;
repeated .benchmarks.google_message3.Message0 field17101 = 157;
repeated string field17102 = 158;
repeated string field17107 = 166;
repeated string field17133 = 567;
repeated string field17134 = 572;
repeated string field17160 = 49;
repeated string field17168 = 32;
repeated string field17170 = 34;
repeated .benchmarks.google_message3.Message0 field17172 = 509;
repeated string field17174 = 39;
repeated .benchmarks.google_message3.Message0 field17175 = 40;
repeated .benchmarks.google_message3.Message0 field17178 = 511;
repeated .benchmarks.google_message3.Message0 field17185 = 50;
repeated int32 field17207 = 1081;
repeated .benchmarks.google_message3.Message0 field17238 = 184;
repeated .benchmarks.google_message3.Message0 field17289 = 177;
repeated .benchmarks.google_message3.Message0 field17290 = 178;
repeated .benchmarks.google_message3.Message0 field17296 = 474;
repeated string field17298 = 44;
repeated .benchmarks.google_message3.Message0 field17301 = 47;
optional .benchmarks.google_message3.Message0 field17412 = 21;
repeated .benchmarks.google_message3.Message0 field17438 = 132;
repeated .benchmarks.google_message3.Message0 field17458 = 512;
repeated string field17460 = 560;
repeated string field17466 = 552;
repeated .benchmarks.google_message3.Message0 field17617 = 1080;
repeated int32 field17618 = 1084;
}

View File

@ -0,0 +1,528 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message3;
import "datasets/google_message3/benchmark_message3_3.proto";
import "datasets/google_message3/benchmark_message3_4.proto";
import "datasets/google_message3/benchmark_message3_5.proto";
import "datasets/google_message3/benchmark_message3_7.proto";
import "datasets/google_message3/benchmark_message3_8.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message22853 {
optional .benchmarks.google_message3.Enum22854 field22869 = 1;
repeated uint32 field22870 = 2 [packed = true];
repeated float field22871 = 3 [packed = true];
repeated float field22872 = 5 [packed = true];
optional .benchmarks.google_message3.UnusedEmptyMessage field22873 = 4;
}
message Message24345 {
optional string field24533 = 1;
optional .benchmarks.google_message3.UnusedEnum field24534 = 22;
optional .benchmarks.google_message3.Message24346 field24535 = 2;
optional string field24536 = 3;
optional string field24537 = 4;
optional .benchmarks.google_message3.UnusedEnum field24538 = 23;
optional string field24539 = 5;
required string field24540 = 6;
optional string field24541 = 7;
optional string field24542 = 8;
optional .benchmarks.google_message3.Message24316 field24543 = 9;
optional .benchmarks.google_message3.Message24376 field24544 = 10;
optional string field24545 = 11;
optional string field24546 = 19;
optional string field24547 = 20;
optional string field24548 = 21;
optional .benchmarks.google_message3.UnusedEmptyMessage field24549 = 12;
optional .benchmarks.google_message3.UnusedEmptyMessage field24550 = 13;
repeated string field24551 = 14;
optional string field24552 = 15;
optional int32 field24553 = 18;
optional .benchmarks.google_message3.Message24379 field24554 = 16;
optional string field24555 = 17;
repeated .benchmarks.google_message3.Message24356 field24556 = 24;
repeated .benchmarks.google_message3.Message24366 field24557 = 25;
}
message Message24403 {
optional .benchmarks.google_message3.Message24401 field24681 = 1;
optional .benchmarks.google_message3.Message24402 field24682 = 2;
}
message Message24391 {
optional string field24631 = 1;
optional string field24632 = 2;
repeated string field24633 = 3;
optional string field24634 = 4;
repeated string field24635 = 5;
repeated string field24636 = 16;
optional string field24637 = 17;
optional .benchmarks.google_message3.UnusedEmptyMessage field24638 = 25;
optional string field24639 = 7;
optional string field24640 = 18;
optional string field24641 = 19;
optional string field24642 = 20;
optional int32 field24643 = 24;
optional .benchmarks.google_message3.Message24379 field24644 = 8;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24645 = 9;
optional .benchmarks.google_message3.UnusedEmptyMessage field24646 = 10;
optional .benchmarks.google_message3.UnusedEmptyMessage field24647 = 11;
optional .benchmarks.google_message3.UnusedEmptyMessage field24648 = 12;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24649 = 13;
optional .benchmarks.google_message3.UnusedEmptyMessage field24650 = 14;
optional string field24651 = 21;
optional int32 field24652 = 22;
optional int32 field24653 = 23;
repeated string field24654 = 15;
repeated string field24655 = 6;
}
message Message27454 {}
message Message27357 {
optional string field27410 = 1;
optional float field27411 = 2;
optional string field27412 = 3;
optional bool field27413 = 4;
optional bool field27414 = 5;
}
message Message27360 {
optional .benchmarks.google_message3.Message27358 field27426 = 1;
optional .benchmarks.google_message3.Enum27361 field27427 = 2;
optional .benchmarks.google_message3.Message27358 field27428 = 3;
repeated .benchmarks.google_message3.UnusedEmptyMessage field27429 = 4;
}
message Message34387 {
optional string field34446 = 1;
repeated .benchmarks.google_message3.Message34381 field34447 = 2;
optional .benchmarks.google_message3.UnusedEnum field34448 = 3;
optional .benchmarks.google_message3.Enum34388 field34449 = 4;
optional int64 field34450 = 5;
}
message Message34621 {
optional double field34651 = 1;
optional double field34652 = 2;
optional double field34653 = 3;
optional double field34654 = 4;
optional double field34655 = 11;
optional .benchmarks.google_message3.UnusedEmptyMessage field34656 = 13;
optional .benchmarks.google_message3.Message34619 field34657 = 14;
optional string field34658 = 5;
optional string field34659 = 9;
optional double field34660 = 12;
optional bytes field34661 = 19;
optional string field34662 = 15;
optional string field34663 = 16;
optional string field34664 = 17;
optional .benchmarks.google_message3.UnusedEmptyMessage field34665 = 18;
optional .benchmarks.google_message3.Message34621 field34666 = 20;
repeated .benchmarks.google_message3.UnusedEmptyMessage field34667 = 100;
optional .benchmarks.google_message3.UnusedEmptyMessage field34668 = 101;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message34621 field34669 = 17562023;
}
}
message Message35476 {
optional string field35484 = 1;
optional string field35485 = 2;
optional string field35486 = 3;
optional .benchmarks.google_message3.Enum35477 field35487 = 4;
optional float field35488 = 5;
optional float field35489 = 6;
optional float field35490 = 7;
optional float field35491 = 8;
optional .benchmarks.google_message3.UnusedEmptyMessage field35492 = 9;
optional int32 field35493 = 10;
optional int32 field35494 = 11;
optional int32 field35495 = 12;
optional string field35496 = 13;
optional string field35497 = 14;
}
message Message949 {
optional string field955 = 1;
optional int64 field956 = 2;
optional int64 field957 = 3;
optional .benchmarks.google_message3.Message730 field958 = 4;
repeated string field959 = 5;
optional string field960 = 6;
optional bool field961 = 7;
}
message Message36869 {
optional int32 field36970 = 1;
optional int32 field36971 = 2;
}
message Message33968 {
repeated group Message33969 = 1 {}
repeated .benchmarks.google_message3.Message33958 field33989 = 3;
optional .benchmarks.google_message3.UnusedEmptyMessage field33990 = 106;
optional bool field33991 = 108;
optional .benchmarks.google_message3.UnusedEnum field33992 = 107;
}
message Message6644 {
optional .benchmarks.google_message3.UnusedEmptyMessage field6701 = 8;
optional string field6702 = 1;
optional double field6703 = 2;
optional .benchmarks.google_message3.UnusedEmptyMessage field6704 = 9;
optional bytes field6705 = 3;
optional bytes field6706 = 19;
optional .benchmarks.google_message3.Message6637 field6707 = 4;
repeated .benchmarks.google_message3.Message6126 field6708 = 18;
optional bool field6709 = 6;
optional .benchmarks.google_message3.Message6643 field6710 = 10;
optional string field6711 = 12;
optional .benchmarks.google_message3.UnusedEmptyMessage field6712 = 14;
optional .benchmarks.google_message3.UnusedEmptyMessage field6713 = 15;
optional .benchmarks.google_message3.UnusedEmptyMessage field6714 = 16;
optional int32 field6715 = 17;
optional .benchmarks.google_message3.UnusedEmptyMessage field6716 = 20;
}
message Message18831 {
repeated group Message18832 = 1 {
optional int32 field18836 = 2;
optional string field18837 = 5;
optional float field18838 = 3;
optional float field18839 = 9;
optional int32 field18840 = 11;
repeated uint64 field18841 = 4;
repeated group Message18833 = 6 {
required uint64 field18843 = 7;
optional string field18844 = 8;
optional float field18845 = 10;
optional int32 field18846 = 12;
optional bool field18847 = 13;
}
}
}
message Message13090 {
optional .benchmarks.google_message3.Message13083 field13141 = 1;
optional .benchmarks.google_message3.Message13088 field13142 = 2;
}
message Message11874 {
optional .benchmarks.google_message3.Message10391 field11888 = 3;
optional string field11889 = 4;
optional .benchmarks.google_message3.Message11873 field11890 = 6;
optional bool field11891 = 7;
extensions 1 to 1;
extensions 2 to 2;
extensions 5 to 5;
}
message Message4144 {
repeated group Message4145 = 1 {
required .benchmarks.google_message3.Enum4146 field4165 = 2;
required int32 field4166 = 3;
optional .benchmarks.google_message3.Enum4160 field4167 = 9;
optional bytes field4168 = 4;
optional .benchmarks.google_message3.Enum4152 field4169 = 5;
optional string field4170 = 6;
}
}
message Message35573 {
optional fixed64 field35695 = 16;
optional string field35696 = 1000;
optional string field35697 = 1004;
optional int32 field35698 = 1003;
repeated group Message35574 = 1012 {}
optional int64 field35700 = 1011;
optional int64 field35701 = 1005;
optional int64 field35702 = 1006;
optional int64 field35703 = 1007;
optional int64 field35704 = 1008;
repeated group Message35575 = 1 {
optional int64 field35709 = 2;
optional string field35710 = 3;
optional string field35711 = 19;
optional int32 field35712 = 20;
optional int32 field35713 = 21;
optional int32 field35714 = 22;
optional bool field35715 = 23;
optional int32 field35716 = 47;
optional int32 field35717 = 48;
optional bool field35718 = 24;
optional fixed64 field35719 = 25;
optional bytes field35720 = 52;
optional int32 field35721 = 18;
optional fixed32 field35722 = 43;
optional bool field35723 = 26;
optional int32 field35724 = 27;
optional int32 field35725 = 17;
optional bool field35726 = 45;
repeated int32 field35727 = 33;
repeated int32 field35728 = 58;
optional float field35729 = 34;
optional float field35730 = 1009;
optional int32 field35731 = 28;
repeated fixed64 field35732 = 1001;
repeated fixed64 field35733 = 1002;
optional int32 field35734 = 44;
optional int32 field35735 = 50;
optional int32 field35736 = 36;
optional int32 field35737 = 40;
optional bool field35738 = 1016;
optional bool field35739 = 1010;
optional int32 field35740 = 37;
optional int32 field35741 = 38;
optional string field35742 = 46;
optional uint32 field35743 = 60;
repeated bytes field35744 = 56;
optional .benchmarks.google_message3.Message0 field35745 = 57;
required group Message35576 = 4 {
optional fixed64 field35747 = 5;
optional int32 field35748 = 6;
optional int32 field35749 = 49;
optional int32 field35750 = 7;
optional uint32 field35751 = 59;
optional int32 field35752 = 14;
optional int32 field35753 = 15;
optional int32 field35754 = 35;
optional bytes field35755 = 53;
optional int32 field35756 = 8;
optional string field35757 = 9;
optional fixed64 field35758 = 10;
optional int32 field35759 = 11;
optional int32 field35760 = 12;
optional int32 field35761 = 41;
optional int32 field35762 = 30;
optional int32 field35763 = 31;
optional int32 field35764 = 13;
optional bytes field35765 = 39;
optional string field35766 = 29;
optional int32 field35767 = 42;
repeated int32 field35768 = 32;
repeated int32 field35769 = 51;
optional int64 field35770 = 54;
optional .benchmarks.google_message3.Message0 field35771 = 55;
}
}
}
message Message36858 {
repeated int32 field36956 = 1;
repeated string field36957 = 2;
repeated string field36958 = 12;
optional int32 field36959 = 3;
optional int32 field36960 = 4;
optional int32 field36961 = 14;
optional string field36962 = 11;
optional bool field36963 = 5;
optional bool field36964 = 13;
optional int64 field36965 = 6;
optional .benchmarks.google_message3.Message35506 field36966 = 7;
repeated group Message36859 = 8 {
required .benchmarks.google_message3.Enum36860 field36968 = 9;
optional float field36969 = 10;
}
}
message Message13174 {
required int32 field13237 = 6;
optional int32 field13238 = 3;
required int32 field13239 = 4;
optional int32 field13240 = 8;
optional double field13241 = 5;
optional double field13242 = 7;
optional int32 field13243 = 17;
optional int32 field13244 = 19;
optional double field13245 = 20;
optional int32 field13246 = 9;
optional double field13247 = 10;
optional int32 field13248 = 11;
optional .benchmarks.google_message3.Message13151 field13249 = 21;
optional int32 field13250 = 1;
optional double field13251 = 2;
optional double field13252 = 15;
optional double field13253 = 16;
optional double field13254 = 12;
optional double field13255 = 13;
optional double field13256 = 14;
optional int32 field13257 = 18;
}
message Message18283 {
optional .benchmarks.google_message3.UnusedEmptyMessage field18478 = 1;
optional int32 field18479 = 4;
optional int32 field18480 = 106;
optional int32 field18481 = 107;
optional int32 field18482 = 108;
optional int32 field18483 = 109;
optional int32 field18484 = 105;
optional int32 field18485 = 113;
optional int32 field18486 = 114;
optional int32 field18487 = 124;
optional int32 field18488 = 125;
optional int32 field18489 = 128;
optional int32 field18490 = 135;
optional bool field18491 = 166;
optional bool field18492 = 136;
optional int32 field18493 = 140;
optional int32 field18494 = 171;
optional int32 field18495 = 148;
optional int32 field18496 = 145;
optional float field18497 = 117;
optional int32 field18498 = 146;
optional string field18499 = 3;
optional .benchmarks.google_message3.UnusedEmptyMessage field18500 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field18501 = 6;
optional .benchmarks.google_message3.UnusedEmptyMessage field18502 = 9;
optional .benchmarks.google_message3.Message18253 field18503 = 155;
optional .benchmarks.google_message3.UnusedEmptyMessage field18504 = 184;
optional .benchmarks.google_message3.UnusedEmptyMessage field18505 = 163;
optional .benchmarks.google_message3.UnusedEmptyMessage field18506 = 16;
repeated int32 field18507 = 20;
repeated int32 field18508 = 7;
repeated string field18509 = 194;
optional bytes field18510 = 30;
optional int32 field18511 = 31;
optional .benchmarks.google_message3.UnusedEmptyMessage field18512 = 178;
optional string field18513 = 8;
optional float field18514 = 2;
optional float field18515 = 100;
optional float field18516 = 101;
optional float field18517 = 102;
optional int32 field18518 = 103;
repeated .benchmarks.google_message3.UnusedEmptyMessage field18519 = 104;
optional int32 field18520 = 110;
optional int32 field18521 = 112;
optional .benchmarks.google_message3.UnusedEmptyMessage field18522 = 111;
optional .benchmarks.google_message3.UnusedEmptyMessage field18523 = 115;
optional .benchmarks.google_message3.UnusedEmptyMessage field18524 = 119;
optional .benchmarks.google_message3.UnusedEmptyMessage field18525 = 127;
optional .benchmarks.google_message3.UnusedEmptyMessage field18526 = 185;
optional int32 field18527 = 120;
optional int32 field18528 = 132;
optional .benchmarks.google_message3.UnusedEmptyMessage field18529 = 126;
optional .benchmarks.google_message3.UnusedEmptyMessage field18530 = 129;
optional .benchmarks.google_message3.UnusedEmptyMessage field18531 = 131;
optional fixed64 field18532 = 150;
optional int32 field18533 = 133;
optional int32 field18534 = 134;
optional int32 field18535 = 139;
optional fixed64 field18536 = 137;
optional fixed64 field18537 = 138;
optional .benchmarks.google_message3.UnusedEmptyMessage field18538 = 141;
optional int32 field18539 = 142;
optional int32 field18540 = 181;
optional .benchmarks.google_message3.Message16816 field18541 = 143;
optional .benchmarks.google_message3.Message16685 field18542 = 154;
optional int32 field18543 = 144;
optional int64 field18544 = 147;
optional int64 field18545 = 149;
optional int32 field18546 = 151;
optional int32 field18547 = 152;
optional int32 field18548 = 153;
optional float field18549 = 161;
optional .benchmarks.google_message3.Message0 field18550 = 123;
repeated int64 field18551 = 156;
optional int32 field18552 = 157;
repeated fixed64 field18553 = 188;
optional int32 field18554 = 158;
optional .benchmarks.google_message3.UnusedEmptyMessage field18555 = 159;
optional bool field18556 = 160;
optional uint64 field18557 = 162;
optional int32 field18558 = 164;
optional .benchmarks.google_message3.UnusedEmptyMessage field18559 = 10;
optional .benchmarks.google_message3.UnusedEmptyMessage field18560 = 167;
optional int32 field18561 = 168;
repeated fixed64 field18562 = 169;
repeated string field18563 = 170;
optional .benchmarks.google_message3.UnusedEmptyMessage field18564 = 172;
optional int64 field18565 = 173;
optional .benchmarks.google_message3.UnusedEmptyMessage field18566 = 174;
optional int64 field18567 = 175;
optional uint32 field18568 = 189;
optional .benchmarks.google_message3.UnusedEmptyMessage field18569 = 176;
optional .benchmarks.google_message3.UnusedEmptyMessage field18570 = 177;
optional uint32 field18571 = 179;
optional uint32 field18572 = 180;
optional .benchmarks.google_message3.UnusedEmptyMessage field18573 = 182;
optional .benchmarks.google_message3.UnusedEmptyMessage field18574 = 183;
optional .benchmarks.google_message3.UnusedEmptyMessage field18575 = 121;
optional .benchmarks.google_message3.UnusedEmptyMessage field18576 = 186;
optional .benchmarks.google_message3.UnusedEmptyMessage field18577 = 187;
optional .benchmarks.google_message3.UnusedEmptyMessage field18578 = 190;
optional int32 field18579 = 191;
optional float field18580 = 192;
optional bool field18581 = 193;
extensions 116 to 116;
extensions 118 to 118;
extensions 130 to 130;
extensions 165 to 165;
}
message Message13169 {
repeated .benchmarks.google_message3.Message13168 field13223 = 1;
required .benchmarks.google_message3.Message13167 field13224 = 2;
optional string field13225 = 3;
}
message Message19255 {
optional string field19257 = 1;
}
message Message35542 {
optional bool field35543 = 1;
optional bool field35544 = 2;
optional bool field35545 = 3;
}
message Message3901 {
optional int32 field3990 = 1;
optional int32 field3991 = 2;
optional int32 field3992 = 3;
optional int32 field3993 = 4;
optional int32 field3994 = 7;
optional int32 field3995 = 8;
optional int32 field3996 = 9;
optional int32 field3997 = 10;
optional int32 field3998 = 11;
optional int32 field3999 = 12;
optional .benchmarks.google_message3.UnusedEnum field4000 = 6;
optional int32 field4001 = 5;
}

View File

@ -0,0 +1,496 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message3;
import "datasets/google_message3/benchmark_message3_4.proto";
import "datasets/google_message3/benchmark_message3_5.proto";
import "datasets/google_message3/benchmark_message3_7.proto";
import "datasets/google_message3/benchmark_message3_8.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message35546 {
optional int64 field35556 = 1;
optional int32 field35557 = 2;
optional bool field35558 = 3;
optional int64 field35559 = 13;
optional group Message35547 = 4 {
required int32 field35569 = 5;
required int32 field35570 = 6;
}
optional group Message35548 = 10 {
required int64 field35571 = 11;
required int64 field35572 = 12;
}
optional bool field35562 = 14;
optional bool field35563 = 15;
optional int32 field35564 = 16;
optional bool field35565 = 17;
optional bool field35566 = 18;
optional string field35567 = 100;
}
message Message2356 {
optional .benchmarks.google_message3.Message1374 field2368 = 121;
optional uint64 field2369 = 1;
optional int32 field2370 = 2;
optional int32 field2371 = 17;
required string field2372 = 3;
optional int32 field2373 = 7;
optional bytes field2374 = 8;
optional string field2375 = 4;
optional string field2376 = 101;
optional int32 field2377 = 102;
optional int32 field2378 = 103;
optional int32 field2379 = 104;
optional int32 field2380 = 113;
optional int32 field2381 = 114;
optional int32 field2382 = 115;
optional int32 field2383 = 117;
optional int32 field2384 = 118;
optional int32 field2385 = 119;
optional int32 field2386 = 105;
optional bytes field2387 = 5;
optional group Message2357 = 6 {
optional int64 field2399 = 9;
optional int32 field2400 = 10;
optional int32 field2401 = 11;
optional int32 field2402 = 12;
optional int32 field2403 = 13;
optional int32 field2404 = 116;
optional int32 field2405 = 106;
required bytes field2406 = 14;
optional int32 field2407 = 45;
optional int32 field2408 = 112;
optional bool field2409 = 122;
optional bytes field2410 = 124;
}
optional string field2389 = 120;
optional group Message2358 = 107 {}
repeated group Message2359 = 40 {
optional string field2413 = 41;
optional string field2414 = 42;
optional string field2415 = 43;
optional string field2416 = 44;
optional int32 field2417 = 46;
optional string field2418 = 47;
optional float field2419 = 110;
optional float field2420 = 111;
}
optional int32 field2392 = 50;
optional .benchmarks.google_message3.UnusedEmptyMessage field2393 = 60;
optional .benchmarks.google_message3.UnusedEmptyMessage field2394 = 70;
optional .benchmarks.google_message3.UnusedEmptyMessage field2395 = 80;
optional .benchmarks.google_message3.UnusedEmptyMessage field2396 = 90;
optional string field2397 = 100;
optional string field2398 = 123;
}
message Message7029 {
required int32 field7183 = 1;
optional int32 field7184 = 2;
optional int32 field7185 = 3;
optional int32 field7186 = 4;
optional int32 field7187 = 5;
optional int32 field7188 = 6;
optional int32 field7189 = 17;
optional int32 field7190 = 18;
optional int32 field7191 = 49;
optional int32 field7192 = 28;
optional int32 field7193 = 33;
optional int32 field7194 = 25;
optional int32 field7195 = 26;
optional int32 field7196 = 40;
optional int32 field7197 = 41;
optional int32 field7198 = 42;
optional int32 field7199 = 43;
optional int32 field7200 = 19;
optional int32 field7201 = 7;
optional int32 field7202 = 8;
optional int32 field7203 = 9;
optional int32 field7204 = 10;
optional int32 field7205 = 11;
optional int32 field7206 = 12;
repeated group Message7030 = 13 {
optional string field7226 = 14;
optional string field7227 = 15;
optional int64 field7228 = 16;
}
repeated group Message7031 = 21 {
optional string field7229 = 22;
optional int32 field7230 = 23;
optional int32 field7231 = 24;
optional int32 field7232 = 30;
optional int32 field7233 = 31;
optional int32 field7234 = 35;
}
optional int32 field7209 = 20;
optional float field7210 = 27;
optional int32 field7211 = 29;
optional int32 field7212 = 32;
optional string field7213 = 48;
optional bool field7214 = 34;
optional int32 field7215 = 36;
optional float field7216 = 37;
optional bool field7217 = 38;
optional bool field7218 = 39;
optional .benchmarks.google_message3.UnusedEmptyMessage field7219 = 44;
optional int32 field7220 = 45;
optional int32 field7221 = 46;
optional int32 field7222 = 47;
optional .benchmarks.google_message3.UnusedEmptyMessage field7223 = 50;
optional int32 field7224 = 51;
}
message Message35538 {
required int64 field35539 = 1;
}
message Message18921 {
optional string field18946 = 1;
optional fixed64 field18947 = 2;
optional int32 field18948 = 3;
optional double field18949 = 4;
optional bool field18950 = 17;
optional bool field18951 = 23;
optional .benchmarks.google_message3.UnusedEmptyMessage field18952 = 24;
repeated group Message18922 = 5 {
optional uint64 field18959 = 6;
optional string field18960 = 13;
optional bool field18961 = 21;
optional bool field18962 = 33;
optional int32 field18963 = 7;
optional int32 field18964 = 8;
optional string field18965 = 9;
optional .benchmarks.google_message3.Message18856 field18966 = 10;
optional uint64 field18967 = 34;
optional .benchmarks.google_message3.UnusedEmptyMessage field18968 = 11;
optional uint64 field18969 = 35;
optional float field18970 = 12;
repeated string field18971 = 14;
optional bool field18972 = 15;
optional bool field18973 = 16;
optional float field18974 = 22;
optional int32 field18975 = 18;
optional int32 field18976 = 19;
optional int32 field18977 = 20;
optional .benchmarks.google_message3.UnusedEmptyMessage field18978 = 25;
optional .benchmarks.google_message3.UnusedEnum field18979 = 26;
repeated string field18980 = 27;
optional float field18981 = 28;
}
repeated .benchmarks.google_message3.UnusedEmptyMessage field18954 = 29;
repeated .benchmarks.google_message3.Message18943 field18955 = 30;
repeated .benchmarks.google_message3.Message18944 field18956 = 31;
repeated .benchmarks.google_message3.UnusedEmptyMessage field18957 = 32;
}
message Message35540 {
optional bool field35541 = 1;
}
message Message3886 {
repeated group Message3887 = 1 {
required string field3932 = 2;
optional string field3933 = 9;
optional .benchmarks.google_message3.Message3850 field3934 = 3;
optional bytes field3935 = 8;
}
}
message Message6743 {
optional .benchmarks.google_message3.Message6721 field6759 = 1;
optional .benchmarks.google_message3.Message6723 field6760 = 2;
optional .benchmarks.google_message3.Message6723 field6761 = 8;
optional .benchmarks.google_message3.Message6725 field6762 = 3;
optional .benchmarks.google_message3.Message6726 field6763 = 4;
optional .benchmarks.google_message3.Message6733 field6764 = 5;
optional .benchmarks.google_message3.Message6734 field6765 = 6;
optional .benchmarks.google_message3.Message6742 field6766 = 7;
}
message Message6773 {
optional .benchmarks.google_message3.Enum6769 field6794 = 1;
optional int32 field6795 = 9;
optional .benchmarks.google_message3.UnusedEnum field6796 = 10;
optional int32 field6797 = 11;
optional int32 field6798 = 2;
optional .benchmarks.google_message3.Enum6774 field6799 = 3;
optional double field6800 = 5;
optional double field6801 = 7;
optional double field6802 = 8;
optional .benchmarks.google_message3.Enum6782 field6803 = 6;
}
message Message8224 {
optional .benchmarks.google_message3.UnusedEmptyMessage field8255 = 1;
optional .benchmarks.google_message3.Message8184 field8256 = 2;
optional .benchmarks.google_message3.Message7966 field8257 = 3;
optional string field8258 = 4;
optional string field8259 = 5;
optional bool field8260 = 6;
optional int64 field8261 = 7;
optional string field8262 = 8;
optional int64 field8263 = 9;
optional double field8264 = 10;
optional int64 field8265 = 11;
repeated string field8266 = 12;
optional int64 field8267 = 13;
optional int32 field8268 = 14;
optional int32 field8269 = 15;
optional int64 field8270 = 16;
optional double field8271 = 17;
optional .benchmarks.google_message3.UnusedEmptyMessage field8272 = 18;
optional .benchmarks.google_message3.UnusedEmptyMessage field8273 = 19;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8274 = 20;
optional bool field8275 = 21;
optional .benchmarks.google_message3.UnusedEmptyMessage field8276 = 22;
optional .benchmarks.google_message3.UnusedEmptyMessage field8277 = 23;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8278 = 24;
optional .benchmarks.google_message3.UnusedEmptyMessage field8279 = 25;
optional bool field8280 = 26;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8281 = 27;
}
message Message8392 {
optional string field8395 = 1;
optional string field8396 = 2;
optional .benchmarks.google_message3.Message7966 field8397 = 3;
optional string field8398 = 4;
optional string field8399 = 5;
optional string field8400 = 6;
optional string field8401 = 7;
optional string field8402 = 8;
optional string field8403 = 9;
}
message Message8130 {
optional string field8156 = 1;
optional string field8157 = 2;
optional string field8158 = 4;
optional .benchmarks.google_message3.UnusedEmptyMessage field8159 = 6;
repeated string field8160 = 7;
optional int64 field8161 = 8;
optional .benchmarks.google_message3.UnusedEmptyMessage field8162 = 9;
optional string field8163 = 10;
optional string field8164 = 11;
optional string field8165 = 12;
optional string field8166 = 13;
optional .benchmarks.google_message3.UnusedEmptyMessage field8167 = 14;
optional .benchmarks.google_message3.UnusedEmptyMessage field8168 = 15;
optional string field8169 = 16;
optional .benchmarks.google_message3.UnusedEnum field8170 = 17;
optional .benchmarks.google_message3.UnusedEnum field8171 = 18;
optional bool field8172 = 19;
optional bool field8173 = 20;
optional double field8174 = 21;
optional int32 field8175 = 22;
optional int32 field8176 = 23;
optional .benchmarks.google_message3.UnusedEmptyMessage field8177 = 24;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8178 = 25;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8179 = 26;
}
message Message8478 {
optional string field8489 = 7;
optional .benchmarks.google_message3.Message7966 field8490 = 1;
optional .benchmarks.google_message3.Message8476 field8491 = 2;
optional int64 field8492 = 3;
optional .benchmarks.google_message3.Message8476 field8493 = 4;
repeated .benchmarks.google_message3.Message8477 field8494 = 5;
optional .benchmarks.google_message3.Message8454 field8495 = 6;
optional .benchmarks.google_message3.UnusedEmptyMessage field8496 = 8;
}
message Message8479 {
optional .benchmarks.google_message3.Message8475 field8497 = 1;
optional .benchmarks.google_message3.Message7966 field8498 = 2;
optional .benchmarks.google_message3.Message8476 field8499 = 3;
optional .benchmarks.google_message3.Message8476 field8500 = 4;
optional string field8501 = 6;
optional string field8502 = 7;
optional .benchmarks.google_message3.Message7966 field8503 = 8;
optional .benchmarks.google_message3.Message8455 field8504 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field8505 = 9;
}
message Message10319 {
optional .benchmarks.google_message3.Enum10325 field10340 = 1;
optional int32 field10341 = 4;
optional int32 field10342 = 5;
optional bytes field10343 = 3;
optional string field10344 = 2;
optional string field10345 = 6;
optional string field10346 = 7;
}
message Message4016 {
required int32 field4017 = 1;
required int32 field4018 = 2;
required int32 field4019 = 3;
required int32 field4020 = 4;
}
message Message12669 {
optional .benchmarks.google_message3.Message12559 field12681 = 1;
optional float field12682 = 2;
optional bool field12683 = 3;
optional .benchmarks.google_message3.Enum12670 field12684 = 4;
}
message Message12819 {
optional double field12834 = 1;
optional double field12835 = 2;
optional double field12836 = 3;
optional double field12837 = 4;
optional double field12838 = 5;
optional double field12839 = 6;
}
message Message12820 {
optional int32 field12840 = 1;
optional int32 field12841 = 2;
optional int32 field12842 = 3;
optional int32 field12843 = 8;
optional int32 field12844 = 4;
optional int32 field12845 = 5;
optional int32 field12846 = 6;
optional int32 field12847 = 7;
}
message Message12821 {
optional int32 field12848 = 1;
optional int32 field12849 = 2;
optional int32 field12850 = 3;
optional int32 field12851 = 4;
optional int32 field12852 = 5;
}
message Message12818 {
optional uint64 field12829 = 1;
optional int32 field12830 = 2;
optional int32 field12831 = 3;
optional int32 field12832 = 5;
repeated .benchmarks.google_message3.Message12817 field12833 = 4;
}
message Message16479 {
optional .benchmarks.google_message3.Message16480 field16484 = 1;
optional int32 field16485 = 5;
optional float field16486 = 2;
optional uint32 field16487 = 4;
optional bool field16488 = 3;
optional uint32 field16489 = 6;
}
message Message16722 {
optional string field16752 = 1;
optional string field16753 = 2;
optional string field16754 = 3;
optional int32 field16755 = 5;
optional string field16756 = 4;
}
message Message16724 {
optional int64 field16761 = 1;
optional float field16762 = 2;
optional int64 field16763 = 3;
optional int64 field16764 = 4;
optional bool field16765 = 5;
repeated string field16766 = 6;
repeated string field16767 = 7;
optional .benchmarks.google_message3.UnusedEmptyMessage field16768 = 8;
optional bool field16769 = 9;
optional uint32 field16770 = 10;
optional .benchmarks.google_message3.Enum16728 field16771 = 11;
repeated int32 field16772 = 12;
optional bool field16773 = 13;
}
message Message17728 {}
message Message24356 {
optional string field24559 = 1;
optional string field24560 = 2;
optional int32 field24561 = 14;
optional string field24562 = 3;
optional string field24563 = 4;
optional string field24564 = 5;
optional .benchmarks.google_message3.UnusedEnum field24565 = 13;
optional string field24566 = 6;
optional .benchmarks.google_message3.Enum24361 field24567 = 12;
optional string field24568 = 7;
optional string field24569 = 8;
optional string field24570 = 9;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24571 = 10;
repeated string field24572 = 11;
repeated string field24573 = 15;
}
message Message24376 {
optional string field24589 = 1;
optional string field24590 = 2;
optional string field24591 = 3;
required .benchmarks.google_message3.Message24377 field24592 = 4;
optional .benchmarks.google_message3.Message24317 field24593 = 5;
optional string field24594 = 6;
optional .benchmarks.google_message3.Message24378 field24595 = 7;
repeated string field24596 = 8;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24597 = 14;
repeated string field24598 = 9;
repeated string field24599 = 10;
repeated string field24600 = 11;
optional string field24601 = 12;
repeated string field24602 = 13;
}
message Message24366 {
optional string field24574 = 1;
optional string field24575 = 2;
optional string field24576 = 3;
optional int32 field24577 = 10;
optional string field24578 = 13;
optional string field24579 = 4;
optional string field24580 = 5;
optional .benchmarks.google_message3.UnusedEnum field24581 = 9;
optional string field24582 = 14;
optional .benchmarks.google_message3.UnusedEnum field24583 = 15;
optional string field24584 = 6;
optional string field24585 = 12;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24586 = 7;
repeated string field24587 = 8;
repeated string field24588 = 11;
}

View File

@ -0,0 +1,514 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message3;
import "datasets/google_message3/benchmark_message3_5.proto";
import "datasets/google_message3/benchmark_message3_6.proto";
import "datasets/google_message3/benchmark_message3_7.proto";
import "datasets/google_message3/benchmark_message3_8.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message24346 {}
message Message24401 {
optional .benchmarks.google_message3.Message24400 field24679 = 1;
}
message Message24402 {
optional .benchmarks.google_message3.Message24400 field24680 = 1;
}
message Message24379 {
optional string field24603 = 1;
optional string field24604 = 2;
optional string field24605 = 3;
required .benchmarks.google_message3.Message24380 field24606 = 4;
optional .benchmarks.google_message3.UnusedEmptyMessage field24607 = 5;
optional string field24608 = 6;
optional .benchmarks.google_message3.Message24381 field24609 = 7;
repeated string field24610 = 8;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24611 = 17;
repeated string field24612 = 9;
repeated string field24613 = 10;
repeated string field24614 = 11;
optional string field24615 = 14;
optional string field24616 = 12;
optional string field24617 = 16;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24618 = 13;
repeated string field24619 = 15;
repeated string field24620 = 18;
}
message Message27358 {
optional int32 field27415 = 1;
optional int32 field27416 = 2;
}
message Message34381 {
optional string field34398 = 1;
optional .benchmarks.google_message3.UnusedEmptyMessage field34399 = 2;
optional .benchmarks.google_message3.UnusedEmptyMessage field34400 = 3;
optional .benchmarks.google_message3.UnusedEmptyMessage field34401 = 4;
optional .benchmarks.google_message3.UnusedEmptyMessage field34402 = 5;
optional bool field34403 = 6;
optional bool field34404 = 7;
optional .benchmarks.google_message3.UnusedEmptyMessage field34405 = 8;
optional bool field34406 = 9;
optional .benchmarks.google_message3.UnusedEmptyMessage field34407 = 10;
}
message Message34619 {
optional double field34641 = 1;
optional double field34642 = 2;
optional double field34643 = 3;
optional double field34644 = 4;
optional double field34645 = 11;
optional double field34646 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field34647 = 100;
}
message Message730 {
optional string field897 = 19;
repeated string field898 = 27;
repeated string field899 = 28;
repeated string field900 = 21;
optional string field901 = 30;
repeated uint32 field902 = 20;
repeated uint32 field903 = 32;
repeated string field904 = 16;
repeated .benchmarks.google_message3.Message697 field905 = 6;
repeated .benchmarks.google_message3.Message704 field906 = 7;
repeated string field907 = 18;
repeated .benchmarks.google_message3.Message703 field908 = 8;
repeated string field909 = 9;
optional .benchmarks.google_message3.Message716 field910 = 10;
optional .benchmarks.google_message3.Message718 field911 = 11;
optional bool field912 = 14;
repeated .benchmarks.google_message3.Message715 field913 = 4;
repeated string field914 = 17;
repeated string field915 = 23;
repeated .benchmarks.google_message3.Message719 field916 = 24;
repeated .benchmarks.google_message3.Message728 field917 = 26;
repeated .benchmarks.google_message3.Message702 field918 = 35;
optional string field919 = 36;
repeated string field920 = 37;
optional int64 field921 = 38;
repeated .benchmarks.google_message3.UnusedEmptyMessage field922 = 39;
repeated .benchmarks.google_message3.UnusedEmptyMessage field923 = 1;
optional .benchmarks.google_message3.UnusedEmptyMessage field924 = 2;
optional .benchmarks.google_message3.UnusedEmptyMessage field925 = 3;
optional .benchmarks.google_message3.UnusedEmptyMessage field926 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field927 = 13;
repeated string field928 = 22;
optional bytes field929 = 31;
extensions 25 to 25;
extensions 29 to 29;
extensions 34 to 34;
extensions 15 to 15;
}
message Message33958 {
optional string field33977 = 1;
optional string field33978 = 9;
repeated group Message33959 = 2 {
required string field33982 = 3;
optional string field33983 = 4;
optional string field33984 = 5;
optional fixed64 field33985 = 8;
optional bool field33986 = 10;
optional .benchmarks.google_message3.Message0 field33987 = 6;
}
optional .benchmarks.google_message3.Enum33960 field33980 = 7;
extend .benchmarks.google_message3.Message0 {
optional .benchmarks.google_message3.Message33958 field33981 = 10747482;
}
}
message Message6637 {
optional .benchmarks.google_message3.UnusedEmptyMessage field6670 = 2;
repeated .benchmarks.google_message3.UnusedEmptyMessage field6671 = 1;
optional int32 field6672 = 3;
repeated string field6673 = 4;
optional .benchmarks.google_message3.UnusedEmptyMessage field6674 = 5;
}
message Message6643 {
optional .benchmarks.google_message3.UnusedEmptyMessage field6683 = 3;
optional .benchmarks.google_message3.UnusedEmptyMessage field6684 = 4;
optional double field6685 = 5;
optional double field6686 = 6;
optional int32 field6687 = 1;
optional int32 field6688 = 2;
optional double field6689 = 9;
optional bytes field6690 = 10;
optional int32 field6691 = 11;
optional bool field6692 = 12;
optional bool field6693 = 13;
optional .benchmarks.google_message3.Message6578 field6694 = 15;
optional .benchmarks.google_message3.UnusedEnum field6695 = 16;
optional int64 field6696 = 17;
repeated .benchmarks.google_message3.UnusedEmptyMessage field6697 = 22;
optional .benchmarks.google_message3.UnusedEmptyMessage field6698 = 19;
optional .benchmarks.google_message3.UnusedEmptyMessage field6699 = 20;
optional int32 field6700 = 21;
}
message Message6126 {
required string field6152 = 1;
repeated .benchmarks.google_message3.UnusedEmptyMessage field6153 = 9;
optional int32 field6154 = 14;
optional bytes field6155 = 10;
optional .benchmarks.google_message3.Message6024 field6156 = 12;
optional int32 field6157 = 4;
optional string field6158 = 5;
optional int32 field6159 = 6;
repeated int32 field6160 = 2;
repeated int32 field6161 = 3;
repeated .benchmarks.google_message3.Message6052 field6162 = 7;
repeated .benchmarks.google_message3.UnusedEmptyMessage field6163 = 11;
optional .benchmarks.google_message3.Enum6065 field6164 = 15;
repeated .benchmarks.google_message3.UnusedEmptyMessage field6165 = 8;
optional bool field6166 = 13;
optional bool field6167 = 16;
optional bool field6168 = 18;
repeated .benchmarks.google_message3.Message6054 field6169 = 17;
optional int32 field6170 = 19;
}
message Message13083 {
optional float field13096 = 1;
repeated group Message13084 = 2 {
required float field13107 = 3;
required int32 field13108 = 4;
optional float field13109 = 5;
repeated .benchmarks.google_message3.Enum13092 field13110 = 6;
}
optional float field13098 = 44;
optional float field13099 = 45;
optional uint64 field13100 = 46;
optional float field13101 = 47;
optional group Message13085 = 16 {}
repeated group Message13086 = 23 {}
repeated group Message13087 = 29 {}
optional .benchmarks.google_message3.UnusedEmptyMessage field13105 = 43;
}
message Message13088 {
repeated group Message13089 = 1 {
required string field13139 = 2;
optional float field13140 = 3;
}
optional int64 field13136 = 4;
optional bool field13137 = 5;
}
message Message10391 {
optional .benchmarks.google_message3.Enum10392 field10411 = 1;
optional .benchmarks.google_message3.UnusedEnum field10412 = 2;
optional int64 field10413 = 3;
optional string field10414 = 4;
optional string field10415 = 5;
optional bytes field10416 = 6;
optional bool field10417 = 8;
optional .benchmarks.google_message3.UnusedEmptyMessage field10418 = 9;
optional bool field10419 = 10;
}
message Message11873 {
optional string field11876 = 1;
optional string field11877 = 4;
optional .benchmarks.google_message3.Message10573 field11878 = 5;
optional .benchmarks.google_message3.Message10582 field11879 = 6;
optional .benchmarks.google_message3.Message10824 field11880 = 7;
optional .benchmarks.google_message3.Message10773 field11881 = 12;
optional .benchmarks.google_message3.Message11866 field11882 = 8;
optional .benchmarks.google_message3.Message10818 field11883 = 13;
optional .benchmarks.google_message3.UnusedEmptyMessage field11884 = 16;
optional .benchmarks.google_message3.Message10155 field11885 = 11;
optional .benchmarks.google_message3.Message10469 field11886 = 14;
optional .benchmarks.google_message3.UnusedEmptyMessage field11887 = 15;
extensions 9 to 9;
extensions 10 to 10;
}
message Message35506 {
optional int32 field35524 = 1;
optional string field35525 = 2;
optional .benchmarks.google_message3.Enum35507 field35526 = 3;
repeated .benchmarks.google_message3.UnusedEmptyMessage field35527 = 4;
}
message Message13151 {
repeated .benchmarks.google_message3.Message13145 field13158 = 1;
}
message Message18253 {
repeated group Message18254 = 1 {
required fixed64 field18362 = 2;
required double field18363 = 3;
}
}
message Message16685 {
repeated .benchmarks.google_message3.Message16686 field16694 = 2;
}
message Message16816 {
optional float field16826 = 1;
optional .benchmarks.google_message3.Enum16819 field16827 = 2;
optional float field16828 = 3;
repeated group Message16817 = 4 {}
optional bool field16830 = 7;
optional bool field16831 = 8;
repeated group Message16818 = 12 {}
optional string field16833 = 10;
optional bool field16834 = 13;
optional bool field16835 = 14;
}
message Message13168 {
required int32 field13212 = 1;
optional fixed64 field13213 = 7;
optional bool field13214 = 8;
optional fixed64 field13215 = 10;
optional bool field13216 = 11;
optional .benchmarks.google_message3.Message12796 field13217 = 9;
required double field13218 = 2;
required bool field13219 = 3;
optional int32 field13220 = 4;
required bool field13221 = 5;
optional int32 field13222 = 6;
}
message Message13167 {
required int32 field13199 = 1;
optional int32 field13200 = 2;
optional int32 field13201 = 3;
optional bool field13202 = 8;
optional fixed64 field13203 = 12;
optional bool field13204 = 13;
optional .benchmarks.google_message3.Message12796 field13205 = 11;
optional fixed64 field13206 = 9;
optional bool field13207 = 10;
repeated int32 field13208 = 4;
optional int32 field13209 = 5;
optional int32 field13210 = 6;
optional int32 field13211 = 7;
}
message Message1374 {
required string field1375 = 1;
optional string field1376 = 2;
}
message Message18943 {}
message Message18944 {}
message Message18856 {
optional string field18857 = 1;
optional string field18858 = 2;
optional bool field18859 = 31;
optional string field18860 = 26;
optional string field18861 = 3;
optional string field18862 = 4;
optional string field18863 = 5;
optional string field18864 = 17;
optional string field18865 = 6;
optional string field18866 = 7;
optional string field18867 = 8;
optional string field18868 = 9;
optional string field18869 = 10;
optional string field18870 = 11;
optional string field18871 = 21;
optional string field18872 = 18;
optional string field18873 = 19;
optional string field18874 = 20;
optional string field18875 = 22;
optional string field18876 = 23;
optional string field18877 = 24;
optional string field18878 = 25;
optional string field18879 = 12;
optional string field18880 = 13;
optional string field18881 = 29;
optional string field18882 = 30;
optional string field18883 = 15;
optional string field18884 = 16;
repeated string field18885 = 14;
optional string field18886 = 27;
optional string field18887 = 28;
}
message Message3850 {
optional .benchmarks.google_message3.Enum3851 field3924 = 2;
optional bool field3925 = 12;
optional int32 field3926 = 4;
optional bool field3927 = 10;
optional bool field3928 = 13;
optional bool field3929 = 14;
}
message Message6721 {
optional .benchmarks.google_message3.Message6722 field6744 = 1;
optional bool field6745 = 2;
optional bool field6746 = 3;
optional bool field6747 = 4;
}
message Message6742 {
optional bool field6758 = 1;
}
message Message6726 {
optional int64 field6752 = 1;
repeated .benchmarks.google_message3.Message6727 field6753 = 2;
}
message Message6733 {
optional int64 field6754 = 1;
optional int64 field6755 = 2;
optional bool field6756 = 3;
}
message Message6723 {
optional int64 field6748 = 1;
repeated .benchmarks.google_message3.Message6724 field6749 = 2;
}
message Message6725 {
optional int32 field6750 = 1;
optional int32 field6751 = 2;
}
message Message6734 {
repeated .benchmarks.google_message3.Message6735 field6757 = 1;
}
message Message8184 {
optional .benchmarks.google_message3.Message7966 field8228 = 1;
optional bool field8229 = 2;
repeated .benchmarks.google_message3.Message8183 field8230 = 3;
}
message Message8477 {
optional .benchmarks.google_message3.Message7966 field8486 = 1;
optional int64 field8487 = 2;
optional string field8488 = 3;
}
message Message8454 {
optional .benchmarks.google_message3.Message8449 field8465 = 1;
optional int64 field8466 = 3;
optional int32 field8467 = 4;
optional bool field8468 = 5;
extend .benchmarks.google_message3.Message8301 {
optional .benchmarks.google_message3.Message8454 field8469 = 66;
}
}
message Message8476 {
optional string field8483 = 1;
optional string field8484 = 2;
optional string field8485 = 3;
}
message Message8455 {
optional .benchmarks.google_message3.Message8449 field8470 = 1;
repeated .benchmarks.google_message3.Message8456 field8471 = 2;
optional .benchmarks.google_message3.Message8457 field8472 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field8473 = 6;
extend .benchmarks.google_message3.Message8302 {
optional .benchmarks.google_message3.Message8455 field8474 = 66;
}
}
message Message8475 {
optional string field8481 = 1;
optional int64 field8482 = 2;
}
message Message12559 {}
message Message12817 {
optional int32 field12826 = 1;
optional int32 field12827 = 2;
optional int32 field12828 = 3;
}
message Message16480 {
optional .benchmarks.google_message3.Message13358 field16490 = 1;
optional .benchmarks.google_message3.Enum16042 field16491 = 2;
optional .benchmarks.google_message3.Message13912 field16492 = 3;
optional string field16493 = 4;
optional string field16494 = 5;
optional string field16495 = 6;
optional string field16496 = 7;
optional .benchmarks.google_message3.Message13358 field16497 = 8;
optional fixed32 field16498 = 9;
}
message Message24317 {
optional string field24446 = 1;
optional .benchmarks.google_message3.Message24312 field24447 = 2;
repeated .benchmarks.google_message3.Message24315 field24448 = 3;
repeated .benchmarks.google_message3.Message24313 field24449 = 4;
repeated .benchmarks.google_message3.Message24316 field24450 = 5;
repeated .benchmarks.google_message3.UnusedEmptyMessage field24451 = 6;
optional .benchmarks.google_message3.UnusedEmptyMessage field24452 = 7;
repeated string field24453 = 8;
repeated string field24454 = 9;
repeated string field24455 = 10;
repeated string field24456 = 28;
optional string field24457 = 11;
optional string field24458 = 12;
optional string field24459 = 13;
optional string field24460 = 14;
repeated string field24461 = 15;
optional string field24462 = 16;
repeated string field24463 = 17;
repeated string field24464 = 18;
repeated string field24465 = 19;
repeated string field24466 = 20;
repeated string field24467 = 21;
repeated string field24468 = 22;
repeated string field24469 = 23;
repeated string field24470 = 24;
optional string field24471 = 25;
optional string field24472 = 26;
repeated string field24473 = 27;
optional bool field24474 = 40;
}

View File

@ -0,0 +1,496 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message3;
import "datasets/google_message3/benchmark_message3_6.proto";
import "datasets/google_message3/benchmark_message3_7.proto";
import "datasets/google_message3/benchmark_message3_8.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message24377 {}
message Message24378 {}
message Message24400 {
optional int32 field24674 = 1;
optional int32 field24675 = 2;
optional int32 field24676 = 3;
optional int32 field24677 = 4;
optional int32 field24678 = 5;
}
message Message24380 {}
message Message24381 {}
message Message719 {
repeated string field881 = 1;
repeated string field882 = 2;
repeated string field883 = 3;
optional .benchmarks.google_message3.Enum720 field884 = 4;
}
message Message728 {
required string field887 = 1;
repeated string field888 = 2;
repeated .benchmarks.google_message3.Message703 field889 = 3;
repeated .benchmarks.google_message3.Message715 field890 = 4;
repeated string field891 = 5;
repeated string field892 = 6;
optional .benchmarks.google_message3.Message718 field893 = 7;
optional .benchmarks.google_message3.Message716 field894 = 8;
repeated string field895 = 9;
extensions 10 to 10;
extensions 11 to 11;
extensions 12 to 12;
}
message Message704 {
optional string field800 = 1;
optional string field801 = 7;
optional string field802 = 2;
optional string field803 = 3;
optional string field804 = 4;
optional string field805 = 5;
optional .benchmarks.google_message3.UnusedEmptyMessage field806 = 6;
}
message Message697 {
optional string field743 = 7;
repeated string field744 = 1;
repeated string field745 = 2;
repeated string field746 = 33;
repeated string field747 = 29;
repeated string field748 = 30;
repeated string field749 = 31;
repeated string field750 = 32;
repeated string field751 = 13;
repeated string field752 = 6;
repeated string field753 = 3;
repeated string field754 = 14;
repeated string field755 = 15;
repeated string field756 = 16;
repeated string field757 = 4;
repeated string field758 = 34;
repeated string field759 = 35;
repeated string field760 = 5;
repeated string field761 = 17;
repeated string field762 = 18;
repeated string field763 = 19;
optional bool field764 = 36;
repeated string field765 = 8;
repeated string field766 = 9;
optional string field767 = 27;
optional bool field768 = 25;
optional .benchmarks.google_message3.Message700 field769 = 10;
optional bool field770 = 11;
optional bool field771 = 24;
repeated string field772 = 12;
repeated string field773 = 20;
repeated string field774 = 21;
repeated string field775 = 22;
repeated .benchmarks.google_message3.Message699 field776 = 23;
repeated .benchmarks.google_message3.Message698 field777 = 37;
optional int64 field778 = 38;
extensions 28 to 28;
extensions 26 to 26;
}
message Message0 {
option message_set_wire_format = true;
extensions 4 to 2147483646;
}
message Message6578 {
optional .benchmarks.google_message3.Enum6579 field6632 = 1;
optional .benchmarks.google_message3.Enum6588 field6633 = 2;
}
message Message6024 {
optional .benchmarks.google_message3.Enum6025 field6048 = 1;
optional string field6049 = 2;
optional .benchmarks.google_message3.UnusedEmptyMessage field6050 = 3;
}
message Message6052 {
required string field6084 = 1;
required bytes field6085 = 2;
}
message Message6054 {
required string field6089 = 1;
optional string field6090 = 2;
}
message Message10573 {
repeated .benchmarks.google_message3.Message10576 field10580 = 1;
optional string field10581 = 2;
extensions 10000 to 536870911;
}
message Message10824 {
required string field10825 = 1;
optional int32 field10826 = 2;
}
message Message10582 {
required bool field10583 = 1;
required double field10584 = 2;
optional bool field10585 = 3;
optional double field10586 = 4;
optional double field10587 = 5;
optional bool field10588 = 6;
}
message Message10155 {
required int32 field10195 = 1;
required int32 field10196 = 2;
optional .benchmarks.google_message3.Enum10157 field10197 = 59;
optional int32 field10198 = 18;
optional int32 field10199 = 19;
optional int32 field10200 = 21;
repeated group Message10156 = 50 {
optional .benchmarks.google_message3.Enum8862 field10266 = 51;
optional int32 field10267 = 52;
optional int32 field10268 = 53;
optional int32 field10269 = 54;
}
optional int32 field10202 = 3;
optional int32 field10203 = 4;
optional int32 field10204 = 5;
optional bool field10205 = 84;
optional bool field10206 = 33;
optional int32 field10207 = 75;
optional float field10208 = 26;
optional int32 field10209 = 27;
optional int32 field10210 = 49;
optional int32 field10211 = 10;
optional float field10212 = 78;
optional .benchmarks.google_message3.Message9151 field10213 = 91;
optional int32 field10214 = 11;
optional int32 field10215 = 12;
optional float field10216 = 41;
optional .benchmarks.google_message3.Message10154 field10217 = 61;
optional int32 field10218 = 23;
optional bytes field10219 = 24;
optional int32 field10220 = 65;
repeated bytes field10221 = 66;
optional int32 field10222 = 70;
optional bytes field10223 = 71;
repeated fixed64 field10224 = 73;
optional float field10225 = 29;
optional int32 field10226 = 30;
optional float field10227 = 31;
optional int32 field10228 = 32;
optional float field10229 = 34;
optional int32 field10230 = 35;
optional string field10231 = 22;
optional fixed64 field10232 = 13;
optional fixed64 field10233 = 20;
optional bool field10234 = 79;
repeated .benchmarks.google_message3.Enum10167 field10235 = 80
[packed = true];
optional int32 field10236 = 14;
optional int32 field10237 = 15;
optional int32 field10238 = 28;
repeated string field10239 = 16;
optional .benchmarks.google_message3.Message9182 field10240 = 17;
optional int32 field10241 = 63;
optional float field10242 = 64;
optional float field10243 = 37;
repeated float field10244 = 43;
optional int32 field10245 = 44;
optional .benchmarks.google_message3.Message9242 field10246 = 45;
optional .benchmarks.google_message3.UnusedEmptyMessage field10247 = 46;
optional .benchmarks.google_message3.UnusedEmptyMessage field10248 = 62;
optional .benchmarks.google_message3.Message8944 field10249 = 48;
optional .benchmarks.google_message3.UnusedEmptyMessage field10250 = 87;
optional int32 field10251 = 58;
optional int32 field10252 = 92;
optional .benchmarks.google_message3.Message9123 field10253 = 93;
optional .benchmarks.google_message3.Message9160 field10254 = 60;
optional .benchmarks.google_message3.Message8890 field10255 = 67;
optional string field10256 = 69;
optional int64 field10257 = 74;
optional float field10258 = 82;
optional float field10259 = 85;
optional float field10260 = 86;
optional int64 field10261 = 83;
optional string field10262 = 77;
optional bool field10263 = 88;
repeated .benchmarks.google_message3.Message9628 field10264 = 94;
extensions 57 to 57;
extensions 1000 to 536870911;
}
message Message11866 {
required .benchmarks.google_message3.Message11014 field11868 = 1;
optional bool field11869 = 2;
optional double field11870 = 3;
optional double field11871 = 4;
repeated .benchmarks.google_message3.UnusedEmptyMessage field11872 = 5;
}
message Message10469 {
optional string field10473 = 1;
optional float field10474 = 2;
optional int32 field10475 = 3;
optional int32 field10476 = 4;
optional int32 field10477 = 5;
optional bool field10478 = 6;
optional bool field10479 = 7;
optional int32 field10480 = 8;
optional float field10481 = 9;
}
message Message10818 {
optional .benchmarks.google_message3.Message10800 field10819 = 1;
optional .benchmarks.google_message3.Message10801 field10820 = 2;
}
message Message10773 {
optional bool field10774 = 9;
optional bool field10775 = 1;
optional bool field10776 = 23;
optional bool field10777 = 2;
optional bool field10778 = 3;
optional int32 field10779 = 4;
optional int32 field10780 = 5;
optional int32 field10781 = 6;
optional int32 field10782 = 7;
optional int32 field10783 = 8;
optional int32 field10784 = 10;
optional .benchmarks.google_message3.Message10749 field10785 = 11;
repeated .benchmarks.google_message3.UnusedEmptyMessage field10786 = 12;
optional bool field10787 = 13;
optional bool field10788 = 15;
optional bool field10789 = 16;
optional int32 field10790 = 17;
optional int32 field10791 = 18;
optional bool field10792 = 19;
optional bool field10793 = 20;
optional bool field10794 = 21;
optional .benchmarks.google_message3.UnusedEnum field10795 = 14;
optional .benchmarks.google_message3.UnusedEnum field10796 = 22;
}
message Message13145 {
required .benchmarks.google_message3.Enum13146 field13155 = 1;
optional float field13156 = 2;
optional float field13157 = 3;
extensions 1000 to 536870911;
}
message Message16686 {}
message Message12796 {
repeated fixed64 field12800 = 1;
optional uint64 field12801 = 2;
}
message Message6722 {}
message Message6727 {}
message Message6724 {}
message Message6735 {}
message Message8183 {
optional string field8226 = 1;
optional string field8227 = 2;
}
message Message8301 {
optional string field8328 = 1;
optional .benchmarks.google_message3.Message7966 field8329 = 2;
optional string field8330 = 3;
optional string field8331 = 4;
repeated .benchmarks.google_message3.Message8290 field8332 = 5;
optional .benchmarks.google_message3.Message7966 field8333 = 6;
repeated .benchmarks.google_message3.Message8298 field8334 = 7;
optional .benchmarks.google_message3.Message8300 field8335 = 8;
optional int64 field8336 = 9;
optional .benchmarks.google_message3.UnusedEmptyMessage field8337 = 10;
optional .benchmarks.google_message3.Message7965 field8338 = 11;
extensions 64 to 536870911;
}
message Message8456 {}
message Message8302 {
optional string field8339 = 1;
optional .benchmarks.google_message3.Message7966 field8340 = 2;
optional string field8341 = 3;
optional string field8342 = 4;
optional string field8343 = 5;
optional string field8344 = 6;
optional string field8345 = 7;
optional int64 field8346 = 8;
optional int64 field8347 = 9;
repeated .benchmarks.google_message3.Message8290 field8348 = 10;
optional string field8349 = 11;
optional .benchmarks.google_message3.UnusedEmptyMessage field8350 = 12;
optional .benchmarks.google_message3.Message8291 field8351 = 13;
optional int64 field8352 = 14;
optional .benchmarks.google_message3.Message8296 field8353 = 15;
optional string field8354 = 16;
optional .benchmarks.google_message3.UnusedEmptyMessage field8355 = 17;
repeated int32 field8356 = 18;
repeated int32 field8357 = 19;
repeated .benchmarks.google_message3.UnusedEmptyMessage field8358 = 20;
optional .benchmarks.google_message3.Message7965 field8359 = 21;
extensions 64 to 536870911;
}
message Message8457 {}
message Message8449 {
optional string field8458 = 1;
optional bool field8459 = 2;
optional .benchmarks.google_message3.Enum8450 field8460 = 3;
repeated string field8461 = 4;
optional string field8462 = 5;
optional string field8463 = 6;
optional .benchmarks.google_message3.Message7966 field8464 = 7;
}
message Message13358 {
required fixed64 field13359 = 1;
required fixed64 field13360 = 2;
optional .benchmarks.google_message3.UnusedEmptyMessage field13361 = 3;
}
message Message13912 {
required fixed32 field13913 = 1;
required fixed32 field13914 = 2;
optional .benchmarks.google_message3.UnusedEmptyMessage field13915 = 500;
optional .benchmarks.google_message3.UnusedEmptyMessage field13916 = 15;
}
message Message24316 {
repeated string field24443 = 1;
repeated string field24444 = 2;
repeated string field24445 = 3;
}
message Message24312 {
optional string field24421 = 1;
optional string field24422 = 2;
repeated string field24423 = 3;
repeated string field24424 = 4;
repeated string field24425 = 5;
repeated string field24426 = 6;
}
message Message24313 {
optional string field24427 = 1;
optional string field24428 = 2;
repeated string field24429 = 3;
optional string field24430 = 4;
optional string field24431 = 5;
optional string field24432 = 6;
optional string field24433 = 7;
repeated string field24434 = 8;
optional string field24435 = 9;
repeated string field24436 = 10;
}
message Message24315 {
required string field24440 = 1;
repeated string field24441 = 2;
repeated string field24442 = 3;
}
message Message716 {
required string field872 = 1;
required int32 field873 = 2;
optional bool field874 = 3;
optional .benchmarks.google_message3.Message717 field875 = 4;
}
message Message718 {
repeated string field878 = 1;
repeated string field879 = 2;
optional string field880 = 3;
}
message Message703 {
required string field795 = 1;
repeated string field796 = 2;
repeated string field797 = 3;
optional string field798 = 4;
repeated string field799 = 5;
}
message Message715 {
required string field859 = 1;
optional string field860 = 7;
repeated .benchmarks.google_message3.Message707 field861 = 2;
repeated .benchmarks.google_message3.Message708 field862 = 3;
repeated .benchmarks.google_message3.Message711 field863 = 4;
repeated .benchmarks.google_message3.Message712 field864 = 5;
repeated .benchmarks.google_message3.Message713 field865 = 6;
repeated .benchmarks.google_message3.Message714 field866 = 8;
repeated .benchmarks.google_message3.Message710 field867 = 9;
repeated .benchmarks.google_message3.Message709 field868 = 10;
repeated .benchmarks.google_message3.Message705 field869 = 11;
repeated .benchmarks.google_message3.Message702 field870 = 12;
repeated .benchmarks.google_message3.Message706 field871 = 13;
}
message Message700 {
repeated string field789 = 1;
repeated string field790 = 2;
}
message Message699 {
required string field787 = 1;
repeated string field788 = 2;
}
message Message698 {
optional string field779 = 1;
optional string field780 = 2;
optional string field781 = 3;
optional string field782 = 4;
optional uint64 field783 = 5;
optional uint32 field784 = 6;
optional int64 field785 = 7;
repeated string field786 = 8;
}

View File

@ -0,0 +1,483 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message3;
import "datasets/google_message3/benchmark_message3_7.proto";
import "datasets/google_message3/benchmark_message3_8.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message10576 {}
message Message10154 {
optional bytes field10192 = 1;
optional int32 field10193 = 2;
}
message Message8944 {
optional string field9045 = 2;
optional string field9046 = 3;
optional string field9047 = 23;
optional string field9048 = 52;
optional int32 field9049 = 53;
optional int32 field9050 = 54;
optional float field9051 = 55;
optional float field9052 = 56;
optional string field9053 = 57;
optional int64 field9054 = 1;
optional bool field9055 = 4;
optional int32 field9056 = 5;
optional int32 field9057 = 6;
optional int32 field9058 = 7;
optional float field9059 = 8;
optional float field9060 = 11;
optional float field9061 = 9;
optional float field9062 = 10;
optional float field9063 = 13;
optional bool field9064 = 14;
optional float field9065 = 70;
optional int32 field9066 = 71;
optional .benchmarks.google_message3.Enum8945 field9067 = 15;
optional int32 field9068 = 16;
optional int32 field9069 = 17;
optional float field9070 = 18;
optional float field9071 = 19;
optional int32 field9072 = 28;
optional int32 field9073 = 29;
optional float field9074 = 60;
optional float field9075 = 61;
optional int32 field9076 = 72;
optional int32 field9077 = 73;
optional .benchmarks.google_message3.Enum8951 field9078 = 62;
optional string field9079 = 20;
optional string field9080 = 21;
optional string field9081 = 22;
optional double field9082 = 31;
optional double field9083 = 32;
optional double field9084 = 33;
optional double field9085 = 36;
optional .benchmarks.google_message3.UnusedEnum field9086 = 37;
optional double field9087 = 38;
optional double field9088 = 39;
optional double field9089 = 63;
optional double field9090 = 64;
optional double field9091 = 65;
optional double field9092 = 34;
optional .benchmarks.google_message3.UnusedEnum field9093 = 35;
optional .benchmarks.google_message3.UnusedEnum field9094 = 66;
optional string field9095 = 40;
optional string field9096 = 41;
optional string field9097 = 42;
optional string field9098 = 43;
optional string field9099 = 44;
optional string field9100 = 45;
optional string field9101 = 46;
optional string field9102 = 47;
optional string field9103 = 48;
optional string field9104 = 49;
optional .benchmarks.google_message3.Message8939 field9105 = 100;
optional int64 field9106 = 101;
}
message Message9182 {
optional string field9205 = 1;
optional string field9206 = 2;
optional float field9207 = 16;
optional int32 field9208 = 17;
optional int32 field9209 = 27;
optional int32 field9210 = 7;
optional int32 field9211 = 8;
optional float field9212 = 26;
optional float field9213 = 22;
optional bool field9214 = 28;
repeated .benchmarks.google_message3.UnusedEmptyMessage field9215 = 21;
repeated .benchmarks.google_message3.UnusedEmptyMessage field9216 = 25;
repeated .benchmarks.google_message3.Message9181 field9217 = 29;
optional bool field9218 = 18;
optional bool field9219 = 19;
optional bool field9220 = 20;
optional .benchmarks.google_message3.Message9164 field9221 = 30;
optional .benchmarks.google_message3.Message9165 field9222 = 31;
optional .benchmarks.google_message3.Message9166 field9223 = 32;
optional float field9224 = 33;
optional .benchmarks.google_message3.Message9151 field9225 = 34;
optional float field9226 = 35;
optional float field9227 = 36;
optional float field9228 = 37;
optional float field9229 = 38;
optional float field9230 = 39;
extensions 3 to 6;
extensions 9 to 15;
extensions 23 to 23;
extensions 24 to 24;
extensions 1000 to 536870911;
}
message Message9160 {
optional int32 field9161 = 1;
optional bytes field9162 = 2;
}
message Message9242 {
repeated .benchmarks.google_message3.Enum9243 field9327 = 1;
}
message Message8890 {
repeated .benchmarks.google_message3.Message8888 field8916 = 1;
}
message Message9123 {
optional float field9135 = 1;
}
message Message9628 {
optional .benchmarks.google_message3.Message9627 field9673 = 1;
optional string field9674 = 2;
repeated int32 field9675 = 3;
optional int32 field9676 = 4;
}
message Message11014 {
optional int32 field11780 = 40;
optional string field11781 = 46;
optional bool field11782 = 47;
optional .benchmarks.google_message3.Enum11107 field11783 = 1;
optional int32 field11784 = 2;
optional double field11785 = 4;
optional int32 field11786 = 5;
optional int32 field11787 = 6;
optional double field11788 = 7;
optional double field11789 = 8;
optional int64 field11790 = 9;
optional bool field11791 = 10;
optional int64 field11792 = 28;
optional bool field11793 = 37;
optional .benchmarks.google_message3.Enum11541 field11794 = 44;
optional double field11795 = 49;
optional double field11796 = 51;
optional int64 field11797 = 54;
optional int64 field11798 = 55;
optional .benchmarks.google_message3.UnusedEnum field11799 = 57;
optional .benchmarks.google_message3.Enum11468 field11800 = 58;
optional int32 field11801 = 59;
optional .benchmarks.google_message3.UnusedEnum field11802 = 60;
optional int32 field11803 = 61;
optional int32 field11804 = 62;
optional int32 field11805 = 69;
optional .benchmarks.google_message3.UnusedEmptyMessage field11806 = 68;
repeated .benchmarks.google_message3.Message11018 field11807 = 71;
optional bool field11808 = 50;
optional bool field11809 = 56;
optional bool field11810 = 66;
optional bool field11811 = 63;
optional bool field11812 = 64;
optional bool field11813 = 65;
optional bool field11814 = 67;
optional .benchmarks.google_message3.Enum11107 field11815 = 15;
optional int64 field11816 = 16;
optional double field11817 = 17;
optional int64 field11818 = 18;
optional int32 field11819 = 19;
optional int64 field11820 = 20;
optional int32 field11821 = 42;
optional int64 field11822 = 52;
optional int64 field11823 = 53;
optional int64 field11824 = 41;
optional double field11825 = 48;
repeated .benchmarks.google_message3.Message11020 field11826 = 70;
repeated .benchmarks.google_message3.UnusedEmptyMessage field11827 = 72;
optional double field11828 = 25;
optional string field11829 = 26;
optional int64 field11830 = 27;
optional int64 field11831 = 32;
optional uint64 field11832 = 33;
optional bool field11833 = 29;
optional bool field11834 = 34;
optional string field11835 = 30;
optional int32 field11836 = 3;
optional int32 field11837 = 31;
optional int32 field11838 = 73;
optional int32 field11839 = 35;
optional .benchmarks.google_message3.Enum11022 field11840 = 36;
optional .benchmarks.google_message3.Message11013 field11841 = 38;
optional double field11842 = 39;
optional int32 field11843 = 45;
optional bool field11844 = 74;
}
message Message10801 {
optional .benchmarks.google_message3.Message10800 field10812 = 1;
repeated .benchmarks.google_message3.Message10802 field10813 = 2;
optional int32 field10814 = 3;
}
message Message10749 {
repeated .benchmarks.google_message3.Message10748 field10754 = 1;
}
message Message8298 {
optional .benchmarks.google_message3.Message7966 field8321 = 1;
optional int64 field8322 = 2;
optional string field8323 = 3;
}
message Message8300 {
optional string field8326 = 1;
optional .benchmarks.google_message3.Message7966 field8327 = 2;
}
message Message8291 {
optional string field8306 = 1;
optional int32 field8307 = 2;
optional string field8308 = 3;
optional string field8309 = 4;
optional .benchmarks.google_message3.Enum8292 field8310 = 5;
}
message Message8296 {
optional .benchmarks.google_message3.Message7966 field8311 = 1;
optional string field8312 = 2;
optional .benchmarks.google_message3.Message7966 field8313 = 3;
optional int32 field8314 = 4;
optional int32 field8315 = 5;
optional string field8316 = 6;
}
message Message7965 {
optional int32 field7967 = 1;
optional int32 field7968 = 2;
}
message Message8290 {
optional string field8304 = 1;
optional string field8305 = 2;
}
message Message717 {
repeated string field876 = 1;
optional double field877 = 2;
}
message Message713 {
required .benchmarks.google_message3.Message708 field852 = 1;
repeated string field853 = 2;
}
message Message705 {
required string field807 = 1;
optional string field808 = 2;
optional string field809 = 3;
optional bool field810 = 4;
optional string field811 = 5;
optional string field812 = 6;
repeated string field813 = 7;
}
message Message709 {
repeated string field829 = 1;
repeated string field830 = 2;
repeated string field831 = 3;
repeated string field832 = 4;
repeated string field833 = 5;
}
message Message702 {
optional string field793 = 1;
optional string field794 = 2;
}
message Message714 {
optional string field854 = 1;
optional string field855 = 2;
optional string field856 = 3;
optional string field857 = 4;
optional uint32 field858 = 5;
}
message Message710 {
repeated string field834 = 1;
optional string field835 = 2;
optional string field836 = 3;
repeated string field837 = 4;
repeated string field838 = 5;
}
message Message706 {
repeated string field814 = 1;
optional string field815 = 2;
repeated string field816 = 3;
repeated string field817 = 4;
}
message Message707 {
required string field818 = 1;
required string field819 = 2;
required string field820 = 3;
optional bool field821 = 4;
repeated string field822 = 5;
}
message Message711 {
optional .benchmarks.google_message3.UnusedEmptyMessage field839 = 1;
repeated string field840 = 4;
repeated string field841 = 2;
repeated string field842 = 3;
}
message Message712 {
repeated string field843 = 1;
required string field844 = 2;
optional string field845 = 3;
repeated string field846 = 4;
repeated string field847 = 5;
optional string field848 = 6;
repeated string field849 = 7;
optional string field850 = 8;
optional string field851 = 9;
}
message Message8939 {
optional string field9010 = 1;
optional string field9011 = 2;
optional string field9012 = 3;
repeated string field9013 = 4;
optional string field9014 = 5;
repeated group Message8940 = 11 {}
optional int64 field9016 = 21;
optional int64 field9017 = 22;
optional int64 field9018 = 23;
optional group Message8941 = 31 {
optional string field9033 = 32;
optional string field9034 = 33;
optional string field9035 = 34;
optional string field9036 = 35;
optional string field9037 = 36;
optional string field9038 = 37;
}
optional .benchmarks.google_message3.Message8942 field9020 = 38;
repeated .benchmarks.google_message3.UnusedEmptyMessage field9021 = 39;
repeated string field9022 = 41;
optional string field9023 = 42;
optional string field9024 = 43;
optional string field9025 = 44;
optional string field9026 = 45;
optional string field9027 = 46;
optional string field9028 = 47;
optional .benchmarks.google_message3.UnusedEnum field9029 = 48;
optional .benchmarks.google_message3.UnusedEnum field9030 = 49;
optional group Message8943 = 51 {
optional string field9039 = 1;
optional string field9040 = 2;
optional string field9041 = 3;
optional string field9042 = 4;
optional string field9043 = 5;
optional string field9044 = 6;
}
}
message Message9181 {
optional string field9204 = 1;
}
message Message9164 {
optional int32 field9168 = 1;
optional int32 field9169 = 2;
optional int32 field9170 = 3;
}
message Message9165 {
optional float field9171 = 1;
optional float field9172 = 2;
}
message Message9166 {
optional float field9173 = 1;
optional int32 field9174 = 2;
}
message Message9151 {
optional double field9152 = 1;
optional double field9153 = 2;
optional float field9154 = 3;
optional float field9155 = 4;
optional float field9156 = 5;
optional float field9157 = 6;
optional float field9158 = 7;
optional float field9159 = 8;
}
message Message8888 {
optional int32 field8908 = 1;
optional .benchmarks.google_message3.Enum8900 field8909 = 4;
repeated int32 field8910 = 2 [packed = true];
optional bytes field8911 = 3;
}
message Message9627 {
required int32 field9668 = 1;
required int32 field9669 = 2;
required int32 field9670 = 3;
required int32 field9671 = 4;
optional float field9672 = 5;
}
message Message11020 {}
message Message11013 {
optional bytes field11757 = 19;
optional bytes field11758 = 1;
optional bytes field11759 = 2;
optional bytes field11760 = 3;
optional bytes field11761 = 4;
optional bytes field11762 = 5;
optional bytes field11763 = 6;
optional bytes field11764 = 7;
optional bytes field11765 = 8;
optional bytes field11766 = 9;
optional bytes field11767 = 10;
optional bytes field11768 = 11;
optional bytes field11769 = 12;
optional bytes field11770 = 13;
optional bytes field11771 = 14;
optional bytes field11772 = 15;
optional bytes field11773 = 16;
optional bytes field11774 = 17;
optional bytes field11775 = 18;
optional bytes field11776 = 20;
optional bytes field11777 = 21;
optional .benchmarks.google_message3.UnusedEmptyMessage field11778 = 23;
repeated .benchmarks.google_message3.Message11011 field11779 = 22;
}

View File

@ -0,0 +1,81 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package benchmarks.google_message3;
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message11018 {}
message Message10800 {
optional string field10808 = 1;
optional int64 field10809 = 2;
optional bool field10810 = 3;
optional float field10811 = 4;
}
message Message10802 {}
message Message10748 {
optional string field10750 = 1;
optional int32 field10751 = 2;
optional int32 field10752 = 3;
optional int32 field10753 = 4;
}
message Message7966 {
optional string field7969 = 1;
optional bool field7970 = 2;
}
message Message708 {
optional .benchmarks.google_message3.Message741 field823 = 1;
repeated string field824 = 6;
optional string field825 = 2;
optional string field826 = 3;
repeated string field827 = 4;
repeated string field828 = 5;
}
message Message8942 {}
message Message11011 {
required bytes field11752 = 1;
required bytes field11753 = 2;
}
message UnusedEmptyMessage {}
message Message741 {
repeated string field936 = 1;
}

View File

@ -0,0 +1,484 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message4;
import "datasets/google_message4/benchmark_message4_1.proto";
import "datasets/google_message4/benchmark_message4_2.proto";
import "datasets/google_message4/benchmark_message4_3.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message GoogleMessage4 {
optional int32 field37503 = 1;
optional .benchmarks.google_message4.UnusedEmptyMessage field37504 = 2;
optional .benchmarks.google_message4.UnusedEmptyMessage field37505 = 3;
optional .benchmarks.google_message4.UnusedEmptyMessage field37506 = 4;
optional .benchmarks.google_message4.UnusedEmptyMessage field37507 = 5;
optional .benchmarks.google_message4.Message37489 field37508 = 6;
optional .benchmarks.google_message4.UnusedEmptyMessage field37509 = 7;
optional .benchmarks.google_message4.UnusedEmptyMessage field37510 = 8;
optional .benchmarks.google_message4.UnusedEmptyMessage field37511 = 9;
optional .benchmarks.google_message4.UnusedEmptyMessage field37512 = 10;
optional .benchmarks.google_message4.UnusedEmptyMessage field37513 = 11;
optional .benchmarks.google_message4.UnusedEmptyMessage field37514 = 12;
optional .benchmarks.google_message4.UnusedEmptyMessage field37515 = 13;
optional .benchmarks.google_message4.UnusedEmptyMessage field37516 = 14;
optional .benchmarks.google_message4.UnusedEmptyMessage field37517 = 15;
optional .benchmarks.google_message4.UnusedEmptyMessage field37518 = 16;
}
message Message37489 {
optional .benchmarks.google_message4.Message2517 field37534 = 3;
optional .benchmarks.google_message4.Message7330 field37535 = 4;
optional .benchmarks.google_message4.Message8815 field37536 = 6;
optional .benchmarks.google_message4.Message8817 field37537 = 7;
optional .benchmarks.google_message4.Message8835 field37538 = 8;
optional .benchmarks.google_message4.Message8848 field37539 = 9;
optional .benchmarks.google_message4.Message8856 field37540 = 11;
optional .benchmarks.google_message4.Message12717 field37541 = 15;
optional .benchmarks.google_message4.Message12748 field37542 = 20;
optional .benchmarks.google_message4.Message7319 field37543 = 22;
optional .benchmarks.google_message4.Message12908 field37544 = 24;
optional .benchmarks.google_message4.Message12910 field37545 = 25;
optional .benchmarks.google_message4.Message12960 field37546 = 30;
optional .benchmarks.google_message4.Message176 field37547 = 33;
optional .benchmarks.google_message4.Message13000 field37548 = 34;
optional .benchmarks.google_message4.Message13035 field37549 = 35;
optional .benchmarks.google_message4.Message37331 field37550 = 36;
optional .benchmarks.google_message4.Message37329 field37551 = 37;
optional .benchmarks.google_message4.Message37327 field37552 = 38;
optional .benchmarks.google_message4.Message37333 field37553 = 39;
optional .benchmarks.google_message4.Message37335 field37554 = 40;
}
message Message7319 {
optional .benchmarks.google_message4.UnusedEmptyMessage field7321 = 1;
optional .benchmarks.google_message4.UnusedEmptyMessage field7322 = 7;
}
message Message12717 {
optional .benchmarks.google_message4.UnusedEmptyMessage field12719 = 1;
optional string field12720 = 2;
optional uint32 field12721 = 3;
optional .benchmarks.google_message4.Message11976 field12722 = 4;
repeated .benchmarks.google_message4.Message11948 field12723 = 5;
optional .benchmarks.google_message4.Message11947 field12724 = 6;
optional .benchmarks.google_message4.Message12687 field12725 = 7;
repeated .benchmarks.google_message4.Message11948 field12726 = 8;
optional int64 field12727 = 9;
}
message Message37331 {
optional .benchmarks.google_message4.UnusedEmptyMessage field37367 = 4;
required .benchmarks.google_message4.Message37326 field37368 = 1;
required int64 field37369 = 2;
required bytes field37370 = 3;
}
message Message8815 {
optional .benchmarks.google_message4.UnusedEmptyMessage field8819 = 1;
repeated .benchmarks.google_message4.Message8768 field8820 = 2;
optional bool field8821 = 3;
}
message Message7330 {
optional .benchmarks.google_message4.UnusedEmptyMessage field7332 = 1;
optional .benchmarks.google_message4.Message3069 field7333 = 2;
optional .benchmarks.google_message4.Message7320 field7334 = 3;
optional .benchmarks.google_message4.UnusedEmptyMessage field7335 = 4;
optional bool field7336 = 5;
optional int64 field7337 = 6;
}
message Message12960 {
optional .benchmarks.google_message4.UnusedEmptyMessage field12962 = 1;
optional .benchmarks.google_message4.Message12948 field12963 = 2;
}
message Message176 {
required string field408 = 1;
optional int32 field409 = 4;
optional string field410 = 50;
optional int32 field411 = 2;
optional uint64 field412 = 47;
optional string field413 = 56;
optional int32 field414 = 24;
optional string field415 = 21;
optional bytes field416 = 3;
optional string field417 = 57;
optional int32 field418 = 51;
optional float field419 = 7;
optional bool field420 = 5;
optional bool field421 = 28;
optional int32 field422 = 6;
repeated int32 field423 = 40;
optional .benchmarks.google_message4.UnusedEmptyMessage field424 = 41;
optional bool field425 = 25;
optional uint64 field426 = 26;
optional int32 field427 = 38;
optional bytes field428 = 15;
optional bytes field429 = 55;
optional bytes field430 = 16;
optional bytes field431 = 23;
optional bool field432 = 33;
optional bytes field433 = 31;
optional bytes field434 = 32;
optional int32 field435 = 36;
optional uint64 field436 = 17;
optional int32 field437 = 45;
optional uint64 field438 = 18;
optional string field439 = 46;
optional .benchmarks.google_message4.UnusedEmptyMessage field440 = 64;
optional int32 field441 = 39;
optional uint64 field442 = 48;
optional bytes field443 = 19;
optional bytes field444 = 42;
optional bytes field445 = 43;
optional string field446 = 44;
optional string field447 = 49;
optional int64 field448 = 20;
optional bool field449 = 53;
optional .benchmarks.google_message4.UnusedEmptyMessage field450 = 54;
repeated .benchmarks.google_message4.UnusedEmptyMessage field451 = 22;
optional .benchmarks.google_message4.UnusedEnum field452 = 27;
optional int32 field453 = 29;
optional int32 field454 = 30;
optional .benchmarks.google_message4.UnusedEnum field455 = 37;
optional .benchmarks.google_message4.UnusedEnum field456 = 34;
optional int32 field457 = 35;
repeated group Message178 = 101 {}
optional bool field459 = 52;
optional uint64 field460 = 58;
optional uint64 field461 = 59;
optional .benchmarks.google_message4.UnusedEmptyMessage field462 = 60;
optional .benchmarks.google_message4.UnusedEmptyMessage field463 = 61;
optional .benchmarks.google_message4.UnusedEnum field464 = 62;
repeated string field465 = 63;
optional .benchmarks.google_message4.UnusedEmptyMessage field466 = 65;
}
message Message8817 {
optional .benchmarks.google_message4.UnusedEmptyMessage field8825 = 1;
repeated .benchmarks.google_message4.Message8768 field8826 = 2;
optional string field8827 = 3;
}
message Message8835 {
optional .benchmarks.google_message4.UnusedEmptyMessage field8837 = 1;
repeated string field8838 = 2;
optional .benchmarks.google_message4.UnusedEnum field8839 = 3;
}
message Message37333 {
optional .benchmarks.google_message4.UnusedEmptyMessage field37372 = 3;
required .benchmarks.google_message4.Message37326 field37373 = 1;
optional uint64 field37374 = 2;
}
message Message13000 {
optional int64 field13015 = 1;
repeated .benchmarks.google_message4.Message12979 field13016 = 2;
}
message Message37335 {
optional .benchmarks.google_message4.UnusedEmptyMessage field37376 = 4;
required .benchmarks.google_message4.Message37326 field37377 = 1;
required .benchmarks.google_message4.Message37173 field37378 = 2;
optional uint64 field37379 = 3;
}
message Message8848 {
optional .benchmarks.google_message4.UnusedEmptyMessage field8850 = 1;
optional string field8851 = 2;
optional bytes field8852 = 3;
}
message Message13035 {
optional int64 field13058 = 1;
repeated int64 field13059 = 2;
}
message Message8856 {
optional .benchmarks.google_message4.UnusedEmptyMessage field8858 = 1;
optional string field8859 = 2;
}
message Message12908 {
optional .benchmarks.google_message4.UnusedEmptyMessage field12912 = 1;
optional string field12913 = 2;
optional .benchmarks.google_message4.Message12799 field12914 = 3;
optional int64 field12915 = 4;
optional .benchmarks.google_message4.Message3804 field12916 = 5;
optional .benchmarks.google_message4.Message12870 field12917 = 6;
}
message Message12910 {
optional .benchmarks.google_message4.UnusedEmptyMessage field12920 = 1;
optional .benchmarks.google_message4.Message12818 field12921 = 2;
repeated .benchmarks.google_message4.Message12903 field12922 = 3;
}
message Message37327 {
optional .benchmarks.google_message4.UnusedEmptyMessage field37347 = 11;
required .benchmarks.google_message4.Message37326 field37348 = 1;
optional bool field37349 = 2;
optional bool field37350 = 3;
optional bool field37351 = 4;
optional bool field37352 = 5;
optional bool field37353 = 6;
optional .benchmarks.google_message4.UnusedEmptyMessage field37354 = 7;
optional uint64 field37355 = 8;
optional bool field37356 = 9;
optional bool field37357 = 10;
}
message Message37329 {
optional .benchmarks.google_message4.UnusedEmptyMessage field37359 = 6;
required .benchmarks.google_message4.Message37326 field37360 = 1;
required int64 field37361 = 2;
required int64 field37362 = 3;
optional bool field37363 = 4;
}
message Message2517 {
optional .benchmarks.google_message4.UnusedEmptyMessage field2519 = 1;
optional .benchmarks.google_message4.Message2356 field2520 = 2;
optional .benchmarks.google_message4.Message0 field2521 = 3;
optional .benchmarks.google_message4.Message2463 field2522 = 4;
repeated .benchmarks.google_message4.Message971 field2523 = 5;
}
message Message12748 {
optional .benchmarks.google_message4.UnusedEmptyMessage field12754 = 1;
optional string field12755 = 2;
optional string field12756 = 3;
optional .benchmarks.google_message4.Enum12735 field12757 = 4;
}
message Message12687 {
repeated .benchmarks.google_message4.Message12686 field12701 = 1;
}
message Message11948 {
optional string field11954 = 1;
repeated .benchmarks.google_message4.Message11949 field11955 = 2;
optional bool field11956 = 3;
}
message Message11976 {
repeated .benchmarks.google_message4.Message11975 field12002 = 1;
}
message Message7320 {
optional .benchmarks.google_message4.UnusedEmptyMessage field7323 = 1;
optional .benchmarks.google_message4.Message7287 field7324 = 8;
}
message Message3069 {
optional .benchmarks.google_message4.Message3061 field3374 = 1;
optional bytes field3375 = 2;
repeated group Message3070 = 3 {
required .benchmarks.google_message4.Enum3071 field3378 = 4;
required bytes field3379 = 5;
}
extensions 10000 to 536870911;
}
message Message12948 {
repeated .benchmarks.google_message4.Message12949 field12958 = 1;
}
message Message8768 {
optional string field8782 = 1;
optional .benchmarks.google_message4.Message8572 field8783 = 2;
optional bool field8784 = 3;
repeated .benchmarks.google_message4.Message8774 field8785 = 4;
optional int64 field8786 = 5;
optional .benchmarks.google_message4.UnusedEmptyMessage field8787 = 6;
optional string field8788 = 7;
}
message Message12979 {
required bytes field12981 = 1;
repeated string field12982 = 2;
optional .benchmarks.google_message4.UnusedEmptyMessage field12983 = 3;
optional int64 field12984 = 4;
optional string field12985 = 5;
optional int32 field12986 = 6;
optional .benchmarks.google_message4.UnusedEmptyMessage field12987 = 7;
}
message Message37173 {
optional string field37252 = 1;
optional int64 field37253 = 2;
optional .benchmarks.google_message4.UnusedEnum field37254 = 4;
optional bool field37255 = 5;
optional bool field37256 = 6;
optional bool field37257 = 7;
optional string field37258 = 8;
optional string field37259 = 9;
optional uint32 field37260 = 10;
optional fixed32 field37261 = 11;
optional string field37262 = 12;
optional string field37263 = 13;
optional string field37264 = 14;
optional int32 field37265 = 15;
optional int64 field37266 = 16;
optional int64 field37267 = 17;
optional int32 field37268 = 18;
optional int32 field37269 = 19;
optional .benchmarks.google_message4.UnusedEmptyMessage field37270 = 20;
optional .benchmarks.google_message4.UnusedEmptyMessage field37271 = 21;
optional .benchmarks.google_message4.UnusedEmptyMessage field37272 = 22;
optional .benchmarks.google_message4.UnusedEmptyMessage field37273 = 23;
optional .benchmarks.google_message4.UnusedEmptyMessage field37274 = 24;
optional string field37275 = 25;
optional bool field37276 = 26;
}
message Message12799 {
required string field12809 = 1;
repeated fixed64 field12810 = 2;
repeated .benchmarks.google_message4.Message12776 field12811 = 8;
repeated int32 field12812 = 4;
repeated .benchmarks.google_message4.Message12798 field12813 = 5;
required int32 field12814 = 3;
optional int32 field12815 = 6;
optional .benchmarks.google_message4.Message12797 field12816 = 7;
}
message Message12870 {
required int32 field12879 = 1;
optional int32 field12880 = 7;
required int32 field12881 = 2;
optional uint64 field12882 = 3;
optional string field12883 = 2001;
optional fixed64 field12884 = 4;
repeated fixed64 field12885 = 14;
optional int32 field12886 = 9;
optional int64 field12887 = 18;
repeated .benchmarks.google_message4.Message12870 field12888 = 8;
optional int32 field12889 = 5;
optional uint64 field12890 = 6;
optional int32 field12891 = 10;
optional int32 field12892 = 11;
optional double field12893 = 12;
optional .benchmarks.google_message4.Message12825 field12894 = 13;
optional double field12895 = 15;
optional string field12896 = 16;
optional .benchmarks.google_message4.Enum12871 field12897 = 17;
optional int32 field12898 = 19;
}
message Message3804 {
required int64 field3818 = 1;
required bool field3819 = 2;
repeated .benchmarks.google_message4.Enum3805 field3820 = 4;
optional int32 field3821 = 5;
optional bool field3822 = 6;
optional int64 field3823 = 7;
optional .benchmarks.google_message4.Enum3783 field3824 = 8;
}
message Message12903 {
optional string field12905 = 1;
optional .benchmarks.google_message4.Message8587 field12906 = 2;
repeated .benchmarks.google_message4.Message8590 field12907 = 3;
}
message Message37326 {
required string field37345 = 1;
optional string field37346 = 2;
}
message Message2356 {
optional .benchmarks.google_message4.Message1374 field2368 = 121;
optional uint64 field2369 = 1;
optional int32 field2370 = 2;
optional int32 field2371 = 17;
required string field2372 = 3;
optional int32 field2373 = 7;
optional bytes field2374 = 8;
optional string field2375 = 4;
optional string field2376 = 101;
optional int32 field2377 = 102;
optional int32 field2378 = 103;
optional int32 field2379 = 104;
optional int32 field2380 = 113;
optional int32 field2381 = 114;
optional int32 field2382 = 115;
optional int32 field2383 = 117;
optional int32 field2384 = 118;
optional int32 field2385 = 119;
optional int32 field2386 = 105;
optional bytes field2387 = 5;
optional group Message2357 = 6 {
optional int64 field2399 = 9;
optional int32 field2400 = 10;
optional int32 field2401 = 11;
optional int32 field2402 = 12;
optional int32 field2403 = 13;
optional int32 field2404 = 116;
optional int32 field2405 = 106;
required bytes field2406 = 14;
optional int32 field2407 = 45;
optional int32 field2408 = 112;
optional bool field2409 = 122;
optional bytes field2410 = 124;
}
optional string field2389 = 120;
optional group Message2358 = 107 {}
repeated group Message2359 = 40 {}
optional int32 field2392 = 50;
optional .benchmarks.google_message4.UnusedEmptyMessage field2393 = 60;
optional .benchmarks.google_message4.UnusedEmptyMessage field2394 = 70;
optional .benchmarks.google_message4.UnusedEmptyMessage field2395 = 80;
optional .benchmarks.google_message4.UnusedEmptyMessage field2396 = 90;
optional string field2397 = 100;
optional string field2398 = 123;
}
message Message0 {
option message_set_wire_format = true;
extensions 4 to 2147483646;
}
message Message971 {
optional string field972 = 1;
optional int32 field973 = 2;
optional bool field974 = 3;
}

View File

@ -0,0 +1,500 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// LINT: ALLOW_GROUPS
syntax = "proto2";
package benchmarks.google_message4;
import "datasets/google_message4/benchmark_message4_2.proto";
import "datasets/google_message4/benchmark_message4_3.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message2463 {
repeated .benchmarks.google_message4.Message2462 field2498 = 1;
}
message Message12686 {
optional string field12699 = 1;
optional .benchmarks.google_message4.Message12685 field12700 = 2;
}
message Message11949 {}
message Message11975 {
optional string field11992 = 1;
optional int32 field11993 = 2;
repeated .benchmarks.google_message4.Message10320 field11994 = 3;
optional .benchmarks.google_message4.Message11947 field11995 = 4;
optional .benchmarks.google_message4.Message11920 field11996 = 5;
optional bool field11997 = 6;
repeated string field11998 = 7;
optional float field11999 = 8;
repeated .benchmarks.google_message4.UnusedEnum field12000 = 9;
optional int32 field12001 = 11;
}
message Message7287 {
optional .benchmarks.google_message4.Message6133 field7311 = 1;
optional .benchmarks.google_message4.UnusedEmptyMessage field7312 = 8;
optional string field7313 = 3;
optional .benchmarks.google_message4.Message6643 field7314 = 4;
optional .benchmarks.google_message4.Enum7288 field7315 = 5;
optional bytes field7316 = 6;
optional .benchmarks.google_message4.UnusedEmptyMessage field7317 = 7;
optional .benchmarks.google_message4.UnusedEmptyMessage field7318 = 9;
}
message Message3061 {
optional string field3286 = 2;
optional int32 field3287 = 77;
optional string field3288 = 49;
required .benchmarks.google_message4.Message3046 field3289 = 3;
optional .benchmarks.google_message4.Message3046 field3290 = 58;
optional group Message3062 = 4 {
required int32 field3335 = 5;
optional int32 field3336 = 6;
optional int32 field3337 = 7;
}
optional .benchmarks.google_message4.Message3060 field3292 = 104;
optional int64 field3293 = 32;
optional int32 field3294 = 41;
optional group Message3063 = 13 {
required int32 field3338 = 14;
optional .benchmarks.google_message4.Enum2851 field3339 = 18;
optional int64 field3340 = 15;
optional int64 field3341 = 23;
}
optional .benchmarks.google_message4.Enum2834 field3296 = 94;
optional bool field3297 = 25;
optional bool field3298 = 50;
optional string field3299 = 89;
optional string field3300 = 91;
optional string field3301 = 105;
optional .benchmarks.google_message4.Message3050 field3302 = 53;
optional fixed64 field3303 = 51;
optional fixed64 field3304 = 106;
optional int32 field3305 = 60;
optional string field3306 = 44;
optional bytes field3307 = 81;
optional string field3308 = 70;
optional bytes field3309 = 45;
optional .benchmarks.google_message4.Enum2806 field3310 = 71;
optional int32 field3311 = 72;
optional bytes field3312 = 78;
optional int32 field3313 = 20;
repeated group Message3064 = 8 {
required .benchmarks.google_message4.Enum2602 field3342 = 9;
optional int32 field3343 = 92;
optional string field3344 = 10;
optional bytes field3345 = 11;
optional int32 field3346 = 12;
optional .benchmarks.google_message4.Message3060 field3347 = 98;
optional .benchmarks.google_message4.UnusedEmptyMessage field3348 = 82;
optional .benchmarks.google_message4.Message3050 field3349 = 80;
optional fixed64 field3350 = 52;
optional int32 field3351 = 33;
optional string field3352 = 42;
optional string field3353 = 69;
optional bytes field3354 = 43;
optional .benchmarks.google_message4.Enum2806 field3355 = 73;
optional int32 field3356 = 74;
optional int32 field3357 = 90;
optional bytes field3358 = 79;
optional int32 field3359 = 19;
optional .benchmarks.google_message4.Enum2834 field3360 = 95;
}
optional .benchmarks.google_message4.UnusedEmptyMessage field3315 = 39;
optional int32 field3316 = 76;
optional group Message3065 = 63 {}
optional .benchmarks.google_message4.Enum2806 field3318 = 54;
optional int32 field3319 = 46;
repeated string field3320 = 24;
optional fixed32 field3321 = 38;
optional bytes field3322 = 99;
optional fixed64 field3323 = 1;
optional fixed64 field3324 = 97;
repeated .benchmarks.google_message4.Message3040 field3325 = 16;
repeated .benchmarks.google_message4.Message3041 field3326 = 61;
optional group Message3066 = 21 {
optional int32 field3366 = 22;
optional int32 field3367 = 55;
optional int32 field3368 = 88;
optional int32 field3369 = 56;
optional int32 field3370 = 75;
optional int32 field3371 = 57;
optional .benchmarks.google_message4.UnusedEmptyMessage field3372 = 85;
optional .benchmarks.google_message4.UnusedEmptyMessage field3373 = 96;
}
optional .benchmarks.google_message4.UnusedEmptyMessage field3328 = 47;
optional .benchmarks.google_message4.UnusedEmptyMessage field3329 = 48;
optional fixed64 field3330 = 40;
optional .benchmarks.google_message4.UnusedEmptyMessage field3331 = 86;
optional .benchmarks.google_message4.UnusedEmptyMessage field3332 = 59;
optional int32 field3333 = 17;
}
message Message12949 {}
message Message8572 {
optional bytes field8647 = 1;
optional bytes field8648 = 3;
optional .benchmarks.google_message4.Message3886 field8649 = 4;
optional .benchmarks.google_message4.Message3919 field8650 = 57;
optional bool field8651 = 5;
optional int32 field8652 = 6;
optional int32 field8653 = 49;
optional .benchmarks.google_message4.Message7905 field8654 = 7;
optional int32 field8655 = 10;
optional .benchmarks.google_message4.UnusedEmptyMessage field8656 = 11;
optional bool field8657 = 35;
optional bytes field8658 = 12;
optional string field8659 = 14;
optional .benchmarks.google_message4.UnusedEmptyMessage field8660 = 13;
optional bytes field8661 = 15;
optional .benchmarks.google_message4.UnusedEmptyMessage field8662 = 17;
optional int32 field8663 = 18;
optional int32 field8664 = 19;
optional bool field8665 = 20;
optional .benchmarks.google_message4.Enum3476 field8666 = 31;
optional bool field8667 = 36;
optional .benchmarks.google_message4.UnusedEmptyMessage field8668 = 39;
optional bytes field8669 = 22;
optional int32 field8670 = 24;
optional .benchmarks.google_message4.Message3052 field8671 = 25;
optional bytes field8672 = 26;
optional bytes field8673 = 28;
optional int32 field8674 = 29;
optional bytes field8675 = 30;
optional bytes field8676 = 32;
optional string field8677 = 33;
optional int32 field8678 = 34;
optional int32 field8679 = 37;
optional double field8680 = 38;
optional double field8681 = 42;
optional .benchmarks.google_message4.Message3922 field8682 = 40;
optional .benchmarks.google_message4.UnusedEmptyMessage field8683 = 43;
optional int64 field8684 = 44;
optional .benchmarks.google_message4.Message7929 field8685 = 45;
optional uint64 field8686 = 46;
optional uint32 field8687 = 48;
optional .benchmarks.google_message4.Message7843 field8688 = 47;
optional .benchmarks.google_message4.Message7864 field8689 = 50;
optional .benchmarks.google_message4.UnusedEmptyMessage field8690 = 52;
optional bool field8691 = 58;
optional bool field8692 = 54;
optional string field8693 = 55;
optional .benchmarks.google_message4.UnusedEmptyMessage field8694 = 41;
optional .benchmarks.google_message4.UnusedEmptyMessage field8695 = 53;
optional .benchmarks.google_message4.Message8575 field8696 = 61;
}
message Message8774 {
optional string field8810 = 1;
optional string field8811 = 2;
optional string field8812 = 3;
optional string field8813 = 4;
optional string field8814 = 5;
}
message Message12776 {
optional string field12786 = 1;
optional fixed64 field12787 = 11;
optional int32 field12788 = 6;
optional int32 field12789 = 13;
optional int32 field12790 = 14;
optional int32 field12791 = 15;
optional int32 field12792 = 16;
optional .benchmarks.google_message4.UnusedEmptyMessage field12793 = 8;
optional .benchmarks.google_message4.Message12774 field12794 = 10;
optional .benchmarks.google_message4.UnusedEmptyMessage field12795 = 12;
extensions 2 to 2;
extensions 3 to 3;
extensions 4 to 4;
extensions 5 to 5;
extensions 7 to 7;
extensions 9 to 9;
}
message Message12798 {
optional int32 field12805 = 1;
optional int32 field12806 = 2;
optional .benchmarks.google_message4.Message12774 field12807 = 6;
optional bool field12808 = 7;
}
message Message12797 {
optional .benchmarks.google_message4.Message12796 field12802 = 1;
repeated .benchmarks.google_message4.Message12796 field12803 = 2;
optional string field12804 = 3;
}
message Message12825 {
repeated .benchmarks.google_message4.Message12818 field12862 = 1;
optional int32 field12863 = 2;
optional .benchmarks.google_message4.Message12819 field12864 = 3;
optional .benchmarks.google_message4.Message12820 field12865 = 4;
optional int32 field12866 = 5;
repeated .benchmarks.google_message4.Message12821 field12867 = 6;
repeated .benchmarks.google_message4.UnusedEmptyMessage field12868 = 7;
}
message Message8590 {}
message Message8587 {}
message Message1374 {
required string field1375 = 1;
optional string field1376 = 2;
}
message Message2462 {
required bytes field2496 = 1;
required double field2497 = 2;
}
message Message12685 {
repeated string field12692 = 1;
repeated string field12693 = 2;
optional int64 field12694 = 3;
optional uint32 field12695 = 4;
repeated string field12696 = 5;
optional string field12697 = 6;
optional string field12698 = 7;
}
message Message10320 {
optional .benchmarks.google_message4.Enum10335 field10347 = 1;
repeated .benchmarks.google_message4.Message10319 field10348 = 2;
optional int32 field10349 = 3;
optional int32 field10350 = 4;
optional int32 field10351 = 5;
optional int32 field10352 = 6;
optional .benchmarks.google_message4.Enum10337 field10353 = 7;
}
message Message11947 {
optional uint32 field11951 = 1;
optional bool field11952 = 2;
optional int32 field11953 = 3;
}
message Message11920 {
optional .benchmarks.google_message4.Enum11901 field11945 = 1;
optional .benchmarks.google_message4.UnusedEnum field11946 = 2;
}
message Message6643 {
optional .benchmarks.google_message4.UnusedEmptyMessage field6683 = 3;
optional .benchmarks.google_message4.UnusedEmptyMessage field6684 = 4;
optional double field6685 = 5;
optional double field6686 = 6;
optional int32 field6687 = 1;
optional int32 field6688 = 2;
optional double field6689 = 9;
optional bytes field6690 = 10;
optional int32 field6691 = 11;
optional bool field6692 = 12;
optional bool field6693 = 13;
optional .benchmarks.google_message4.Message6578 field6694 = 15;
optional .benchmarks.google_message4.UnusedEnum field6695 = 16;
optional int64 field6696 = 17;
repeated .benchmarks.google_message4.UnusedEmptyMessage field6697 = 22;
optional .benchmarks.google_message4.UnusedEmptyMessage field6698 = 19;
optional .benchmarks.google_message4.UnusedEmptyMessage field6699 = 20;
optional int32 field6700 = 21;
}
message Message6133 {
optional .benchmarks.google_message4.Message4016 field6173 = 12;
optional double field6174 = 16;
required string field6175 = 1;
required string field6176 = 2;
required string field6177 = 3;
optional string field6178 = 4;
optional string field6179 = 8;
repeated .benchmarks.google_message4.Message6109 field6180 = 5;
repeated .benchmarks.google_message4.Message5908 field6181 = 13;
repeated .benchmarks.google_message4.Message6107 field6182 = 7;
repeated .benchmarks.google_message4.Message6126 field6183 = 9;
repeated .benchmarks.google_message4.Message6129 field6184 = 15;
optional int32 field6185 = 10;
optional int32 field6186 = 11;
optional .benchmarks.google_message4.Message4016 field6187 = 17;
optional double field6188 = 14;
optional double field6189 = 18;
optional string field6190 = 19;
optional string field6191 = 20;
repeated .benchmarks.google_message4.Message5881 field6192 = 21;
}
message Message6109 {
optional string field6140 = 1;
required .benchmarks.google_message4.Enum6111 field6141 = 2;
optional int32 field6142 = 9;
optional string field6143 = 3;
repeated .benchmarks.google_message4.Message6110 field6144 = 4;
repeated int32 field6145 = 7;
repeated int32 field6146 = 8;
optional .benchmarks.google_message4.Message6133 field6147 = 10;
repeated int32 field6148 = 11;
optional string field6149 = 12;
optional string field6150 = 13;
optional bool field6151 = 14;
extensions 1000 to 536870911;
}
message Message3046 {
required .benchmarks.google_message4.Enum2593 field3222 = 1;
optional int32 field3223 = 4;
}
message Message3060 {
optional int64 field3283 = 1;
optional int64 field3284 = 2;
optional int64 field3285 = 3;
}
message Message3041 {
optional string field3214 = 1;
optional int32 field3215 = 2;
}
message Message3040 {
required fixed64 field3209 = 1;
repeated fixed64 field3210 = 4;
optional int32 field3211 = 5;
optional fixed64 field3212 = 2;
required string field3213 = 3;
}
message Message3050 {
optional bytes field3245 = 5;
optional int32 field3246 = 2;
optional bytes field3247 = 6;
optional int32 field3248 = 4;
optional fixed32 field3249 = 1;
optional fixed32 field3250 = 3;
}
message Message7905 {
optional int32 field7911 = 1;
optional bool field7912 = 2;
optional bytes field7913 = 3;
optional int32 field7914 = 4;
optional int32 field7915 = 5;
optional bytes field7916 = 6;
optional int32 field7917 = 7;
}
message Message3886 {
repeated group Message3887 = 1 {
required string field3932 = 2;
optional string field3933 = 9;
optional .benchmarks.google_message4.Message3850 field3934 = 3;
optional bytes field3935 = 8;
}
}
message Message7864 {
optional string field7866 = 1;
optional string field7867 = 2;
repeated .benchmarks.google_message4.Message7865 field7868 = 5;
repeated .benchmarks.google_message4.Message7865 field7869 = 6;
repeated .benchmarks.google_message4.Message7865 field7870 = 7;
repeated .benchmarks.google_message4.UnusedEmptyMessage field7871 = 8;
}
message Message3922 {
optional uint64 field4012 = 1;
}
message Message3052 {
repeated string field3254 = 1;
repeated string field3255 = 2;
repeated bytes field3256 = 3;
repeated string field3257 = 4;
optional bool field3258 = 5;
optional int32 field3259 = 6;
optional int32 field3260 = 7;
optional string field3261 = 8;
optional string field3262 = 9;
}
message Message8575 {}
message Message7843 {
optional bool field7844 = 5;
optional int32 field7845 = 1;
optional .benchmarks.google_message4.UnusedEmptyMessage field7846 = 22;
repeated int32 field7847 = 3;
repeated string field7848 = 11;
optional .benchmarks.google_message4.UnusedEnum field7849 = 15;
optional .benchmarks.google_message4.UnusedEmptyMessage field7850 = 6;
optional .benchmarks.google_message4.UnusedEmptyMessage field7851 = 14;
optional .benchmarks.google_message4.UnusedEmptyMessage field7852 = 10;
optional .benchmarks.google_message4.Message7511 field7853 = 13;
optional .benchmarks.google_message4.UnusedEmptyMessage field7854 = 16;
optional .benchmarks.google_message4.UnusedEmptyMessage field7855 = 17;
optional .benchmarks.google_message4.UnusedEmptyMessage field7856 = 19;
optional .benchmarks.google_message4.UnusedEmptyMessage field7857 = 18;
optional .benchmarks.google_message4.UnusedEnum field7858 = 20;
optional int32 field7859 = 2;
}
message Message3919 {
repeated .benchmarks.google_message4.Message3920 field4009 = 1;
}
message Message7929 {
optional int64 field7942 = 1;
optional int64 field7943 = 4;
optional int64 field7944 = 5;
optional int64 field7945 = 12;
optional int64 field7946 = 13;
optional int64 field7947 = 18;
optional int64 field7948 = 6;
optional int64 field7949 = 7;
repeated .benchmarks.google_message4.Message7919 field7950 = 8;
repeated .benchmarks.google_message4.UnusedEmptyMessage field7951 = 20;
repeated .benchmarks.google_message4.Message7920 field7952 = 14;
repeated .benchmarks.google_message4.Message7921 field7953 = 15;
repeated .benchmarks.google_message4.Message7928 field7954 = 17;
optional int64 field7955 = 19;
optional bool field7956 = 2;
optional int64 field7957 = 3;
optional int64 field7958 = 9;
repeated .benchmarks.google_message4.UnusedEmptyMessage field7959 = 10;
repeated bytes field7960 = 11;
optional int64 field7961 = 16;
}

View File

@ -0,0 +1,316 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package benchmarks.google_message4;
import "datasets/google_message4/benchmark_message4_3.proto";
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
message Message12774 {
optional uint32 field12777 = 1;
optional uint32 field12778 = 2;
optional uint32 field12779 = 3;
optional uint32 field12780 = 4;
optional uint32 field12781 = 5;
optional bool field12782 = 6;
}
message Message12796 {
repeated fixed64 field12800 = 1;
optional uint64 field12801 = 2;
}
message Message12821 {
optional int32 field12848 = 1;
optional int32 field12849 = 2;
optional int32 field12850 = 3;
optional int32 field12851 = 4;
optional int32 field12852 = 5;
}
message Message12820 {
optional int32 field12840 = 1;
optional int32 field12841 = 2;
optional int32 field12842 = 3;
optional int32 field12843 = 8;
optional int32 field12844 = 4;
optional int32 field12845 = 5;
optional int32 field12846 = 6;
optional int32 field12847 = 7;
}
message Message12819 {
optional double field12834 = 1;
optional double field12835 = 2;
optional double field12836 = 3;
optional double field12837 = 4;
optional double field12838 = 5;
optional double field12839 = 6;
}
message Message12818 {
optional uint64 field12829 = 1;
optional int32 field12830 = 2;
optional int32 field12831 = 3;
optional int32 field12832 = 5;
repeated .benchmarks.google_message4.Message12817 field12833 = 4;
}
message Message10319 {
optional .benchmarks.google_message4.Enum10325 field10340 = 1;
optional int32 field10341 = 4;
optional int32 field10342 = 5;
optional bytes field10343 = 3;
optional string field10344 = 2;
optional string field10345 = 6;
optional string field10346 = 7;
}
message Message6578 {
optional .benchmarks.google_message4.Enum6579 field6632 = 1;
optional .benchmarks.google_message4.Enum6588 field6633 = 2;
}
message Message6126 {
required string field6152 = 1;
repeated .benchmarks.google_message4.Message6127 field6153 = 9;
optional int32 field6154 = 14;
optional bytes field6155 = 10;
optional .benchmarks.google_message4.Message6024 field6156 = 12;
optional int32 field6157 = 4;
optional string field6158 = 5;
optional int32 field6159 = 6;
repeated int32 field6160 = 2;
repeated int32 field6161 = 3;
repeated .benchmarks.google_message4.Message6052 field6162 = 7;
repeated .benchmarks.google_message4.UnusedEmptyMessage field6163 = 11;
optional .benchmarks.google_message4.Enum6065 field6164 = 15;
repeated .benchmarks.google_message4.Message6127 field6165 = 8;
optional bool field6166 = 13;
optional bool field6167 = 16;
optional bool field6168 = 18;
repeated .benchmarks.google_message4.Message6054 field6169 = 17;
optional int32 field6170 = 19;
}
message Message5881 {
required double field5897 = 1;
optional string field5898 = 5;
optional .benchmarks.google_message4.Message5861 field5899 = 2;
optional .benchmarks.google_message4.UnusedEmptyMessage field5900 = 3;
optional .benchmarks.google_message4.Message5867 field5901 = 4;
optional .benchmarks.google_message4.Message5880 field5902 = 6;
}
message Message6110 {}
message Message6107 {
optional .benchmarks.google_message4.Message4016 field6134 = 1;
optional int32 field6135 = 2;
optional string field6136 = 3;
repeated int32 field6137 = 4;
optional int32 field6138 = 5;
repeated .benchmarks.google_message4.Message6108 field6139 = 6;
}
message Message6129 {
required .benchmarks.google_message4.Enum6130 field6171 = 1;
required string field6172 = 2;
}
message Message5908 {
optional string field5971 = 1;
optional int32 field5972 = 2;
optional int32 field5973 = 3;
optional .benchmarks.google_message4.Enum5909 field5974 = 45;
optional .benchmarks.google_message4.Enum5912 field5975 = 4;
optional fixed32 field5976 = 50;
optional fixed32 field5977 = 5;
optional fixed32 field5978 = 6;
optional string field5979 = 7;
optional .benchmarks.google_message4.Enum5915 field5980 = 8;
optional .benchmarks.google_message4.Message5903 field5981 = 9;
optional .benchmarks.google_message4.Message5903 field5982 = 10;
optional .benchmarks.google_message4.Enum5920 field5983 = 11;
optional .benchmarks.google_message4.Enum5923 field5984 = 40;
optional .benchmarks.google_message4.Message5903 field5985 = 41;
optional .benchmarks.google_message4.Message5903 field5986 = 42;
optional .benchmarks.google_message4.Enum5928 field5987 = 47;
optional bool field5988 = 48;
repeated fixed32 field5989 = 49;
optional string field5990 = 12;
optional .benchmarks.google_message4.Message5903 field5991 = 13;
optional .benchmarks.google_message4.Message5903 field5992 = 14;
optional .benchmarks.google_message4.Message5903 field5993 = 15;
optional .benchmarks.google_message4.Message5903 field5994 = 16;
optional .benchmarks.google_message4.Message5903 field5995 = 32;
optional .benchmarks.google_message4.Message5903 field5996 = 33;
optional .benchmarks.google_message4.Message5903 field5997 = 34;
optional .benchmarks.google_message4.Message5903 field5998 = 35;
optional .benchmarks.google_message4.Enum5931 field5999 = 17;
optional .benchmarks.google_message4.Enum5935 field6000 = 18;
optional .benchmarks.google_message4.Enum5939 field6001 = 36;
optional .benchmarks.google_message4.Enum5939 field6002 = 37;
repeated int32 field6003 = 19;
optional uint32 field6004 = 20;
optional uint32 field6005 = 21;
optional uint32 field6006 = 22;
optional uint32 field6007 = 23;
optional .benchmarks.google_message4.Enum5946 field6008 = 24;
optional .benchmarks.google_message4.Enum5946 field6009 = 25;
optional .benchmarks.google_message4.Enum5946 field6010 = 26;
optional .benchmarks.google_message4.Enum5946 field6011 = 27;
optional fixed32 field6012 = 28;
optional fixed32 field6013 = 29;
optional fixed32 field6014 = 30;
optional fixed32 field6015 = 31;
optional int32 field6016 = 38;
optional float field6017 = 39;
optional .benchmarks.google_message4.Enum5957 field6018 = 43;
optional .benchmarks.google_message4.Message5907 field6019 = 44;
optional .benchmarks.google_message4.Enum5962 field6020 = 46;
}
message Message3850 {
optional .benchmarks.google_message4.Enum3851 field3924 = 2;
optional bool field3925 = 12;
optional int32 field3926 = 4;
optional bool field3927 = 10;
optional bool field3928 = 13;
optional bool field3929 = 14;
}
message Message7865 {}
message Message7511 {
optional bool field7523 = 1;
optional .benchmarks.google_message4.Enum7512 field7524 = 2;
optional int32 field7525 = 3;
optional int32 field7526 = 4;
optional bool field7527 = 5;
optional int32 field7528 = 6;
optional int32 field7529 = 7;
}
message Message3920 {}
message Message7928 {
optional string field7940 = 1;
optional int64 field7941 = 2;
}
message Message7921 {
optional int32 field7936 = 1;
optional int64 field7937 = 2;
optional float field7938 = 3;
optional .benchmarks.google_message4.Enum7922 field7939 = 4;
}
message Message7920 {
optional int64 field7934 = 1;
optional int64 field7935 = 2;
}
message Message7919 {
optional fixed64 field7931 = 1;
optional int64 field7932 = 2;
optional bytes field7933 = 3;
}
message Message12817 {
optional int32 field12826 = 1;
optional int32 field12827 = 2;
optional int32 field12828 = 3;
}
message Message6054 {
required string field6089 = 1;
optional string field6090 = 2;
}
message Message6127 {}
message Message6052 {
required string field6084 = 1;
required bytes field6085 = 2;
}
message Message6024 {
optional .benchmarks.google_message4.Enum6025 field6048 = 1;
optional string field6049 = 2;
optional .benchmarks.google_message4.UnusedEmptyMessage field6050 = 3;
}
message Message5861 {
required .benchmarks.google_message4.Enum5862 field5882 = 1;
required string field5883 = 2;
optional bool field5884 = 3;
optional string field5885 = 4;
}
message Message5880 {
optional string field5896 = 1;
}
message Message5867 {
optional .benchmarks.google_message4.Enum5868 field5890 = 1;
optional string field5891 = 2;
optional .benchmarks.google_message4.Enum5873 field5892 = 3;
optional int32 field5893 = 4;
optional .benchmarks.google_message4.UnusedEnum field5894 = 5;
optional bool field5895 = 6;
}
message Message4016 {
required int32 field4017 = 1;
required int32 field4018 = 2;
required int32 field4019 = 3;
required int32 field4020 = 4;
}
message Message6108 {}
message Message5907 {
optional .benchmarks.google_message4.Message5903 field5967 = 1;
optional .benchmarks.google_message4.Message5903 field5968 = 2;
optional .benchmarks.google_message4.Message5903 field5969 = 3;
optional .benchmarks.google_message4.Message5903 field5970 = 4;
}
message UnusedEmptyMessage {}
message Message5903 {
required int32 field5965 = 1;
optional .benchmarks.google_message4.Enum5904 field5966 = 2;
}

View File

@ -0,0 +1,779 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package benchmarks.google_message4;
option cc_enable_arenas = true;
option java_package = "com.google.protobuf.benchmarks";
enum UnusedEnum {
UNUSED_ENUM_VALUE1 = 0;
UNUSED_ENUM_VALUE2 = 1;
}
enum Enum2593 {
ENUM_VALUE2594 = 0;
ENUM_VALUE2595 = 1;
ENUM_VALUE2596 = 2;
ENUM_VALUE2597 = 3;
ENUM_VALUE2598 = 4;
ENUM_VALUE2599 = 5;
ENUM_VALUE2600 = 6;
ENUM_VALUE2601 = 7;
}
enum Enum2834 {
ENUM_VALUE2835 = 0;
ENUM_VALUE2836 = 1;
ENUM_VALUE2837 = 2;
}
enum Enum2806 {
ENUM_VALUE2807 = 0;
ENUM_VALUE2808 = 1;
ENUM_VALUE2809 = 2;
ENUM_VALUE2810 = 3;
ENUM_VALUE2811 = 4;
ENUM_VALUE2812 = 5;
ENUM_VALUE2813 = 6;
ENUM_VALUE2814 = 7;
ENUM_VALUE2815 = 8;
ENUM_VALUE2816 = 9;
ENUM_VALUE2817 = 10;
ENUM_VALUE2818 = 11;
ENUM_VALUE2819 = 12;
ENUM_VALUE2820 = 13;
ENUM_VALUE2821 = 14;
}
enum Enum2851 {
option allow_alias = true;
ENUM_VALUE2852 = 0;
ENUM_VALUE2853 = 0;
ENUM_VALUE2854 = 1;
ENUM_VALUE2855 = 2;
ENUM_VALUE2856 = 3;
ENUM_VALUE2857 = 4;
ENUM_VALUE2858 = 5;
ENUM_VALUE2859 = 6;
ENUM_VALUE2860 = 7;
ENUM_VALUE2861 = 8;
ENUM_VALUE2862 = 9;
ENUM_VALUE2863 = 10;
ENUM_VALUE2864 = 11;
ENUM_VALUE2865 = 12;
ENUM_VALUE2866 = 13;
ENUM_VALUE2867 = 14;
ENUM_VALUE2868 = 15;
ENUM_VALUE2869 = 16;
ENUM_VALUE2870 = 17;
ENUM_VALUE2871 = 18;
ENUM_VALUE2872 = 19;
ENUM_VALUE2873 = 20;
ENUM_VALUE2874 = 21;
ENUM_VALUE2875 = 22;
ENUM_VALUE2876 = 23;
ENUM_VALUE2877 = 24;
ENUM_VALUE2878 = 25;
ENUM_VALUE2879 = 26;
ENUM_VALUE2880 = 27;
ENUM_VALUE2881 = 28;
ENUM_VALUE2882 = 29;
ENUM_VALUE2883 = 30;
ENUM_VALUE2884 = 31;
ENUM_VALUE2885 = 32;
ENUM_VALUE2886 = 33;
ENUM_VALUE2887 = 34;
ENUM_VALUE2888 = 35;
ENUM_VALUE2889 = 36;
ENUM_VALUE2890 = 37;
ENUM_VALUE2891 = 38;
ENUM_VALUE2892 = 39;
ENUM_VALUE2893 = 40;
ENUM_VALUE2894 = 41;
ENUM_VALUE2895 = 42;
ENUM_VALUE2896 = 43;
ENUM_VALUE2897 = 44;
ENUM_VALUE2898 = 45;
ENUM_VALUE2899 = 46;
ENUM_VALUE2900 = 47;
ENUM_VALUE2901 = 48;
ENUM_VALUE2902 = 49;
ENUM_VALUE2903 = 50;
ENUM_VALUE2904 = 51;
ENUM_VALUE2905 = 52;
ENUM_VALUE2906 = 53;
ENUM_VALUE2907 = 54;
ENUM_VALUE2908 = 55;
ENUM_VALUE2909 = 56;
ENUM_VALUE2910 = 57;
ENUM_VALUE2911 = 58;
ENUM_VALUE2912 = 59;
ENUM_VALUE2913 = 60;
ENUM_VALUE2914 = 61;
ENUM_VALUE2915 = 62;
ENUM_VALUE2916 = 63;
ENUM_VALUE2917 = 64;
ENUM_VALUE2918 = 65;
ENUM_VALUE2919 = 66;
ENUM_VALUE2920 = 67;
ENUM_VALUE2921 = 68;
ENUM_VALUE2922 = 69;
ENUM_VALUE2923 = 70;
ENUM_VALUE2924 = 71;
ENUM_VALUE2925 = 72;
ENUM_VALUE2926 = 73;
ENUM_VALUE2927 = 74;
ENUM_VALUE2928 = 75;
ENUM_VALUE2929 = 76;
ENUM_VALUE2930 = 77;
ENUM_VALUE2931 = 78;
ENUM_VALUE2932 = 79;
ENUM_VALUE2933 = 80;
ENUM_VALUE2934 = 81;
ENUM_VALUE2935 = 82;
ENUM_VALUE2936 = 83;
ENUM_VALUE2937 = 84;
ENUM_VALUE2938 = 85;
ENUM_VALUE2939 = 86;
ENUM_VALUE2940 = 87;
ENUM_VALUE2941 = 88;
ENUM_VALUE2942 = 89;
ENUM_VALUE2943 = 90;
ENUM_VALUE2944 = 91;
ENUM_VALUE2945 = 92;
ENUM_VALUE2946 = 93;
ENUM_VALUE2947 = 94;
ENUM_VALUE2948 = 95;
ENUM_VALUE2949 = 96;
ENUM_VALUE2950 = 97;
ENUM_VALUE2951 = 98;
ENUM_VALUE2952 = 99;
ENUM_VALUE2953 = 100;
ENUM_VALUE2954 = 101;
ENUM_VALUE2955 = 102;
ENUM_VALUE2956 = 103;
ENUM_VALUE2957 = 104;
ENUM_VALUE2958 = 105;
ENUM_VALUE2959 = 106;
ENUM_VALUE2960 = 107;
ENUM_VALUE2961 = 108;
ENUM_VALUE2962 = 109;
ENUM_VALUE2963 = 110;
ENUM_VALUE2964 = 111;
ENUM_VALUE2965 = 112;
ENUM_VALUE2966 = 113;
ENUM_VALUE2967 = 114;
ENUM_VALUE2968 = 115;
ENUM_VALUE2969 = 116;
ENUM_VALUE2970 = 117;
ENUM_VALUE2971 = 118;
ENUM_VALUE2972 = 119;
}
enum Enum2602 {
ENUM_VALUE2603 = 0;
ENUM_VALUE2604 = 1;
ENUM_VALUE2605 = 2;
ENUM_VALUE2606 = 3;
ENUM_VALUE2607 = 4;
ENUM_VALUE2608 = 5;
ENUM_VALUE2609 = 6;
ENUM_VALUE2610 = 7;
ENUM_VALUE2611 = 8;
ENUM_VALUE2612 = 9;
ENUM_VALUE2613 = 10;
ENUM_VALUE2614 = 11;
}
enum Enum3071 {
ENUM_VALUE3072 = 1;
ENUM_VALUE3073 = 2;
ENUM_VALUE3074 = 3;
ENUM_VALUE3075 = 4;
ENUM_VALUE3076 = 5;
ENUM_VALUE3077 = 6;
ENUM_VALUE3078 = 7;
ENUM_VALUE3079 = 8;
ENUM_VALUE3080 = 9;
ENUM_VALUE3081 = 10;
ENUM_VALUE3082 = 11;
ENUM_VALUE3083 = 12;
ENUM_VALUE3084 = 13;
ENUM_VALUE3085 = 14;
ENUM_VALUE3086 = 15;
ENUM_VALUE3087 = 16;
ENUM_VALUE3088 = 17;
ENUM_VALUE3089 = 18;
ENUM_VALUE3090 = 19;
ENUM_VALUE3091 = 20;
ENUM_VALUE3092 = 21;
ENUM_VALUE3093 = 22;
ENUM_VALUE3094 = 23;
ENUM_VALUE3095 = 24;
ENUM_VALUE3096 = 25;
ENUM_VALUE3097 = 26;
ENUM_VALUE3098 = 27;
ENUM_VALUE3099 = 28;
}
enum Enum3805 {
ENUM_VALUE3806 = 0;
ENUM_VALUE3807 = 1;
ENUM_VALUE3808 = 2;
ENUM_VALUE3809 = 3;
ENUM_VALUE3810 = 4;
ENUM_VALUE3811 = 5;
ENUM_VALUE3812 = 6;
ENUM_VALUE3813 = 7;
ENUM_VALUE3814 = 8;
ENUM_VALUE3815 = 9;
ENUM_VALUE3816 = 11;
ENUM_VALUE3817 = 10;
}
enum Enum3783 {
ENUM_VALUE3784 = 0;
ENUM_VALUE3785 = 1;
ENUM_VALUE3786 = 2;
ENUM_VALUE3787 = 3;
ENUM_VALUE3788 = 4;
ENUM_VALUE3789 = 5;
ENUM_VALUE3790 = 6;
ENUM_VALUE3791 = 7;
ENUM_VALUE3792 = 8;
ENUM_VALUE3793 = 9;
ENUM_VALUE3794 = 10;
ENUM_VALUE3795 = 11;
ENUM_VALUE3796 = 12;
ENUM_VALUE3797 = 13;
ENUM_VALUE3798 = 14;
ENUM_VALUE3799 = 15;
ENUM_VALUE3800 = 16;
ENUM_VALUE3801 = 20;
ENUM_VALUE3802 = 21;
ENUM_VALUE3803 = 50;
}
enum Enum3851 {
ENUM_VALUE3852 = 0;
ENUM_VALUE3853 = 1;
ENUM_VALUE3854 = 2;
ENUM_VALUE3855 = 3;
ENUM_VALUE3856 = 4;
ENUM_VALUE3857 = 5;
ENUM_VALUE3858 = 6;
ENUM_VALUE3859 = 7;
ENUM_VALUE3860 = 8;
ENUM_VALUE3861 = 9;
ENUM_VALUE3862 = 10;
ENUM_VALUE3863 = 11;
ENUM_VALUE3864 = 12;
ENUM_VALUE3865 = 13;
ENUM_VALUE3866 = 14;
ENUM_VALUE3867 = 15;
ENUM_VALUE3868 = 16;
ENUM_VALUE3869 = 17;
}
enum Enum5862 {
ENUM_VALUE5863 = 1;
ENUM_VALUE5864 = 2;
ENUM_VALUE5865 = 3;
}
enum Enum5868 {
ENUM_VALUE5869 = 0;
ENUM_VALUE5870 = 1;
ENUM_VALUE5871 = 2;
ENUM_VALUE5872 = 3;
}
enum Enum5873 {
ENUM_VALUE5874 = 0;
ENUM_VALUE5875 = 1;
ENUM_VALUE5876 = 2;
}
enum Enum5904 {
ENUM_VALUE5905 = 0;
ENUM_VALUE5906 = 1;
}
enum Enum5909 {
ENUM_VALUE5910 = 0;
ENUM_VALUE5911 = 1;
}
enum Enum5912 {
ENUM_VALUE5913 = 0;
ENUM_VALUE5914 = 1;
}
enum Enum5915 {
ENUM_VALUE5916 = 0;
ENUM_VALUE5917 = 1;
ENUM_VALUE5918 = 2;
ENUM_VALUE5919 = 3;
}
enum Enum5920 {
ENUM_VALUE5921 = 0;
ENUM_VALUE5922 = 1;
}
enum Enum5923 {
ENUM_VALUE5924 = 0;
ENUM_VALUE5925 = 1;
ENUM_VALUE5926 = 2;
ENUM_VALUE5927 = 3;
}
enum Enum5928 {
ENUM_VALUE5929 = 0;
ENUM_VALUE5930 = 1;
}
enum Enum5931 {
ENUM_VALUE5932 = 0;
ENUM_VALUE5933 = 1;
ENUM_VALUE5934 = 2;
}
enum Enum5935 {
ENUM_VALUE5936 = 0;
ENUM_VALUE5937 = 1;
ENUM_VALUE5938 = 2;
}
enum Enum5939 {
ENUM_VALUE5940 = 0;
ENUM_VALUE5941 = 1;
ENUM_VALUE5942 = 2;
ENUM_VALUE5943 = 3;
ENUM_VALUE5944 = 4;
ENUM_VALUE5945 = 5;
}
enum Enum5946 {
ENUM_VALUE5947 = 0;
ENUM_VALUE5948 = 1;
ENUM_VALUE5949 = 2;
ENUM_VALUE5950 = 3;
ENUM_VALUE5951 = 4;
ENUM_VALUE5952 = 5;
ENUM_VALUE5953 = 6;
ENUM_VALUE5954 = 7;
ENUM_VALUE5955 = 8;
ENUM_VALUE5956 = 9;
}
enum Enum5957 {
ENUM_VALUE5958 = 0;
ENUM_VALUE5959 = 1;
ENUM_VALUE5960 = 2;
ENUM_VALUE5961 = 3;
}
enum Enum5962 {
ENUM_VALUE5963 = 0;
ENUM_VALUE5964 = 1;
}
enum Enum6025 {
ENUM_VALUE6026 = 0;
ENUM_VALUE6027 = 1;
ENUM_VALUE6028 = 2;
ENUM_VALUE6029 = 3;
ENUM_VALUE6030 = 4;
ENUM_VALUE6031 = 5;
ENUM_VALUE6032 = 6;
ENUM_VALUE6033 = 7;
ENUM_VALUE6034 = 8;
ENUM_VALUE6035 = 9;
ENUM_VALUE6036 = 10;
ENUM_VALUE6037 = 11;
ENUM_VALUE6038 = 12;
ENUM_VALUE6039 = 13;
ENUM_VALUE6040 = 14;
ENUM_VALUE6041 = 15;
ENUM_VALUE6042 = 16;
ENUM_VALUE6043 = 17;
ENUM_VALUE6044 = 18;
ENUM_VALUE6045 = 19;
ENUM_VALUE6046 = 20;
ENUM_VALUE6047 = 21;
}
enum Enum6111 {
ENUM_VALUE6112 = 1;
ENUM_VALUE6113 = 2;
ENUM_VALUE6114 = 3;
ENUM_VALUE6115 = 4;
ENUM_VALUE6116 = 5;
ENUM_VALUE6117 = 6;
ENUM_VALUE6118 = 7;
ENUM_VALUE6119 = 8;
ENUM_VALUE6120 = 9;
ENUM_VALUE6121 = 10;
ENUM_VALUE6122 = 11;
ENUM_VALUE6123 = 12;
ENUM_VALUE6124 = 13;
ENUM_VALUE6125 = 14;
}
enum Enum6065 {
ENUM_VALUE6066 = 0;
ENUM_VALUE6067 = 1;
ENUM_VALUE6068 = 2;
ENUM_VALUE6069 = 3;
ENUM_VALUE6070 = 4;
ENUM_VALUE6071 = 5;
ENUM_VALUE6072 = 6;
ENUM_VALUE6073 = 7;
ENUM_VALUE6074 = 8;
ENUM_VALUE6075 = 9;
ENUM_VALUE6076 = 10;
ENUM_VALUE6077 = 11;
ENUM_VALUE6078 = 12;
ENUM_VALUE6079 = 13;
ENUM_VALUE6080 = 14;
}
enum Enum6130 {
ENUM_VALUE6131 = 0;
ENUM_VALUE6132 = 1;
}
enum Enum6579 {
ENUM_VALUE6580 = 0;
ENUM_VALUE6581 = 2;
ENUM_VALUE6582 = 3;
ENUM_VALUE6583 = 5;
ENUM_VALUE6584 = 10;
ENUM_VALUE6585 = 15;
ENUM_VALUE6586 = 25;
ENUM_VALUE6587 = 30;
}
enum Enum6588 {
ENUM_VALUE6589 = 0;
ENUM_VALUE6590 = 1;
ENUM_VALUE6591 = 2;
ENUM_VALUE6592 = 3;
ENUM_VALUE6593 = 4;
ENUM_VALUE6594 = 5;
ENUM_VALUE6595 = 6;
ENUM_VALUE6596 = 7;
ENUM_VALUE6597 = 8;
ENUM_VALUE6598 = 9;
ENUM_VALUE6599 = 10;
ENUM_VALUE6600 = 11;
ENUM_VALUE6601 = 12;
ENUM_VALUE6602 = 13;
ENUM_VALUE6603 = 14;
ENUM_VALUE6604 = 15;
ENUM_VALUE6605 = 16;
ENUM_VALUE6606 = 17;
ENUM_VALUE6607 = 19;
ENUM_VALUE6608 = 20;
ENUM_VALUE6609 = 21;
ENUM_VALUE6610 = 22;
ENUM_VALUE6611 = 23;
ENUM_VALUE6612 = 24;
ENUM_VALUE6613 = 25;
ENUM_VALUE6614 = 26;
ENUM_VALUE6615 = 27;
ENUM_VALUE6616 = 28;
ENUM_VALUE6617 = 29;
ENUM_VALUE6618 = 30;
ENUM_VALUE6619 = 31;
ENUM_VALUE6620 = 32;
ENUM_VALUE6621 = 33;
ENUM_VALUE6622 = 34;
}
enum Enum7288 {
ENUM_VALUE7289 = 0;
ENUM_VALUE7290 = 1;
ENUM_VALUE7291 = 2;
ENUM_VALUE7292 = 3;
}
enum Enum7512 {
ENUM_VALUE7513 = 0;
ENUM_VALUE7514 = 1;
ENUM_VALUE7515 = 2;
ENUM_VALUE7516 = 3;
ENUM_VALUE7517 = 4;
ENUM_VALUE7518 = 5;
ENUM_VALUE7519 = 6;
ENUM_VALUE7520 = 7;
}
enum Enum7922 {
ENUM_VALUE7923 = 1;
ENUM_VALUE7924 = 2;
ENUM_VALUE7925 = 3;
ENUM_VALUE7926 = 4;
ENUM_VALUE7927 = 5;
}
enum Enum3476 {
ENUM_VALUE3477 = 0;
ENUM_VALUE3478 = 1;
ENUM_VALUE3479 = 2;
ENUM_VALUE3480 = 3;
ENUM_VALUE3481 = 4;
ENUM_VALUE3482 = 5;
ENUM_VALUE3483 = 6;
ENUM_VALUE3484 = 7;
ENUM_VALUE3485 = 8;
ENUM_VALUE3486 = 9;
ENUM_VALUE3487 = 10;
ENUM_VALUE3488 = 11;
ENUM_VALUE3489 = 12;
ENUM_VALUE3490 = 13;
ENUM_VALUE3491 = 14;
ENUM_VALUE3492 = 15;
ENUM_VALUE3493 = 16;
ENUM_VALUE3494 = 17;
ENUM_VALUE3495 = 18;
ENUM_VALUE3496 = 19;
ENUM_VALUE3497 = 20;
ENUM_VALUE3498 = 21;
ENUM_VALUE3499 = 22;
ENUM_VALUE3500 = 23;
ENUM_VALUE3501 = 24;
ENUM_VALUE3502 = 25;
ENUM_VALUE3503 = 26;
ENUM_VALUE3504 = 27;
ENUM_VALUE3505 = 28;
ENUM_VALUE3506 = 29;
ENUM_VALUE3507 = 30;
ENUM_VALUE3508 = 31;
ENUM_VALUE3509 = 32;
ENUM_VALUE3510 = 33;
ENUM_VALUE3511 = 34;
ENUM_VALUE3512 = 35;
ENUM_VALUE3513 = 36;
ENUM_VALUE3514 = 37;
ENUM_VALUE3515 = 38;
ENUM_VALUE3516 = 39;
ENUM_VALUE3517 = 40;
ENUM_VALUE3518 = 41;
ENUM_VALUE3519 = 42;
ENUM_VALUE3520 = 43;
ENUM_VALUE3521 = 44;
ENUM_VALUE3522 = 45;
ENUM_VALUE3523 = 46;
ENUM_VALUE3524 = 47;
ENUM_VALUE3525 = 48;
ENUM_VALUE3526 = 49;
ENUM_VALUE3527 = 50;
ENUM_VALUE3528 = 51;
ENUM_VALUE3529 = 52;
ENUM_VALUE3530 = 53;
ENUM_VALUE3531 = 54;
ENUM_VALUE3532 = 55;
ENUM_VALUE3533 = 56;
ENUM_VALUE3534 = 57;
ENUM_VALUE3535 = 58;
ENUM_VALUE3536 = 59;
ENUM_VALUE3537 = 60;
ENUM_VALUE3538 = 61;
ENUM_VALUE3539 = 62;
ENUM_VALUE3540 = 63;
ENUM_VALUE3541 = 64;
ENUM_VALUE3542 = 65;
ENUM_VALUE3543 = 66;
ENUM_VALUE3544 = 67;
ENUM_VALUE3545 = 68;
ENUM_VALUE3546 = 69;
ENUM_VALUE3547 = 70;
ENUM_VALUE3548 = 71;
ENUM_VALUE3549 = 72;
ENUM_VALUE3550 = 73;
ENUM_VALUE3551 = 74;
ENUM_VALUE3552 = 75;
ENUM_VALUE3553 = 76;
ENUM_VALUE3554 = 77;
ENUM_VALUE3555 = 78;
ENUM_VALUE3556 = 79;
ENUM_VALUE3557 = 80;
ENUM_VALUE3558 = 81;
ENUM_VALUE3559 = 82;
ENUM_VALUE3560 = 83;
ENUM_VALUE3561 = 84;
ENUM_VALUE3562 = 85;
ENUM_VALUE3563 = 86;
ENUM_VALUE3564 = 87;
ENUM_VALUE3565 = 88;
ENUM_VALUE3566 = 89;
ENUM_VALUE3567 = 90;
ENUM_VALUE3568 = 91;
ENUM_VALUE3569 = 92;
ENUM_VALUE3570 = 93;
ENUM_VALUE3571 = 94;
ENUM_VALUE3572 = 95;
ENUM_VALUE3573 = 96;
ENUM_VALUE3574 = 97;
ENUM_VALUE3575 = 98;
ENUM_VALUE3576 = 99;
ENUM_VALUE3577 = 100;
ENUM_VALUE3578 = 101;
ENUM_VALUE3579 = 102;
ENUM_VALUE3580 = 103;
ENUM_VALUE3581 = 104;
ENUM_VALUE3582 = 105;
ENUM_VALUE3583 = 106;
ENUM_VALUE3584 = 107;
ENUM_VALUE3585 = 108;
ENUM_VALUE3586 = 109;
ENUM_VALUE3587 = 110;
ENUM_VALUE3588 = 111;
ENUM_VALUE3589 = 112;
ENUM_VALUE3590 = 113;
ENUM_VALUE3591 = 114;
ENUM_VALUE3592 = 115;
ENUM_VALUE3593 = 116;
ENUM_VALUE3594 = 117;
ENUM_VALUE3595 = 118;
ENUM_VALUE3596 = 119;
ENUM_VALUE3597 = 120;
ENUM_VALUE3598 = 121;
ENUM_VALUE3599 = 122;
ENUM_VALUE3600 = 123;
ENUM_VALUE3601 = 124;
ENUM_VALUE3602 = 125;
ENUM_VALUE3603 = 126;
ENUM_VALUE3604 = 127;
ENUM_VALUE3605 = 128;
ENUM_VALUE3606 = 129;
ENUM_VALUE3607 = 130;
ENUM_VALUE3608 = 131;
ENUM_VALUE3609 = 132;
ENUM_VALUE3610 = 133;
ENUM_VALUE3611 = 134;
ENUM_VALUE3612 = 135;
ENUM_VALUE3613 = 136;
ENUM_VALUE3614 = 137;
ENUM_VALUE3615 = 138;
ENUM_VALUE3616 = 139;
ENUM_VALUE3617 = 140;
ENUM_VALUE3618 = 141;
ENUM_VALUE3619 = 142;
ENUM_VALUE3620 = 143;
ENUM_VALUE3621 = 144;
ENUM_VALUE3622 = 145;
ENUM_VALUE3623 = 146;
ENUM_VALUE3624 = 147;
ENUM_VALUE3625 = 148;
ENUM_VALUE3626 = 149;
ENUM_VALUE3627 = 150;
ENUM_VALUE3628 = 151;
ENUM_VALUE3629 = 152;
ENUM_VALUE3630 = 153;
ENUM_VALUE3631 = 154;
ENUM_VALUE3632 = 155;
ENUM_VALUE3633 = 156;
ENUM_VALUE3634 = 157;
ENUM_VALUE3635 = 158;
ENUM_VALUE3636 = 159;
ENUM_VALUE3637 = 160;
ENUM_VALUE3638 = 161;
ENUM_VALUE3639 = 162;
ENUM_VALUE3640 = 163;
ENUM_VALUE3641 = 164;
ENUM_VALUE3642 = 165;
ENUM_VALUE3643 = 166;
ENUM_VALUE3644 = 167;
ENUM_VALUE3645 = 168;
ENUM_VALUE3646 = 169;
ENUM_VALUE3647 = 170;
ENUM_VALUE3648 = 171;
ENUM_VALUE3649 = 172;
ENUM_VALUE3650 = 173;
ENUM_VALUE3651 = 174;
ENUM_VALUE3652 = 175;
ENUM_VALUE3653 = 176;
ENUM_VALUE3654 = 177;
ENUM_VALUE3655 = 178;
ENUM_VALUE3656 = 179;
ENUM_VALUE3657 = 180;
ENUM_VALUE3658 = 181;
ENUM_VALUE3659 = 182;
ENUM_VALUE3660 = 183;
}
enum Enum10325 {
ENUM_VALUE10326 = 0;
ENUM_VALUE10327 = 1;
ENUM_VALUE10328 = 2;
ENUM_VALUE10329 = 3;
ENUM_VALUE10330 = 4;
ENUM_VALUE10331 = 5;
ENUM_VALUE10332 = 6;
ENUM_VALUE10333 = 7;
ENUM_VALUE10334 = 8;
}
enum Enum10335 { ENUM_VALUE10336 = 0; }
enum Enum10337 {
ENUM_VALUE10338 = 0;
ENUM_VALUE10339 = 1;
}
enum Enum11901 {
ENUM_VALUE11902 = 0;
ENUM_VALUE11903 = 1;
ENUM_VALUE11904 = 2;
ENUM_VALUE11905 = 3;
}
enum Enum12735 {
ENUM_VALUE12736 = 0;
ENUM_VALUE12737 = 1;
ENUM_VALUE12738 = 2;
ENUM_VALUE12739 = 3;
}
enum Enum12871 {
ENUM_VALUE12872 = 1;
ENUM_VALUE12873 = 2;
ENUM_VALUE12874 = 3;
ENUM_VALUE12875 = 4;
ENUM_VALUE12876 = 5;
ENUM_VALUE12877 = 6;
}

View File

@ -0,0 +1,254 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <fstream>
#include <iostream>
#include "benchmark/benchmark.h"
#include "gogo/cpp_no_group/benchmarks.pb.h"
#include "gogo/cpp_no_group/datasets/google_message1/proto2/benchmark_message1_proto2.pb.h"
#include "gogo/cpp_no_group/datasets/google_message1/proto3/benchmark_message1_proto3.pb.h"
#include "gogo/cpp_no_group/datasets/google_message2/benchmark_message2.pb.h"
#include "gogo/cpp_no_group/datasets/google_message3/benchmark_message3.pb.h"
#include "gogo/cpp_no_group/datasets/google_message4/benchmark_message4.pb.h"
#define PREFIX "dataset."
#define SUFFIX ".pb"
using benchmarks::BenchmarkDataset;
using google::protobuf::Arena;
using google::protobuf::Descriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::Message;
using google::protobuf::MessageFactory;
class Fixture : public benchmark::Fixture {
public:
Fixture(const BenchmarkDataset& dataset, const std::string& suffix) {
for (int i = 0; i < dataset.payload_size(); i++) {
payloads_.push_back(dataset.payload(i));
}
const Descriptor* d =
DescriptorPool::generated_pool()->FindMessageTypeByName(
dataset.message_name());
if (!d) {
std::cerr << "Couldn't find message named '" << dataset.message_name()
<< "\n";
}
prototype_ = MessageFactory::generated_factory()->GetPrototype(d);
SetName((dataset.name() + suffix).c_str());
}
protected:
std::vector<std::string> payloads_;
const Message* prototype_;
};
class WrappingCounter {
public:
WrappingCounter(size_t limit) : value_(0), limit_(limit) {}
size_t Next() {
size_t ret = value_;
if (++value_ == limit_) {
value_ = 0;
}
return ret;
}
private:
size_t value_;
size_t limit_;
};
template <class T>
class ParseNewFixture : public Fixture {
public:
ParseNewFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_parse_new") {}
virtual void BenchmarkCase(benchmark::State& state) {
WrappingCounter i(payloads_.size());
size_t total = 0;
while (state.KeepRunning()) {
T m;
const std::string& payload = payloads_[i.Next()];
total += payload.size();
m.ParseFromString(payload);
}
state.SetBytesProcessed(total);
}
};
template <class T>
class ParseNewArenaFixture : public Fixture {
public:
ParseNewArenaFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_parse_newarena") {}
virtual void BenchmarkCase(benchmark::State& state) {
WrappingCounter i(payloads_.size());
size_t total = 0;
Arena arena;
while (state.KeepRunning()) {
arena.Reset();
Message* m = Arena::CreateMessage<T>(&arena);
const std::string& payload = payloads_[i.Next()];
total += payload.size();
m->ParseFromString(payload);
}
state.SetBytesProcessed(total);
}
};
template <class T>
class ParseReuseFixture : public Fixture {
public:
ParseReuseFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_parse_reuse") {}
virtual void BenchmarkCase(benchmark::State& state) {
T m;
WrappingCounter i(payloads_.size());
size_t total = 0;
while (state.KeepRunning()) {
const std::string& payload = payloads_[i.Next()];
total += payload.size();
m.ParseFromString(payload);
}
state.SetBytesProcessed(total);
}
};
template <class T>
class SerializeFixture : public Fixture {
public:
SerializeFixture(const BenchmarkDataset& dataset)
: Fixture(dataset, "_serialize") {
for (size_t i = 0; i < payloads_.size(); i++) {
message_.push_back(new T);
message_.back()->ParseFromString(payloads_[i]);
}
}
~SerializeFixture() {
for (size_t i = 0; i < message_.size(); i++) {
delete message_[i];
}
}
virtual void BenchmarkCase(benchmark::State& state) {
size_t total = 0;
std::string str;
WrappingCounter i(payloads_.size());
while (state.KeepRunning()) {
str.clear();
message_[i.Next()]->SerializeToString(&str);
total += str.size();
}
state.SetBytesProcessed(total);
}
private:
std::vector<T*> message_;
};
std::string ReadFile(const std::string& name) {
std::ifstream file(name.c_str());
GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" << name <<
"', please make sure you are running "
"this command from the benchmarks/ "
"directory.\n";
return std::string((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
}
template <class T>
void RegisterBenchmarksForType(const BenchmarkDataset& dataset) {
::benchmark::internal::RegisterBenchmarkInternal(
new ParseNewFixture<T>(dataset));
::benchmark::internal::RegisterBenchmarkInternal(
new ParseReuseFixture<T>(dataset));
::benchmark::internal::RegisterBenchmarkInternal(
new ParseNewArenaFixture<T>(dataset));
::benchmark::internal::RegisterBenchmarkInternal(
new SerializeFixture<T>(dataset));
}
void RegisterBenchmarks(const std::string& dataset_bytes) {
BenchmarkDataset dataset;
GOOGLE_CHECK(dataset.ParseFromString(dataset_bytes));
if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") {
RegisterBenchmarksForType<benchmarks::proto3::GoogleMessage1>(dataset);
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") {
RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage1>(dataset);
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") {
RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage2>(dataset);
} else if (dataset.message_name() ==
"benchmarks.google_message3.GoogleMessage3") {
RegisterBenchmarksForType
<benchmarks::google_message3::GoogleMessage3>(dataset);
} else if (dataset.message_name() ==
"benchmarks.google_message4.GoogleMessage4") {
RegisterBenchmarksForType
<benchmarks::google_message4::GoogleMessage4>(dataset);
} else {
std::cerr << "Unknown message type: " << dataset.message_name();
exit(1);
}
}
int main(int argc, char *argv[]) {
::benchmark::Initialize(&argc, argv);
if (argc == 1) {
std::cerr << "Usage: ./cpp-benchmark <input data>" << std::endl;
std::cerr << "input data is in the format of \"benchmarks.proto\""
<< std::endl;
return 1;
} else {
for (int i = 1; i < argc; i++) {
RegisterBenchmarks(ReadFile(argv[i]));
}
}
::benchmark::RunSpecifiedBenchmarks();
}

View File

@ -0,0 +1,138 @@
syntax = "proto2";
package benchmarks;
option java_outer_classname = "GoogleSize";
option optimize_for = CODE_SIZE;
message SizeMessage1 {
required string field1 = 1;
optional string field9 = 9;
optional string field18 = 18;
optional bool field80 = 80 [default=false];
optional bool field81 = 81 [default=true];
required int32 field2 = 2;
required int32 field3 = 3;
optional int32 field280 = 280;
optional int32 field6 = 6 [default=0];
optional int64 field22 = 22;
optional string field4 = 4;
repeated fixed64 field5 = 5;
optional bool field59 = 59 [default=false];
optional string field7 = 7;
optional int32 field16 = 16;
optional int32 field130 = 130 [default=0];
optional bool field12 = 12 [default=true];
optional bool field17 = 17 [default=true];
optional bool field13 = 13 [default=true];
optional bool field14 = 14 [default=true];
optional int32 field104 = 104 [default=0];
optional int32 field100 = 100 [default=0];
optional int32 field101 = 101 [default=0];
optional string field102 = 102;
optional string field103 = 103;
optional int32 field29 = 29 [default=0];
optional bool field30 = 30 [default=false];
optional int32 field60 = 60 [default=-1];
optional int32 field271 = 271 [default=-1];
optional int32 field272 = 272 [default=-1];
optional int32 field150 = 150;
optional int32 field23 = 23 [default=0];
optional bool field24 = 24 [default=false];
optional int32 field25 = 25 [default=0];
optional SizeMessage1SubMessage field15 = 15;
optional bool field78 = 78;
optional int32 field67 = 67 [default=0];
optional int32 field68 = 68;
optional int32 field128 = 128 [default=0];
optional string field129 = 129 [default="xxxxxxxxxxxxxxxxxxxxx"];
optional int32 field131 = 131 [default=0];
}
message SizeMessage1SubMessage {
optional int32 field1 = 1 [default=0];
optional int32 field2 = 2 [default=0];
optional int32 field3 = 3 [default=0];
optional string field15 = 15;
optional bool field12 = 12 [default=true];
optional int64 field13 = 13;
optional int64 field14 = 14;
optional int32 field16 = 16;
optional int32 field19 = 19 [default=2];
optional bool field20 = 20 [default=true];
optional bool field28 = 28 [default=true];
optional fixed64 field21 = 21;
optional int32 field22 = 22;
optional bool field23 = 23 [ default=false ];
optional bool field206 = 206 [default=false];
optional fixed32 field203 = 203;
optional int32 field204 = 204;
optional string field205 = 205;
optional uint64 field207 = 207;
optional uint64 field300 = 300;
}
message SizeMessage2 {
optional string field1 = 1;
optional int64 field3 = 3;
optional int64 field4 = 4;
optional int64 field30 = 30;
optional bool field75 = 75 [default=false];
optional string field6 = 6;
optional bytes field2 = 2;
optional int32 field21 = 21 [default=0];
optional int32 field71 = 71;
optional float field25 = 25;
optional int32 field109 = 109 [default=0];
optional int32 field210 = 210 [default=0];
optional int32 field211 = 211 [default=0];
optional int32 field212 = 212 [default=0];
optional int32 field213 = 213 [default=0];
optional int32 field216 = 216 [default=0];
optional int32 field217 = 217 [default=0];
optional int32 field218 = 218 [default=0];
optional int32 field220 = 220 [default=0];
optional int32 field221 = 221 [default=0];
optional float field222 = 222 [default=0.0];
optional int32 field63 = 63;
repeated group Group1 = 10 {
required float field11 = 11;
optional float field26 = 26;
optional string field12 = 12;
optional string field13 = 13;
repeated string field14 = 14;
required uint64 field15 = 15;
optional int32 field5 = 5;
optional string field27 = 27;
optional int32 field28 = 28;
optional string field29 = 29;
optional string field16 = 16;
repeated string field22 = 22;
repeated int32 field73 = 73;
optional int32 field20 = 20 [default=0];
optional string field24 = 24;
optional SizeMessage2GroupedMessage field31 = 31;
}
repeated string field128 = 128;
optional int64 field131 = 131;
repeated string field127 = 127;
optional int32 field129 = 129;
repeated int64 field130 = 130;
optional bool field205 = 205 [default=false];
optional bool field206 = 206 [default=false];
}
message SizeMessage2GroupedMessage {
optional float field1 = 1;
optional float field2 = 2;
optional float field3 = 3 [default=0.0];
optional bool field4 = 4;
optional bool field5 = 5;
optional bool field6 = 6 [default=true];
optional bool field7 = 7 [default=false];
optional float field8 = 8;
optional bool field9 = 9;
optional float field10 = 10;
optional int64 field11 = 11;
}

View File

@ -0,0 +1,31 @@
#include <Python.h>
#include "benchmarks.pb.h"
#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h"
#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h"
#include "datasets/google_message2/benchmark_message2.pb.h"
#include "datasets/google_message3/benchmark_message3.pb.h"
#include "datasets/google_message4/benchmark_message4.pb.h"
static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT,
"libbenchmark_messages",
"Benchmark messages Python module",
-1,
NULL,
NULL,
NULL,
NULL,
NULL};
extern "C" {
PyMODINIT_FUNC PyInit_libbenchmark_messages() {
benchmarks::BenchmarkDataset().descriptor();
benchmarks::proto3::GoogleMessage1().descriptor();
benchmarks::proto2::GoogleMessage1().descriptor();
benchmarks::proto2::GoogleMessage2().descriptor();
benchmarks::google_message3::GoogleMessage3().descriptor();
benchmarks::google_message4::GoogleMessage4().descriptor();
return PyModule_Create(&_module);
}
}

View File

@ -0,0 +1,74 @@
#include "benchmarks.pb.h"
#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h"
#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h"
#include "datasets/google_message2/benchmark_message2.pb.h"
#include "datasets/google_message3/benchmark_message3.pb.h"
#include "datasets/google_message4/benchmark_message4.pb.h"
#include "data_proto2_to_proto3_util.h"
#include <fstream>
using google::protobuf::util::GogoDataStripper;
std::string ReadFile(const std::string& name) {
std::ifstream file(name.c_str());
GOOGLE_CHECK(file.is_open()) << "Couldn't find file '"
<< name
<< "', please make sure you are running this command from the benchmarks"
<< " directory.\n";
return std::string((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
}
int main(int argc, char *argv[]) {
if (argc % 2 == 0 || argc == 1) {
std::cerr << "Usage: [input_files] [output_file_names] where " <<
"input_files are one to one mapping to output_file_names." <<
std::endl;
return 1;
}
for (int i = argc / 2; i > 0; i--) {
const std::string &input_file = argv[i];
const std::string &output_file = argv[i + argc / 2];
std::cerr << "Generating " << input_file
<< " to " << output_file << std::endl;
benchmarks::BenchmarkDataset dataset;
Message* message;
std::string dataset_payload = ReadFile(input_file);
GOOGLE_CHECK(dataset.ParseFromString(dataset_payload))
<< "Can' t parse data file " << input_file;
if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") {
message = new benchmarks::proto3::GoogleMessage1;
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") {
message = new benchmarks::proto2::GoogleMessage1;
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") {
message = new benchmarks::proto2::GoogleMessage2;
} else if (dataset.message_name() ==
"benchmarks.google_message3.GoogleMessage3") {
message = new benchmarks::google_message3::GoogleMessage3;
} else if (dataset.message_name() ==
"benchmarks.google_message4.GoogleMessage4") {
message = new benchmarks::google_message4::GoogleMessage4;
} else {
std::cerr << "Unknown message type: " << dataset.message_name();
exit(1);
}
for (int i = 0; i < dataset.payload_size(); i++) {
message->ParseFromString(dataset.payload(i));
GogoDataStripper stripper;
stripper.StripMessage(message);
dataset.set_payload(i, message->SerializeAsString());
}
std::ofstream ofs(output_file);
ofs << dataset.SerializeAsString();
ofs.close();
}
return 0;
}

View File

@ -0,0 +1,74 @@
#include "benchmarks.pb.h"
#include "datasets/google_message1/proto2/benchmark_message1_proto2.pb.h"
#include "datasets/google_message1/proto3/benchmark_message1_proto3.pb.h"
#include "datasets/google_message2/benchmark_message2.pb.h"
#include "datasets/google_message3/benchmark_message3.pb.h"
#include "datasets/google_message4/benchmark_message4.pb.h"
#include "data_proto2_to_proto3_util.h"
#include <fstream>
using google::protobuf::util::Proto3DataStripper;
std::string ReadFile(const std::string& name) {
std::ifstream file(name.c_str());
GOOGLE_CHECK(file.is_open()) << "Couldn't find file '"
<< name
<< "', please make sure you are running this command from the benchmarks"
<< " directory.\n";
return std::string((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
}
int main(int argc, char *argv[]) {
if (argc % 2 == 0 || argc == 1) {
std::cerr << "Usage: [input_files] [output_file_names] where " <<
"input_files are one to one mapping to output_file_names." <<
std::endl;
return 1;
}
for (int i = argc / 2; i > 0; i--) {
const std::string &input_file = argv[i];
const std::string &output_file = argv[i + argc / 2];
std::cerr << "Generating " << input_file
<< " to " << output_file << std::endl;
benchmarks::BenchmarkDataset dataset;
Message* message;
std::string dataset_payload = ReadFile(input_file);
GOOGLE_CHECK(dataset.ParseFromString(dataset_payload))
<< "Can' t parse data file " << input_file;
if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") {
message = new benchmarks::proto3::GoogleMessage1;
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") {
message = new benchmarks::proto2::GoogleMessage1;
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") {
message = new benchmarks::proto2::GoogleMessage2;
} else if (dataset.message_name() ==
"benchmarks.google_message3.GoogleMessage3") {
message = new benchmarks::google_message3::GoogleMessage3;
} else if (dataset.message_name() ==
"benchmarks.google_message4.GoogleMessage4") {
message = new benchmarks::google_message4::GoogleMessage4;
} else {
std::cerr << "Unknown message type: " << dataset.message_name();
exit(1);
}
for (int i = 0; i < dataset.payload_size(); i++) {
message->ParseFromString(dataset.payload(i));
Proto3DataStripper stripper;
stripper.StripMessage(message);
dataset.set_payload(i, message->SerializeAsString());
}
std::ofstream ofs(output_file);
ofs << dataset.SerializeAsString();
ofs.close();
}
return 0;
}

View File

@ -0,0 +1,103 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "schema_proto2_to_proto3_util.h"
#include "google/protobuf/compiler/plugin.h"
using google::protobuf::FileDescriptorProto;
using google::protobuf::FileDescriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::io::Printer;
using google::protobuf::util::SchemaGroupStripper;
using google::protobuf::util::EnumScrubber;
namespace google {
namespace protobuf {
namespace compiler {
namespace {
string StripProto(string filename) {
if (filename.substr(filename.size() - 11) == ".protodevel") {
// .protodevel
return filename.substr(0, filename.size() - 11);
} else {
// .proto
return filename.substr(0, filename.size() - 6);
}
}
DescriptorPool new_pool_;
} // namespace
class GoGoProtoGenerator : public CodeGenerator {
public:
virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files,
const string& parameter,
GeneratorContext* context,
string* error) const {
for (int i = 0; i < files.size(); i++) {
for (auto file : files) {
bool can_generate =
(new_pool_.FindFileByName(file->name()) == nullptr);
for (int j = 0; j < file->dependency_count(); j++) {
can_generate &= (new_pool_.FindFileByName(
file->dependency(j)->name()) != nullptr);
}
for (int j = 0; j < file->public_dependency_count(); j++) {
can_generate &= (new_pool_.FindFileByName(
file->public_dependency(j)->name()) != nullptr);
}
for (int j = 0; j < file->weak_dependency_count(); j++) {
can_generate &= (new_pool_.FindFileByName(
file->weak_dependency(j)->name()) != nullptr);
}
if (can_generate) {
Generate(file, parameter, context, error);
break;
}
}
}
return true;
}
virtual bool Generate(const FileDescriptor* file,
const string& parameter,
GeneratorContext* context,
string* error) const {
FileDescriptorProto new_file;
file->CopyTo(&new_file);
SchemaGroupStripper::StripFile(file, &new_file);
EnumScrubber enum_scrubber;
enum_scrubber.ScrubFile(&new_file);
string filename = file->name();
string basename = StripProto(filename);
std::vector<std::pair<string,string>> option_pairs;
ParseGeneratorParameter(parameter, &option_pairs);
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
context->Open(basename + ".proto"));
string content = new_pool_.BuildFile(new_file)->DebugString();
Printer printer(output.get(), '$');
printer.WriteRaw(content.c_str(), content.size());
return true;
}
};
} // namespace compiler
} // namespace protobuf
} // namespace google
int main(int argc, char* argv[]) {
google::protobuf::compiler::GoGoProtoGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}

View File

@ -0,0 +1,115 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "schema_proto2_to_proto3_util.h"
#include "google/protobuf/compiler/plugin.h"
using google::protobuf::FileDescriptorProto;
using google::protobuf::FileDescriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::io::Printer;
using google::protobuf::util::SchemaGroupStripper;
using google::protobuf::util::EnumScrubber;
using google::protobuf::util::ExtensionStripper;
using google::protobuf::util::FieldScrubber;
namespace google {
namespace protobuf {
namespace compiler {
namespace {
string StripProto(string filename) {
return filename.substr(0, filename.rfind(".proto"));
}
DescriptorPool* GetPool() {
static DescriptorPool *pool = new DescriptorPool();
return pool;
}
} // namespace
class Proto2ToProto3Generator final : public CodeGenerator {
public:
bool GenerateAll(const std::vector<const FileDescriptor*>& files,
const string& parameter,
GeneratorContext* context,
string* error) const {
for (int i = 0; i < files.size(); i++) {
for (auto file : files) {
if (CanGenerate(file)) {
Generate(file, parameter, context, error);
break;
}
}
}
return true;
}
bool Generate(const FileDescriptor* file,
const string& parameter,
GeneratorContext* context,
string* error) const {
FileDescriptorProto new_file;
file->CopyTo(&new_file);
SchemaGroupStripper::StripFile(file, &new_file);
EnumScrubber enum_scrubber;
enum_scrubber.ScrubFile(&new_file);
ExtensionStripper::StripFile(&new_file);
FieldScrubber::ScrubFile(&new_file);
new_file.set_syntax("proto3");
string filename = file->name();
string basename = StripProto(filename);
std::vector<std::pair<string,string>> option_pairs;
ParseGeneratorParameter(parameter, &option_pairs);
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
context->Open(basename + ".proto"));
string content = GetPool()->BuildFile(new_file)->DebugString();
Printer printer(output.get(), '$');
printer.WriteRaw(content.c_str(), content.size());
return true;
}
private:
bool CanGenerate(const FileDescriptor* file) const {
if (GetPool()->FindFileByName(file->name()) != nullptr) {
return false;
}
for (int j = 0; j < file->dependency_count(); j++) {
if (GetPool()->FindFileByName(file->dependency(j)->name()) == nullptr) {
return false;
}
}
for (int j = 0; j < file->public_dependency_count(); j++) {
if (GetPool()->FindFileByName(
file->public_dependency(j)->name()) == nullptr) {
return false;
}
}
for (int j = 0; j < file->weak_dependency_count(); j++) {
if (GetPool()->FindFileByName(
file->weak_dependency(j)->name()) == nullptr) {
return false;
}
}
return true;
}
};
} // namespace compiler
} // namespace protobuf
} // namespace google
int main(int argc, char* argv[]) {
google::protobuf::compiler::Proto2ToProto3Generator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}

View File

@ -0,0 +1,173 @@
# Internal Starlark definitions for Protobuf.
load("@rules_cc//cc:defs.bzl", starlark_cc_proto_library = "cc_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
load(":compiler_config_setting.bzl", "create_compiler_config_setting")
package(
default_visibility = [
# Public, but Protobuf only visibility.
"//:__subpackages__",
],
)
create_compiler_config_setting(
name = "config_msvc",
value = "msvc-cl",
)
# Android NDK builds can specify different crosstool_top flags to choose which
# STL they use for C++. We need these multiple variants to catch all of those
# versions of crosstool_top and reliably detect Android.
#
# For more info on the various crosstool_tops used by NDK Bazel builds, see:
# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl
config_setting(
name = "config_android",
values = {
"crosstool_top": "//external:android/crosstool",
},
)
config_setting(
name = "config_android-stlport",
values = {
"crosstool_top": "@androidndk//:toolchain-stlport",
},
)
config_setting(
name = "config_android-libcpp",
values = {
"crosstool_top": "@androidndk//:toolchain-libcpp",
},
)
config_setting(
name = "config_android-gnu-libstdcpp",
values = {
"crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp",
},
)
config_setting(
name = "config_android-default",
values = {
"crosstool_top": "@androidndk//:default_crosstool",
},
)
config_setting(
name = "config_win32",
values = {
"cpu": "win32",
},
)
config_setting(
name = "config_win64",
values = {
"cpu": "win64",
},
)
# Internal testing:
starlark_cc_proto_library(
name = "any_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:any_proto"],
)
starlark_cc_proto_library(
name = "api_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:api_proto"],
)
starlark_cc_proto_library(
name = "compiler_plugin_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:compiler_plugin_proto"],
)
starlark_cc_proto_library(
name = "descriptor_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:descriptor_proto"],
)
starlark_cc_proto_library(
name = "duration_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:duration_proto"],
)
starlark_cc_proto_library(
name = "empty_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:empty_proto"],
)
starlark_cc_proto_library(
name = "field_mask_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:field_mask_proto"],
)
starlark_cc_proto_library(
name = "source_context_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:source_context_proto"],
)
starlark_cc_proto_library(
name = "struct_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:struct_proto"],
)
starlark_cc_proto_library(
name = "timestamp_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:timestamp_proto"],
)
starlark_cc_proto_library(
name = "type_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:type_proto"],
)
starlark_cc_proto_library(
name = "wrappers_cc_proto",
visibility = ["//visibility:private"],
deps = ["//:wrappers_proto"],
)
cc_proto_blacklist_test(
name = "cc_proto_blacklist_test",
deps = [
":any_cc_proto",
":api_cc_proto",
":compiler_plugin_cc_proto",
":descriptor_cc_proto",
":duration_cc_proto",
":empty_cc_proto",
":field_mask_cc_proto",
":source_context_cc_proto",
":struct_cc_proto",
":timestamp_cc_proto",
":type_cc_proto",
":wrappers_cc_proto",
],
)
pkg_files(
name = "dist_files",
srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)

View File

@ -0,0 +1,38 @@
"""Contains a unittest to verify that `cc_proto_library` does not generate code for blacklisted `.proto` sources (i.e. WKPs)."""
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
def _cc_proto_blacklist_test_impl(ctx):
"""Verifies that there are no C++ compile actions for Well-Known-Protos.
Args:
ctx: The rule context.
Returns: A (not further specified) sequence of providers.
"""
env = unittest.begin(ctx)
for dep in ctx.attr.deps:
files = dep.files.to_list()
asserts.equals(
env,
[],
files,
"Expected that target '{}' does not provide files, got {}".format(
dep.label,
len(files),
),
)
return unittest.end(env)
cc_proto_blacklist_test = unittest.make(
impl = _cc_proto_blacklist_test_impl,
attrs = {
"deps": attr.label_list(
mandatory = True,
providers = [CcInfo],
),
},
)

View File

@ -0,0 +1,23 @@
"""Creates config_setting that allows selecting based on 'compiler' value."""
def create_compiler_config_setting(name, value, visibility = None):
# The "do_not_use_tools_cpp_compiler_present" attribute exists to
# distinguish between older versions of Bazel that do not support
# "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do.
# In the future, the only way to select on the compiler will be through
# flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
# be removed.
if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
native.config_setting(
name = name,
flag_values = {
"@bazel_tools//tools/cpp:compiler": value,
},
visibility = visibility,
)
else:
native.config_setting(
name = name,
values = {"compiler": value},
visibility = visibility,
)

View File

@ -0,0 +1,47 @@
# C++ compile/link options for Protobuf.
COPTS = select({
"//build_defs:config_msvc": [
"/wd4065", # switch statement contains 'default' but no 'case' labels
"/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
"/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
"/wd4307", # 'operator' : integral constant overflow
"/wd4309", # 'conversion' : truncation of constant value
"/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
"/wd4355", # 'this' : used in base member initializer list
"/wd4506", # no definition for inline function 'function'
"/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4996", # The compiler encountered a deprecated declaration.
],
"//conditions:default": [
"-DHAVE_ZLIB",
"-Woverloaded-virtual",
"-Wno-sign-compare",
],
})
# Android and MSVC builds do not need to link in a separate pthread library.
LINK_OPTS = select({
"//build_defs:config_android": [],
"//build_defs:config_android-stlport": [],
"//build_defs:config_android-libcpp": [],
"//build_defs:config_android-gnu-libstdcpp": [],
"//build_defs:config_android-default": [],
"//build_defs:config_msvc": [
# Suppress linker warnings about files with no symbols defined.
"-ignore:4221",
],
"//conditions:default": [
"-lpthread",
"-lm",
],
})
# When cross-compiling for Windows we need to statically link pthread and the C++ library.
PROTOC_LINK_OPTS = select({
"//build_defs:config_win32": ["-static"],
"//build_defs:config_win64": ["-static"],
"//conditions:default": [],
})

View File

@ -0,0 +1,62 @@
#!/bin/bash
# This script verifies that BUILD files and cmake files are in sync with src/Makefile.am
set -eo pipefail
if [ "$(uname)" != "Linux" ]; then
echo "build_files_updated_unittest only supported on Linux. Skipping..."
exit 0
fi
# Keep in sync with files needed by update_file_lists.sh
generated_files=(
"BUILD"
"cmake/extract_includes.bat.in"
"cmake/libprotobuf-lite.cmake"
"cmake/libprotobuf.cmake"
"cmake/libprotoc.cmake"
"cmake/tests.cmake"
"src/Makefile.am"
)
# If we're running in Bazel, use the Bazel-provided temp-dir.
if [ -n "${TEST_TMPDIR}" ]; then
# Env-var TEST_TMPDIR is set, assume that this is Bazel.
# Bazel may have opinions whether we are allowed to delete TEST_TMPDIR.
test_root="${TEST_TMPDIR}/build_files_updated_unittest"
mkdir "${test_root}"
else
# Seems like we're not executed by Bazel.
test_root=$(mktemp -d)
fi
# From now on, fail if there are any unbound variables.
set -u
# Remove artifacts after test is finished.
function cleanup {
rm -rf "${test_root}"
}
trap cleanup EXIT
# Create golden dir and add snapshot of current state.
golden_dir="${test_root}/golden"
mkdir -p "${golden_dir}/cmake" "${golden_dir}/src"
for file in ${generated_files[@]}; do
cp "${file}" "${golden_dir}/${file}"
done
# Create test dir, copy current state into it, and execute update script.
test_dir="${test_root}/test"
cp -R "${golden_dir}" "${test_dir}"
cp "update_file_lists.sh" "${test_dir}/update_file_lists.sh"
chmod +x "${test_dir}/update_file_lists.sh"
cd "${test_root}/test"
bash "${test_dir}/update_file_lists.sh"
# Test whether there are any differences
for file in ${generated_files[@]}; do
diff -du "${golden_dir}/${file}" "${test_dir}/${file}"
done

View File

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.5)
message(WARNING "Calling of cmake with source directory set to \"cmake\" subdirectory of Protocol Buffers project is deprecated. Top-level directory of Protocol Buffers project should be used instead.")
project(protobuf C CXX)
set(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE TRUE)
include(../CMakeLists.txt)

View File

@ -0,0 +1,399 @@
This directory contains *CMake* files that can be used to build protobuf
with *MSVC* on *Windows*. You can build the project from *Command Prompt*
and using an *Visual Studio* IDE.
You need to have [CMake](http://www.cmake.org), [Visual Studio](https://www.visualstudio.com)
and optionally [Git](http://git-scm.com) installed on your computer before proceeding.
Most of the instructions will be given to the *Сommand Prompt*, but the same
actions can be performed using appropriate GUI tools.
Environment Setup
=================
Open the appropriate *Command Prompt* from the *Start* menu.
For example *x86 Native Tools Command Prompt for VS 2019*:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>
Change to your working directory:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>cd C:\Path\to
C:\Path\to>
Where *C:\Path\to* is path to your real working directory.
Create a folder where protobuf headers/libraries/binaries will be installed after built:
C:\Path\to>mkdir install
If *cmake* command is not available from *Command Prompt*, add it to system *PATH* variable:
C:\Path\to>set PATH=%PATH%;C:\Program Files (x86)\CMake\bin
If *git* command is not available from *Command Prompt*, add it to system *PATH* variable:
C:\Path\to>set PATH=%PATH%;C:\Program Files\Git\cmd
Optionally, you will want to download [ninja](https://ninja-build.org/) and add it to your *PATH* variable.
C:\Path\to>set PATH=%PATH%;C:\tools\ninja
Good. Now you are ready to continue.
Getting Sources
===============
You can get the latest stable source packages from the release page:
https://github.com/protocolbuffers/protobuf/releases/latest
For example: if you only need C++, download `protobuf-cpp-[VERSION].tar.gz`; if
you need C++ and Java, download `protobuf-java-[VERSION].tar.gz` (every package
contains C++ source already); if you need C++ and multiple other languages,
download `protobuf-all-[VERSION].tar.gz`.
Or you can use git to clone from protobuf git repository.
C:\Path\to> mkdir src & cd src
C:\Path\to\src> git clone -b [release_tag] https://github.com/protocolbuffers/protobuf.git
Where *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *main*
if you want to get the latest code.
Go to the project folder:
C:\Path\to\src> cd protobuf
C:\Path\to\src\protobuf>
Remember to update any submodules if you are using git clone (you can skip this
step if you are using a release .tar.gz or .zip package):
```console
C:\Path\to\src\protobuf> git submodule update --init --recursive
```
Good. Now you are ready for *CMake* configuration.
CMake Configuration
===================
*CMake* supports a lot of different
[generators](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html)
for various native build systems.
Of most interest to Windows programmers are the following:
* [Makefile](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#makefile-generators).
This generates NMake Makefiles for Visual Studio. These work, but they are rather slow.
* [Visual Studio](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators)
This generates a Visual Studio solution for the project.
* [Ninja](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#ninja-generator)
This uses the external tool [Ninja](https://ninja-build.org/) to build. It is the fastest solution available.
Note that as of Visual Studio 2015, Visual Studio includes
[support for opening directly CMake-based projects](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio).
It is considered good practice not to build CMake projects in the source tree but in a separate folder.
Create a temporary *build* folder and change your working directory to it:
mkdir C:\Path\to\build\protobuf
cd C:\Path\to\build\protobuf
C:\Path\to\build\protobuf>
The *Makefile* and *Ninja* generators can build the project in only one configuration, so you need to build
a separate folder for each configuration.
To start using a *Release* configuration via the *NMmake* generator:
C:\Path\to\build\protobuf>mkdir release & cd release
C:\Path\to\build\protobuf\release>cmake -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install ^
C:\Path\to\src\protobuf
It will generate a *NMake* *Makefile* in the current directory.
To use *Debug* configuration using *Ninja*:
C:\Path\to\build\protobuf>mkdir debug & cd debug
C:\Path\to\build\protobuf\debug>cmake -G "Ninja" ^
-DCMAKE_BUILD_TYPE=Debug ^
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install ^
C:\Path\to\src\protobuf
It will generate *Ninja* build scripts in current directory.
The *Visual Studio* generator is multi-configuration: it will generate a single *.sln* file that can be used for both *Debug* and *Release*:
C:\Path\to\build\protobuf>mkdir solution & cd solution
C:\Path\to\build\protobuf\solution>cmake -G "Visual Studio 16 2019" ^
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install ^
C:\Path\to\src\protobuf
It will generate *Visual Studio* solution file *protobuf.sln* in current directory.
Unit Tests
----------
Unit tests are being built along with the rest of protobuf. The unit tests require Google Mock (now a part of Google Test).
A copy of [Google Test](https://github.com/google/googletest) is included as a Git submodule in the `third-party/googletest` folder.
(You do need to initialize the Git submodules as explained above.)
Alternately, you may want to use protobuf in a larger set-up, you may want to use that standard CMake approach where
you build and install a shared copy of Google Test.
After you've built and installed your Google Test copy, you need add the following definition to your *cmake* command line
during the configuration step: `-Dprotobuf_USE_EXTERNAL_GTEST=ON`.
This will cause the standard CMake `find_package(GTest REQUIRED)` to be used.
[find_package](https://cmake.org/cmake/help/latest/command/find_package.html) will search in a default location,
which on Windows is *C:\Program Files*. This is most likely not what you want. You will want instead to search for
Google Test in your project's root directory (i.e. the same directory you've passed to `CMAKE_INSTALL_PREFIX` when
building Google Test). For this, you need to set the `CMAKE_PREFIX_PATH` CMake variable. (There are other ways in CMake,
see the [manual](https://cmake.org/cmake/help/latest/command/find_package.html) for details.)
For example:
C:\Path\to\build\protobuf>mkdir solution & cd solution
C:\Path\to\build\protobuf\solution>cmake -G "Visual Studio 16 2019" ^
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install ^
-DCMAKE_PREFIX_PATH=C:\Path\to\my_big_project ^
-Dprotobuf_USE_EXTERNAL_GTEST=ON ^
C:\Path\to\src\protobuf
In most cases, `CMAKE_PREFIX_PATH` and `CMAKE_INSTALL_PREFIX` will point to the same directory.
To disable testing completely, you need to add the following argument to you *cmake* command line: `-Dprotobuf_BUILD_TESTS=OFF`.
For example:
C:\Path\to\build\protobuf\solution>cmake -G "Visual Studio 16 2019" ^
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install ^
-Dprotobuf_BUILD_TESTS=OFF ^
C:\Path\to\src\protobuf
Compiling
=========
The standard way to compile a *CMake* project is `cmake --build <directory>`.
Note that if your generator supports multiple configurations, you will probably want to specify which one to build:
cmake --build C:\Path\to\build\protobuf\solution --config Release
You can also run directly the build tool you've configured:
C:\Path\to\build\protobuf\release>nmake
or
C:\Path\to\build\protobuf\debug>ninja
And wait for the compilation to finish.
If you prefer to use the IDE:
* Open the generated protobuf.sln file in Microsoft Visual Studio.
* Choose "Debug" or "Release" configuration as desired.
* From the Build menu, choose "Build Solution".
And wait for the compilation to finish.
Testing
=======
To run unit-tests, first you must compile protobuf as described above.
Then run:
C:\Path\to\protobuf\cmake\build\release>ctest --progress --output-on-failure
You can also build the `check` target (not idiomatic CMake usage, though):
C:\Path\to\protobuf\cmake\build\release>cmake --build . --target check
or
C:\Path\to\build\protobuf\release>ninja check
You can also build project *check* from Visual Studio solution.
Yes, it may sound strange, but it works.
You should see output similar to:
Running main() from gmock_main.cc
[==========] Running 1546 tests from 165 test cases.
...
[==========] 1546 tests from 165 test cases ran. (2529 ms total)
[ PASSED ] 1546 tests.
To run specific tests, you need to pass some command line arguments to the test program itself:
C:\Path\to\build\protobuf\release>tests.exe --gtest_filter=AnyTest*
Running main() from gmock_main.cc
Note: Google Test filter = AnyTest*
[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from AnyTest
[ RUN ] AnyTest.TestPackAndUnpack
[ OK ] AnyTest.TestPackAndUnpack (0 ms)
[ RUN ] AnyTest.TestPackAndUnpackAny
[ OK ] AnyTest.TestPackAndUnpackAny (0 ms)
[ RUN ] AnyTest.TestIs
[ OK ] AnyTest.TestIs (0 ms)
[----------] 3 tests from AnyTest (1 ms total)
[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (2 ms total)
[ PASSED ] 3 tests.
Note that the tests must be run from the source folder.
If all tests are passed, safely continue.
Installing
==========
To install protobuf to the *install* folder you've specified in the configuration step, you need to build the `install` target:
cmake --build C:\Path\to\build\protobuf\solution --config Release --target install
Or if you prefer:
C:\Path\to\build\protobuf\release>nmake install
or
C:\Path\to\build\protobuf\debug>ninja install
You can also build project *INSTALL* from Visual Studio solution.
It sounds not so strange and it works.
This will create the following folders under the *install* location:
* bin - that contains protobuf *protoc.exe* compiler;
* include - that contains C++ headers and protobuf *.proto files;
* lib - that contains linking libraries and *CMake* configuration files for *protobuf* package.
Now you can if needed:
* Copy the contents of the include directory to wherever you want to put headers.
* Copy protoc.exe wherever you put build tools (probably somewhere in your PATH).
* Copy linking libraries libprotobuf[d].lib, libprotobuf-lite[d].lib, and libprotoc[d].lib wherever you put libraries.
To avoid conflicts between the MSVC debug and release runtime libraries, when
compiling a debug build of your application, you may need to link against a
debug build of libprotobufd.lib with "d" postfix. Similarly, release builds should link against
release libprotobuf.lib library.
DLLs vs. static linking
=======================
Static linking is now the default for the Protocol Buffer libraries. Due to
issues with Win32's use of a separate heap for each DLL, as well as binary
compatibility issues between different versions of MSVC's STL library, it is
recommended that you use static linkage only. However, it is possible to
build libprotobuf and libprotoc as DLLs if you really want. To do this,
do the following:
* Add an additional flag `-Dprotobuf_BUILD_SHARED_LIBS=ON` when invoking cmake
* Follow the same steps as described in the above section.
* When compiling your project, make sure to `#define PROTOBUF_USE_DLLS`.
When distributing your software to end users, we strongly recommend that you
do NOT install libprotobuf.dll or libprotoc.dll to any shared location.
Instead, keep these libraries next to your binaries, in your application's
own install directory. C++ makes it very difficult to maintain binary
compatibility between releases, so it is likely that future versions of these
libraries will *not* be usable as drop-in replacements.
If your project is itself a DLL intended for use by third-party software, we
recommend that you do NOT expose protocol buffer objects in your library's
public interface, and that you statically link protocol buffers into your
library.
ZLib support
============
If you want to include GzipInputStream and GzipOutputStream
(google/protobuf/io/gzip_stream.h) in libprotobuf, you will need to do a few
additional steps.
Obtain a copy of the zlib library. The pre-compiled DLL at zlib.net works.
You need prepare it:
* Make sure zlib's two headers are in your `C:\Path\to\install\include` path
* Make sure zlib's linking libraries (*.lib file) is in your
`C:\Path\to\install\lib` library path.
You can also compile it from source by yourself.
Getting sources:
C:\Path\to\src>git clone -b v1.2.8 https://github.com/madler/zlib.git
C:\Path\to\src>cd zlib
Compiling and Installing:
C:\Path\to\src\zlib>mkdir C:\Path\to\build\zlib & cd C:\Path\to\build\zlib
C:\Path\to\build\zlib>mkdir release & cd release
C:\Path\to\build\zlib\release>cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install C:\Path\to\src\zlib
C:\Path\to\src\zlib\build\release>cmake --build . --target install
You can make *debug* version or use *Visual Studio* generator also as before for the
protobuf project.
Now add *bin* folder from *install* to system *PATH*:
C:\Path\to>set PATH=%PATH%;C:\Path\to\install\bin
You need reconfigure protobuf with flag `-Dprotobuf_WITH_ZLIB=ON` when invoking cmake.
Note that if you have compiled ZLIB yourself, as stated above,
further disable the option `-Dprotobuf_MSVC_STATIC_RUNTIME=OFF`.
If it reports NOTFOUND for zlib_include or zlib_lib, you might haven't put
the headers or the .lib file in the right directory.
If you already have ZLIB library and headers at some other location on your system then alternatively you can define following configuration flags to locate them:
-DZLIB_INCLUDE_DIR=<path to dir containing zlib headers>
-DZLIB_LIB=<path to dir containing zlib>
Build and testing protobuf as usual.
Notes on Compiler Warnings
==========================
The following warnings have been disabled while building the protobuf libraries
and compiler. You may have to disable some of them in your own project as
well, or live with them.
* C4244 - Conversion from 'type1' to 'type2', possible loss of data.
* C4251 - 'identifier' : class 'type' needs to have dll-interface to be used by
clients of class 'type2'
* C4267 - Conversion from 'size_t' to 'type', possible loss of data.
* C4305 - 'identifier' : truncation from 'type1' to 'type2'
* C4355 - 'this' : used in base member initializer list
* C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
* C4996 - 'function': was declared deprecated
C4251 is of particular note, if you are compiling the Protocol Buffer library
as a DLL (see previous section). The protocol buffer library uses templates in
its public interfaces. MSVC does not provide any reasonable way to export
template classes from a DLL. However, in practice, it appears that exporting
templates is not necessary anyway. Since the complete definition of any
template is available in the header files, anyone importing the DLL will just
end up compiling instances of the templates into their own binary. The
Protocol Buffer implementation does not rely on static template members being
unique, so there should be no problem with this, but MSVC prints warning
nevertheless. So, we disable it. Unfortunately, this warning will also be
produced when compiling code which merely uses protocol buffers, meaning you
may have to disable it in your code too.

View File

@ -0,0 +1,49 @@
add_custom_command(
OUTPUT ${protobuf_SOURCE_DIR}/conformance/conformance.pb.cc
DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/conformance/conformance.proto
COMMAND ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/conformance/conformance.proto
--proto_path=${protobuf_SOURCE_DIR}/conformance
--cpp_out=${protobuf_SOURCE_DIR}/conformance
)
add_custom_command(
OUTPUT ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.proto
${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.proto
COMMAND ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.proto
--proto_path=${protobuf_SOURCE_DIR}/src
--cpp_out=${protobuf_SOURCE_DIR}/src
)
add_executable(conformance_test_runner
${protobuf_SOURCE_DIR}/conformance/binary_json_conformance_suite.cc
${protobuf_SOURCE_DIR}/conformance/binary_json_conformance_suite.h
${protobuf_SOURCE_DIR}/conformance/conformance.pb.cc
${protobuf_SOURCE_DIR}/conformance/conformance_test.cc
${protobuf_SOURCE_DIR}/conformance/conformance_test_runner.cc
${protobuf_SOURCE_DIR}/conformance/third_party/jsoncpp/json.h
${protobuf_SOURCE_DIR}/conformance/third_party/jsoncpp/jsoncpp.cpp
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.cc
)
add_executable(conformance_cpp
${protobuf_SOURCE_DIR}/conformance/conformance.pb.cc
${protobuf_SOURCE_DIR}/conformance/conformance_cpp.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.cc
)
target_include_directories(
conformance_test_runner
PUBLIC ${protobuf_SOURCE_DIR}/conformance)
target_include_directories(
conformance_cpp
PUBLIC ${protobuf_SOURCE_DIR}/conformance)
target_link_libraries(conformance_test_runner libprotobuf)
target_link_libraries(conformance_cpp libprotobuf)

View File

@ -0,0 +1,57 @@
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Examples Configuring...")
endif()
get_filename_component(examples_dir "${protobuf_SOURCE_DIR}/examples" ABSOLUTE)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Examples Configuring done")
endif()
include(ExternalProject)
# Internal utility function: Create a custom target representing a build of examples with custom options.
function(add_examples_build NAME)
ExternalProject_Add(${NAME}
PREFIX ${NAME}
SOURCE_DIR "${examples_dir}"
BINARY_DIR ${NAME}
STAMP_DIR ${NAME}/logs
INSTALL_COMMAND "" #Skip
LOG_CONFIGURE 1
CMAKE_CACHE_ARGS "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-Dprotobuf_VERBOSE:BOOL=${protobuf_VERBOSE}"
${ARGN}
)
set_property(TARGET ${NAME} PROPERTY FOLDER "Examples")
set_property(TARGET ${NAME} PROPERTY EXCLUDE_FROM_ALL TRUE)
endfunction()
# Add examples as an external project.
# sub_directory cannot be used because the find_package(protobuf) call would cause failures with redefined targets.
add_examples_build(examples "-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}")
add_dependencies(examples libprotobuf protoc)
option(protobuf_BUILD_EXAMPLES_MULTITEST "Build Examples in multiple configurations. Useful for testing." OFF)
mark_as_advanced(protobuf_BUILD_EXAMPLES_MULTITEST)
if(protobuf_BUILD_EXAMPLES_MULTITEST)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#Build using the legacy compatibility module.
add_examples_build(examples-legacy
"-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}"
"-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE"
)
add_dependencies(examples-legacy libprotobuf protoc)
#Build using the installed library.
add_examples_build(examples-installed
"-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}"
)
#Build using the installed library in legacy compatibility mode.
add_examples_build(examples-installed-legacy
"-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}"
"-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE"
)
endif()

View File

@ -0,0 +1,144 @@
mkdir include
mkdir include\google
mkdir include\google\protobuf
mkdir include\google\protobuf\compiler
mkdir include\google\protobuf\compiler\cpp
mkdir include\google\protobuf\compiler\csharp
mkdir include\google\protobuf\compiler\java
mkdir include\google\protobuf\compiler\objectivec
mkdir include\google\protobuf\compiler\php
mkdir include\google\protobuf\compiler\python
mkdir include\google\protobuf\compiler\ruby
mkdir include\google\protobuf\io
mkdir include\google\protobuf\stubs
mkdir include\google\protobuf\util
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h" include\google\protobuf\any.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h" include\google\protobuf\any.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h" include\google\protobuf\api.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h" include\google\protobuf\arena.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena_impl.h" include\google\protobuf\arena_impl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h" include\google\protobuf\arenastring.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenaz_sampler.h" include\google\protobuf\arenaz_sampler.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h" include\google\protobuf\compiler\code_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h" include\google\protobuf\compiler\command_line_interface.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\file.h" include\google\protobuf\compiler\cpp\file.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h" include\google\protobuf\compiler\cpp\cpp_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\generator.h" include\google\protobuf\compiler\cpp\generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\helpers.h" include\google\protobuf\compiler\cpp\helpers.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\names.h" include\google\protobuf\compiler\cpp\names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_doc_comment.h" include\google\protobuf\compiler\csharp\csharp_doc_comment.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h" include\google\protobuf\compiler\csharp\csharp_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h" include\google\protobuf\compiler\csharp\csharp_names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_options.h" include\google\protobuf\compiler\csharp\csharp_options.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h" include\google\protobuf\compiler\importer.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\generator.h" include\google\protobuf\compiler\java\generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h" include\google\protobuf\compiler\java\java_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\kotlin_generator.h" include\google\protobuf\compiler\java\kotlin_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\names.h" include\google\protobuf\compiler\java\names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h" include\google\protobuf\compiler\objectivec\objectivec_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h" include\google\protobuf\compiler\objectivec\objectivec_helpers.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h" include\google\protobuf\compiler\parser.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\php\php_generator.h" include\google\protobuf\compiler\php\php_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h" include\google\protobuf\compiler\plugin.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h" include\google\protobuf\compiler\plugin.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\generator.h" include\google\protobuf\compiler\python\generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\pyi_generator.h" include\google\protobuf\compiler\python\pyi_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h" include\google\protobuf\compiler\python\python_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h" include\google\protobuf\compiler\ruby\ruby_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h" include\google\protobuf\descriptor.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h" include\google\protobuf\descriptor.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h" include\google\protobuf\descriptor_database.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h" include\google\protobuf\duration.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h" include\google\protobuf\dynamic_message.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h" include\google\protobuf\empty.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\endian.h" include\google\protobuf\endian.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\explicitly_constructed.h" include\google\protobuf\explicitly_constructed.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h" include\google\protobuf\extension_set.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set_inl.h" include\google\protobuf\extension_set_inl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_access_listener.h" include\google\protobuf\field_access_listener.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h" include\google\protobuf\field_mask.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h" include\google\protobuf\generated_enum_reflection.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h" include\google\protobuf\generated_enum_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_bases.h" include\google\protobuf\generated_message_bases.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h" include\google\protobuf\generated_message_reflection.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_decl.h" include\google\protobuf\generated_message_tctable_decl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_impl.h" include\google\protobuf\generated_message_tctable_impl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h" include\google\protobuf\generated_message_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\has_bits.h" include\google\protobuf\has_bits.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message.h" include\google\protobuf\implicit_weak_message.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\inlined_string_field.h" include\google\protobuf\inlined_string_field.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h" include\google\protobuf\io\coded_stream.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h" include\google\protobuf\io\gzip_stream.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\io_win32.h" include\google\protobuf\io\io_win32.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h" include\google\protobuf\io\printer.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h" include\google\protobuf\io\strtod.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h" include\google\protobuf\io\tokenizer.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h" include\google\protobuf\io\zero_copy_stream.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h" include\google\protobuf\io\zero_copy_stream_impl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h" include\google\protobuf\io\zero_copy_stream_impl_lite.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h" include\google\protobuf\map.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h" include\google\protobuf\map_entry.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h" include\google\protobuf\map_entry_lite.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h" include\google\protobuf\map_field.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h" include\google\protobuf\map_field_inl.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h" include\google\protobuf\map_field_lite.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h" include\google\protobuf\map_type_handler.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h" include\google\protobuf\message.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h" include\google\protobuf\message_lite.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h" include\google\protobuf\metadata.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata_lite.h" include\google\protobuf\metadata_lite.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\parse_context.h" include\google\protobuf\parse_context.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\port.h" include\google\protobuf\port.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\port_def.inc" include\google\protobuf\port_def.inc
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\port_undef.inc" include\google\protobuf\port_undef.inc
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h" include\google\protobuf\reflection.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h" include\google\protobuf\reflection_ops.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h" include\google\protobuf\repeated_field.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_ptr_field.h" include\google\protobuf\repeated_ptr_field.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h" include\google\protobuf\service.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h" include\google\protobuf\source_context.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h" include\google\protobuf\struct.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h" include\google\protobuf\stubs\bytestream.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h" include\google\protobuf\stubs\callback.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h" include\google\protobuf\stubs\casts.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h" include\google\protobuf\stubs\common.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h" include\google\protobuf\stubs\hash.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h" include\google\protobuf\stubs\logging.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h" include\google\protobuf\stubs\macros.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\map_util.h" include\google\protobuf\stubs\map_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h" include\google\protobuf\stubs\mutex.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h" include\google\protobuf\stubs\once.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h" include\google\protobuf\stubs\platform_macros.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\port.h" include\google\protobuf\stubs\port.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\status.h" include\google\protobuf\stubs\status.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stl_util.h" include\google\protobuf\stubs\stl_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stringpiece.h" include\google\protobuf\stubs\stringpiece.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\strutil.h" include\google\protobuf\stubs\strutil.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h" include\google\protobuf\stubs\template_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h" include\google\protobuf\text_format.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h" include\google\protobuf\timestamp.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h" include\google\protobuf\type.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h" include\google\protobuf\unknown_field_set.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\delimited_message_util.h" include\google\protobuf\util\delimited_message_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h" include\google\protobuf\util\field_comparator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_mask_util.h" include\google\protobuf\util\field_mask_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h" include\google\protobuf\util\json_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h" include\google\protobuf\util\message_differencer.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\time_util.h" include\google\protobuf\util\time_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h" include\google\protobuf\util\type_resolver.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h" include\google\protobuf\util\type_resolver_util.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h" include\google\protobuf\wire_format.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite.h" include\google\protobuf\wire_format_lite.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h" include\google\protobuf\wrappers.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.proto" include\google\protobuf\any.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.proto" include\google\protobuf\api.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.proto" include\google\protobuf\compiler\plugin.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.proto" include\google\protobuf\descriptor.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.proto" include\google\protobuf\duration.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.proto" include\google\protobuf\empty.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.proto" include\google\protobuf\field_mask.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.proto" include\google\protobuf\source_context.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.proto" include\google\protobuf\struct.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.proto" include\google\protobuf\timestamp.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.proto" include\google\protobuf\type.proto
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.proto" include\google\protobuf\wrappers.proto

View File

@ -0,0 +1,156 @@
include(GNUInstallDirs)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf-lite.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc @ONLY)
set(_protobuf_libraries libprotobuf-lite libprotobuf)
if (protobuf_BUILD_LIBPROTOC)
list(APPEND _protobuf_libraries libprotoc)
endif (protobuf_BUILD_LIBPROTOC)
foreach(_library ${_protobuf_libraries})
set_property(TARGET ${_library}
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
if (UNIX AND NOT APPLE)
set_property(TARGET ${_library}
PROPERTY INSTALL_RPATH "$ORIGIN")
elseif (APPLE)
set_property(TARGET ${_library}
PROPERTY INSTALL_RPATH "@loader_path")
endif()
install(TARGETS ${_library} EXPORT protobuf-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
endforeach()
if (protobuf_BUILD_PROTOC_BINARIES)
install(TARGETS protoc EXPORT protobuf-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
if (UNIX AND NOT APPLE)
set_property(TARGET protoc
PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
elseif (APPLE)
set_property(TARGET protoc
PROPERTY INSTALL_RPATH "@loader_path/../lib")
endif()
endif (protobuf_BUILD_PROTOC_BINARIES)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
file(STRINGS ${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in _extract_strings
REGEX "^copy")
foreach(_extract_string ${_extract_strings})
string(REGEX REPLACE "^.* .+ include\\\\(.+)$" "\\1"
_header ${_extract_string})
string(REPLACE "\\" "/" _header ${_header})
get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/src/${_header}" ABSOLUTE)
get_filename_component(_extract_name ${_header} NAME)
get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" DIRECTORY)
if(EXISTS "${_extract_from}")
install(FILES "${_extract_from}"
DESTINATION "${_extract_to}"
COMPONENT protobuf-headers
RENAME "${_extract_name}")
else()
message(AUTHOR_WARNING "The file \"${_extract_from}\" is listed in "
"\"${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in\" "
"but there not exists. The file will not be installed.")
endif()
endforeach()
# Internal function for parsing auto tools scripts
function(_protobuf_auto_list FILE_NAME VARIABLE)
file(STRINGS ${FILE_NAME} _strings)
set(_list)
foreach(_string ${_strings})
set(_found)
string(REGEX MATCH "^[ \t]*${VARIABLE}[ \t]*=[ \t]*" _found "${_string}")
if(_found)
string(LENGTH "${_found}" _length)
string(SUBSTRING "${_string}" ${_length} -1 _draft_list)
foreach(_item ${_draft_list})
string(STRIP "${_item}" _item)
list(APPEND _list "${_item}")
endforeach()
endif()
endforeach()
set(${VARIABLE} ${_list} PARENT_SCOPE)
endfunction()
# Install well-known type proto files
_protobuf_auto_list("${protobuf_SOURCE_DIR}/src/Makefile.am" nobase_dist_proto_DATA)
foreach(_file ${nobase_dist_proto_DATA})
get_filename_component(_file_from "${protobuf_SOURCE_DIR}/src/${_file}" ABSOLUTE)
get_filename_component(_file_name ${_file} NAME)
get_filename_component(_dir ${_file} DIRECTORY)
if(EXISTS "${_file_from}")
install(FILES "${_file_from}"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_dir}"
COMPONENT protobuf-protos
RENAME "${_file_name}")
else()
message(AUTHOR_WARNING "The file \"${_file_from}\" is listed in "
"\"${protobuf_SOURCE_DIR}/src/Makefile.am\" as nobase_dist_proto_DATA "
"but there not exists. The file will not be installed.")
endif()
endforeach()
# Install configuration
set(_cmakedir_desc "Directory relative to CMAKE_INSTALL to install the cmake configuration files")
set(_exampledir_desc "Directory relative to CMAKE_INSTALL_DATA to install examples")
if(NOT MSVC)
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/protobuf" CACHE STRING "${_cmakedir_desc}")
set(CMAKE_INSTALL_EXAMPLEDIR "${CMAKE_INSTALL_DATADIR}/protobuf/examples" CACHE STRING "${_exampledir_desc}")
else()
set(CMAKE_INSTALL_CMAKEDIR "cmake" CACHE STRING "${_cmakedir_desc}")
set(CMAKE_INSTALL_EXAMPLEDIR "examples" CACHE STRING "${_exampledir_desc}")
endif()
mark_as_advanced(CMAKE_INSTALL_CMAKEDIR)
mark_as_advanced(CMAKE_INSTALL_EXAMPLEDIR)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-config.cmake.in
${CMAKE_INSTALL_CMAKEDIR}/protobuf-config.cmake @ONLY)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-config-version.cmake.in
${CMAKE_INSTALL_CMAKEDIR}/protobuf-config-version.cmake @ONLY)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-module.cmake.in
${CMAKE_INSTALL_CMAKEDIR}/protobuf-module.cmake @ONLY)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake
${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)
# Allows the build directory to be used as a find directory.
if (protobuf_BUILD_PROTOC_BINARIES)
export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
)
else (protobuf_BUILD_PROTOC_BINARIES)
export(TARGETS libprotobuf-lite libprotobuf
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
)
endif (protobuf_BUILD_PROTOC_BINARIES)
install(EXPORT protobuf-targets
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
NAMESPACE protobuf::
COMPONENT protobuf-export)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
COMPONENT protobuf-export
PATTERN protobuf-targets.cmake EXCLUDE
)
option(protobuf_INSTALL_EXAMPLES "Install the examples folder" OFF)
if(protobuf_INSTALL_EXAMPLES)
install(DIRECTORY examples/
DESTINATION "${CMAKE_INSTALL_EXAMPLEDIR}"
COMPONENT protobuf-examples)
endif()

View File

@ -0,0 +1,118 @@
set(libprotobuf_lite_files
${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arenaz_sampler.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_tctable_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/implicit_weak_message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/inlined_string_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/coded_stream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/io_win32.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/strtod.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/message_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/parse_context.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/int128.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/status.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/statusor.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringpiece.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/time.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc
)
set(libprotobuf_lite_includes
${protobuf_SOURCE_DIR}/src/google/protobuf/any.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_impl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arenaz_sampler.h
${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h
${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_tctable_decl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_tctable_impl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/has_bits.h
${protobuf_SOURCE_DIR}/src/google/protobuf/implicit_weak_message.h
${protobuf_SOURCE_DIR}/src/google/protobuf/inlined_string_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/coded_stream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/io_win32.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/strtod.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_entry_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_field_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_type_handler.h
${protobuf_SOURCE_DIR}/src/google/protobuf/message_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/metadata_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/parse_context.h
${protobuf_SOURCE_DIR}/src/google/protobuf/port.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/callback.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/casts.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/hash.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/logging.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/macros.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/map_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/mutex.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/once.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/platform_macros.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/port.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/status.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stl_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringpiece.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/template_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h
)
add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_files} ${libprotobuf_lite_includes} ${protobuf_version_rc_file})
if(protobuf_HAVE_LD_VERSION_SCRIPT)
if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13)
target_link_options(libprotobuf-lite PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf-lite.map)
elseif(protobuf_BUILD_SHARED_LIBS)
target_link_libraries(libprotobuf-lite PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf-lite.map)
endif()
set_target_properties(libprotobuf-lite PROPERTIES
LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotobuf-lite.map)
endif()
target_link_libraries(libprotobuf-lite PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if(protobuf_LINK_LIBATOMIC)
target_link_libraries(libprotobuf-lite PRIVATE atomic)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
target_link_libraries(libprotobuf-lite PRIVATE log)
endif()
target_include_directories(libprotobuf-lite PUBLIC ${protobuf_SOURCE_DIR}/src)
if(protobuf_BUILD_SHARED_LIBS)
target_compile_definitions(libprotobuf-lite
PUBLIC PROTOBUF_USE_DLLS
PRIVATE LIBPROTOBUF_EXPORTS)
endif()
set_target_properties(libprotobuf-lite PROPERTIES
VERSION ${protobuf_VERSION}
SOVERSION 32
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)

View File

@ -0,0 +1,134 @@
set(libprotobuf_files
${protobuf_SOURCE_DIR}/src/google/protobuf/any.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/importer.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/parser.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_heavy.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_reflection.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_tctable_full.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/gzip_stream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/printer.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/tokenizer.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_ops.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/service.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/substitute.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_mask_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/datapiece.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/default_value_objectwriter.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/error_listener.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/field_mask_utility.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/json_escaping.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/json_objectwriter.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/json_stream_parser.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/object_writer.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/proto_writer.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/protostream_objectsource.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/protostream_objectwriter.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/type_info.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/utility.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/time_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc
)
set(libprotobuf_includes
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/importer.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/parser.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.h
${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.h
${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/field_access_listener.h
${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_reflection.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_reflection.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/gzip_stream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/printer.h
${protobuf_SOURCE_DIR}/src/google/protobuf/io/tokenizer.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_entry.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_field_inl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/message.h
${protobuf_SOURCE_DIR}/src/google/protobuf/metadata.h
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection.h
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_internal.h
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_ops.h
${protobuf_SOURCE_DIR}/src/google/protobuf/service.h
${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.h
${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_mask_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/time_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.h
)
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes} ${protobuf_version_rc_file})
if(protobuf_HAVE_LD_VERSION_SCRIPT)
if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13)
target_link_options(libprotobuf PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf.map)
elseif(protobuf_BUILD_SHARED_LIBS)
target_link_libraries(libprotobuf PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf.map)
endif()
set_target_properties(libprotobuf PROPERTIES
LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotobuf.map)
endif()
target_link_libraries(libprotobuf PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if(protobuf_WITH_ZLIB)
target_link_libraries(libprotobuf PRIVATE ${ZLIB_LIBRARIES})
endif()
if(protobuf_LINK_LIBATOMIC)
target_link_libraries(libprotobuf PRIVATE atomic)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
target_link_libraries(libprotobuf PRIVATE log)
endif()
target_include_directories(libprotobuf PUBLIC ${protobuf_SOURCE_DIR}/src)
if(protobuf_BUILD_SHARED_LIBS)
target_compile_definitions(libprotobuf
PUBLIC PROTOBUF_USE_DLLS
PRIVATE LIBPROTOBUF_EXPORTS)
endif()
set_target_properties(libprotobuf PROPERTIES
VERSION ${protobuf_VERSION}
SOVERSION 32
OUTPUT_NAME ${LIB_PREFIX}protobuf
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf ALIAS libprotobuf)

View File

@ -0,0 +1,136 @@
set(libprotoc_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/enum.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/enum_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/extension.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/file.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/helpers.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/map_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/message_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/padding_optimizer.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/parse_function_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/primitive_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/service.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/string_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_enum.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_field_base.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_helpers.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_map_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_message_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/context.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/doc_comment.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/enum.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/enum_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/enum_field_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/enum_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/extension.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/extension_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/file.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/generator_factory.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/helpers.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/kotlin_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/map_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/map_field_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/message_builder.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/message_builder_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/message_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/message_field_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/message_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/name_resolver.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/primitive_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/primitive_field_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/service.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/shared_code_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/string_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/string_field_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_file.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/php/php_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/helpers.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/pyi_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/ruby/ruby_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/subprocess.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/zip_writer.cc
)
set(libprotoc_headers
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/file.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/helpers.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/names.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_doc_comment.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_names.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_options.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/java_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/kotlin_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/names.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/php/php_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/pyi_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/python_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/ruby/ruby_generator.h
)
add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
${libprotoc_files} ${libprotoc_headers} ${protobuf_version_rc_file})
if(protobuf_HAVE_LD_VERSION_SCRIPT)
if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13)
target_link_options(libprotoc PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotoc.map)
elseif(protobuf_BUILD_SHARED_LIBS)
target_link_libraries(libprotoc PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotoc.map)
endif()
set_target_properties(libprotoc PROPERTIES
LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotoc.map)
endif()
target_link_libraries(libprotoc PRIVATE libprotobuf)
if(protobuf_BUILD_SHARED_LIBS)
target_compile_definitions(libprotoc
PUBLIC PROTOBUF_USE_DLLS
PRIVATE LIBPROTOC_EXPORTS)
endif()
set_target_properties(libprotoc PROPERTIES
COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
VERSION ${protobuf_VERSION}
SOVERSION 32
OUTPUT_NAME ${LIB_PREFIX}protoc
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotoc ALIAS libprotoc)

View File

@ -0,0 +1,60 @@
set(PACKAGE_VERSION "@protobuf_VERSION@")
set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "@protobuf_VERSION_PRERELEASE@" PARENT_SCOPE)
# Prerelease versions cannot be passed in directly via the find_package command,
# so we allow users to specify it in a variable
if(NOT DEFINED "${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE")
set("${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" "")
else()
set(PACKAGE_FIND_VERSION ${PACKAGE_FIND_VERSION}-${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE})
endif()
set(PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}")
# VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL.
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise
if(PACKAGE_FIND_VERSION) #Only perform version checks if one is given
if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
# Do not match prerelease versions to non-prerelease version requests.
if(NOT "@protobuf_VERSION_PRERELEASE@" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "")
message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '@protobuf_VERSION_PRERELEASE@' or greater.")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
# Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers.
if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "@protobuf_VERSION_PRERELEASE@")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
endif()
endif()
# Check and save build options used to create this package
macro(_check_and_save_build_option OPTION VALUE)
if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND
NOT ${PACKAGE_FIND_NAME}_${OPTION} STREQUAL ${VALUE})
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE} PARENT_SCOPE)
endmacro()
_check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@)
_check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@)
_check_and_save_build_option(BUILD_SHARED_LIBS @protobuf_BUILD_SHARED_LIBS@)
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if(CMAKE_SIZEOF_VOID_P AND "@CMAKE_SIZEOF_VOID_P@")
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT CMAKE_SIZEOF_VOID_P EQUAL "@CMAKE_SIZEOF_VOID_P@")
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
endif()

View File

@ -0,0 +1,169 @@
# User options
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake")
# Depend packages
@_protobuf_FIND_ZLIB@
# Imported targets
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake")
function(protobuf_generate)
include(CMakeParseArguments)
set(_options APPEND_PATH)
set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN PLUGIN_OPTIONS)
if(COMMAND target_sources)
list(APPEND _singleargs TARGET)
endif()
set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS PROTOC_OPTIONS)
cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}")
if(NOT protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET)
message(SEND_ERROR "Error: protobuf_generate called without any targets or source files")
return()
endif()
if(NOT protobuf_generate_OUT_VAR AND NOT protobuf_generate_TARGET)
message(SEND_ERROR "Error: protobuf_generate called without a target or output variable")
return()
endif()
if(NOT protobuf_generate_LANGUAGE)
set(protobuf_generate_LANGUAGE cpp)
endif()
string(TOLOWER ${protobuf_generate_LANGUAGE} protobuf_generate_LANGUAGE)
if(NOT protobuf_generate_PROTOC_OUT_DIR)
set(protobuf_generate_PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
if(protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp)
set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}")
endif()
foreach(_option ${_dll_export_decl} ${protobuf_generate_PLUGIN_OPTIONS})
# append comma - not using CMake lists and string replacement as users
# might have semicolons in options
if(_plugin_options)
set( _plugin_options "${_plugin_options},")
endif()
set(_plugin_options "${_plugin_options}${_option}")
endforeach()
if(protobuf_generate_PLUGIN)
set(_plugin "--plugin=${protobuf_generate_PLUGIN}")
endif()
if(NOT protobuf_generate_GENERATE_EXTENSIONS)
if(protobuf_generate_LANGUAGE STREQUAL cpp)
set(protobuf_generate_GENERATE_EXTENSIONS .pb.h .pb.cc)
elseif(protobuf_generate_LANGUAGE STREQUAL python)
set(protobuf_generate_GENERATE_EXTENSIONS _pb2.py)
else()
message(SEND_ERROR "Error: protobuf_generate given unknown Language ${LANGUAGE}, please provide a value for GENERATE_EXTENSIONS")
return()
endif()
endif()
if(protobuf_generate_TARGET)
get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES)
foreach(_file ${_source_list})
if(_file MATCHES "proto$")
list(APPEND protobuf_generate_PROTOS ${_file})
endif()
endforeach()
endif()
if(NOT protobuf_generate_PROTOS)
message(SEND_ERROR "Error: protobuf_generate could not find any .proto files")
return()
endif()
if(protobuf_generate_APPEND_PATH)
# Create an include path for each file specified
foreach(_file ${protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_file} ABSOLUTE)
get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
list(FIND _protobuf_include_path ${_abs_dir} _contains_already)
if(${_contains_already} EQUAL -1)
list(APPEND _protobuf_include_path -I ${_abs_dir})
endif()
endforeach()
endif()
foreach(DIR ${protobuf_generate_IMPORT_DIRS})
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
if(${_contains_already} EQUAL -1)
list(APPEND _protobuf_include_path -I ${ABS_PATH})
endif()
endforeach()
if(NOT _protobuf_include_path)
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
endif()
set(_generated_srcs_all)
foreach(_proto ${protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_proto} ABSOLUTE)
get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
get_filename_component(_file_full_name ${_proto} NAME)
string(FIND "${_file_full_name}" "." _file_last_ext_pos REVERSE)
string(SUBSTRING "${_file_full_name}" 0 ${_file_last_ext_pos} _basename)
set(_suitable_include_found FALSE)
foreach(DIR ${_protobuf_include_path})
if(NOT DIR STREQUAL "-I")
file(RELATIVE_PATH _rel_dir ${DIR} ${_abs_dir})
string(FIND "${_rel_dir}" "../" _is_in_parent_folder)
if (NOT ${_is_in_parent_folder} EQUAL 0)
set(_suitable_include_found TRUE)
break()
endif()
endif()
endforeach()
if(NOT _suitable_include_found)
message(SEND_ERROR "Error: protobuf_generate could not find any correct proto include directory.")
return()
endif()
set(_generated_srcs)
foreach(_ext ${protobuf_generate_GENERATE_EXTENSIONS})
list(APPEND _generated_srcs "${protobuf_generate_PROTOC_OUT_DIR}/${_rel_dir}/${_basename}${_ext}")
endforeach()
list(APPEND _generated_srcs_all ${_generated_srcs})
set(_comment "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}")
if(protobuf_generate_PROTOC_OPTIONS)
set(_comment "${_comment}, protoc-options: ${protobuf_generate_PROTOC_OPTIONS}")
endif()
if(_plugin_options)
set(_comment "${_comment}, plugin-options: ${_plugin_options}")
endif()
add_custom_command(
OUTPUT ${_generated_srcs}
COMMAND protobuf::protoc
ARGS ${protobuf_generate_PROTOC_OPTIONS} --${protobuf_generate_LANGUAGE}_out ${_plugin_options}:${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file}
DEPENDS ${_abs_file} protobuf::protoc
COMMENT ${_comment}
VERBATIM )
endforeach()
set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE)
if(protobuf_generate_OUT_VAR)
set(${protobuf_generate_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE)
endif()
if(protobuf_generate_TARGET)
target_sources(${protobuf_generate_TARGET} PRIVATE ${_generated_srcs_all})
endif()
endfunction()
# CMake FindProtobuf module compatible file
if(protobuf_MODULE_COMPATIBLE)
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-module.cmake")
endif()

View File

@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: Protocol Buffers
Description: Google's Data Interchange Format
Version: @protobuf_VERSION@
Libs: -L${libdir} -lprotobuf-lite @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir}
Conflicts: protobuf

View File

@ -0,0 +1,189 @@
# This file contains backwards compatibility patches for various legacy functions and variables
# Functions
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
cmake_parse_arguments(protobuf_generate_cpp "" "EXPORT_MACRO" "" ${ARGN})
set(_proto_files "${protobuf_generate_cpp_UNPARSED_ARGUMENTS}")
if(NOT _proto_files)
message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
return()
endif()
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
set(_append_arg APPEND_PATH)
endif()
if(DEFINED Protobuf_IMPORT_DIRS)
set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
endif()
set(_outvar)
protobuf_generate(${_append_arg} LANGUAGE cpp EXPORT_MACRO ${protobuf_generate_cpp_EXPORT_MACRO} OUT_VAR _outvar ${_import_arg} PROTOS ${_proto_files})
set(${SRCS})
set(${HDRS})
foreach(_file ${_outvar})
if(_file MATCHES "cc$")
list(APPEND ${SRCS} ${_file})
else()
list(APPEND ${HDRS} ${_file})
endif()
endforeach()
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
endfunction()
function(PROTOBUF_GENERATE_PYTHON SRCS)
if(NOT ARGN)
message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files")
return()
endif()
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
set(_append_arg APPEND_PATH)
endif()
if(DEFINED Protobuf_IMPORT_DIRS)
set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
endif()
set(_outvar)
protobuf_generate(${_append_arg} LANGUAGE python OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN})
set(${SRCS} ${_outvar} PARENT_SCOPE)
endfunction()
# Environment
# Backwards compatibility
# Define camel case versions of input variables
foreach(UPPER
PROTOBUF_SRC_ROOT_FOLDER
PROTOBUF_IMPORT_DIRS
PROTOBUF_DEBUG
PROTOBUF_LIBRARY
PROTOBUF_PROTOC_LIBRARY
PROTOBUF_INCLUDE_DIR
PROTOBUF_PROTOC_EXECUTABLE
PROTOBUF_LIBRARY_DEBUG
PROTOBUF_PROTOC_LIBRARY_DEBUG
PROTOBUF_LITE_LIBRARY
PROTOBUF_LITE_LIBRARY_DEBUG
)
if (DEFINED ${UPPER})
string(REPLACE "PROTOBUF_" "Protobuf_" Camel ${UPPER})
if (NOT DEFINED ${Camel})
set(${Camel} ${${UPPER}})
endif()
endif()
endforeach()
if(DEFINED Protobuf_SRC_ROOT_FOLDER)
message(AUTHOR_WARNING "Variable Protobuf_SRC_ROOT_FOLDER defined, but not"
" used in CONFIG mode")
endif()
include(SelectLibraryConfigurations)
# Internal function: search for normal library as well as a debug one
# if the debug one is specified also include debug/optimized keywords
# in *_LIBRARIES variable
function(_protobuf_find_libraries name filename)
if(${name}_LIBRARIES)
# Use result recorded by a previous call.
elseif(${name}_LIBRARY)
# Honor cache entry used by CMake 3.5 and lower.
set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE)
elseif(TARGET protobuf::lib${filename})
get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename}
LOCATION_RELEASE)
get_target_property(${name}_LIBRARY_RELWITHDEBINFO protobuf::lib${filename}
LOCATION_RELWITHDEBINFO)
get_target_property(${name}_LIBRARY_MINSIZEREL protobuf::lib${filename}
LOCATION_MINSIZEREL)
get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename}
LOCATION_DEBUG)
select_library_configurations(${name})
set(${name}_LIBRARY ${${name}_LIBRARY} PARENT_SCOPE)
set(${name}_LIBRARIES ${${name}_LIBRARIES} PARENT_SCOPE)
endif()
endfunction()
#
# Main.
#
# By default have PROTOBUF_GENERATE_CPP macro pass -I to protoc
# for each directory where a proto file is referenced.
if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH)
set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE)
endif()
# The Protobuf library
_protobuf_find_libraries(Protobuf protobuf)
# The Protobuf Lite library
_protobuf_find_libraries(Protobuf_LITE protobuf-lite)
# The Protobuf Protoc Library
_protobuf_find_libraries(Protobuf_PROTOC protoc)
# Set the include directory
get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
INTERFACE_INCLUDE_DIRECTORIES)
# Set the protoc Executable
if(NOT Protobuf_PROTOC_EXECUTABLE AND TARGET protobuf::protoc)
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_RELEASE)
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_RELWITHDEBINFO)
endif()
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_MINSIZEREL)
endif()
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_DEBUG)
endif()
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_NOCONFIG)
endif()
endif()
# Version info variable
set(Protobuf_VERSION "@protobuf_VERSION@")
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf
REQUIRED_VARS Protobuf_PROTOC_EXECUTABLE Protobuf_LIBRARIES Protobuf_INCLUDE_DIRS
VERSION_VAR Protobuf_VERSION
)
# Backwards compatibility
# Define upper case versions of output variables
foreach(Camel
Protobuf_VERSION
Protobuf_SRC_ROOT_FOLDER
Protobuf_IMPORT_DIRS
Protobuf_DEBUG
Protobuf_INCLUDE_DIRS
Protobuf_LIBRARIES
Protobuf_PROTOC_LIBRARIES
Protobuf_LITE_LIBRARIES
Protobuf_LIBRARY
Protobuf_PROTOC_LIBRARY
Protobuf_INCLUDE_DIR
Protobuf_PROTOC_EXECUTABLE
Protobuf_LIBRARY_DEBUG
Protobuf_PROTOC_LIBRARY_DEBUG
Protobuf_LITE_LIBRARY
Protobuf_LITE_LIBRARY_DEBUG
)
string(TOUPPER ${Camel} UPPER)
set(${UPPER} ${${Camel}})
endforeach()

View File

@ -0,0 +1,7 @@
# Verbose output
option(protobuf_VERBOSE "Enable for verbose output" OFF)
mark_as_advanced(protobuf_VERBOSE)
# FindProtobuf module compatible
option(protobuf_MODULE_COMPATIBLE "CMake built-in FindProtobuf.cmake module compatible" OFF)
mark_as_advanced(protobuf_MODULE_COMPATIBLE)

View File

@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: Protocol Buffers
Description: Google's Data Interchange Format
Version: @protobuf_VERSION@
Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir}
Conflicts: protobuf-lite

View File

@ -0,0 +1,13 @@
set(protoc_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/main.cc
)
add_executable(protoc ${protoc_files} ${protobuf_version_rc_file})
target_link_libraries(protoc
libprotoc
libprotobuf
)
add_executable(protobuf::protoc ALIAS protoc)
set_target_properties(protoc PROPERTIES
VERSION ${protobuf_VERSION})

View File

@ -0,0 +1,294 @@
option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF)
option(protobuf_TEST_XML_OUTDIR "Output directory for XML logs from tests." "")
option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH
"Using absolute test_plugin path in tests" ON)
mark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
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 STATIC
"${googlemock_source_dir}/src/gmock-all.cc"
"${googletest_source_dir}/src/gtest-all.cc"
)
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)
endif()
set(lite_test_protos
${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_unittest.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import_lite.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import_public_lite.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lite.proto
)
set(tests_protos
${protobuf_SOURCE_DIR}/src/google/protobuf/any_test.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/test_bad_identifiers.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/test_large_enum_value.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/map_proto2_unittest.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/map_unittest.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_arena.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_custom_options.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_drop_unknown_fields.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_embed_optimize_for.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_empty.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_enormous_descriptor.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import_public.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lazy_dependencies.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lazy_dependencies_custom_option.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lazy_dependencies_enum.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lite_imports_nonlite.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_mset.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_mset_wire_format.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_no_field_presence.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_no_generic_services.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_optimize_for.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_preserve_unknown_enum.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_preserve_unknown_enum2.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_arena.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_arena_lite.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_lite.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_optional.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_well_known_types.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/anys.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/books.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/default_value.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/default_value_test.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/field_mask.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/maps.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/oneofs.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/proto3.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/struct.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/timestamp_duration.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/wrappers.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format_proto3.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest.proto
)
macro(compile_proto_file filename)
string(REPLACE .proto .pb.cc pb_file ${filename})
add_custom_command(
OUTPUT ${pb_file}
DEPENDS ${protobuf_PROTOC_EXE} ${filename}
COMMAND ${protobuf_PROTOC_EXE} ${filename}
--proto_path=${protobuf_SOURCE_DIR}/src
--cpp_out=${protobuf_SOURCE_DIR}/src
--experimental_allow_proto3_optional
)
endmacro(compile_proto_file)
set(lite_test_proto_files)
foreach(proto_file ${lite_test_protos})
compile_proto_file(${proto_file})
set(lite_test_proto_files ${lite_test_proto_files} ${pb_file})
endforeach(proto_file)
set(tests_proto_files)
foreach(proto_file ${tests_protos})
compile_proto_file(${proto_file})
set(tests_proto_files ${tests_proto_files} ${pb_file})
endforeach(proto_file)
set(common_lite_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_test_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_test_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util_lite.cc
)
add_library(protobuf-lite-test-common STATIC
${common_lite_test_files} ${lite_test_proto_files})
target_link_libraries(protobuf-lite-test-common libprotobuf-lite GTest::gmock)
set(common_test_files
${common_lite_test_files}
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map_test_util.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_tester.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/googletest.cc
)
add_library(protobuf-test-common STATIC
${common_test_files} ${tests_proto_files})
target_link_libraries(protobuf-test-common libprotobuf GTest::gmock)
set(tests_files
${protobuf_SOURCE_DIR}/src/google/protobuf/any_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arenaz_sampler_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/annotation_test_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/annotation_test_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/bootstrap_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/message_size_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/metadata_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/move_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/plugin_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/unittest.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/importer_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/doc_comment_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/plugin_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/parser_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/plugin_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/drop_unknown_fields_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_reflection_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_tctable_lite_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/inlined_string_field_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/coded_stream_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/io_win32_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/printer_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/tokenizer_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map_field_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map_test.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/message_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/message_unittest.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/no_field_presence_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/preserve_unknown_enum_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_arena_lite_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_arena_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_lite_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_lite_unittest.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_ops_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field_reflection_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/int128_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/status_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/statusor_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringpiece_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/template_util_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/time_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_mask_util_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/json_objectwriter_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/json_stream_parser_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/protostream_objectsource_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/type_info_test_helper.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_util_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/time_util_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/well_known_types_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_unittest.inc
)
if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$<TARGET_FILE:test_plugin>")
endif()
if(MINGW)
set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing")
# required for tests on MinGW Win64
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
endif()
endif()
if(protobuf_TEST_XML_OUTDIR)
if(NOT "${protobuf_TEST_XML_OUTDIR}" MATCHES "[/\\]$")
string(APPEND protobuf_TEST_XML_OUTDIR "/")
endif()
set(protobuf_GTEST_ARGS "--gtest_output=xml:${protobuf_TEST_XML_OUTDIR}")
else()
set(protobuf_GTEST_ARGS)
endif()
add_executable(tests ${tests_files})
if (MSVC)
target_compile_options(tests PRIVATE
/wd4146 # unary minus operator applied to unsigned type, result still unsigned
)
endif()
target_link_libraries(tests protobuf-lite-test-common protobuf-test-common libprotoc libprotobuf GTest::gmock_main)
set(test_plugin_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/test_plugin.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.h
)
add_executable(test_plugin ${test_plugin_files})
target_link_libraries(test_plugin libprotoc libprotobuf GTest::gmock)
set(lite_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/lite_unittest.cc
)
add_executable(lite-test ${lite_test_files})
target_link_libraries(lite-test protobuf-lite-test-common libprotobuf-lite GTest::gmock_main)
add_test(NAME lite-test
COMMAND lite-test ${protobuf_GTEST_ARGS})
set(lite_arena_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/lite_arena_unittest.cc
)
add_executable(lite-arena-test ${lite_arena_test_files})
target_link_libraries(lite-arena-test protobuf-lite-test-common libprotobuf-lite GTest::gmock_main)
add_test(NAME lite-arena-test
COMMAND lite-arena-test ${protobuf_GTEST_ARGS})
add_custom_target(check
COMMAND tests
DEPENDS tests test_plugin
WORKING_DIRECTORY ${protobuf_SOURCE_DIR})
add_test(NAME check
COMMAND tests ${protobuf_GTEST_ARGS}
WORKING_DIRECTORY "${protobuf_SOURCE_DIR}")

View File

@ -0,0 +1,45 @@
#define VS_FF_DEBUG 0x1L
#define VS_VERSION_INFO 0x1L
#define VS_FFI_FILEFLAGSMASK 0x17L
#define VER_PRIVATEBUILD 0x0L
#define VER_PRERELEASE 0x0L
#define VOS__WINDOWS32 0x4L
#define VFT_DLL 0x2L
#define VFT2_UNKNOWN 0x0L
#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION @protobuf_RC_FILEVERSION@
PRODUCTVERSION @protobuf_RC_FILEVERSION@
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS VER_DEBUG
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
BEGIN
BLOCK "VarFileInfo"
BEGIN
// English language (0x409) and the Windows Unicode codepage (1200)
VALUE "Translation", 0x409, 1200
END
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "Compiled with @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@\0"
VALUE "ProductVersion", "@protobuf_VERSION@\0"
VALUE "FileVersion", "@protobuf_VERSION@\0"
VALUE "InternalName", "protobuf\0"
VALUE "ProductName", "Protocol Buffers - Google's Data Interchange Format\0"
VALUE "CompanyName", "Google Inc.\0"
VALUE "LegalCopyright", "Copyright 2008 Google Inc. All rights reserved.\0"
VALUE "Licence", "BSD\0"
VALUE "Info", "https://developers.google.com/protocol-buffers/\0"
END
END
END

348
3party/protobuf-3.21.12/compile Executable file
View File

@ -0,0 +1,348 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN* | MSYS*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/* | msys/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

1754
3party/protobuf-3.21.12/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,218 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* the name of <hash_map> */
#undef HASH_MAP_CLASS
/* the location of <unordered_map> or <hash_map> */
#undef HASH_MAP_H
/* the namespace of hash_map/hash_set */
#undef HASH_NAMESPACE
/* the name of <hash_set> */
#undef HASH_SET_CLASS
/* the location of <unordered_set> or <hash_set> */
#undef HASH_SET_H
/* define if the compiler supports basic C++11 syntax */
#undef HAVE_CXX11
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `ftruncate' function. */
#undef HAVE_FTRUNCATE
/* define if the compiler has hash_map */
#undef HAVE_HASH_MAP
/* define if the compiler has hash_set */
#undef HAVE_HASH_SET
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the <minix/config.h> header file. */
#undef HAVE_MINIX_CONFIG_H
/* Define to 1 if you have the `mkdir' function. */
#undef HAVE_MKDIR
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Enable classes using zlib compression. */
#undef HAVE_ZLIB
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable general extensions on macOS. */
#ifndef _DARWIN_C_SOURCE
# undef _DARWIN_C_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable X/Open compliant socket functions that do not require linking
with -lxnet on HP-UX 11.11. */
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
# undef _HPUX_ALT_XOPEN_SOCKET_API
#endif
/* Identify the host operating system as Minix.
This macro does not affect the system headers' behavior.
A future release of Autoconf may stop defining this macro. */
#ifndef _MINIX
# undef _MINIX
#endif
/* Enable general extensions on NetBSD.
Enable NetBSD compatibility extensions on Minix. */
#ifndef _NETBSD_SOURCE
# undef _NETBSD_SOURCE
#endif
/* Enable OpenBSD compatibility extensions on NetBSD.
Oddly enough, this does nothing on OpenBSD. */
#ifndef _OPENBSD_SOURCE
# undef _OPENBSD_SOURCE
#endif
/* Define to 1 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_SOURCE
# undef _POSIX_SOURCE
#endif
/* Define to 2 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_1_SOURCE
# undef _POSIX_1_SOURCE
#endif
/* Enable POSIX-compatible threading on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
# undef __STDC_WANT_IEC_60559_BFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# undef __STDC_WANT_IEC_60559_DFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
#endif
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
#ifndef __STDC_WANT_LIB_EXT2__
# undef __STDC_WANT_LIB_EXT2__
#endif
/* Enable extensions specified by ISO/IEC 24747:2009. */
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
# undef __STDC_WANT_MATH_SPEC_FUNCS__
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable X/Open extensions. Define to 500 only if necessary
to make mbstate_t available. */
#ifndef _XOPEN_SOURCE
# undef _XOPEN_SOURCE
#endif
/* Version number of package */
#undef VERSION

1890
3party/protobuf-3.21.12/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

25276
3party/protobuf-3.21.12/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,247 @@
## Process this file with autoconf to produce configure.
## In general, the safest way to proceed is to run ./autogen.sh
AC_PREREQ(2.59)
# Note: If you change the version, you must also update it in:
# * Protobuf.podspec
# * csharp/Google.Protobuf.Tools.nuspec
# * csharp/src/*/AssemblyInfo.cs
# * csharp/src/Google.Protobuf/Google.Protobuf.nuspec
# * java/*/pom.xml
# * python/google/protobuf/__init__.py
# * protoc-artifacts/pom.xml
# * src/google/protobuf/stubs/common.h
# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
#
# In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.21.12],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])
AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
# The config file is generated but not used by the source code, since we only
# need very few of them, e.g. HAVE_PTHREAD and HAVE_ZLIB. Those macros are
# passed down in CXXFLAGS manually in src/Makefile.am
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
case "$DIST_LANG" in
"") DIST_LANG=all ;;
all | cpp | csharp | java | python | javanano | objectivec | ruby | php) ;;
*) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
esac
AC_SUBST(DIST_LANG)
# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
# the best choice for libprotobuf.
AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
[CFLAGS=""])
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
[CXXFLAGS=""])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])
# Silent rules enabled: the output is minimal but informative.
# In particular, the warnings from the compiler stick out very clearly.
# To see all logs, use the --disable-silent-rules on configure or via make V=1
AM_SILENT_RULES([yes])
AC_ARG_WITH([zlib],
[AS_HELP_STRING([--with-zlib],
[include classes for streaming compressed data in and out @<:@default=check@:>@])],
[],[with_zlib=check])
AC_ARG_WITH([zlib-include],
[AS_HELP_STRING([--with-zlib-include=PATH],
[zlib include directory])],
[CPPFLAGS="-I$withval $CPPFLAGS"])
AC_ARG_WITH([zlib-lib],
[AS_HELP_STRING([--with-zlib-lib=PATH],
[zlib lib directory])],
[LDFLAGS="-L$withval $LDFLAGS"])
AC_ARG_WITH([protoc],
[AS_HELP_STRING([--with-protoc=COMMAND],
[use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],
[],[with_protoc=no])
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CXX_FOR_BUILD
AC_LANG([C++])
ACX_USE_SYSTEM_EXTENSIONS
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
AS_CASE([$target_os], [darwin*], [AC_PROG_OBJC], [AM_CONDITIONAL([am__fastdepOBJC], [false])])
# test_util.cc takes forever to compile with GCC and optimization turned on.
AC_MSG_CHECKING([C++ compiler flags...])
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
AS_IF([test "$GCC" = "yes"],[
PROTOBUF_OPT_FLAG="-O2"
CXXFLAGS="${CXXFLAGS} -g"
])
# Protocol Buffers contains several checks that are intended to be used only
# for debugging and which might hurt performance. Most users are probably
# end users who don't want these checks, so add -DNDEBUG by default.
CXXFLAGS="$CXXFLAGS -std=c++11 -DNDEBUG"
AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
],[
AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
])
AC_SUBST(PROTOBUF_OPT_FLAG)
ACX_CHECK_SUNCC
# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
# to the link
AC_PROG_LIBTOOL
# Check whether the linker supports version scripts
AC_MSG_CHECKING([whether the linker supports version scripts])
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
cat > conftest.map <<EOF
{
global:
main;
local:
*;
};
EOF
AC_LINK_IFELSE(
[AC_LANG_SOURCE([int main() { return 0; }])],
[have_ld_version_script=yes; AC_MSG_RESULT(yes)],
[have_ld_version_script=no; AC_MSG_RESULT(no)])
LDFLAGS=$save_LDFLAGS
AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT], [test "$have_ld_version_script" = "yes"])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
# Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_STRTOD
AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
# Check for zlib.
HAVE_ZLIB=0
AS_IF([test "$with_zlib" != no], [
AC_MSG_CHECKING([zlib version])
# First check the zlib header version.
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#include <zlib.h>
#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
# error zlib version too old
#endif
]], [])], [
AC_MSG_RESULT([ok (1.2.0.4 or later)])
# Also need to add -lz to the linker flags and make sure this succeeds.
AC_SEARCH_LIBS([zlibVersion], [z], [
AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
HAVE_ZLIB=1
], [
AS_IF([test "$with_zlib" != check], [
AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found])
])
])
], [
AS_IF([test "$with_zlib" = check], [
AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)])
], [
AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)])
])
])
])
AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
# Add -std=c++11 if necesssary. It is important for us to do this before the
# libatomic check below, since that also depends on C++11.
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
dnl On some platforms, std::atomic needs a helper library
AC_MSG_CHECKING(whether -latomic is needed)
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <atomic>
#include <cstdint>
std::atomic<std::int64_t> v;
int main() {
return v;
}
]])], STD_ATOMIC_NEED_LIBATOMIC=no, STD_ATOMIC_NEED_LIBATOMIC=yes)
AC_MSG_RESULT($STD_ATOMIC_NEED_LIBATOMIC)
if test "x$STD_ATOMIC_NEED_LIBATOMIC" = xyes; then
LIBATOMIC_LIBS="-latomic"
fi
AC_SUBST([LIBATOMIC_LIBS])
AS_IF([test "$with_protoc" != "no"], [
PROTOC=$with_protoc
AS_IF([test "$with_protoc" = "yes"], [
# No argument given. Use system protoc.
PROTOC=protoc
])
AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
# Does not start with a slash, but contains a slash. So, it's a relative
# path (as opposed to an absolute path or an executable in $PATH).
# Since it will actually be executed from the src directory, prefix with
# the current directory. We also insert $ac_top_build_prefix in case this
# is a nested package and --with-protoc was actually given on the outer
# package's configure script.
PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
])
AC_SUBST([PROTOC])
])
AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
AX_PTHREAD
AM_CONDITIONAL([HAVE_PTHREAD], [test "x$ax_pthread_ok" = "xyes"])
# We still keep this for improving pbconfig.h for unsupported platforms.
AC_CXX_STL_HASH
# Enable ObjC support for conformance directory on OS X.
OBJC_CONFORMANCE_TEST=0
case "$target_os" in
darwin*)
OBJC_CONFORMANCE_TEST=1
;;
esac
AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])
AC_MSG_CHECKING(whether -llog is needed)
ANDROID_TEST=no
case "$target_os" in
*android*)
ANDROID_TEST=yes
;;
esac
AC_MSG_RESULT($ANDROID_TEST)
if test "x$ANDROID_TEST" = xyes; then
LIBLOG_LIBS="-llog"
fi
AC_SUBST([LIBLOG_LIBS])
# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
# too.
export CFLAGS
export CXXFLAGS
AC_CONFIG_SUBDIRS([third_party/googletest])
AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
AC_OUTPUT

View File

@ -0,0 +1,183 @@
# Conformance testing for Protobuf.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
load(
"@rules_pkg//:mappings.bzl",
"pkg_attributes",
"pkg_filegroup",
"pkg_files",
"strip_prefix",
)
exports_files([
"conformance_test_runner.sh",
"failure_list_java.txt",
"failure_list_java_lite.txt",
"text_format_failure_list_java.txt",
"text_format_failure_list_java_lite.txt",
])
cc_proto_library(
name = "test_messages_proto2_proto_cc",
deps = ["//:test_messages_proto2_proto"],
)
cc_proto_library(
name = "test_messages_proto3_proto_cc",
deps = ["//:test_messages_proto3_proto"],
)
proto_library(
name = "conformance_proto",
srcs = ["conformance.proto"],
visibility = ["//visibility:public"],
)
cc_proto_library(
name = "conformance_proto_cc",
deps = [":conformance_proto"],
)
java_proto_library(
name = "conformance_java_proto",
visibility = [
"//java:__subpackages__",
],
deps = [":conformance_proto"],
)
java_lite_proto_library(
name = "conformance_java_proto_lite",
visibility = [
"//java:__subpackages__",
],
deps = [":conformance_proto"],
)
cc_library(
name = "jsoncpp",
srcs = ["third_party/jsoncpp/jsoncpp.cpp"],
hdrs = ["third_party/jsoncpp/json.h"],
includes = ["."],
)
cc_library(
name = "conformance_test",
srcs = [
"conformance_test.cc",
"conformance_test_runner.cc",
],
hdrs = [
"conformance_test.h",
],
includes = ["."],
deps = [":conformance_proto_cc"],
)
cc_library(
name = "binary_json_conformance_suite",
srcs = ["binary_json_conformance_suite.cc"],
hdrs = ["binary_json_conformance_suite.h"],
deps = [
":conformance_test",
":jsoncpp",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
],
)
cc_library(
name = "text_format_conformance_suite",
srcs = ["text_format_conformance_suite.cc"],
hdrs = ["text_format_conformance_suite.h"],
deps = [
":conformance_test",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
],
)
cc_binary(
name = "conformance_test_runner",
srcs = ["conformance_test_main.cc"],
visibility = ["//visibility:public"],
deps = [
":binary_json_conformance_suite",
":conformance_test",
":text_format_conformance_suite",
],
)
java_binary(
name = "conformance_java",
srcs = ["ConformanceJava.java"],
main_class = "ConformanceJava",
visibility = [
"//java:__subpackages__",
],
deps = [
":conformance_java_proto",
"//:protobuf_java",
"//:protobuf_java_util",
"//:test_messages_proto2_java_proto",
"//:test_messages_proto3_java_proto",
],
)
java_binary(
name = "conformance_java_lite",
srcs = ["ConformanceJavaLite.java"],
main_class = "ConformanceJavaLite",
visibility = [
"//java:__subpackages__",
],
deps = [
":conformance_java_proto_lite",
"//:protobuf_java_util",
"//:protobuf_javalite",
"//:test_messages_proto2_java_proto_lite",
"//:test_messages_proto3_java_proto_lite",
],
)
filegroup(
name = "all_files",
srcs = glob(["**/*"]),
visibility = ["//:__pkg__"],
)
pkg_files(
name = "dist_files",
srcs = glob(
["**/*"],
exclude = [
# Handled by dist_scripts:
"conformance_test_runner.sh",
# The following are not in autotools dist:
"autoload.php",
"conformance_nodejs.js",
"failure_list_jruby.txt",
"update_failure_list.py",
],
),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
pkg_files(
name = "dist_scripts",
srcs = ["conformance_test_runner.sh"],
attributes = pkg_attributes(mode = "0555"),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
pkg_filegroup(
name = "all_dist_files",
srcs = [
":dist_files",
":dist_scripts",
],
visibility = ["//pkg:__pkg__"],
)

View File

@ -0,0 +1,418 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.ByteString;
import com.google.protobuf.CodedInputStream;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Parser;
import com.google.protobuf.TextFormat;
import com.google.protobuf.conformance.Conformance;
import com.google.protobuf.util.JsonFormat;
import com.google.protobuf.util.JsonFormat.TypeRegistry;
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
import com.google.protobuf_test_messages.proto2.TestMessagesProto2.TestAllTypesProto2;
import com.google.protobuf_test_messages.proto3.TestMessagesProto3;
import com.google.protobuf_test_messages.proto3.TestMessagesProto3.TestAllTypesProto3;
import java.nio.ByteBuffer;
import java.util.ArrayList;
class ConformanceJava {
private int testCount = 0;
private TypeRegistry typeRegistry;
private boolean readFromStdin(byte[] buf, int len) throws Exception {
int ofs = 0;
while (len > 0) {
int read = System.in.read(buf, ofs, len);
if (read == -1) {
return false; // EOF
}
ofs += read;
len -= read;
}
return true;
}
private void writeToStdout(byte[] buf) throws Exception {
System.out.write(buf);
}
// Returns -1 on EOF (the actual values will always be positive).
private int readLittleEndianIntFromStdin() throws Exception {
byte[] buf = new byte[4];
if (!readFromStdin(buf, 4)) {
return -1;
}
return (buf[0] & 0xff)
| ((buf[1] & 0xff) << 8)
| ((buf[2] & 0xff) << 16)
| ((buf[3] & 0xff) << 24);
}
private void writeLittleEndianIntToStdout(int val) throws Exception {
byte[] buf = new byte[4];
buf[0] = (byte) val;
buf[1] = (byte) (val >> 8);
buf[2] = (byte) (val >> 16);
buf[3] = (byte) (val >> 24);
writeToStdout(buf);
}
private enum BinaryDecoderType {
BTYE_STRING_DECODER,
BYTE_ARRAY_DECODER,
ARRAY_BYTE_BUFFER_DECODER,
READONLY_ARRAY_BYTE_BUFFER_DECODER,
DIRECT_BYTE_BUFFER_DECODER,
READONLY_DIRECT_BYTE_BUFFER_DECODER,
INPUT_STREAM_DECODER;
}
private static class BinaryDecoder<T extends AbstractMessage> {
public T decode(
ByteString bytes, BinaryDecoderType type, Parser<T> parser, ExtensionRegistry extensions)
throws InvalidProtocolBufferException {
switch (type) {
case BTYE_STRING_DECODER:
case BYTE_ARRAY_DECODER:
return parser.parseFrom(bytes, extensions);
case ARRAY_BYTE_BUFFER_DECODER:
{
ByteBuffer buffer = ByteBuffer.allocate(bytes.size());
bytes.copyTo(buffer);
buffer.flip();
return parser.parseFrom(CodedInputStream.newInstance(buffer), extensions);
}
case READONLY_ARRAY_BYTE_BUFFER_DECODER:
{
return parser.parseFrom(
CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer()), extensions);
}
case DIRECT_BYTE_BUFFER_DECODER:
{
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
bytes.copyTo(buffer);
buffer.flip();
return parser.parseFrom(CodedInputStream.newInstance(buffer), extensions);
}
case READONLY_DIRECT_BYTE_BUFFER_DECODER:
{
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
bytes.copyTo(buffer);
buffer.flip();
return parser.parseFrom(
CodedInputStream.newInstance(buffer.asReadOnlyBuffer()), extensions);
}
case INPUT_STREAM_DECODER:
{
return parser.parseFrom(bytes.newInput(), extensions);
}
}
return null;
}
}
private <T extends AbstractMessage> T parseBinary(
ByteString bytes, Parser<T> parser, ExtensionRegistry extensions)
throws InvalidProtocolBufferException {
ArrayList<T> messages = new ArrayList<>();
ArrayList<InvalidProtocolBufferException> exceptions = new ArrayList<>();
for (int i = 0; i < BinaryDecoderType.values().length; i++) {
messages.add(null);
exceptions.add(null);
}
if (messages.isEmpty()) {
throw new RuntimeException("binary decoder types missing");
}
BinaryDecoder<T> decoder = new BinaryDecoder<>();
boolean hasMessage = false;
boolean hasException = false;
for (int i = 0; i < BinaryDecoderType.values().length; ++i) {
try {
// = BinaryDecoderType.values()[i].parseProto3(bytes);
messages.set(i, decoder.decode(bytes, BinaryDecoderType.values()[i], parser, extensions));
hasMessage = true;
} catch (InvalidProtocolBufferException e) {
exceptions.set(i, e);
hasException = true;
}
}
if (hasMessage && hasException) {
StringBuilder sb =
new StringBuilder("Binary decoders disagreed on whether the payload was valid.\n");
for (int i = 0; i < BinaryDecoderType.values().length; ++i) {
sb.append(BinaryDecoderType.values()[i].name());
if (messages.get(i) != null) {
sb.append(" accepted the payload.\n");
} else {
sb.append(" rejected the payload.\n");
}
}
throw new RuntimeException(sb.toString());
}
if (hasException) {
// We do not check if exceptions are equal. Different implementations may return different
// exception messages. Throw an arbitrary one out instead.
InvalidProtocolBufferException exception = null;
for (InvalidProtocolBufferException e : exceptions) {
if (exception != null) {
exception.addSuppressed(e);
} else {
exception = e;
}
}
throw exception;
}
// Fast path comparing all the messages with the first message, assuming equality being
// symmetric and transitive.
boolean allEqual = true;
for (int i = 1; i < messages.size(); ++i) {
if (!messages.get(0).equals(messages.get(i))) {
allEqual = false;
break;
}
}
// Slow path: compare and find out all unequal pairs.
if (!allEqual) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < messages.size() - 1; ++i) {
for (int j = i + 1; j < messages.size(); ++j) {
if (!messages.get(i).equals(messages.get(j))) {
sb.append(BinaryDecoderType.values()[i].name())
.append(" and ")
.append(BinaryDecoderType.values()[j].name())
.append(" parsed the payload differently.\n");
}
}
}
throw new RuntimeException(sb.toString());
}
return messages.get(0);
}
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
AbstractMessage testMessage;
String messageType = request.getMessageType();
boolean isProto3 =
messageType.equals("protobuf_test_messages.proto3.TestAllTypesProto3");
boolean isProto2 =
messageType.equals("protobuf_test_messages.proto2.TestAllTypesProto2");
switch (request.getPayloadCase()) {
case PROTOBUF_PAYLOAD:
{
if (isProto3) {
try {
ExtensionRegistry extensions = ExtensionRegistry.newInstance();
TestMessagesProto3.registerAllExtensions(extensions);
testMessage =
parseBinary(
request.getProtobufPayload(), TestAllTypesProto3.parser(), extensions);
} catch (InvalidProtocolBufferException e) {
return Conformance.ConformanceResponse.newBuilder()
.setParseError(e.getMessage())
.build();
}
} else if (isProto2) {
try {
ExtensionRegistry extensions = ExtensionRegistry.newInstance();
TestMessagesProto2.registerAllExtensions(extensions);
testMessage =
parseBinary(
request.getProtobufPayload(), TestAllTypesProto2.parser(), extensions);
} catch (InvalidProtocolBufferException e) {
return Conformance.ConformanceResponse.newBuilder()
.setParseError(e.getMessage())
.build();
}
} else {
throw new IllegalArgumentException(
"Protobuf request has unexpected payload type: " + messageType);
}
break;
}
case JSON_PAYLOAD:
{
try {
JsonFormat.Parser parser = JsonFormat.parser().usingTypeRegistry(typeRegistry);
if (request.getTestCategory()
== Conformance.TestCategory.JSON_IGNORE_UNKNOWN_PARSING_TEST) {
parser = parser.ignoringUnknownFields();
}
if (isProto3) {
TestMessagesProto3.TestAllTypesProto3.Builder builder =
TestMessagesProto3.TestAllTypesProto3.newBuilder();
parser.merge(request.getJsonPayload(), builder);
testMessage = builder.build();
} else if (isProto2) {
TestMessagesProto2.TestAllTypesProto2.Builder builder =
TestMessagesProto2.TestAllTypesProto2.newBuilder();
parser.merge(request.getJsonPayload(), builder);
testMessage = builder.build();
} else {
throw new IllegalArgumentException(
"Protobuf request has unexpected payload type: " + messageType);
}
} catch (InvalidProtocolBufferException e) {
return Conformance.ConformanceResponse.newBuilder()
.setParseError(e.getMessage())
.build();
}
break;
}
case TEXT_PAYLOAD:
{
if (isProto3) {
try {
TestMessagesProto3.TestAllTypesProto3.Builder builder =
TestMessagesProto3.TestAllTypesProto3.newBuilder();
TextFormat.merge(request.getTextPayload(), builder);
testMessage = builder.build();
} catch (TextFormat.ParseException e) {
return Conformance.ConformanceResponse.newBuilder()
.setParseError(e.getMessage())
.build();
}
} else if (isProto2) {
try {
TestMessagesProto2.TestAllTypesProto2.Builder builder =
TestMessagesProto2.TestAllTypesProto2.newBuilder();
TextFormat.merge(request.getTextPayload(), builder);
testMessage = builder.build();
} catch (TextFormat.ParseException e) {
return Conformance.ConformanceResponse.newBuilder()
.setParseError(e.getMessage())
.build();
}
} else {
throw new IllegalArgumentException(
"Protobuf request has unexpected payload type: " + messageType);
}
break;
}
case PAYLOAD_NOT_SET:
{
throw new IllegalArgumentException("Request didn't have payload.");
}
default:
{
throw new IllegalArgumentException("Unexpected payload case.");
}
}
switch (request.getRequestedOutputFormat()) {
case UNSPECIFIED:
throw new IllegalArgumentException("Unspecified output format.");
case PROTOBUF:
{
ByteString messageString = testMessage.toByteString();
return Conformance.ConformanceResponse.newBuilder()
.setProtobufPayload(messageString)
.build();
}
case JSON:
try {
return Conformance.ConformanceResponse.newBuilder()
.setJsonPayload(
JsonFormat.printer().usingTypeRegistry(typeRegistry).print(testMessage))
.build();
} catch (InvalidProtocolBufferException | IllegalArgumentException e) {
return Conformance.ConformanceResponse.newBuilder()
.setSerializeError(e.getMessage())
.build();
}
case TEXT_FORMAT:
return Conformance.ConformanceResponse.newBuilder()
.setTextPayload(TextFormat.printer().printToString(testMessage))
.build();
default:
{
throw new IllegalArgumentException("Unexpected request output.");
}
}
}
private boolean doTestIo() throws Exception {
int bytes = readLittleEndianIntFromStdin();
if (bytes == -1) {
return false; // EOF
}
byte[] serializedInput = new byte[bytes];
if (!readFromStdin(serializedInput, bytes)) {
throw new RuntimeException("Unexpected EOF from test program.");
}
Conformance.ConformanceRequest request =
Conformance.ConformanceRequest.parseFrom(serializedInput);
Conformance.ConformanceResponse response = doTest(request);
byte[] serializedOutput = response.toByteArray();
writeLittleEndianIntToStdout(serializedOutput.length);
writeToStdout(serializedOutput);
return true;
}
public void run() throws Exception {
typeRegistry =
TypeRegistry.newBuilder()
.add(TestMessagesProto3.TestAllTypesProto3.getDescriptor())
.build();
while (doTestIo()) {
this.testCount++;
}
System.err.println(
"ConformanceJava: received EOF from test runner after " + this.testCount + " tests");
}
public static void main(String[] args) throws Exception {
new ConformanceJava().run();
}
}

View File

@ -0,0 +1,351 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import com.google.protobuf.ByteString;
import com.google.protobuf.CodedInputStream;
import com.google.protobuf.ExtensionRegistryLite;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.MessageLite;
import com.google.protobuf.Parser;
import com.google.protobuf.conformance.Conformance;
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
import com.google.protobuf_test_messages.proto2.TestMessagesProto2.TestAllTypesProto2;
import com.google.protobuf_test_messages.proto3.TestMessagesProto3;
import com.google.protobuf_test_messages.proto3.TestMessagesProto3.TestAllTypesProto3;
import java.nio.ByteBuffer;
import java.util.ArrayList;
class ConformanceJavaLite {
private int testCount = 0;
private boolean readFromStdin(byte[] buf, int len) throws Exception {
int ofs = 0;
while (len > 0) {
int read = System.in.read(buf, ofs, len);
if (read == -1) {
return false; // EOF
}
ofs += read;
len -= read;
}
return true;
}
private void writeToStdout(byte[] buf) throws Exception {
System.out.write(buf);
}
// Returns -1 on EOF (the actual values will always be positive).
private int readLittleEndianIntFromStdin() throws Exception {
byte[] buf = new byte[4];
if (!readFromStdin(buf, 4)) {
return -1;
}
return (buf[0] & 0xff)
| ((buf[1] & 0xff) << 8)
| ((buf[2] & 0xff) << 16)
| ((buf[3] & 0xff) << 24);
}
private void writeLittleEndianIntToStdout(int val) throws Exception {
byte[] buf = new byte[4];
buf[0] = (byte) val;
buf[1] = (byte) (val >> 8);
buf[2] = (byte) (val >> 16);
buf[3] = (byte) (val >> 24);
writeToStdout(buf);
}
private enum BinaryDecoderType {
BTYE_STRING_DECODER,
BYTE_ARRAY_DECODER,
ARRAY_BYTE_BUFFER_DECODER,
READONLY_ARRAY_BYTE_BUFFER_DECODER,
DIRECT_BYTE_BUFFER_DECODER,
READONLY_DIRECT_BYTE_BUFFER_DECODER,
INPUT_STREAM_DECODER;
}
private static class BinaryDecoder<T extends MessageLite> {
public T decode(
ByteString bytes,
BinaryDecoderType type,
Parser<T> parser,
ExtensionRegistryLite extensions)
throws InvalidProtocolBufferException {
switch (type) {
case BTYE_STRING_DECODER:
case BYTE_ARRAY_DECODER:
return parser.parseFrom(bytes, extensions);
case ARRAY_BYTE_BUFFER_DECODER:
{
ByteBuffer buffer = ByteBuffer.allocate(bytes.size());
bytes.copyTo(buffer);
buffer.flip();
return parser.parseFrom(CodedInputStream.newInstance(buffer), extensions);
}
case READONLY_ARRAY_BYTE_BUFFER_DECODER:
{
return parser.parseFrom(
CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer()), extensions);
}
case DIRECT_BYTE_BUFFER_DECODER:
{
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
bytes.copyTo(buffer);
buffer.flip();
return parser.parseFrom(CodedInputStream.newInstance(buffer), extensions);
}
case READONLY_DIRECT_BYTE_BUFFER_DECODER:
{
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
bytes.copyTo(buffer);
buffer.flip();
return parser.parseFrom(
CodedInputStream.newInstance(buffer.asReadOnlyBuffer()), extensions);
}
case INPUT_STREAM_DECODER:
{
return parser.parseFrom(bytes.newInput(), extensions);
}
}
return null;
}
}
private <T extends MessageLite> T parseBinary(
ByteString bytes, Parser<T> parser, ExtensionRegistryLite extensions)
throws InvalidProtocolBufferException {
ArrayList<T> messages = new ArrayList<>();
ArrayList<InvalidProtocolBufferException> exceptions = new ArrayList<>();
for (int i = 0; i < BinaryDecoderType.values().length; i++) {
messages.add(null);
exceptions.add(null);
}
if (messages.isEmpty()) {
throw new RuntimeException("binary decoder types missing");
}
BinaryDecoder<T> decoder = new BinaryDecoder<>();
boolean hasMessage = false;
boolean hasException = false;
for (int i = 0; i < BinaryDecoderType.values().length; ++i) {
try {
messages.set(i, decoder.decode(bytes, BinaryDecoderType.values()[i], parser, extensions));
hasMessage = true;
} catch (InvalidProtocolBufferException e) {
exceptions.set(i, e);
hasException = true;
}
}
if (hasMessage && hasException) {
StringBuilder sb =
new StringBuilder("Binary decoders disagreed on whether the payload was valid.\n");
for (int i = 0; i < BinaryDecoderType.values().length; ++i) {
sb.append(BinaryDecoderType.values()[i].name());
if (messages.get(i) != null) {
sb.append(" accepted the payload.\n");
} else {
sb.append(" rejected the payload.\n");
}
}
throw new RuntimeException(sb.toString());
}
if (hasException) {
// We do not check if exceptions are equal. Different implementations may return different
// exception messages. Throw an arbitrary one out instead.
InvalidProtocolBufferException exception = null;
for (InvalidProtocolBufferException e : exceptions) {
if (exception != null) {
exception.addSuppressed(e);
} else {
exception = e;
}
}
throw exception;
}
// Fast path comparing all the messages with the first message, assuming equality being
// symmetric and transitive.
boolean allEqual = true;
for (int i = 1; i < messages.size(); ++i) {
if (!messages.get(0).equals(messages.get(i))) {
allEqual = false;
break;
}
}
// Slow path: compare and find out all unequal pairs.
if (!allEqual) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < messages.size() - 1; ++i) {
for (int j = i + 1; j < messages.size(); ++j) {
if (!messages.get(i).equals(messages.get(j))) {
sb.append(BinaryDecoderType.values()[i].name())
.append(" and ")
.append(BinaryDecoderType.values()[j].name())
.append(" parsed the payload differently.\n");
}
}
}
throw new RuntimeException(sb.toString());
}
return messages.get(0);
}
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
com.google.protobuf.MessageLite testMessage;
boolean isProto3 =
request.getMessageType().equals("protobuf_test_messages.proto3.TestAllTypesProto3");
boolean isProto2 =
request.getMessageType().equals("protobuf_test_messages.proto2.TestAllTypesProto2");
switch (request.getPayloadCase()) {
case PROTOBUF_PAYLOAD:
{
if (isProto3) {
try {
ExtensionRegistryLite extensions = ExtensionRegistryLite.newInstance();
TestMessagesProto3.registerAllExtensions(extensions);
testMessage =
parseBinary(
request.getProtobufPayload(), TestAllTypesProto3.parser(), extensions);
} catch (InvalidProtocolBufferException e) {
return Conformance.ConformanceResponse.newBuilder()
.setParseError(e.getMessage())
.build();
}
} else if (isProto2) {
try {
ExtensionRegistryLite extensions = ExtensionRegistryLite.newInstance();
TestMessagesProto2.registerAllExtensions(extensions);
testMessage =
parseBinary(
request.getProtobufPayload(), TestAllTypesProto2.parser(), extensions);
} catch (InvalidProtocolBufferException e) {
return Conformance.ConformanceResponse.newBuilder()
.setParseError(e.getMessage())
.build();
}
} else {
throw new RuntimeException("Protobuf request doesn't have specific payload type.");
}
break;
}
case JSON_PAYLOAD:
{
return Conformance.ConformanceResponse.newBuilder()
.setSkipped("Lite runtime does not support JSON format.")
.build();
}
case TEXT_PAYLOAD:
{
return Conformance.ConformanceResponse.newBuilder()
.setSkipped("Lite runtime does not support Text format.")
.build();
}
case PAYLOAD_NOT_SET:
{
throw new RuntimeException("Request didn't have payload.");
}
default:
{
throw new RuntimeException("Unexpected payload case.");
}
}
switch (request.getRequestedOutputFormat()) {
case UNSPECIFIED:
throw new RuntimeException("Unspecified output format.");
case PROTOBUF:
return Conformance.ConformanceResponse.newBuilder()
.setProtobufPayload(testMessage.toByteString())
.build();
case JSON:
return Conformance.ConformanceResponse.newBuilder()
.setSkipped("Lite runtime does not support JSON format.")
.build();
case TEXT_FORMAT:
return Conformance.ConformanceResponse.newBuilder()
.setSkipped("Lite runtime does not support Text format.")
.build();
default:
{
throw new RuntimeException("Unexpected request output.");
}
}
}
private boolean doTestIo() throws Exception {
int bytes = readLittleEndianIntFromStdin();
if (bytes == -1) {
return false; // EOF
}
byte[] serializedInput = new byte[bytes];
if (!readFromStdin(serializedInput, bytes)) {
throw new RuntimeException("Unexpected EOF from test program.");
}
Conformance.ConformanceRequest request =
Conformance.ConformanceRequest.parseFrom(serializedInput);
Conformance.ConformanceResponse response = doTest(request);
byte[] serializedOutput = response.toByteArray();
writeLittleEndianIntToStdout(serializedOutput.length);
writeToStdout(serializedOutput);
return true;
}
public void run() throws Exception {
while (doTestIo()) {
this.testCount++;
}
System.err.println(
"ConformanceJavaLite: received EOF from test runner after " + this.testCount + " tests");
}
public static void main(String[] args) throws Exception {
new ConformanceJavaLite().run();
}
}

View File

@ -0,0 +1,372 @@
## Process this file with automake to produce Makefile.in
conformance_protoc_inputs = \
conformance.proto \
$(top_srcdir)/src/google/protobuf/test_messages_proto3.proto
# proto2 input files, should be separated with proto3, as we
# can't generate proto2 files for php.
conformance_proto2_protoc_inputs = \
$(top_srcdir)/src/google/protobuf/test_messages_proto2.proto
well_known_type_protoc_inputs = \
$(top_srcdir)/src/google/protobuf/any.proto \
$(top_srcdir)/src/google/protobuf/duration.proto \
$(top_srcdir)/src/google/protobuf/field_mask.proto \
$(top_srcdir)/src/google/protobuf/struct.proto \
$(top_srcdir)/src/google/protobuf/timestamp.proto \
$(top_srcdir)/src/google/protobuf/wrappers.proto
protoc_outputs = \
conformance.pb.cc \
conformance.pb.h
other_language_protoc_outputs = \
conformance_pb2.py \
Conformance.pbobjc.h \
Conformance.pbobjc.m \
conformance_pb.js \
conformance_pb.rb \
com/google/protobuf/Any.java \
com/google/protobuf/AnyOrBuilder.java \
com/google/protobuf/AnyProto.java \
com/google/protobuf/BoolValue.java \
com/google/protobuf/BoolValueOrBuilder.java \
com/google/protobuf/BytesValue.java \
com/google/protobuf/BytesValueOrBuilder.java \
com/google/protobuf/conformance/Conformance.java \
com/google/protobuf/DoubleValue.java \
com/google/protobuf/DoubleValueOrBuilder.java \
com/google/protobuf/Duration.java \
com/google/protobuf/DurationOrBuilder.java \
com/google/protobuf/DurationProto.java \
com/google/protobuf/FieldMask.java \
com/google/protobuf/FieldMaskOrBuilder.java \
com/google/protobuf/FieldMaskProto.java \
com/google/protobuf/FloatValue.java \
com/google/protobuf/FloatValueOrBuilder.java \
com/google/protobuf/Int32Value.java \
com/google/protobuf/Int32ValueOrBuilder.java \
com/google/protobuf/Int64Value.java \
com/google/protobuf/Int64ValueOrBuilder.java \
com/google/protobuf/ListValue.java \
com/google/protobuf/ListValueOrBuilder.java \
com/google/protobuf/NullValue.java \
com/google/protobuf/StringValue.java \
com/google/protobuf/StringValueOrBuilder.java \
com/google/protobuf/Struct.java \
com/google/protobuf/StructOrBuilder.java \
com/google/protobuf/StructProto.java \
com/google/protobuf/Timestamp.java \
com/google/protobuf/TimestampOrBuilder.java \
com/google/protobuf/TimestampProto.java \
com/google/protobuf/UInt32Value.java \
com/google/protobuf/UInt32ValueOrBuilder.java \
com/google/protobuf/UInt64Value.java \
com/google/protobuf/UInt64ValueOrBuilder.java \
com/google/protobuf/Value.java \
com/google/protobuf/ValueOrBuilder.java \
com/google/protobuf/WrappersProto.java \
com/google/protobuf_test_messages/proto3/TestMessagesProto3.java \
com/google/protobuf_test_messages/proto2/TestMessagesProto2.java \
google/protobuf/any.pb.cc \
google/protobuf/any.pb.h \
google/protobuf/any.rb \
google/protobuf/any_pb2.py \
google/protobuf/duration.pb.cc \
google/protobuf/duration.pb.h \
google/protobuf/duration.rb \
google/protobuf/duration_pb2.py \
google/protobuf/field_mask.pb.cc \
google/protobuf/field_mask.pb.h \
google/protobuf/field_mask.rb \
google/protobuf/field_mask_pb2.py \
google/protobuf/struct.pb.cc \
google/protobuf/struct.pb.h \
google/protobuf/struct.rb \
google/protobuf/struct_pb2.py \
google/protobuf/TestMessagesProto2.pbobjc.h \
google/protobuf/TestMessagesProto2.pbobjc.m \
google/protobuf/TestMessagesProto3.pbobjc.h \
google/protobuf/TestMessagesProto3.pbobjc.m \
google/protobuf/test_messages_proto3.pb.cc \
google/protobuf/test_messages_proto3.pb.h \
google/protobuf/test_messages_proto2.pb.cc \
google/protobuf/test_messages_proto2.pb.h \
google/protobuf/test_messages_proto3_pb.rb \
google/protobuf/test_messages_proto3_pb2.py \
google/protobuf/test_messages_proto2_pb2.py \
google/protobuf/timestamp.pb.cc \
google/protobuf/timestamp.pb.h \
google/protobuf/timestamp.rb \
google/protobuf/timestamp_pb2.py \
google/protobuf/wrappers.pb.cc \
google/protobuf/wrappers.pb.h \
google/protobuf/wrappers.rb \
google/protobuf/wrappers_pb2.py \
Conformance/ConformanceRequest.php \
Conformance/ConformanceResponse.php \
Conformance/FailureSet.php \
Conformance/WireFormat.php \
GPBMetadata/Conformance.php \
GPBMetadata/Google/Protobuf/Any.php \
GPBMetadata/Google/Protobuf/Duration.php \
GPBMetadata/Google/Protobuf/FieldMask.php \
GPBMetadata/Google/Protobuf/Struct.php \
GPBMetadata/Google/Protobuf/TestMessagesProto3.php \
GPBMetadata/Google/Protobuf/Timestamp.php \
GPBMetadata/Google/Protobuf/Wrappers.php \
Google/Protobuf/Any.php \
Google/Protobuf/BoolValue.php \
Google/Protobuf/BytesValue.php \
Google/Protobuf/DoubleValue.php \
Google/Protobuf/Duration.php \
Google/Protobuf/FieldMask.php \
Google/Protobuf/FloatValue.php \
Google/Protobuf/Int32Value.php \
Google/Protobuf/Int64Value.php \
Google/Protobuf/ListValue.php \
Google/Protobuf/NullValue.php \
Google/Protobuf/StringValue.php \
Google/Protobuf/Struct.php \
Google/Protobuf/Timestamp.php \
Google/Protobuf/UInt32Value.php \
Google/Protobuf/UInt64Value.php \
Google/Protobuf/Value.php \
Protobuf_test_messages/Proto3/ForeignEnum.php \
Protobuf_test_messages/Proto3/ForeignMessage.php \
Protobuf_test_messages/Proto3/TestAllTypes_NestedEnum.php \
Protobuf_test_messages/Proto3/TestAllTypes_NestedMessage.php \
Protobuf_test_messages/Proto3/TestAllTypes.php
# lite/com/google/protobuf/Any.java \
# lite/com/google/protobuf/AnyOrBuilder.java \
# lite/com/google/protobuf/AnyProto.java \
# lite/com/google/protobuf/BoolValue.java \
# lite/com/google/protobuf/BoolValueOrBuilder.java \
# lite/com/google/protobuf/BytesValue.java \
# lite/com/google/protobuf/BytesValueOrBuilder.java \
# lite/com/google/protobuf/conformance/Conformance.java \
# lite/com/google/protobuf/DoubleValue.java \
# lite/com/google/protobuf/DoubleValueOrBuilder.java \
# lite/com/google/protobuf/Duration.java \
# lite/com/google/protobuf/DurationOrBuilder.java \
# lite/com/google/protobuf/DurationProto.java \
# lite/com/google/protobuf/FieldMask.java \
# lite/com/google/protobuf/FieldMaskOrBuilder.java \
# lite/com/google/protobuf/FieldMaskProto.java \
# lite/com/google/protobuf/FloatValue.java \
# lite/com/google/protobuf/FloatValueOrBuilder.java \
# lite/com/google/protobuf/Int32Value.java \
# lite/com/google/protobuf/Int32ValueOrBuilder.java \
# lite/com/google/protobuf/Int64Value.java \
# lite/com/google/protobuf/Int64ValueOrBuilder.java \
# lite/com/google/protobuf/ListValue.java \
# lite/com/google/protobuf/ListValueOrBuilder.java \
# lite/com/google/protobuf/NullValue.java \
# lite/com/google/protobuf/StringValue.java \
# lite/com/google/protobuf/StringValueOrBuilder.java \
# lite/com/google/protobuf/Struct.java \
# lite/com/google/protobuf/StructOrBuilder.java \
# lite/com/google/protobuf/StructProto.java \
# lite/com/google/protobuf/Timestamp.java \
# lite/com/google/protobuf/TimestampOrBuilder.java \
# lite/com/google/protobuf/TimestampProto.java \
# lite/com/google/protobuf/UInt32Value.java \
# lite/com/google/protobuf/UInt32ValueOrBuilder.java \
# lite/com/google/protobuf/UInt64Value.java \
# lite/com/google/protobuf/UInt64ValueOrBuilder.java \
# lite/com/google/protobuf/Value.java \
# lite/com/google/protobuf/ValueOrBuilder.java \
# lite/com/google/protobuf/WrappersProto.java
bin_PROGRAMS = conformance-test-runner conformance-cpp
# All source files excepet C++/Objective-C ones should be explicitly listed
# here because the autoconf tools don't include files of other languages
# automatically.
EXTRA_DIST = \
ConformanceJava.java \
ConformanceJavaLite.java \
README.md \
conformance.proto \
conformance_python.py \
conformance_ruby.rb \
conformance_php.php \
failure_list_cpp.txt \
failure_list_csharp.txt \
failure_list_java.txt \
failure_list_js.txt \
failure_list_objc.txt \
failure_list_python.txt \
failure_list_python_cpp.txt \
failure_list_python-post26.txt \
failure_list_ruby.txt \
failure_list_php.txt \
failure_list_php_c.txt
conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la
conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \
conformance_test_main.cc \
binary_json_conformance_suite.h \
binary_json_conformance_suite.cc \
text_format_conformance_suite.h \
text_format_conformance_suite.cc \
conformance_test_runner.cc \
third_party/jsoncpp/json.h \
third_party/jsoncpp/jsoncpp.cpp
nodist_conformance_test_runner_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc google/protobuf/test_messages_proto2.pb.cc
conformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)
conformance_test_runner_CXXFLAGS = -std=c++11
# Explicit deps because BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_cpp" could fail if parallel enough.
conformance_test_runner-conformance_test.$(OBJEXT): conformance.pb.h
conformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h
conformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la
conformance_cpp_SOURCES = conformance_cpp.cc
nodist_conformance_cpp_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc google/protobuf/test_messages_proto2.pb.cc
conformance_cpp_CPPFLAGS = -I$(top_srcdir)/src
# Explicit dep because BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_cpp" could fail if parallel enough.
conformance_cpp-conformance_cpp.$(OBJEXT): conformance.pb.h
if OBJC_CONFORMANCE_TEST
bin_PROGRAMS += conformance-objc
conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m
nodist_conformance_objc_SOURCES = Conformance.pbobjc.m google/protobuf/TestMessagesProto2.pbobjc.m google/protobuf/TestMessagesProto3.pbobjc.m
# On travis, the build fails without the isysroot because whatever system
# headers are being found don't include generics support for
# NSArray/NSDictionary, the only guess is their image at one time had an odd
# setup for Xcode and old frameworks are being found.
conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk macosx --show-sdk-path`
conformance_objc_LDFLAGS = -framework Foundation
# Explicit dep because BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_objc" could fail if parallel enough.
conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h google/protobuf/TestMessagesProto2.pbobjc.h google/protobuf/TestMessagesProto3.pbobjc.h
endif
# JavaScript well-known types are expected to be in a directory called
# google-protobuf, because they are usually in the google-protobuf npm
# package. But we want to use the sources from our tree, so we recreate
# that directory structure here.
google-protobuf:
mkdir google-protobuf
if USE_EXTERNAL_PROTOC
# Some implementations include pre-generated versions of well-known types.
protoc_middleman: $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. $(conformance_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. $(conformance_proto2_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. $(well_known_type_protoc_inputs)
## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
touch protoc_middleman
else
# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
# relative to srcdir, which may not be the same as the current directory when
# building out-of-tree.
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd $(conformance_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd $(conformance_proto2_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd $(well_known_type_protoc_inputs) )
## @mkdir -p lite
## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) )
touch protoc_middleman
endif
$(protoc_outputs): protoc_middleman
$(other_language_protoc_outputs): protoc_middleman
CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp conformance-php conformance-php-c $(other_language_protoc_outputs)
MAINTAINERCLEANFILES = \
Makefile.in
javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs)
jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java com/google/protobuf_test_messages/proto3/TestMessagesProto3.java com/google/protobuf_test_messages/proto2/TestMessagesProto2.java
@touch javac_middleman
conformance-java: javac_middleman
@echo "Writing shortcut script conformance-java..."
@echo '#! /bin/sh' > conformance-java
@jar=`ls ../java/util/target/*jar-with-dependencies.jar` && echo java -classpath .:../java/target/classes:$$jar ConformanceJava '$$@' >> conformance-java
@chmod +x conformance-java
javac_middleman_lite: ConformanceJavaLite.java protoc_middleman $(other_language_protoc_outputs)
javac -classpath ../java/lite/target/classes:lite ConformanceJavaLite.java lite/com/google/protobuf/conformance/Conformance.java
@touch javac_middleman_lite
conformance-java-lite: javac_middleman_lite
@echo "Writing shortcut script conformance-java-lite..."
@echo '#! /bin/sh' > conformance-java-lite
@echo java -classpath .:../java/lite/target/classes:lite ConformanceJavaLite '$$@' >> conformance-java-lite
@chmod +x conformance-java-lite
# Currently the conformance code is alongside the rest of the C#
# source, as it's easier to maintain there. We assume we've already
# built that, so we just need a script to run it.
conformance-csharp: $(other_language_protoc_outputs)
@echo "Writing shortcut script conformance-csharp..."
@echo '#! /bin/sh' > conformance-csharp
@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp3.1/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
@chmod +x conformance-csharp
conformance-php:
@echo "Writing shortcut script conformance-php..."
@echo '#! /bin/sh' > conformance-php
@echo 'php -d auto_prepend_file=autoload.php ./conformance_php.php' >> conformance-php
@chmod +x conformance-php
conformance-php-c:
@echo "Writing shortcut script conformance-php-c..."
@echo '#! /bin/sh' > conformance-php-c
@echo 'php -dextension=../php/ext/google/protobuf/modules/protobuf.so ./conformance_php.php' >> conformance-php-c
@chmod +x conformance-php-c
# Targets for actually running tests.
test_cpp: protoc_middleman conformance-test-runner conformance-cpp
./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt --text_format_failure_list text_format_failure_list_cpp.txt ./conformance-cpp
test_java: protoc_middleman conformance-test-runner conformance-java
./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt --text_format_failure_list text_format_failure_list_java.txt ./conformance-java
test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite
./conformance-test-runner --enforce_recommended ./conformance-java-lite
test_csharp: protoc_middleman conformance-test-runner conformance-csharp
./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt --text_format_failure_list text_format_failure_list_csharp.txt ./conformance-csharp
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
test_jruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_jruby.txt --text_format_failure_list text_format_failure_list_jruby.txt ./conformance_ruby.rb
test_php: protoc_middleman conformance-test-runner conformance-php $(other_language_protoc_outputs)
./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php
test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
# These depend on library paths being properly set up. The easiest way to
# run them is to just use "tox" from the python dir.
test_python: protoc_middleman conformance-test-runner
./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt --text_format_failure_list text_format_failure_list_python.txt ./conformance_python.py
test_python_cpp: protoc_middleman conformance-test-runner
./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt --text_format_failure_list text_format_failure_list_python_cpp.txt ./conformance_python.py
if OBJC_CONFORMANCE_TEST
test_objc: protoc_middleman conformance-test-runner conformance-objc
./conformance-test-runner --enforce_recommended --failure_list failure_list_objc.txt ./conformance-objc
endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
Protocol Buffers - Google's data interchange format
===================================================
Copyright 2008 Google Inc.
This directory contains conformance tests for testing completeness and
correctness of Protocol Buffers implementations. These tests are designed
to be easy to run against any Protocol Buffers implementation.
This directory contains the tester process `conformance-test`, which
contains all of the tests themselves. Then separate programs written
in whatever language you want to test communicate with the tester
program over a pipe.
Before running any of these tests, make sure you run `make` in the base
directory to build `protoc`, since all the tests depend on it.
$ make
Running the tests for C++
-------------------------
To run the tests against the C++ implementation, run:
$ cd conformance && make test_cpp
Running the tests for JavaScript (Node.js)
------------------------------------------
To run the JavaScript tests against Node.js, make sure you have "node"
on your path and then run:
$ cd conformance && make test_nodejs
Running the tests for Ruby (MRI)
--------------------------------
To run the Ruby tests against MRI, first build the C extension:
$ cd ruby && rake
Then run the tests like so:
$ cd conformance && make test_ruby
Running the tests for other languages
-------------------------------------
Most of the languages in the Protobuf source tree are set up to run
conformance tests. However some of them are more tricky to set up
properly. See `tests.sh` in the base of the repository to see how
Kokoro runs the tests.
Testing other Protocol Buffer implementations
---------------------------------------------
To run these tests against a new Protocol Buffers implementation, write a
program in your language that uses the protobuf implementation you want
to test. This program should implement the testing protocol defined in
[conformance.proto](https://github.com/protocolbuffers/protobuf/blob/main/conformance/conformance.proto).
This is designed to be as easy as possible: the C++ version is only
150 lines and is a good example for what this program should look like
(see [conformance_cpp.cc](https://github.com/protocolbuffers/protobuf/blob/main/conformance/conformance_cpp.cc)).
The program only needs to be able to read from stdin and write to stdout.
Portability
-----------
Note that the test runner currently does not work on Windows. Patches
to fix this are welcome! (But please get in touch first to settle on
a general implementation strategy).

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,141 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
#define CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
#include "third_party/jsoncpp/json.h"
#include "conformance_test.h"
namespace google {
namespace protobuf {
class BinaryAndJsonConformanceSuite : public ConformanceTestSuite {
public:
BinaryAndJsonConformanceSuite() {}
private:
void RunSuiteImpl() override;
void RunJsonTests();
void RunJsonTestsForFieldNameConvention();
void RunJsonTestsForNonRepeatedTypes();
void RunJsonTestsForRepeatedTypes();
void RunJsonTestsForNullTypes();
void RunJsonTestsForWrapperTypes();
void RunJsonTestsForFieldMask();
void RunJsonTestsForStruct();
void RunJsonTestsForValue();
void RunJsonTestsForAny();
void RunValidJsonTest(const std::string& test_name, ConformanceLevel level,
const std::string& input_json,
const std::string& equivalent_text_format);
void RunValidJsonTestWithProtobufInput(
const std::string& test_name, ConformanceLevel level,
const protobuf_test_messages::proto3::TestAllTypesProto3& input,
const std::string& equivalent_text_format);
void RunValidJsonIgnoreUnknownTest(const std::string& test_name,
ConformanceLevel level,
const std::string& input_json,
const std::string& equivalent_text_format);
void RunValidProtobufTest(const std::string& test_name,
ConformanceLevel level,
const std::string& input_protobuf,
const std::string& equivalent_text_format,
bool is_proto3);
void RunValidBinaryProtobufTest(const std::string& test_name,
ConformanceLevel level,
const std::string& input_protobuf,
bool is_proto3);
void RunValidBinaryProtobufTest(const std::string& test_name,
ConformanceLevel level,
const std::string& input_protobuf,
const std::string& expected_protobuf,
bool is_proto3);
void RunValidProtobufTestWithMessage(
const std::string& test_name, ConformanceLevel level,
const Message* input, const std::string& equivalent_text_format,
bool is_proto3);
bool ParseJsonResponse(
const conformance::ConformanceResponse& response,
Message* test_message);
bool ParseResponse(
const conformance::ConformanceResponse& response,
const ConformanceRequestSetting& setting,
Message* test_message) override;
typedef std::function<bool(const Json::Value&)> Validator;
void RunValidJsonTestWithValidator(const std::string& test_name,
ConformanceLevel level,
const std::string& input_json,
const Validator& validator,
bool is_proto3);
void ExpectParseFailureForJson(const std::string& test_name,
ConformanceLevel level,
const std::string& input_json);
void ExpectSerializeFailureForJson(const std::string& test_name,
ConformanceLevel level,
const std::string& text_format);
void ExpectParseFailureForProtoWithProtoVersion(const std::string& proto,
const std::string& test_name,
ConformanceLevel level,
bool is_proto3);
void ExpectParseFailureForProto(const std::string& proto,
const std::string& test_name,
ConformanceLevel level);
void ExpectHardParseFailureForProto(const std::string& proto,
const std::string& test_name,
ConformanceLevel level);
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
void TestIllegalTags();
template <class MessageType>
void TestOneofMessage (MessageType &message,
bool is_proto3);
template <class MessageType>
void TestUnknownMessage (MessageType &message,
bool is_proto3);
void TestValidDataForType(
google::protobuf::FieldDescriptor::Type,
std::vector<std::pair<std::string, std::string>> values);
void TestValidDataForRepeatedScalarMessage();
void TestValidDataForMapType(google::protobuf::FieldDescriptor::Type,
google::protobuf::FieldDescriptor::Type);
void TestValidDataForOneofType(google::protobuf::FieldDescriptor::Type);
void TestMergeOneofMessage();
void TestOverwriteMessageValueMap();
std::unique_ptr<google::protobuf::util::TypeResolver> type_resolver_;
std::string type_url_;
};
} // namespace protobuf
} // namespace google
#endif // CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H

View File

@ -0,0 +1,176 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto3";
package conformance;
option java_package = "com.google.protobuf.conformance";
// This defines the conformance testing protocol. This protocol exists between
// the conformance test suite itself and the code being tested. For each test,
// the suite will send a ConformanceRequest message and expect a
// ConformanceResponse message.
//
// You can either run the tests in two different ways:
//
// 1. in-process (using the interface in conformance_test.h).
//
// 2. as a sub-process communicating over a pipe. Information about how to
// do this is in conformance_test_runner.cc.
//
// Pros/cons of the two approaches:
//
// - running as a sub-process is much simpler for languages other than C/C++.
//
// - running as a sub-process may be more tricky in unusual environments like
// iOS apps, where fork/stdin/stdout are not available.
enum WireFormat {
UNSPECIFIED = 0;
PROTOBUF = 1;
JSON = 2;
JSPB = 3; // Google internal only. Opensource testees just skip it.
TEXT_FORMAT = 4;
}
enum TestCategory {
UNSPECIFIED_TEST = 0;
BINARY_TEST = 1; // Test binary wire format.
JSON_TEST = 2; // Test json wire format.
// Similar to JSON_TEST. However, during parsing json, testee should ignore
// unknown fields. This feature is optional. Each implementation can decide
// whether to support it. See
// https://developers.google.com/protocol-buffers/docs/proto3#json_options
// for more detail.
JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
// Test jspb wire format. Google internal only. Opensource testees just skip it.
JSPB_TEST = 4;
// Test text format. For cpp, java and python, testees can already deal with
// this type. Testees of other languages can simply skip it.
TEXT_FORMAT_TEST = 5;
}
// The conformance runner will request a list of failures as the first request.
// This will be known by message_type == "conformance.FailureSet", a conformance
// test should return a serialized FailureSet in protobuf_payload.
message FailureSet {
repeated string failure = 1;
}
// Represents a single test case's input. The testee should:
//
// 1. parse this proto (which should always succeed)
// 2. parse the protobuf or JSON payload in "payload" (which may fail)
// 3. if the parse succeeded, serialize the message in the requested format.
message ConformanceRequest {
// The payload (whether protobuf of JSON) is always for a
// protobuf_test_messages.proto3.TestAllTypes proto (as defined in
// src/google/protobuf/proto3_test_messages.proto).
//
// TODO(haberman): if/when we expand the conformance tests to support proto2,
// we will want to include a field that lets the payload/response be a
// protobuf_test_messages.google.protobuf.TestAllTypes message instead.
oneof payload {
bytes protobuf_payload = 1;
string json_payload = 2;
// Google internal only. Opensource testees just skip it.
string jspb_payload = 7;
string text_payload = 8;
}
// Which format should the testee serialize its message to?
WireFormat requested_output_format = 3;
// The full name for the test message to use; for the moment, either:
// protobuf_test_messages.proto3.TestAllTypesProto3 or
// protobuf_test_messages.google.protobuf.TestAllTypesProto2.
string message_type = 4;
// Each test is given a specific test category. Some category may need
// specific support in testee programs. Refer to the definition of TestCategory
// for more information.
TestCategory test_category = 5;
// Specify details for how to encode jspb.
JspbEncodingConfig jspb_encoding_options = 6;
// This can be used in json and text format. If true, testee should print
// unknown fields instead of ignore. This feature is optional.
bool print_unknown_fields = 9;
}
// Represents a single test case's output.
message ConformanceResponse {
oneof result {
// This string should be set to indicate parsing failed. The string can
// provide more information about the parse error if it is available.
//
// Setting this string does not necessarily mean the testee failed the
// test. Some of the test cases are intentionally invalid input.
string parse_error = 1;
// If the input was successfully parsed but errors occurred when
// serializing it to the requested output format, set the error message in
// this field.
string serialize_error = 6;
// This should be set if some other error occurred. This will always
// indicate that the test failed. The string can provide more information
// about the failure.
string runtime_error = 2;
// If the input was successfully parsed and the requested output was
// protobuf, serialize it to protobuf and set it in this field.
bytes protobuf_payload = 3;
// If the input was successfully parsed and the requested output was JSON,
// serialize to JSON and set it in this field.
string json_payload = 4;
// For when the testee skipped the test, likely because a certain feature
// wasn't supported, like JSON input/output.
string skipped = 5;
// If the input was successfully parsed and the requested output was JSPB,
// serialize to JSPB and set it in this field. JSPB is google internal only
// format. Opensource testees can just skip it.
string jspb_payload = 7;
// If the input was successfully parsed and the requested output was
// TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field.
string text_payload = 8;
}
}
// Encoding options for jspb format.
message JspbEncodingConfig {
// Encode the value field of Any as jspb array if true, otherwise binary.
bool use_jspb_array_any_format = 1;
}

View File

@ -0,0 +1,268 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <errno.h>
#include <stdarg.h>
#include <unistd.h>
#include <google/protobuf/message.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h>
#include <google/protobuf/stubs/status.h>
#include "conformance.pb.h"
#include <google/protobuf/test_messages_proto2.pb.h>
#include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/stubs/status.h>
using conformance::ConformanceRequest;
using conformance::ConformanceResponse;
using google::protobuf::Descriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::Message;
using google::protobuf::MessageFactory;
using google::protobuf::TextFormat;
using google::protobuf::util::BinaryToJsonString;
using google::protobuf::util::JsonParseOptions;
using google::protobuf::util::JsonToBinaryString;
using google::protobuf::util::NewTypeResolverForDescriptorPool;
using google::protobuf::util::TypeResolver;
using protobuf_test_messages::proto3::TestAllTypesProto3;
using protobuf_test_messages::proto2::TestAllTypesProto2;
using std::string;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
const char* kFailures[] = {
};
static string GetTypeUrl(const Descriptor* message) {
return string(kTypeUrlPrefix) + "/" + message->full_name();
}
int test_count = 0;
bool verbose = false;
TypeResolver* type_resolver;
string* type_url;
namespace google {
namespace protobuf {
using util::Status;
bool CheckedRead(int fd, void *buf, size_t len) {
size_t ofs = 0;
while (len > 0) {
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
if (bytes_read == 0) return false;
if (bytes_read < 0) {
GOOGLE_LOG(FATAL) << "Error reading from test runner: " << strerror(errno);
}
len -= bytes_read;
ofs += bytes_read;
}
return true;
}
void CheckedWrite(int fd, const void *buf, size_t len) {
if (write(fd, buf, len) != len) {
GOOGLE_LOG(FATAL) << "Error writing to test runner: " << strerror(errno);
}
}
void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
Message *test_message;
google::protobuf::LinkMessageReflection<TestAllTypesProto2>();
google::protobuf::LinkMessageReflection<TestAllTypesProto3>();
const Descriptor *descriptor = DescriptorPool::generated_pool()->FindMessageTypeByName(
request.message_type());
if (!descriptor) {
GOOGLE_LOG(FATAL) << "No such message type: " << request.message_type();
}
test_message = MessageFactory::generated_factory()->GetPrototype(descriptor)->New();
switch (request.payload_case()) {
case ConformanceRequest::kProtobufPayload: {
if (!test_message->ParseFromString(request.protobuf_payload())) {
// Getting parse details would involve something like:
// http://stackoverflow.com/questions/22121922/how-can-i-get-more-details-about-errors-generated-during-protobuf-parsing-c
response->set_parse_error("Parse error (no more details available).");
return;
}
break;
}
case ConformanceRequest::kJsonPayload: {
string proto_binary;
JsonParseOptions options;
options.ignore_unknown_fields =
(request.test_category() ==
conformance::JSON_IGNORE_UNKNOWN_PARSING_TEST);
util::Status status =
JsonToBinaryString(type_resolver, *type_url, request.json_payload(),
&proto_binary, options);
if (!status.ok()) {
response->set_parse_error(string("Parse error: ") +
std::string(status.message()));
return;
}
if (!test_message->ParseFromString(proto_binary)) {
response->set_runtime_error(
"Parsing JSON generates invalid proto output.");
return;
}
break;
}
case ConformanceRequest::kTextPayload: {
if (!TextFormat::ParseFromString(request.text_payload(), test_message)) {
response->set_parse_error("Parse error");
return;
}
break;
}
case ConformanceRequest::PAYLOAD_NOT_SET:
GOOGLE_LOG(FATAL) << "Request didn't have payload.";
break;
default:
GOOGLE_LOG(FATAL) << "unknown payload type: " << request.payload_case();
break;
}
conformance::FailureSet failures;
if (descriptor == failures.GetDescriptor()) {
for (const char* s : kFailures) failures.add_failure(s);
test_message = &failures;
}
switch (request.requested_output_format()) {
case conformance::UNSPECIFIED:
GOOGLE_LOG(FATAL) << "Unspecified output format";
break;
case conformance::PROTOBUF: {
GOOGLE_CHECK(test_message->SerializeToString(
response->mutable_protobuf_payload()));
break;
}
case conformance::JSON: {
string proto_binary;
GOOGLE_CHECK(test_message->SerializeToString(&proto_binary));
util::Status status =
BinaryToJsonString(type_resolver, *type_url, proto_binary,
response->mutable_json_payload());
if (!status.ok()) {
response->set_serialize_error(
string("Failed to serialize JSON output: ") +
std::string(status.message()));
return;
}
break;
}
case conformance::TEXT_FORMAT: {
TextFormat::Printer printer;
printer.SetHideUnknownFields(!request.print_unknown_fields());
GOOGLE_CHECK(printer.PrintToString(*test_message,
response->mutable_text_payload()));
break;
}
default:
GOOGLE_LOG(FATAL) << "Unknown output format: "
<< request.requested_output_format();
}
}
bool DoTestIo() {
string serialized_input;
string serialized_output;
ConformanceRequest request;
ConformanceResponse response;
uint32_t bytes;
if (!CheckedRead(STDIN_FILENO, &bytes, sizeof(uint32_t))) {
// EOF.
return false;
}
serialized_input.resize(bytes);
if (!CheckedRead(STDIN_FILENO, (char*)serialized_input.c_str(), bytes)) {
GOOGLE_LOG(ERROR) << "Unexpected EOF on stdin. " << strerror(errno);
}
if (!request.ParseFromString(serialized_input)) {
GOOGLE_LOG(FATAL) << "Parse of ConformanceRequest proto failed.";
return false;
}
DoTest(request, &response);
response.SerializeToString(&serialized_output);
bytes = serialized_output.size();
CheckedWrite(STDOUT_FILENO, &bytes, sizeof(uint32_t));
CheckedWrite(STDOUT_FILENO, serialized_output.c_str(), bytes);
if (verbose) {
fprintf(stderr, "conformance-cpp: request=%s, response=%s\n",
request.ShortDebugString().c_str(),
response.ShortDebugString().c_str());
}
test_count++;
return true;
}
} // namespace protobuf
} // namespace google
int main() {
type_resolver = NewTypeResolverForDescriptorPool(
kTypeUrlPrefix, DescriptorPool::generated_pool());
type_url = new string(GetTypeUrl(TestAllTypesProto3::descriptor()));
while (1) {
if (!google::protobuf::DoTestIo()) {
fprintf(stderr, "conformance-cpp: received EOF from test runner "
"after %d tests, exiting\n", test_count);
return 0;
}
}
}

View File

@ -0,0 +1,215 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2015 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "Conformance.pbobjc.h"
#import "google/protobuf/TestMessagesProto2.pbobjc.h"
#import "google/protobuf/TestMessagesProto3.pbobjc.h"
static void Die(NSString *format, ...) __dead2;
static BOOL verbose = NO;
static int32_t testCount = 0;
static void Die(NSString *format, ...) {
va_list args;
va_start(args, format);
NSString *msg = [[NSString alloc] initWithFormat:format arguments:args];
NSLog(@"%@", msg);
va_end(args);
[msg release];
exit(66);
}
static NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes) {
NSData *data = [handle readDataOfLength:numBytes];
NSUInteger dataLen = data.length;
if (dataLen == 0) {
return nil; // EOF.
}
if (dataLen != numBytes) {
Die(@"Failed to read the request length (%d), only got: %@",
numBytes, data);
}
return data;
}
static ConformanceResponse *DoTest(ConformanceRequest *request) {
ConformanceResponse *response = [ConformanceResponse message];
GPBMessage *testMessage = nil;
switch (request.payloadOneOfCase) {
case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase:
response.runtimeError =
[NSString stringWithFormat:@"Request didn't have a payload: %@", request];
break;
case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: {
Class msgClass = nil;
if ([request.messageType isEqual:@"protobuf_test_messages.proto3.TestAllTypesProto3"]) {
msgClass = [Proto3TestAllTypesProto3 class];
} else if ([request.messageType isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) {
msgClass = [TestAllTypesProto2 class];
} else {
response.runtimeError =
[NSString stringWithFormat:@"Protobuf request had an unknown message_type: %@",
request.messageType];
break;
}
NSError *error = nil;
testMessage = [msgClass parseFromData:request.protobufPayload error:&error];
if (!testMessage) {
response.parseError =
[NSString stringWithFormat:@"Parse error: %@", error];
}
break;
}
case ConformanceRequest_Payload_OneOfCase_JsonPayload:
response.skipped = @"ObjC doesn't support parsing JSON";
break;
case ConformanceRequest_Payload_OneOfCase_JspbPayload:
response.skipped =
@"ConformanceRequest had a jspb_payload ConformanceRequest.payload;"
" those aren't supposed to happen with opensource.";
break;
case ConformanceRequest_Payload_OneOfCase_TextPayload:
response.skipped = @"ObjC doesn't support parsing TextFormat";
break;
}
if (testMessage) {
switch (request.requestedOutputFormat) {
case WireFormat_GPBUnrecognizedEnumeratorValue:
case WireFormat_Unspecified:
response.runtimeError =
[NSString stringWithFormat:@"Unrecognized/unspecified output format: %@", request];
break;
case WireFormat_Protobuf:
response.protobufPayload = testMessage.data;
if (!response.protobufPayload) {
response.serializeError =
[NSString stringWithFormat:@"Failed to make data from: %@", testMessage];
}
break;
case WireFormat_Json:
response.skipped = @"ObjC doesn't support generating JSON";
break;
case WireFormat_Jspb:
response.skipped =
@"ConformanceRequest had a requested_output_format of JSPB WireFormat; that"
" isn't supposed to happen with opensource.";
break;
case WireFormat_TextFormat:
// ObjC only has partial objc generation, so don't attempt any tests that need
// support.
response.skipped = @"ObjC doesn't support generating TextFormat";
break;
}
}
return response;
}
static uint32_t UInt32FromLittleEndianData(NSData *data) {
if (data.length != sizeof(uint32_t)) {
Die(@"Data not the right size for uint32_t: %@", data);
}
uint32_t value;
memcpy(&value, data.bytes, sizeof(uint32_t));
return CFSwapInt32LittleToHost(value);
}
static NSData *UInt32ToLittleEndianData(uint32_t num) {
uint32_t value = CFSwapInt32HostToLittle(num);
return [NSData dataWithBytes:&value length:sizeof(uint32_t)];
}
static BOOL DoTestIo(NSFileHandle *input, NSFileHandle *output) {
// See conformance_test_runner.cc for the wire format.
NSData *data = CheckedReadDataOfLength(input, sizeof(uint32_t));
if (!data) {
// EOF.
return NO;
}
uint32_t numBytes = UInt32FromLittleEndianData(data);
data = CheckedReadDataOfLength(input, numBytes);
if (!data) {
Die(@"Failed to read request");
}
NSError *error = nil;
ConformanceRequest *request = [ConformanceRequest parseFromData:data
error:&error];
if (!request) {
Die(@"Failed to parse the message data: %@", error);
}
ConformanceResponse *response = DoTest(request);
if (!response) {
Die(@"Failed to make a reply from %@", request);
}
data = response.data;
[output writeData:UInt32ToLittleEndianData((int32_t)data.length)];
[output writeData:data];
if (verbose) {
NSLog(@"Request: %@", request);
NSLog(@"Response: %@", response);
}
++testCount;
return YES;
}
int main(int argc, const char *argv[]) {
@autoreleasepool {
NSFileHandle *input = [[NSFileHandle fileHandleWithStandardInput] retain];
NSFileHandle *output = [[NSFileHandle fileHandleWithStandardOutput] retain];
BOOL notDone = YES;
while (notDone) {
@autoreleasepool {
notDone = DoTestIo(input, output);
}
}
NSLog(@"Received EOF from test runner after %d tests, exiting.", testCount);
}
return 0;
}

View File

@ -0,0 +1,120 @@
<?php
require_once("Conformance/WireFormat.php");
require_once("Conformance/ConformanceResponse.php");
require_once("Conformance/ConformanceRequest.php");
require_once("Conformance/FailureSet.php");
require_once("Conformance/JspbEncodingConfig.php");
require_once("Conformance/TestCategory.php");
require_once("Protobuf_test_messages/Proto3/ForeignMessage.php");
require_once("Protobuf_test_messages/Proto3/ForeignEnum.php");
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3.php");
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3/AliasedEnum.php");
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedMessage.php");
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedEnum.php");
require_once("GPBMetadata/Conformance.php");
require_once("GPBMetadata/Google/Protobuf/TestMessagesProto3.php");
use \Conformance\TestCategory;
use \Conformance\WireFormat;
if (!ini_get("date.timezone")) {
ini_set("date.timezone", "UTC");
}
$test_count = 0;
function doTest($request)
{
$test_message = new \Protobuf_test_messages\Proto3\TestAllTypesProto3();
$response = new \Conformance\ConformanceResponse();
if ($request->getPayload() == "protobuf_payload") {
if ($request->getMessageType() == "conformance.FailureSet") {
$response->setProtobufPayload("");
return $response;
} elseif ($request->getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") {
try {
$test_message->mergeFromString($request->getProtobufPayload());
} catch (Exception $e) {
$response->setParseError($e->getMessage());
return $response;
}
} elseif ($request->getMessageType() == "protobuf_test_messages.proto2.TestAllTypesProto2") {
$response->setSkipped("PHP doesn't support proto2");
return $response;
} else {
trigger_error("Protobuf request doesn't have specific payload type", E_USER_ERROR);
}
} elseif ($request->getPayload() == "json_payload") {
$ignore_json_unknown =
($request->getTestCategory() ==
TestCategory::JSON_IGNORE_UNKNOWN_PARSING_TEST);
try {
$test_message->mergeFromJsonString($request->getJsonPayload(),
$ignore_json_unknown);
} catch (Exception $e) {
$response->setParseError($e->getMessage());
return $response;
}
} elseif ($request->getPayload() == "text_payload") {
$response->setSkipped("PHP doesn't support text format yet");
return $response;
} else {
trigger_error("Request didn't have payload.", E_USER_ERROR);
}
if ($request->getRequestedOutputFormat() == WireFormat::UNSPECIFIED) {
trigger_error("Unspecified output format.", E_USER_ERROR);
} elseif ($request->getRequestedOutputFormat() == WireFormat::PROTOBUF) {
$response->setProtobufPayload($test_message->serializeToString());
} elseif ($request->getRequestedOutputFormat() == WireFormat::JSON) {
try {
$response->setJsonPayload($test_message->serializeToJsonString());
} catch (Exception $e) {
$response->setSerializeError($e->getMessage());
return $response;
}
}
return $response;
}
function doTestIO()
{
$length_bytes = fread(STDIN, 4);
if (strlen($length_bytes) == 0) {
return false; # EOF
} elseif (strlen($length_bytes) != 4) {
fwrite(STDERR, "I/O error\n");
return false;
}
$length = unpack("V", $length_bytes)[1];
$serialized_request = fread(STDIN, $length);
if (strlen($serialized_request) != $length) {
trigger_error("I/O error", E_USER_ERROR);
}
$request = new \Conformance\ConformanceRequest();
$request->mergeFromString($serialized_request);
$response = doTest($request);
$serialized_response = $response->serializeToString();
fwrite(STDOUT, pack("V", strlen($serialized_response)));
fwrite(STDOUT, $serialized_response);
$GLOBALS['test_count'] += 1;
return true;
}
while(true){
if (!doTestIO()) {
fprintf(STDERR,
"conformance_php: received EOF from test runner " +
"after %d tests, exiting\n", $test_count);
exit;
}
}

View File

@ -0,0 +1,213 @@
#!/usr/bin/env python
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""A conformance test implementation for the Python protobuf library.
See conformance.proto for more information.
"""
import struct
import sys
import os
from google.protobuf import json_format
from google.protobuf import message
from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
from google.protobuf import text_format
import conformance_pb2
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)
test_count = 0
verbose = False
class ProtocolError(Exception):
pass
def do_test(request):
response = conformance_pb2.ConformanceResponse()
if request.message_type == "conformance.FailureSet":
failure_set = conformance_pb2.FailureSet()
failures = []
# TODO(gerbens): Remove, this is a hack to detect if the old vs new
# parser is used by the cpp code. Relying on a bug in the old parser.
hack_proto = test_messages_proto2_pb2.TestAllTypesProto2()
old_parser = True
try:
hack_proto.ParseFromString(b"\322\002\001")
except message.DecodeError as e:
old_parser = False
if old_parser:
# the string above is one of the failing conformance test strings of the
# old parser. If we succeed the c++ implementation is using the old
# parser so we add the list of failing conformance tests.
failures = [
"Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.DOUBLE",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FLOAT",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64",
"Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.DOUBLE",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FLOAT",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64",
]
for x in failures:
failure_set.failure.append(x)
response.protobuf_payload = failure_set.SerializeToString()
return response
isProto3 = (request.message_type == "protobuf_test_messages.proto3.TestAllTypesProto3")
isJson = (request.WhichOneof('payload') == 'json_payload')
isProto2 = (request.message_type == "protobuf_test_messages.proto2.TestAllTypesProto2")
if (not isProto3) and (not isJson) and (not isProto2):
raise ProtocolError("Protobuf request doesn't have specific payload type")
test_message = test_messages_proto2_pb2.TestAllTypesProto2() if isProto2 else \
test_messages_proto3_pb2.TestAllTypesProto3()
try:
if request.WhichOneof('payload') == 'protobuf_payload':
try:
test_message.ParseFromString(request.protobuf_payload)
except message.DecodeError as e:
response.parse_error = str(e)
return response
elif request.WhichOneof('payload') == 'json_payload':
try:
ignore_unknown_fields = \
request.test_category == \
conformance_pb2.JSON_IGNORE_UNKNOWN_PARSING_TEST
json_format.Parse(request.json_payload, test_message,
ignore_unknown_fields)
except Exception as e:
response.parse_error = str(e)
return response
elif request.WhichOneof('payload') == 'text_payload':
try:
text_format.Parse(request.text_payload, test_message)
except Exception as e:
response.parse_error = str(e)
return response
else:
raise ProtocolError("Request didn't have payload.")
if request.requested_output_format == conformance_pb2.UNSPECIFIED:
raise ProtocolError("Unspecified output format")
elif request.requested_output_format == conformance_pb2.PROTOBUF:
response.protobuf_payload = test_message.SerializeToString()
elif request.requested_output_format == conformance_pb2.JSON:
try:
response.json_payload = json_format.MessageToJson(test_message)
except Exception as e:
response.serialize_error = str(e)
return response
elif request.requested_output_format == conformance_pb2.TEXT_FORMAT:
response.text_payload = text_format.MessageToString(
test_message, print_unknown_fields=request.print_unknown_fields)
except Exception as e:
response.runtime_error = str(e)
return response
def do_test_io():
length_bytes = sys.stdin.read(4)
if len(length_bytes) == 0:
return False # EOF
elif len(length_bytes) != 4:
raise IOError("I/O error")
# "I" is "unsigned int", so this depends on running on a platform with
# 32-bit "unsigned int" type. The Python struct module unfortunately
# has no format specifier for uint32_t.
length = struct.unpack("<I", length_bytes)[0]
serialized_request = sys.stdin.read(length)
if len(serialized_request) != length:
raise IOError("I/O error")
request = conformance_pb2.ConformanceRequest()
request.ParseFromString(serialized_request)
response = do_test(request)
serialized_response = response.SerializeToString()
sys.stdout.write(struct.pack("<I", len(serialized_response)))
sys.stdout.write(serialized_response)
sys.stdout.flush()
if verbose:
sys.stderr.write("conformance_python: request=%s, response=%s\n" % (
request.ShortDebugString().c_str(),
response.ShortDebugString().c_str()))
global test_count
test_count += 1
return True
while True:
if not do_test_io():
sys.stderr.write("conformance_python: received EOF from test runner " +
"after %s tests, exiting\n" % (test_count))
sys.exit(0)

View File

@ -0,0 +1,146 @@
#!/usr/bin/env ruby
#
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'conformance_pb'
require 'google/protobuf/test_messages_proto3_pb'
require 'google/protobuf/test_messages_proto2_pb'
$test_count = 0
$verbose = false
def do_test(request)
test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.new
response = Conformance::ConformanceResponse.new
descriptor = Google::Protobuf::DescriptorPool.generated_pool.lookup(request.message_type)
unless descriptor
response.skipped = "Unknown message type: " + request.message_type
end
begin
case request.payload
when :protobuf_payload
begin
test_message = descriptor.msgclass.decode(request.protobuf_payload)
rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8')
return response
end
when :json_payload
begin
options = {}
if request.test_category == :JSON_IGNORE_UNKNOWN_PARSING_TEST
options[:ignore_unknown_fields] = true
end
test_message = descriptor.msgclass.decode_json(request.json_payload, options)
rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8')
return response
end
when :text_payload
begin
response.skipped = "Ruby doesn't support text format"
return response
end
when nil
fail "Request didn't have payload"
end
case request.requested_output_format
when :UNSPECIFIED
fail 'Unspecified output format'
when :PROTOBUF
begin
response.protobuf_payload = test_message.to_proto
rescue Google::Protobuf::ParseError => err
response.serialize_error = err.message.encode('utf-8')
end
when :JSON
begin
response.json_payload = test_message.to_json
rescue Google::Protobuf::ParseError => err
response.serialize_error = err.message.encode('utf-8')
end
when nil
fail "Request didn't have requested output format"
end
rescue StandardError => err
response.runtime_error = err.message.encode('utf-8')
end
response
end
# Returns true if the test ran successfully, false on legitimate EOF.
# If EOF is encountered in an unexpected place, raises IOError.
def do_test_io
length_bytes = STDIN.read(4)
return false if length_bytes.nil?
length = length_bytes.unpack('V').first
serialized_request = STDIN.read(length)
if serialized_request.nil? || serialized_request.length != length
fail IOError
end
request = Conformance::ConformanceRequest.decode(serialized_request)
response = do_test(request)
serialized_response = Conformance::ConformanceResponse.encode(response)
STDOUT.write([serialized_response.length].pack('V'))
STDOUT.write(serialized_response)
STDOUT.flush
if $verbose
STDERR.puts("conformance_ruby: request=#{request.to_json}, " \
"response=#{response.to_json}\n")
end
$test_count += 1
true
end
loop do
unless do_test_io
STDERR.puts('conformance_ruby: received EOF from test runner ' \
"after #{$test_count} tests, exiting")
break
end
end

View File

@ -0,0 +1,468 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "conformance_test.h"
#include <stdarg.h>
#include <fstream>
#include <set>
#include <string>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/message.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/field_comparator.h>
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/message_differencer.h>
#include "conformance.pb.h"
using conformance::ConformanceRequest;
using conformance::ConformanceResponse;
using conformance::WireFormat;
using google::protobuf::TextFormat;
using google::protobuf::util::DefaultFieldComparator;
using google::protobuf::util::MessageDifferencer;
using std::string;
namespace {
static string ToOctString(const string& binary_string) {
string oct_string;
for (size_t i = 0; i < binary_string.size(); i++) {
uint8_t c = binary_string.at(i);
uint8_t high = c / 64;
uint8_t mid = (c % 64) / 8;
uint8_t low = c % 8;
oct_string.push_back('\\');
oct_string.push_back('0' + high);
oct_string.push_back('0' + mid);
oct_string.push_back('0' + low);
}
return oct_string;
}
} // namespace
namespace google {
namespace protobuf {
ConformanceTestSuite::ConformanceRequestSetting::ConformanceRequestSetting(
ConformanceLevel level,
conformance::WireFormat input_format,
conformance::WireFormat output_format,
conformance::TestCategory test_category,
const Message& prototype_message,
const string& test_name, const string& input)
: level_(level),
input_format_(input_format),
output_format_(output_format),
prototype_message_(prototype_message),
prototype_message_for_compare_(prototype_message.New()),
test_name_(test_name) {
switch (input_format) {
case conformance::PROTOBUF: {
request_.set_protobuf_payload(input);
break;
}
case conformance::JSON: {
request_.set_json_payload(input);
break;
}
case conformance::JSPB: {
request_.set_jspb_payload(input);
break;
}
case conformance::TEXT_FORMAT: {
request_.set_text_payload(input);
break;
}
default:
GOOGLE_LOG(FATAL) << "Unspecified input format";
}
request_.set_test_category(test_category);
request_.set_message_type(prototype_message.GetDescriptor()->full_name());
request_.set_requested_output_format(output_format);
}
std::unique_ptr<Message>
ConformanceTestSuite::ConformanceRequestSetting::NewTestMessage() const {
return std::unique_ptr<Message>(prototype_message_for_compare_->New());
}
string ConformanceTestSuite::ConformanceRequestSetting::
GetTestName() const {
string rname =
prototype_message_.GetDescriptor()->file()->syntax() ==
FileDescriptor::SYNTAX_PROTO3 ? "Proto3" : "Proto2";
return StrCat(ConformanceLevelToString(level_), ".", rname, ".",
InputFormatString(input_format_), ".", test_name_, ".",
OutputFormatString(output_format_));
}
string ConformanceTestSuite::ConformanceRequestSetting::
ConformanceLevelToString(
ConformanceLevel level) const {
switch (level) {
case REQUIRED: return "Required";
case RECOMMENDED: return "Recommended";
}
GOOGLE_LOG(FATAL) << "Unknown value: " << level;
return "";
}
string ConformanceTestSuite::ConformanceRequestSetting::
InputFormatString(conformance::WireFormat format) const {
switch (format) {
case conformance::PROTOBUF:
return "ProtobufInput";
case conformance::JSON:
return "JsonInput";
case conformance::TEXT_FORMAT:
return "TextFormatInput";
default:
GOOGLE_LOG(FATAL) << "Unspecified output format";
}
return "";
}
string ConformanceTestSuite::ConformanceRequestSetting::
OutputFormatString(conformance::WireFormat format) const {
switch (format) {
case conformance::PROTOBUF:
return "ProtobufOutput";
case conformance::JSON:
return "JsonOutput";
case conformance::TEXT_FORMAT:
return "TextFormatOutput";
default:
GOOGLE_LOG(FATAL) << "Unspecified output format";
}
return "";
}
void ConformanceTestSuite::ReportSuccess(const string& test_name) {
if (expected_to_fail_.erase(test_name) != 0) {
StringAppendF(&output_,
"ERROR: test %s is in the failure list, but test succeeded. "
"Remove it from the failure list.\n",
test_name.c_str());
unexpected_succeeding_tests_.insert(test_name);
}
successes_++;
}
void ConformanceTestSuite::ReportFailure(const string& test_name,
ConformanceLevel level,
const ConformanceRequest& request,
const ConformanceResponse& response,
const char* fmt, ...) {
if (expected_to_fail_.erase(test_name) == 1) {
expected_failures_++;
if (!verbose_)
return;
} else if (level == RECOMMENDED && !enforce_recommended_) {
StringAppendF(&output_, "WARNING, test=%s: ", test_name.c_str());
} else {
StringAppendF(&output_, "ERROR, test=%s: ", test_name.c_str());
unexpected_failing_tests_.insert(test_name);
}
va_list args;
va_start(args, fmt);
StringAppendV(&output_, fmt, args);
va_end(args);
StringAppendF(&output_, " request=%s, response=%s\n",
request.ShortDebugString().c_str(),
response.ShortDebugString().c_str());
}
void ConformanceTestSuite::ReportSkip(const string& test_name,
const ConformanceRequest& request,
const ConformanceResponse& response) {
if (verbose_) {
StringAppendF(&output_, "SKIPPED, test=%s request=%s, response=%s\n",
test_name.c_str(), request.ShortDebugString().c_str(),
response.ShortDebugString().c_str());
}
skipped_.insert(test_name);
}
void ConformanceTestSuite::RunValidInputTest(
const ConformanceRequestSetting& setting,
const string& equivalent_text_format) {
std::unique_ptr<Message> reference_message(setting.NewTestMessage());
GOOGLE_CHECK(TextFormat::ParseFromString(equivalent_text_format,
reference_message.get()))
<< "Failed to parse data for test case: " << setting.GetTestName()
<< ", data: " << equivalent_text_format;
const string equivalent_wire_format = reference_message->SerializeAsString();
RunValidBinaryInputTest(setting, equivalent_wire_format);
}
void ConformanceTestSuite::RunValidBinaryInputTest(
const ConformanceRequestSetting& setting,
const string& equivalent_wire_format, bool require_same_wire_format) {
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
RunTest(setting.GetTestName(), request, &response);
VerifyResponse(setting, equivalent_wire_format, response, true,
require_same_wire_format);
}
void ConformanceTestSuite::VerifyResponse(
const ConformanceRequestSetting& setting,
const string& equivalent_wire_format, const ConformanceResponse& response,
bool need_report_success, bool require_same_wire_format) {
std::unique_ptr<Message> test_message(setting.NewTestMessage());
const ConformanceRequest& request = setting.GetRequest();
const string& test_name = setting.GetTestName();
ConformanceLevel level = setting.GetLevel();
std::unique_ptr<Message> reference_message = setting.NewTestMessage();
GOOGLE_CHECK(reference_message->ParseFromString(equivalent_wire_format))
<< "Failed to parse wire data for test case: " << test_name;
switch (response.result_case()) {
case ConformanceResponse::RESULT_NOT_SET:
ReportFailure(test_name, level, request, response,
"Response didn't have any field in the Response.");
return;
case ConformanceResponse::kParseError:
case ConformanceResponse::kRuntimeError:
case ConformanceResponse::kSerializeError:
ReportFailure(test_name, level, request, response,
"Failed to parse input or produce output.");
return;
case ConformanceResponse::kSkipped:
ReportSkip(test_name, request, response);
return;
default:
if (!ParseResponse(response, setting, test_message.get())) return;
}
MessageDifferencer differencer;
DefaultFieldComparator field_comparator;
field_comparator.set_treat_nan_as_equal(true);
differencer.set_field_comparator(&field_comparator);
string differences;
differencer.ReportDifferencesToString(&differences);
bool check = false;
if (require_same_wire_format) {
GOOGLE_DCHECK_EQ(response.result_case(), ConformanceResponse::kProtobufPayload);
const string& protobuf_payload = response.protobuf_payload();
check = equivalent_wire_format == protobuf_payload;
differences = StrCat("Expect: ", ToOctString(equivalent_wire_format),
", but got: ", ToOctString(protobuf_payload));
} else {
check = differencer.Compare(*reference_message, *test_message);
}
if (check) {
if (need_report_success) {
ReportSuccess(test_name);
}
} else {
ReportFailure(test_name, level, request, response,
"Output was not equivalent to reference message: %s.",
differences.c_str());
}
}
void ConformanceTestSuite::RunTest(const string& test_name,
const ConformanceRequest& request,
ConformanceResponse* response) {
if (test_names_.insert(test_name).second == false) {
GOOGLE_LOG(FATAL) << "Duplicated test name: " << test_name;
}
string serialized_request;
string serialized_response;
request.SerializeToString(&serialized_request);
runner_->RunTest(test_name, serialized_request, &serialized_response);
if (!response->ParseFromString(serialized_response)) {
response->Clear();
response->set_runtime_error("response proto could not be parsed.");
}
if (verbose_) {
StringAppendF(&output_,
"conformance test: name=%s, request=%s, response=%s\n",
test_name.c_str(),
request.ShortDebugString().c_str(),
response->ShortDebugString().c_str());
}
}
bool ConformanceTestSuite::CheckSetEmpty(
const std::set<string>& set_to_check,
const std::string& write_to_file,
const std::string& msg) {
if (set_to_check.empty()) {
return true;
} else {
StringAppendF(&output_, "\n");
StringAppendF(&output_, "%s\n\n", msg.c_str());
for (std::set<string>::const_iterator iter = set_to_check.begin();
iter != set_to_check.end(); ++iter) {
StringAppendF(&output_, " %s\n", iter->c_str());
}
StringAppendF(&output_, "\n");
if (!write_to_file.empty()) {
std::string full_filename;
const std::string* filename = &write_to_file;
if (!output_dir_.empty()) {
full_filename = output_dir_;
if (*output_dir_.rbegin() != '/') {
full_filename.push_back('/');
}
full_filename += write_to_file;
filename = &full_filename;
}
std::ofstream os(*filename);
if (os) {
for (std::set<string>::const_iterator iter = set_to_check.begin();
iter != set_to_check.end(); ++iter) {
os << *iter << "\n";
}
} else {
StringAppendF(&output_, "Failed to open file: %s\n",
filename->c_str());
}
}
return false;
}
}
string ConformanceTestSuite::WireFormatToString(
WireFormat wire_format) {
switch (wire_format) {
case conformance::PROTOBUF:
return "PROTOBUF";
case conformance::JSON:
return "JSON";
case conformance::JSPB:
return "JSPB";
case conformance::TEXT_FORMAT:
return "TEXT_FORMAT";
case conformance::UNSPECIFIED:
return "UNSPECIFIED";
default:
GOOGLE_LOG(FATAL) << "unknown wire type: " << wire_format;
}
return "";
}
void ConformanceTestSuite::AddExpectedFailedTest(const std::string& test_name) {
expected_to_fail_.insert(test_name);
}
bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
std::string* output, const string& filename,
conformance::FailureSet* failure_list) {
runner_ = runner;
successes_ = 0;
expected_failures_ = 0;
skipped_.clear();
test_names_.clear();
unexpected_failing_tests_.clear();
unexpected_succeeding_tests_.clear();
output_ = "\nCONFORMANCE TEST BEGIN ====================================\n\n";
failure_list_filename_ = filename;
expected_to_fail_.clear();
for (const string& failure : failure_list->failure()) {
AddExpectedFailedTest(failure);
}
RunSuiteImpl();
bool ok = true;
if (!CheckSetEmpty(expected_to_fail_, "nonexistent_tests.txt",
"These tests were listed in the failure list, but they "
"don't exist. Remove them from the failure list by "
"running:\n"
" ./update_failure_list.py " + failure_list_filename_ +
" --remove nonexistent_tests.txt")) {
ok = false;
}
if (!CheckSetEmpty(unexpected_failing_tests_, "failing_tests.txt",
"These tests failed. If they can't be fixed right now, "
"you can add them to the failure list so the overall "
"suite can succeed. Add them to the failure list by "
"running:\n"
" ./update_failure_list.py " + failure_list_filename_ +
" --add failing_tests.txt")) {
ok = false;
}
if (!CheckSetEmpty(unexpected_succeeding_tests_, "succeeding_tests.txt",
"These tests succeeded, even though they were listed in "
"the failure list. Remove them from the failure list "
"by running:\n"
" ./update_failure_list.py " + failure_list_filename_ +
" --remove succeeding_tests.txt")) {
ok = false;
}
if (verbose_) {
CheckSetEmpty(skipped_, "",
"These tests were skipped (probably because support for some "
"features is not implemented)");
}
StringAppendF(&output_,
"CONFORMANCE SUITE %s: %d successes, %zu skipped, "
"%d expected failures, %zu unexpected failures.\n",
ok ? "PASSED" : "FAILED", successes_, skipped_.size(),
expected_failures_, unexpected_failing_tests_.size());
StringAppendF(&output_, "\n");
output->assign(output_);
return ok;
}
} // namespace protobuf
} // namespace google

View File

@ -0,0 +1,329 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file defines a protocol for running the conformance test suite
// in-process. In other words, the suite itself will run in the same process as
// the code under test.
//
// For pros and cons of this approach, please see conformance.proto.
#ifndef CONFORMANCE_CONFORMANCE_TEST_H
#define CONFORMANCE_CONFORMANCE_TEST_H
#include <functional>
#include <string>
#include <vector>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/util/type_resolver.h>
#include "conformance.pb.h"
namespace conformance {
class ConformanceRequest;
class ConformanceResponse;
} // namespace conformance
namespace protobuf_test_messages {
namespace proto3 {
class TestAllTypesProto3;
} // namespace proto3
} // namespace protobuf_test_messages
namespace google {
namespace protobuf {
class ConformanceTestSuite;
class ConformanceTestRunner {
public:
virtual ~ConformanceTestRunner() {}
// Call to run a single conformance test.
//
// "input" is a serialized conformance.ConformanceRequest.
// "output" should be set to a serialized conformance.ConformanceResponse.
//
// If there is any error in running the test itself, set "runtime_error" in
// the response.
virtual void RunTest(const std::string& test_name,
const std::string& input,
std::string* output) = 0;
};
// Test runner that spawns the process being tested and communicates with it
// over a pipe.
class ForkPipeRunner : public ConformanceTestRunner {
public:
// Note: Run() doesn't take ownership of the pointers inside suites.
static int Run(int argc, char *argv[],
const std::vector<ConformanceTestSuite*>& suites);
ForkPipeRunner(const std::string& executable,
const std::vector<std::string>& executable_args)
: child_pid_(-1),
executable_(executable),
executable_args_(executable_args) {}
explicit ForkPipeRunner(const std::string& executable)
: child_pid_(-1), executable_(executable) {}
virtual ~ForkPipeRunner() {}
void RunTest(const std::string& test_name,
const std::string& request,
std::string* response);
private:
void SpawnTestProgram();
void CheckedWrite(int fd, const void *buf, size_t len);
bool TryRead(int fd, void *buf, size_t len);
void CheckedRead(int fd, void *buf, size_t len);
int write_fd_;
int read_fd_;
pid_t child_pid_;
std::string executable_;
const std::vector<std::string> executable_args_;
std::string current_test_name_;
};
// Class representing the test suite itself. To run it, implement your own
// class derived from ConformanceTestRunner, class derived from
// ConformanceTestSuite and then write code like:
//
// class MyConformanceTestSuite : public ConformanceTestSuite {
// public:
// void RunSuiteImpl() {
// // INSERT ACTUAL TESTS.
// }
// };
//
// class MyConformanceTestRunner : public ConformanceTestRunner {
// public:
// static int Run(int argc, char *argv[],
// ConformanceTestSuite* suite);
//
// private:
// virtual void RunTest(...) {
// // INSERT YOUR FRAMEWORK-SPECIFIC CODE HERE.
// }
// };
//
// int main() {
// MyConformanceTestSuite suite;
// MyConformanceTestRunner::Run(argc, argv, &suite);
// }
//
class ConformanceTestSuite {
public:
ConformanceTestSuite()
: verbose_(false),
enforce_recommended_(false),
failure_list_flag_name_("--failure_list") {}
virtual ~ConformanceTestSuite() {}
void SetVerbose(bool verbose) { verbose_ = verbose; }
// Whether to require the testee to pass RECOMMENDED tests. By default failing
// a RECOMMENDED test case will not fail the entire suite but will only
// generated a warning. If this flag is set to true, RECOMMENDED tests will
// be treated the same way as REQUIRED tests and failing a RECOMMENDED test
// case will cause the entire test suite to fail as well. An implementation
// can enable this if it wants to be strictly conforming to protobuf spec.
// See the comments about ConformanceLevel below to learn more about the
// difference between REQUIRED and RECOMMENDED test cases.
void SetEnforceRecommended(bool value) {
enforce_recommended_ = value;
}
// Gets the flag name to the failure list file.
// By default, this would return --failure_list
std::string GetFailureListFlagName() { return failure_list_flag_name_; }
void SetFailureListFlagName(const std::string& failure_list_flag_name) {
failure_list_flag_name_ = failure_list_flag_name;
}
// Sets the path of the output directory.
void SetOutputDir(const char* output_dir) {
output_dir_ = output_dir;
}
// Run all the conformance tests against the given test runner.
// Test output will be stored in "output".
//
// Returns true if the set of failing tests was exactly the same as the
// failure list.
// The filename here is *only* used to create/format useful error messages for
// how to update the failure list. We do NOT read this file at all.
bool RunSuite(ConformanceTestRunner* runner, std::string* output,
const std::string& filename,
conformance::FailureSet* failure_list);
protected:
// Test cases are classified into a few categories:
// REQUIRED: the test case must be passed for an implementation to be
// interoperable with other implementations. For example, a
// parser implementation must accept both packed and unpacked
// form of repeated primitive fields.
// RECOMMENDED: the test case is not required for the implementation to
// be interoperable with other implementations, but is
// recommended for best performance and compatibility. For
// example, a proto3 serializer should serialize repeated
// primitive fields in packed form, but an implementation
// failing to do so will still be able to communicate with
// other implementations.
enum ConformanceLevel {
REQUIRED = 0,
RECOMMENDED = 1,
};
class ConformanceRequestSetting {
public:
ConformanceRequestSetting(ConformanceLevel level,
conformance::WireFormat input_format,
conformance::WireFormat output_format,
conformance::TestCategory test_category,
const Message& prototype_message,
const std::string& test_name,
const std::string& input);
virtual ~ConformanceRequestSetting() {}
std::unique_ptr<Message> NewTestMessage() const;
std::string GetTestName() const;
const conformance::ConformanceRequest& GetRequest() const {
return request_;
}
const ConformanceLevel GetLevel() const {
return level_;
}
std::string ConformanceLevelToString(ConformanceLevel level) const;
void SetPrintUnknownFields(bool print_unknown_fields) {
request_.set_print_unknown_fields(true);
}
void SetPrototypeMessageForCompare(const Message& message) {
prototype_message_for_compare_.reset(message.New());
}
protected:
virtual std::string InputFormatString(conformance::WireFormat format) const;
virtual std::string OutputFormatString(
conformance::WireFormat format) const;
conformance::ConformanceRequest request_;
private:
ConformanceLevel level_;
::conformance::WireFormat input_format_;
::conformance::WireFormat output_format_;
const Message& prototype_message_;
std::unique_ptr<Message> prototype_message_for_compare_;
std::string test_name_;
};
bool CheckSetEmpty(const std::set<std::string>& set_to_check,
const std::string& write_to_file, const std::string& msg);
std::string WireFormatToString(conformance::WireFormat wire_format);
// Parse payload in the response to the given message. Returns true on
// success.
virtual bool ParseResponse(
const conformance::ConformanceResponse& response,
const ConformanceRequestSetting& setting,
Message* test_message) = 0;
void VerifyResponse(const ConformanceRequestSetting& setting,
const std::string& equivalent_wire_format,
const conformance::ConformanceResponse& response,
bool need_report_success, bool require_same_wire_format);
void ReportSuccess(const std::string& test_name);
void ReportFailure(const std::string& test_name, ConformanceLevel level,
const conformance::ConformanceRequest& request,
const conformance::ConformanceResponse& response,
const char* fmt, ...);
void ReportSkip(const std::string& test_name,
const conformance::ConformanceRequest& request,
const conformance::ConformanceResponse& response);
void RunValidInputTest(const ConformanceRequestSetting& setting,
const std::string& equivalent_text_format);
void RunValidBinaryInputTest(const ConformanceRequestSetting& setting,
const std::string& equivalent_wire_format,
bool require_same_wire_format = false);
void RunTest(const std::string& test_name,
const conformance::ConformanceRequest& request,
conformance::ConformanceResponse* response);
void AddExpectedFailedTest(const std::string& test_name);
virtual void RunSuiteImpl() = 0;
ConformanceTestRunner* runner_;
int successes_;
int expected_failures_;
bool verbose_;
bool enforce_recommended_;
std::string output_;
std::string output_dir_;
std::string failure_list_flag_name_;
std::string failure_list_filename_;
// The set of test names that are expected to fail in this run, but haven't
// failed yet.
std::set<std::string> expected_to_fail_;
// The set of test names that have been run. Used to ensure that there are no
// duplicate names in the suite.
std::set<std::string> test_names_;
// The set of tests that failed, but weren't expected to.
std::set<std::string> unexpected_failing_tests_;
// The set of tests that succeeded, but weren't expected to.
std::set<std::string> unexpected_succeeding_tests_;
// The set of tests that the testee opted out of;
std::set<std::string> skipped_;
};
} // namespace protobuf
} // namespace google
#endif // CONFORMANCE_CONFORMANCE_TEST_H

View File

@ -0,0 +1,40 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "binary_json_conformance_suite.h"
#include "conformance_test.h"
#include "text_format_conformance_suite.h"
int main(int argc, char *argv[]) {
google::protobuf::BinaryAndJsonConformanceSuite binary_and_json_suite;
google::protobuf::TextFormatConformanceTestSuite text_format_suite;
return google::protobuf::ForkPipeRunner::Run(
argc, argv, {&binary_and_json_suite, &text_format_suite});
}

View File

@ -0,0 +1,351 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file contains a program for running the test suite in a separate
// process. The other alternative is to run the suite in-process. See
// conformance.proto for pros/cons of these two options.
//
// This program will fork the process under test and communicate with it over
// its stdin/stdout:
//
// +--------+ pipe +----------+
// | tester | <------> | testee |
// | | | |
// | C++ | | any lang |
// +--------+ +----------+
//
// The tester contains all of the test cases and their expected output.
// The testee is a simple program written in the target language that reads
// each test case and attempts to produce acceptable output for it.
//
// Every test consists of a ConformanceRequest/ConformanceResponse
// request/reply pair. The protocol on the pipe is simply:
//
// 1. tester sends 4-byte length N (little endian)
// 2. tester sends N bytes representing a ConformanceRequest proto
// 3. testee sends 4-byte length M (little endian)
// 4. testee sends M bytes representing a ConformanceResponse proto
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <algorithm>
#include <fstream>
#include <vector>
#include <google/protobuf/stubs/stringprintf.h>
#include "conformance.pb.h"
#include "conformance_test.h"
using conformance::ConformanceResponse;
using google::protobuf::ConformanceTestSuite;
using std::string;
using std::vector;
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define GOOGLE_CHECK_SYSCALL(call) \
if (call < 0) { \
perror(#call " " __FILE__ ":" TOSTRING(__LINE__)); \
exit(1); \
}
namespace google {
namespace protobuf {
void ParseFailureList(const char *filename,
conformance::FailureSet *failure_list) {
std::ifstream infile(filename);
if (!infile.is_open()) {
fprintf(stderr, "Couldn't open failure list file: %s\n", filename);
exit(1);
}
for (string line; getline(infile, line);) {
// Remove whitespace.
line.erase(std::remove_if(line.begin(), line.end(), ::isspace),
line.end());
// Remove comments.
line = line.substr(0, line.find("#"));
if (!line.empty()) {
failure_list->add_failure(line);
}
}
}
void UsageError() {
fprintf(stderr,
"Usage: conformance-test-runner [options] <test-program>\n");
fprintf(stderr, "\n");
fprintf(stderr, "Options:\n");
fprintf(stderr,
" --failure_list <filename> Use to specify list of tests\n");
fprintf(stderr,
" that are expected to fail. File\n");
fprintf(stderr,
" should contain one test name per\n");
fprintf(stderr,
" line. Use '#' for comments.\n");
fprintf(stderr,
" --text_format_failure_list <filename> Use to specify list \n");
fprintf(stderr,
" of tests that are expected to \n");
fprintf(stderr,
" fail in the \n");
fprintf(stderr,
" text_format_conformance_suite. \n");
fprintf(stderr,
" File should contain one test name \n");
fprintf(stderr,
" per line. Use '#' for comments.\n");
fprintf(stderr,
" --enforce_recommended Enforce that recommended test\n");
fprintf(stderr,
" cases are also passing. Specify\n");
fprintf(stderr,
" this flag if you want to be\n");
fprintf(stderr,
" strictly conforming to protobuf\n");
fprintf(stderr,
" spec.\n");
fprintf(stderr,
" --output_dir <dirname> Directory to write\n"
" output files.\n");
exit(1);
}
void ForkPipeRunner::RunTest(
const std::string& test_name,
const std::string& request,
std::string* response) {
if (child_pid_ < 0) {
SpawnTestProgram();
}
current_test_name_ = test_name;
uint32_t len = request.size();
CheckedWrite(write_fd_, &len, sizeof(uint32_t));
CheckedWrite(write_fd_, request.c_str(), request.size());
if (!TryRead(read_fd_, &len, sizeof(uint32_t))) {
// We failed to read from the child, assume a crash and try to reap.
GOOGLE_LOG(INFO) << "Trying to reap child, pid=" << child_pid_;
int status = 0;
waitpid(child_pid_, &status, WEXITED);
string error_msg;
if (WIFEXITED(status)) {
StringAppendF(&error_msg,
"child exited, status=%d", WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
StringAppendF(&error_msg,
"child killed by signal %d", WTERMSIG(status));
}
GOOGLE_LOG(INFO) << error_msg;
child_pid_ = -1;
conformance::ConformanceResponse response_obj;
response_obj.set_runtime_error(error_msg);
response_obj.SerializeToString(response);
return;
}
response->resize(len);
CheckedRead(read_fd_, (void*)response->c_str(), len);
}
int ForkPipeRunner::Run(
int argc, char *argv[], const std::vector<ConformanceTestSuite*>& suites) {
if (suites.empty()) {
fprintf(stderr, "No test suites found.\n");
return EXIT_FAILURE;
}
bool all_ok = true;
for (ConformanceTestSuite* suite : suites) {
string program;
std::vector<string> program_args;
string failure_list_filename;
conformance::FailureSet failure_list;
for (int arg = 1; arg < argc; ++arg) {
if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) {
if (++arg == argc) UsageError();
failure_list_filename = argv[arg];
ParseFailureList(argv[arg], &failure_list);
} else if (strcmp(argv[arg], "--verbose") == 0) {
suite->SetVerbose(true);
} else if (strcmp(argv[arg], "--enforce_recommended") == 0) {
suite->SetEnforceRecommended(true);
} else if (strcmp(argv[arg], "--output_dir") == 0) {
if (++arg == argc) UsageError();
suite->SetOutputDir(argv[arg]);
} else if (argv[arg][0] == '-') {
bool recognized_flag = false;
for (ConformanceTestSuite* suite : suites) {
if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) {
if (++arg == argc) UsageError();
recognized_flag = true;
}
}
if (!recognized_flag) {
fprintf(stderr, "Unknown option: %s\n", argv[arg]);
UsageError();
}
} else {
program += argv[arg];
while (arg < argc) {
program_args.push_back(argv[arg]);
arg++;
}
}
}
ForkPipeRunner runner(program, program_args);
std::string output;
all_ok = all_ok &&
suite->RunSuite(&runner, &output, failure_list_filename, &failure_list);
fwrite(output.c_str(), 1, output.size(), stderr);
}
return all_ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
// TODO(haberman): make this work on Windows, instead of using these
// UNIX-specific APIs.
//
// There is a platform-agnostic API in
// src/google/protobuf/compiler/subprocess.h
//
// However that API only supports sending a single message to the subprocess.
// We really want to be able to send messages and receive responses one at a
// time:
//
// 1. Spawning a new process for each test would take way too long for thousands
// of tests and subprocesses like java that can take 100ms or more to start
// up.
//
// 2. Sending all the tests in one big message and receiving all results in one
// big message would take away our visibility about which test(s) caused a
// crash or other fatal error. It would also give us only a single failure
// instead of all of them.
void ForkPipeRunner::SpawnTestProgram() {
int toproc_pipe_fd[2];
int fromproc_pipe_fd[2];
if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) {
perror("pipe");
exit(1);
}
pid_t pid = fork();
if (pid < 0) {
perror("fork");
exit(1);
}
if (pid) {
// Parent.
GOOGLE_CHECK_SYSCALL(close(toproc_pipe_fd[0]));
GOOGLE_CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
write_fd_ = toproc_pipe_fd[1];
read_fd_ = fromproc_pipe_fd[0];
child_pid_ = pid;
} else {
// Child.
GOOGLE_CHECK_SYSCALL(close(STDIN_FILENO));
GOOGLE_CHECK_SYSCALL(close(STDOUT_FILENO));
GOOGLE_CHECK_SYSCALL(dup2(toproc_pipe_fd[0], STDIN_FILENO));
GOOGLE_CHECK_SYSCALL(dup2(fromproc_pipe_fd[1], STDOUT_FILENO));
GOOGLE_CHECK_SYSCALL(close(toproc_pipe_fd[0]));
GOOGLE_CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
GOOGLE_CHECK_SYSCALL(close(toproc_pipe_fd[1]));
GOOGLE_CHECK_SYSCALL(close(fromproc_pipe_fd[0]));
std::unique_ptr<char[]> executable(new char[executable_.size() + 1]);
memcpy(executable.get(), executable_.c_str(), executable_.size());
executable[executable_.size()] = '\0';
std::vector<const char *> argv;
argv.push_back(executable.get());
for (size_t i = 0; i < executable_args_.size(); ++i) {
argv.push_back(executable_args_[i].c_str());
}
argv.push_back(nullptr);
// Never returns.
GOOGLE_CHECK_SYSCALL(execv(executable.get(), const_cast<char **>(argv.data())));
}
}
void ForkPipeRunner::CheckedWrite(int fd, const void *buf, size_t len) {
if (static_cast<size_t>(write(fd, buf, len)) != len) {
GOOGLE_LOG(FATAL) << current_test_name_
<< ": error writing to test program: " << strerror(errno);
}
}
bool ForkPipeRunner::TryRead(int fd, void *buf, size_t len) {
size_t ofs = 0;
while (len > 0) {
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
if (bytes_read == 0) {
GOOGLE_LOG(ERROR) << current_test_name_ << ": unexpected EOF from test program";
return false;
} else if (bytes_read < 0) {
GOOGLE_LOG(ERROR) << current_test_name_
<< ": error reading from test program: " << strerror(errno);
return false;
}
len -= bytes_read;
ofs += bytes_read;
}
return true;
}
void ForkPipeRunner::CheckedRead(int fd, void *buf, size_t len) {
if (!TryRead(fd, buf, len)) {
GOOGLE_LOG(FATAL) << current_test_name_
<< ": error reading from test program: " << strerror(errno);
}
}
} // namespace protobuf
} // namespace google

View File

@ -0,0 +1,28 @@
# PLEASE DO NOT DEPEND ON THE CONTENTS OF THIS FILE, IT IS UNSTABLE.
def conformance_test(name, testee, failure_list = None, text_format_failure_list = None):
args = ["--testee %s" % _strip_bazel(testee)]
failure_lists = []
if failure_list:
args = args + ["--failure_list %s" % _strip_bazel(failure_list)]
failure_lists = failure_lists + [failure_list]
if text_format_failure_list:
args = args + ["--text_format_failure_list %s" % _strip_bazel(text_format_failure_list)]
failure_lists = failure_lists + [text_format_failure_list]
native.sh_test(
name = name,
srcs = ["//conformance:conformance_test_runner.sh"],
data = [testee] + failure_lists + [
"//conformance:conformance_test_runner",
],
args = args,
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
def _strip_bazel(testee):
if testee.startswith("//"):
testee = testee.replace("//", "com_google_protobuf/")
return testee.replace(":", "/")

View File

@ -0,0 +1,37 @@
# This is the list of conformance tests that are known to fail for the C++
# implementation right now. These should be fixed.
#
# By listing them here we can keep tabs on which ones are failing and be sure
# that we don't introduce regressions in other tests.
#
# TODO(haberman): insert links to corresponding bugs tracking the issue.
# Should we use GitHub issues or the Google-internal bug tracker?
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
Recommended.FieldMaskTooManyUnderscore.JsonOutput
Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedFalse
Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedTrue
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.Proto3.JsonInput.FieldNameDuplicate
Recommended.Proto3.JsonInput.FieldNameDuplicateDifferentCasing1
Recommended.Proto3.JsonInput.FieldNameDuplicateDifferentCasing2
Recommended.Proto3.JsonInput.FieldNameNotQuoted
Recommended.Proto3.JsonInput.MapFieldValueIsNull
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull
Recommended.Proto3.JsonInput.RepeatedFieldTrailingComma
Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithNewlines
Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithSpace
Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace
Recommended.Proto3.JsonInput.StringFieldSingleQuoteBoth
Recommended.Proto3.JsonInput.StringFieldSingleQuoteKey
Recommended.Proto3.JsonInput.StringFieldSingleQuoteValue
Recommended.Proto3.JsonInput.StringFieldUppercaseEscapeLetter
Recommended.Proto3.JsonInput.TrailingCommaInAnObject
Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithNewlines
Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpace
Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
Recommended.Proto2.JsonInput.FieldNameExtension.Validator

View File

@ -0,0 +1,7 @@
Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Required.Proto3.JsonInput.OneofFieldNullFirst.JsonOutput
Required.Proto3.JsonInput.OneofFieldNullFirst.ProtobufOutput
Required.Proto3.JsonInput.OneofFieldNullSecond.JsonOutput
Required.Proto3.JsonInput.OneofFieldNullSecond.ProtobufOutput

View File

@ -0,0 +1,44 @@
# This is the list of conformance tests that are known to fail for the Java
# implementation right now. These should be fixed.
#
# By listing them here we can keep tabs on which ones are failing and be sure
# that we don't introduce regressions in other tests.
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
Recommended.FieldMaskTooManyUnderscore.JsonOutput
Recommended.Proto3.JsonInput.BoolFieldAllCapitalFalse
Recommended.Proto3.JsonInput.BoolFieldAllCapitalTrue
Recommended.Proto3.JsonInput.BoolFieldCamelCaseFalse
Recommended.Proto3.JsonInput.BoolFieldCamelCaseTrue
Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedFalse
Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedTrue
Recommended.Proto3.JsonInput.BoolMapFieldKeyNotQuoted
Recommended.Proto3.JsonInput.DoubleFieldInfinityNotQuoted
Recommended.Proto3.JsonInput.DoubleFieldNanNotQuoted
Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.Proto3.JsonInput.FieldNameDuplicate
Recommended.Proto3.JsonInput.FieldNameNotQuoted
Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted
Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted
Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted
Recommended.Proto3.JsonInput.Int32MapFieldKeyNotQuoted
Recommended.Proto3.JsonInput.Int64MapFieldKeyNotQuoted
Recommended.Proto3.JsonInput.JsonWithComments
Recommended.Proto3.JsonInput.StringFieldSingleQuoteBoth
Recommended.Proto3.JsonInput.StringFieldSingleQuoteKey
Recommended.Proto3.JsonInput.StringFieldSingleQuoteValue
Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder
Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.Proto3.JsonInput.Uint32MapFieldKeyNotQuoted
Recommended.Proto3.JsonInput.Uint64MapFieldKeyNotQuoted
Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Required.Proto3.JsonInput.EnumFieldNotQuoted
Required.Proto3.JsonInput.Int32FieldLeadingZero
Required.Proto3.JsonInput.Int32FieldNegativeWithLeadingZero
Required.Proto3.JsonInput.Int32FieldPlusSign
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
Required.Proto3.JsonInput.StringFieldNotAString

View File

@ -0,0 +1,162 @@
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.ENUM[4].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.ENUM[5].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.FIXED64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.INT32[7].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.INT64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.SFIXED64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.SINT64[2].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.UINT32[8].ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.UINT64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[4].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[5].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.FIXED64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.INT32[7].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.INT64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SFIXED64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.SINT64[2].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.UINT32[8].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.UINT64[2].ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.ENUM.ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.ENUM[4].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.ENUM[5].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.FIXED64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.INT32[7].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.INT64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.SFIXED64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.SINT64[2].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.UINT32[8].ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataScalar.UINT64[2].ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.ENUM.ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.ENUM[4].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.ENUM[5].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.FIXED64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.INT32[7].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.INT64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.SFIXED64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.SINT64[2].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.UINT32[8].ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.UINT64[2].ProtobufOutput

View File

@ -0,0 +1,2 @@
# JSON input or output tests are skipped (in conformance_objc.m) as mobile
# platforms don't support JSON wire format to avoid code bloat.

View File

@ -0,0 +1,30 @@
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
Recommended.FieldMaskTooManyUnderscore.JsonOutput
Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator
Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.Int32FieldNotInteger
Required.Proto3.JsonInput.Int64FieldNotInteger
Required.Proto3.JsonInput.OneofFieldDuplicate
Required.Proto3.JsonInput.OneofFieldNullSecond.JsonOutput
Required.Proto3.JsonInput.OneofFieldNullSecond.ProtobufOutput
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
Required.Proto3.JsonInput.RepeatedListValue.JsonOutput
Required.Proto3.JsonInput.RepeatedListValue.ProtobufOutput
Required.Proto3.JsonInput.StringFieldNotAString
Required.Proto3.JsonInput.Uint32FieldNotInteger
Required.Proto3.JsonInput.Uint64FieldNotInteger
Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.JsonOutput
Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.JsonOutput
Required.Proto3.ProtobufInput.ValidDataOneof.MESSAGE.Merge.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput
Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[2].JsonOutput

View File

@ -0,0 +1,2 @@
Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator

View File

@ -0,0 +1,2 @@
JsonInput.StringFieldSurrogateInWrongOrder
JsonInput.StringFieldUnpairedHighSurrogate

View File

@ -0,0 +1,8 @@
# This is the list of conformance tests that are known to fail for the
# Python/C++ implementation right now. These should be fixed.
#
# By listing them here we can keep tabs on which ones are failing and be sure
# that we don't introduce regressions in other tests.
#
# TODO(haberman): insert links to corresponding bugs tracking the issue.
# Should we use GitHub issues or the Google-internal bug tracker?

View File

@ -0,0 +1,58 @@
Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.UnpackedOutput.ProtobufOutput

View File

@ -0,0 +1,478 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "text_format_conformance_suite.h"
#include <google/protobuf/any.pb.h>
#include <google/protobuf/text_format.h>
#include "conformance_test.h"
#include <google/protobuf/test_messages_proto2.pb.h>
#include <google/protobuf/test_messages_proto3.pb.h>
namespace proto2_messages = protobuf_test_messages::proto2;
using conformance::ConformanceRequest;
using conformance::ConformanceResponse;
using conformance::WireFormat;
using google::protobuf::Message;
using google::protobuf::TextFormat;
using proto2_messages::TestAllTypesProto2;
using proto2_messages::UnknownToTestAllTypes;
using protobuf_test_messages::proto3::TestAllTypesProto3;
using std::string;
namespace google {
namespace protobuf {
TextFormatConformanceTestSuite::TextFormatConformanceTestSuite() {
SetFailureListFlagName("--text_format_failure_list");
}
bool TextFormatConformanceTestSuite::ParseTextFormatResponse(
const ConformanceResponse& response,
const ConformanceRequestSetting& setting, Message* test_message) {
TextFormat::Parser parser;
const ConformanceRequest& request = setting.GetRequest();
if (request.print_unknown_fields()) {
parser.AllowFieldNumber(true);
}
if (!parser.ParseFromString(response.text_payload(), test_message)) {
GOOGLE_LOG(ERROR) << "INTERNAL ERROR: internal text->protobuf transcode "
<< "yielded unparseable proto. Text payload: "
<< response.text_payload();
return false;
}
return true;
}
bool TextFormatConformanceTestSuite::ParseResponse(
const ConformanceResponse& response,
const ConformanceRequestSetting& setting, Message* test_message) {
const ConformanceRequest& request = setting.GetRequest();
WireFormat requested_output = request.requested_output_format();
const string& test_name = setting.GetTestName();
ConformanceLevel level = setting.GetLevel();
switch (response.result_case()) {
case ConformanceResponse::kProtobufPayload: {
if (requested_output != conformance::PROTOBUF) {
ReportFailure(test_name, level, request, response,
StrCat("Test was asked for ",
WireFormatToString(requested_output),
" output but provided PROTOBUF instead.")
.c_str());
return false;
}
if (!test_message->ParseFromString(response.protobuf_payload())) {
ReportFailure(test_name, level, request, response,
"Protobuf output we received from test was unparseable.");
return false;
}
break;
}
case ConformanceResponse::kTextPayload: {
if (requested_output != conformance::TEXT_FORMAT) {
ReportFailure(test_name, level, request, response,
StrCat("Test was asked for ",
WireFormatToString(requested_output),
" output but provided TEXT_FORMAT instead.")
.c_str());
return false;
}
if (!ParseTextFormatResponse(response, setting, test_message)) {
ReportFailure(
test_name, level, request, response,
"TEXT_FORMAT output we received from test was unparseable.");
return false;
}
break;
}
default:
GOOGLE_LOG(FATAL) << test_name
<< ": unknown payload type: " << response.result_case();
}
return true;
}
void TextFormatConformanceTestSuite::ExpectParseFailure(const string& test_name,
ConformanceLevel level,
const string& input) {
TestAllTypesProto3 prototype;
// We don't expect output, but if the program erroneously accepts the protobuf
// we let it send its response as this. We must not leave it unspecified.
ConformanceRequestSetting setting(
level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT,
conformance::TEXT_FORMAT_TEST, prototype, test_name, input);
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
string effective_test_name =
StrCat(setting.ConformanceLevelToString(level),
".Proto3.TextFormatInput.", test_name);
RunTest(effective_test_name, request, &response);
if (response.result_case() == ConformanceResponse::kParseError) {
ReportSuccess(effective_test_name);
} else if (response.result_case() == ConformanceResponse::kSkipped) {
ReportSkip(effective_test_name, request, response);
} else {
ReportFailure(effective_test_name, level, request, response,
"Should have failed to parse, but didn't.");
}
}
void TextFormatConformanceTestSuite::RunValidTextFormatTest(
const string& test_name, ConformanceLevel level, const string& input_text) {
TestAllTypesProto3 prototype;
RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype);
}
void TextFormatConformanceTestSuite::RunValidTextFormatTestProto2(
const string& test_name, ConformanceLevel level, const string& input_text) {
TestAllTypesProto2 prototype;
RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype);
}
void TextFormatConformanceTestSuite::RunValidTextFormatTestWithMessage(
const string& test_name, ConformanceLevel level, const string& input_text,
const Message& prototype) {
ConformanceRequestSetting setting1(
level, conformance::TEXT_FORMAT, conformance::PROTOBUF,
conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text);
RunValidInputTest(setting1, input_text);
ConformanceRequestSetting setting2(
level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT,
conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text);
RunValidInputTest(setting2, input_text);
}
void TextFormatConformanceTestSuite::RunValidUnknownTextFormatTest(
const string& test_name, const Message& message) {
string serialized_input;
message.SerializeToString(&serialized_input);
TestAllTypesProto3 prototype;
ConformanceRequestSetting setting1(
RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT,
conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Drop",
serialized_input);
setting1.SetPrototypeMessageForCompare(message);
RunValidBinaryInputTest(setting1, "");
ConformanceRequestSetting setting2(
RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT,
conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Print",
serialized_input);
setting2.SetPrototypeMessageForCompare(message);
setting2.SetPrintUnknownFields(true);
RunValidBinaryInputTest(setting2, serialized_input);
}
void TextFormatConformanceTestSuite::RunSuiteImpl() {
RunValidTextFormatTest("HelloWorld", REQUIRED,
"optional_string: 'Hello, World!'");
// Integer fields.
RunValidTextFormatTest("Int32FieldMaxValue", REQUIRED,
"optional_int32: 2147483647");
RunValidTextFormatTest("Int32FieldMinValue", REQUIRED,
"optional_int32: -2147483648");
RunValidTextFormatTest("Uint32FieldMaxValue", REQUIRED,
"optional_uint32: 4294967295");
RunValidTextFormatTest("Int64FieldMaxValue", REQUIRED,
"optional_int64: 9223372036854775807");
RunValidTextFormatTest("Int64FieldMinValue", REQUIRED,
"optional_int64: -9223372036854775808");
RunValidTextFormatTest("Uint64FieldMaxValue", REQUIRED,
"optional_uint64: 18446744073709551615");
// Parsers reject out-of-bound integer values.
ExpectParseFailure("Int32FieldTooLarge", REQUIRED,
"optional_int32: 2147483648");
ExpectParseFailure("Int32FieldTooSmall", REQUIRED,
"optional_int32: -2147483649");
ExpectParseFailure("Uint32FieldTooLarge", REQUIRED,
"optional_uint32: 4294967296");
ExpectParseFailure("Int64FieldTooLarge", REQUIRED,
"optional_int64: 9223372036854775808");
ExpectParseFailure("Int64FieldTooSmall", REQUIRED,
"optional_int64: -9223372036854775809");
ExpectParseFailure("Uint64FieldTooLarge", REQUIRED,
"optional_uint64: 18446744073709551616");
// Floating point fields
RunValidTextFormatTest("FloatField", REQUIRED,
"optional_float: 3.192837");
RunValidTextFormatTest("FloatFieldWithVeryPreciseNumber", REQUIRED,
"optional_float: 3.123456789123456789");
RunValidTextFormatTest("FloatFieldMaxValue", REQUIRED,
"optional_float: 3.4028235e+38");
RunValidTextFormatTest("FloatFieldMinValue", REQUIRED,
"optional_float: 1.17549e-38");
RunValidTextFormatTest("FloatFieldNaNValue", REQUIRED,
"optional_float: NaN");
RunValidTextFormatTest("FloatFieldPosInfValue", REQUIRED,
"optional_float: inf");
RunValidTextFormatTest("FloatFieldNegInfValue", REQUIRED,
"optional_float: -inf");
RunValidTextFormatTest("FloatFieldWithInt32Max", REQUIRED,
"optional_float: 4294967296");
RunValidTextFormatTest("FloatFieldLargerThanInt64", REQUIRED,
"optional_float: 9223372036854775808");
RunValidTextFormatTest("FloatFieldTooLarge", REQUIRED,
"optional_float: 3.4028235e+39");
RunValidTextFormatTest("FloatFieldTooSmall", REQUIRED,
"optional_float: 1.17549e-39");
RunValidTextFormatTest("FloatFieldLargerThanUint64", REQUIRED,
"optional_float: 18446744073709551616");
// String literals x {Strings, Bytes}
for (const auto& field_type : std::vector<std::string>{"String", "Bytes"}) {
const std::string field_name =
field_type == "String" ? "optional_string" : "optional_bytes";
RunValidTextFormatTest(
StrCat("StringLiteralConcat", field_type), REQUIRED,
StrCat(field_name, ": 'first' \"second\"\n'third'"));
RunValidTextFormatTest(
StrCat("StringLiteralBasicEscapes", field_type), REQUIRED,
StrCat(field_name, ": '\\a\\b\\f\\n\\r\\t\\v\\?\\\\\\'\\\"'"));
RunValidTextFormatTest(
StrCat("StringLiteralOctalEscapes", field_type), REQUIRED,
StrCat(field_name, ": '\\341\\210\\264'"));
RunValidTextFormatTest(StrCat("StringLiteralHexEscapes", field_type),
REQUIRED,
StrCat(field_name, ": '\\xe1\\x88\\xb4'"));
RunValidTextFormatTest(
StrCat("StringLiteralShortUnicodeEscape", field_type),
RECOMMENDED, StrCat(field_name, ": '\\u1234'"));
RunValidTextFormatTest(
StrCat("StringLiteralLongUnicodeEscapes", field_type),
RECOMMENDED, StrCat(field_name, ": '\\U00001234\\U00010437'"));
// String literals don't include line feeds.
ExpectParseFailure(StrCat("StringLiteralIncludesLF", field_type),
REQUIRED,
StrCat(field_name, ": 'first line\nsecond line'"));
// Unicode escapes don't include code points that lie beyond the planes
// (> 0x10ffff).
ExpectParseFailure(
StrCat("StringLiteralLongUnicodeEscapeTooLarge", field_type),
REQUIRED, StrCat(field_name, ": '\\U00110000'"));
// Unicode escapes don't include surrogates.
ExpectParseFailure(
StrCat("StringLiteralShortUnicodeEscapeSurrogatePair",
field_type),
RECOMMENDED, StrCat(field_name, ": '\\ud801\\udc37'"));
ExpectParseFailure(
StrCat("StringLiteralShortUnicodeEscapeSurrogateFirstOnly",
field_type),
RECOMMENDED, StrCat(field_name, ": '\\ud800'"));
ExpectParseFailure(
StrCat("StringLiteralShortUnicodeEscapeSurrogateSecondOnly",
field_type),
RECOMMENDED, StrCat(field_name, ": '\\udc00'"));
ExpectParseFailure(
StrCat("StringLiteralLongUnicodeEscapeSurrogateFirstOnly",
field_type),
RECOMMENDED, StrCat(field_name, ": '\\U0000d800'"));
ExpectParseFailure(
StrCat("StringLiteralLongUnicodeEscapeSurrogateSecondOnly",
field_type),
RECOMMENDED, StrCat(field_name, ": '\\U0000dc00'"));
ExpectParseFailure(
StrCat("StringLiteralLongUnicodeEscapeSurrogatePair", field_type),
RECOMMENDED, StrCat(field_name, ": '\\U0000d801\\U00000dc37'"));
ExpectParseFailure(
StrCat("StringLiteralUnicodeEscapeSurrogatePairLongShort",
field_type),
RECOMMENDED, StrCat(field_name, ": '\\U0000d801\\udc37'"));
ExpectParseFailure(
StrCat("StringLiteralUnicodeEscapeSurrogatePairShortLong",
field_type),
RECOMMENDED, StrCat(field_name, ": '\\ud801\\U0000dc37'"));
// The following method depend on the type of field, as strings have extra
// validation.
const auto test_method =
field_type == "String"
? &TextFormatConformanceTestSuite::ExpectParseFailure
: &TextFormatConformanceTestSuite::RunValidTextFormatTest;
// String fields reject invalid UTF-8 byte sequences; bytes fields don't.
(this->*test_method)(StrCat(field_type, "FieldBadUTF8Octal"),
REQUIRED, StrCat(field_name, ": '\\300'"));
(this->*test_method)(StrCat(field_type, "FieldBadUTF8Hex"), REQUIRED,
StrCat(field_name, ": '\\xc0'"));
}
// Group fields
RunValidTextFormatTestProto2("GroupFieldNoColon", REQUIRED,
"Data { group_int32: 1 }");
RunValidTextFormatTestProto2("GroupFieldWithColon", REQUIRED,
"Data: { group_int32: 1 }");
RunValidTextFormatTestProto2("GroupFieldEmpty", REQUIRED,
"Data {}");
// Unknown Fields
UnknownToTestAllTypes message;
// Unable to print unknown Fixed32/Fixed64 fields as if they are known.
// Fixed32/Fixed64 fields are not added in the tests.
message.set_optional_int32(123);
message.set_optional_string("hello");
message.set_optional_bool(true);
RunValidUnknownTextFormatTest("ScalarUnknownFields", message);
message.Clear();
message.mutable_nested_message()->set_c(111);
RunValidUnknownTextFormatTest("MessageUnknownFields", message);
message.Clear();
message.mutable_optionalgroup()->set_a(321);
RunValidUnknownTextFormatTest("GroupUnknownFields", message);
message.add_repeated_int32(1);
message.add_repeated_int32(2);
message.add_repeated_int32(3);
RunValidUnknownTextFormatTest("RepeatedUnknownFields", message);
// Any fields
RunValidTextFormatTest("AnyField", REQUIRED,
R"(
optional_any: {
[type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3] {
optional_int32: 12345
}
}
)");
RunValidTextFormatTest("AnyFieldWithRawBytes", REQUIRED,
R"(
optional_any: {
type_url: "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3"
value: "\b\271`"
}
)");
ExpectParseFailure("AnyFieldWithInvalidType", REQUIRED,
R"(
optional_any: {
[type.googleapis.com/unknown] {
optional_int32: 12345
}
}
)");
// Map fields
TestAllTypesProto3 prototype;
(*prototype.mutable_map_string_string())["c"] = "value";
(*prototype.mutable_map_string_string())["b"] = "value";
(*prototype.mutable_map_string_string())["a"] = "value";
RunValidTextFormatTestWithMessage("AlphabeticallySortedMapStringKeys",
REQUIRED,
R"(
map_string_string {
key: "a"
value: "value"
}
map_string_string {
key: "b"
value: "value"
}
map_string_string {
key: "c"
value: "value"
}
)",
prototype);
prototype.Clear();
(*prototype.mutable_map_int32_int32())[3] = 0;
(*prototype.mutable_map_int32_int32())[2] = 0;
(*prototype.mutable_map_int32_int32())[1] = 0;
RunValidTextFormatTestWithMessage("AlphabeticallySortedMapIntKeys", REQUIRED,
R"(
map_int32_int32 {
key: 1
value: 0
}
map_int32_int32 {
key: 2
value: 0
}
map_int32_int32 {
key: 3
value: 0
}
)",
prototype);
prototype.Clear();
(*prototype.mutable_map_bool_bool())[true] = false;
(*prototype.mutable_map_bool_bool())[false] = false;
RunValidTextFormatTestWithMessage("AlphabeticallySortedMapBoolKeys", REQUIRED,
R"(
map_bool_bool {
key: false
value: false
}
map_bool_bool {
key: true
value: false
}
)",
prototype);
prototype.Clear();
ConformanceRequestSetting setting_map(
REQUIRED, conformance::TEXT_FORMAT, conformance::PROTOBUF,
conformance::TEXT_FORMAT_TEST, prototype, "DuplicateMapKey", R"(
map_string_nested_message {
key: "duplicate"
value: { a: 123 }
}
map_string_nested_message {
key: "duplicate"
value: { corecursive: {} }
}
)");
// The last-specified value will be retained in a parsed map
RunValidInputTest(setting_map, R"(
map_string_nested_message {
key: "duplicate"
value: { corecursive: {} }
}
)");
}
} // namespace protobuf
} // namespace google

Some files were not shown because too many files have changed in this diff Show More