Compare commits

...

800 Commits

Author SHA1 Message Date
2ca6abf87e [*] ive yet to see a single project of theirs beside gtest compile on a supported platform. v8 "clang on linux" where the fucking header does the wrong thing explicitly. v8 "msvc under windows". now this under msvc. fuck you, google. fuck you and your incompetent half-assed libraries. here's my contribution to a needlessly long commit log of fucking ungodly maintenance.
A challenge to anyone reading this:
> Scroll down this commit log
> Pick a random day
> Open all the commits
> Remind yourself this bullshit runs a $1,210 billion company.
> ....out of thousands of employees worth $1.65m/year (revenue per employee), they can barely muster +- 20 lines or even leave the configs/docs
> ...try not to kill yourself
2022-06-23 19:45:53 +01:00
Erik Mavrinac
9f58ee3f04
Update to C# 10 and upgrade code style (#10105) 2022-06-23 10:05:16 +01:00
Dennis Shao
352444ecd5
Merge pull request #10167 from shaod2/master
Fix to generate Python gendocs.
2022-06-22 17:07:55 -05:00
Dennis Shao
1275ce88f9 Add missing rst files 2022-06-22 21:50:12 +00:00
Dennis Shao
c62c2340ca Update rst files for Python generated docs 2022-06-22 21:33:46 +00:00
Dennis Shao
e09804591d
Merge branch 'protocolbuffers:main' into master 2022-06-22 14:46:13 -05:00
Jonathan Ringer
046bde0017
Allow for CMAKE_INSTALL_CMAKEDIR to be absolute (#10090)
Package repositories such as NixOS will pass
an absolute paths to CMAKE.

- Also clarify installation of cmake configuration
files between the build and install directories.
2022-06-22 10:43:13 -07:00
Dennis Shao
1640336fcf
Create .repo-metadata.json 2022-06-21 18:07:57 -05:00
Dennis Shao
3f0f59b00e
Merge pull request #10160 from shaod2/master
Update options.md
2022-06-21 16:56:58 -05:00
Dennis Shao
a9d9c00bff
Update options.md
https://github.com/protocolbuffers/protobuf/issues/10153
2022-06-21 14:52:40 -05:00
deannagarcia
0933faa9ba
Merge pull request #10140 from protocolbuffers/updateDocuploaderVersion
Update versions for publish python script
2022-06-21 17:39:42 +00:00
Jorg Brown
cecbb0a70e
Merge pull request #10148 from jorgbrown/sync-stage
Integrate from Piper for C++, Java, and Python

* Modernize conformance_cpp.cc.
* Don't request 64-byte alignment unless the toolchain supports it.
2022-06-18 19:32:48 -07:00
Jorg Brown
feb726159f Remove * Take StringPiece instead of const string& in absl stubs. from CHANGES.txt since we're not taking it. 2022-06-18 19:27:22 -07:00
Jorg Brown
7bb756c1cc Re-instate commit c0fc2e881b 2022-06-18 19:22:47 -07:00
Jorg Brown
24d0a3bed1 Revert all changes to strutil.{h,cc} from this PR 2022-06-18 18:01:06 -07:00
Jorg Brown
a075d2fb14 Remove extraneous ';' 2022-06-18 15:27:10 -07:00
Jorg Brown
81491e034f Can't use char * for quoted literals. I knew that. 2022-06-18 15:16:40 -07:00
Jorg Brown
e9668e41be Find out who is calling StringReplace, or if the call is from strutil
itself.
2022-06-18 14:54:10 -07:00
Jorg Brown
dc7f4debbc More debugging information please 2022-06-17 21:11:17 -07:00
Jorg Brown
126841ed7d Add some extra tracing to figure out a crash during build 2022-06-17 19:34:14 -07:00
Jorg Brown
a94d41960e Add missing file names to BUILD.bazel files. 2022-06-17 17:19:14 -07:00
Jorg Brown
8deb95bda9 Fix typo and update CHANGES.txt 2022-06-17 13:59:28 -07:00
Jorg Brown
4eeaacd3fd Merge tag 'refs/tags/sync-piper' into sync-stage
# Conflicts:
#	src/google/protobuf/compiler/java/message_serialization.cc
2022-06-17 10:08:18 -07:00
Jorg Brown
a3e1de0113 Sync from Piper @455586341
PROTOBUF_SYNC_PIPER
2022-06-17 04:13:20 -07:00
Dilan Sachintha Nayanajith
92ac51fd43
Update options.md (#10137) 2022-06-16 08:59:10 -07:00
mkruskal-google
6e34912084
Removing deleted files from dist rule (#10141) 2022-06-15 17:00:35 -07:00
Dave MacLachlan
e04ca460fb Fix up missing include files for unordered_set/map 2022-06-15 14:36:19 -04:00
Deanna Garcia
87ac4650a3 Update versions for publish python script 2022-06-15 17:22:55 +00:00
Thomas Van Lenten
772c98984a Add package_as_prefix_forced_prefix generation option.
This is a generation option that provides serves the same purpose as the
existing GPB_OBJC_USE_PACKAGE_AS_PREFIX_PREFIX environment variable; just
providing a different way to set/enable it.
2022-06-15 09:52:57 -04:00
Jon Skeet
cacb096002 Add CodeRush directory to .gitignore for C#
This is just a temporary directory for CodeRush, and should never
contain anything worth checking in. (Like the .vs directory.)
2022-06-14 10:03:38 +01:00
Jon Skeet
837db77ecf Remove C# code specific to .NET 3.5
The codebase has changed a lot since it was last able to compile
with .NET 3.5, so we don't need this vestigial code.
2022-06-14 10:03:38 +01:00
Joshua Haberman
c38281dd20
Merge pull request #10102 from fiboknacky/update-fielddescriptor
Exposed more functions in FieldDescriptor and OneofDescriptor.
2022-06-12 20:49:34 -07:00
Elliotte Rusty Harold
a612a75b68
Merge pull request #10130 from elharo/sync-stage
Integrate from Piper for C++, Java, and Python
2022-06-11 11:17:50 +00:00
Elliotte Rusty Harold
b53e63bae1 update CHANGE list 2022-06-10 18:45:38 -04:00
Elliotte Rusty Harold
81fc22c8ab Merge tag 'refs/tags/sync-piper' into sync-stage 2022-06-10 18:37:12 -04:00
Elliotte Rusty Harold
5a9bf6c7de Sync from Piper @454255492
PROTOBUF_SYNC_PIPER
2022-06-10 18:37:11 -04:00
Elliotte Rusty Harold
9f53ec3996 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-06-10 16:04:55 -04:00
Elliotte Rusty Harold
24dad62f40 Sync from Piper @454225000
PROTOBUF_SYNC_PIPER
2022-06-10 16:04:55 -04:00
Elliotte Rusty Harold
70e2923365 update CHANGE list 2022-06-10 14:33:54 -04:00
Elliotte Rusty Harold
31ba940bfe Merge tag 'refs/tags/sync-piper' into sync-stage 2022-06-10 14:32:15 -04:00
Elliotte Rusty Harold
ce537e8a3e Sync from Piper @454206746
PROTOBUF_SYNC_PIPER
2022-06-10 14:32:14 -04:00
Marc Plano-Lesay
85225b83c3
Remove unused Offset function (#10120)
This fails to build with -Werror.
2022-06-09 16:59:07 -07:00
David Neto
af699898d2
Length check accommodates NUL emitted by sprintf (#10128)
Update the length check in google::protobuf::CEscapeInternal to account
for the extra NUL character emitted by snprintf when escaping hex and
octal sequences.

That function is an internal detail, not exported via any header.
Internally, it is used in two places, and both calls make buffers
that do have space for the extra NUL.
So in the actual usage, the check is redundant.
2022-06-09 16:30:53 -07:00
Chenwei Xiao
1bbf6f37cc
Correct file extention of README (#10125) 2022-06-09 15:52:50 -07:00
YJ
2bc5f95fe3
add missing quotes (#10123) 2022-06-09 13:27:39 -07:00
Dave MacLachlan
922f5024cb Clean up some warnings
Move to explicit on single arg c'tors.
Move to unordered container types when working with pointers as order is likely unnecessary and just a performance issue.
2022-06-09 08:19:06 -04:00
Elliotte Rusty Harold
2b19a8062a update CHANGE list 2022-06-09 07:45:29 -04:00
Elliotte Rusty Harold
f5ba6c8610 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-06-09 07:42:15 -04:00
Elliotte Rusty Harold
9e24b1912e Sync from Piper @453894829
PROTOBUF_SYNC_PIPER
2022-06-09 07:42:14 -04:00
Thanet (Knack) Praneenararat
0f1574aae2 Fixed bugs of OneofDescriptor. 2022-06-09 17:00:00 +09:00
Elliotte Rusty Harold
0a16bdfbe6
Ignore configure~ (#10117)
fixes #9974
@acozzette
2022-06-08 14:59:30 -04:00
Elliotte Rusty Harold
4d96482e72 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-06-08 12:49:35 -04:00
Elliotte Rusty Harold
3ba3c6a36f Sync from Piper @453701696
PROTOBUF_SYNC_PIPER
2022-06-08 12:49:35 -04:00
strangewiz
c0fc2e881b
Remove use of sprintf in strutil.cc (#10112)
Co-authored-by: Justin Cohen <justincohen@google.com>
2022-06-07 16:13:33 -07:00
secup
d37cbfd448
Update inlined_string_field.h (#10107)
Modify to #ifdef to prevent certain projects to report warnings are errors. thx u
2022-06-07 16:12:13 -07:00
mkruskal-google
3380463ff8
Deleting python release kokoro setup. This has been replaced by upb's python release (#10055) 2022-06-03 14:50:53 -07:00
Thanet (Knack) Praneenararat
594f2a9b0d Fixes bugs of isSynthetic and makes containing_oneof work 2022-06-04 01:40:22 +09:00
Thanet (Knack) Praneenararat
238331b359 Added support for getRealContainingOneof() and getContainingOneof() 2022-06-03 17:19:23 +09:00
zhangskz
0663080c5a
Revert third party/benchmark commit from Piper integrate and add ignore=dirty to submodule (#10104)
* Revert change to third_party/benchmark from Piper->Github sync

* Add ignore=dirty to third_party/benchmark submodule
2022-06-02 18:32:45 -04:00
Namgoo Lee
e7cc1aa970
remove const from function return type if returning const value (#10101) 2022-06-02 12:38:35 -07:00
zhangskz
4548b4ac0e
Merge pull request #10103 from zhangskz/sync-stage
Integrate from Piper for C++, Java, and Python
2022-06-02 18:28:15 +00:00
Sandy Zhang
f138d5de25 Sync from Piper @452551755
PROTOBUF_SYNC_PIPER
2022-06-02 16:14:25 +00:00
Sandy Zhang
2ad33999ee Merge tag 'refs/tags/sync-piper' into sync-stage 2022-06-02 16:14:25 +00:00
Thanet (Knack) Praneenararat
b27dd18676 Exposed more functions in FieldDescriptor and OneofDescriptor. 2022-06-03 00:08:44 +09:00
David L. Jones
67f46d2495
Switch normal macos build to use cmake. (#10092) 2022-06-01 18:24:53 -07:00
David L. Jones
dc14b4be42
Change update_file_lists.sh to work based on Bazel-generated file lists (#10091)
This commit changes update_file_lists.sh to use Bazel as the source of truth. Currently, only the cmake build is actually affected, but Automake should be fairly straightforward to convert.

The file lists were originally factored out in PR#10027. This commit actually switches over to the Bazel-generated lists.
2022-06-01 18:23:05 -07:00
appledragon
45b7f62b1b
use char to find instead of string (#10094)
* [Bazel] Add a doc explaining our C++ build systems and distribution archives. (#10073)

* use char to find instead of string

Co-authored-by: David L. Jones <dlj@google.com>
2022-06-01 14:18:16 -07:00
David L. Jones
bd85edfbd9
[Bazel] Add a doc explaining our C++ build systems and distribution archives. (#10073) 2022-05-31 17:52:26 -07:00
David L. Jones
74b2c7c7ce
Move cmake file lists into src/file_lists.cmake. (#10027)
This is in preparation for generating file lists automatically.

I am putting the list of files under src/, not under cmake/, so that it will be next to the file list for automake (see #10029). I can certainly put the list back under cmake/, but in general, I think we probably want to move the cmake targets e.g. to src/CMakeLists.txt anyhow.
2022-05-31 16:16:02 -07:00
David L. Jones
c2e99db90b
Add filegroups for test sources and include them in file lists. (#10049)
These will be used to generate lists of sources for non-Bazel builds.
2022-05-31 15:59:28 -07:00
zhangskz
1ec6f26ce7
Remove expected cmake failure due to missing abseil sources, since ab… (#10089)
* Remove expected cmake failure due to missing abseil sources, since absl dep was rolled back

* Add back cmake.sh run using extracted sources
2022-05-31 16:45:44 -04:00
bttk
85fcd02e32
Remove merge markers from BUILD.bazel and fix incorrect merge (#10084)
* Remove merge markers from BUILD.bazel

* fix build errors
2022-05-31 15:34:59 -04:00
zhangskz
045172f35a
Merge pull request #10072 from protocolbuffers/main-202205272356
Merge 21.x to main after 21.1 release
2022-05-31 16:13:37 +00:00
Dennis Shao
a11fa4529f
Merge pull request #10059 from shaod2/sync-stage
Integrate from Piper for C++, Java, and Python
2022-05-31 11:12:11 -05:00
Sandy Zhang
e16d9348d7 Fix php generator merge to include php revert change from 21.x 2022-05-28 00:27:59 +00:00
Sandy Zhang
15e09f56b0 Fix unsaved merge resolution 2022-05-28 00:17:14 +00:00
Sandy Zhang
258514019f Merge 21.x into main 2022-05-28 00:06:34 +00:00
zhangskz
55fe00e35e
Merge pull request #10071 from protocolbuffers/21.x-202205272218
Update version.json to 21.2-dev
2022-05-27 23:25:37 +00:00
zhangskz
fd896733a5
Merge branch '21.x' into 21.x-202205272218 2022-05-27 23:24:44 +00:00
Sandy Zhang
6bd7c2e48c Update version.json to: 21.2-dev 2022-05-27 23:19:49 +00:00
Adam Cozzette
7f02c3b16b
Fix continuous aarch64 builds (#10067)
Some of the continuous aarch64 builds started failing yesterday because
the autotools -> CMake change caused the protoc binary to end up in an
unexpected location. This change fixes the problem by putting a symlink
in the src/ directory.
2022-05-27 11:11:05 -07:00
Sandy Zhang
569a0517fa Updated changelog 2022-05-27 14:07:46 -04:00
Protobuf Team Bot
38e3a11a29 Updating version.json and repo version numbers to: 21.1 2022-05-27 14:07:46 -04:00
Protobuf Team Bot
e73ed1630f Updating version.json and repo version numbers to: 21.1 2022-05-27 09:37:14 -07:00
zhangskz
5bbb8f7b2c
Update upb commit to include fix for segmentation fault when instantiating field via repeated field assignment (#10066) 2022-05-27 12:16:33 -04:00
deannagarcia
d4e1c668ad
Merge pull request #10047 from protocolbuffers/temp
Update version.json to: 21.1-dev
2022-05-27 16:02:45 +00:00
David L. Jones
ceaae1b6a3
[Bazel] Add back a filegroup for :well_known_protos. (#10061)
This was removed in #9915, since it is misleadingly named (the set of sources is "well known," but not the same as the Well-Known Types).
2022-05-26 16:32:15 -07:00
Adam Cozzette
3b029b1f4f
Revert "Fix cmake install targets (#9822)" (#10060)
This reverts commit c80808ce1d.

Thix fixes #10045. Somehow the change caused these four .cmake files to
stop being installed:

protobuf-config.cmake
protobuf-config-version.cmake
protobuf-module.cmake
protobuf-options.cmake

After reverting the change, I confirmed that the files are being
installed again.
2022-05-26 14:11:37 -07:00
zhangskz
16a86804c0
Update upb commit/sha256 to include updated python wheel (#10058) 2022-05-26 15:36:41 -04:00
Dennis Shao
6dd8af4ecf Sync from Piper @451217119
PROTOBUF_SYNC_PIPER
2022-05-26 19:21:41 +00:00
Dennis Shao
0e8b241eb4 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-05-26 19:21:41 +00:00
Adam Cozzette
f7e2e0b301
Remove Abseil dependency from CMake build (#10056)
* Revert "Added cmake abseil include guard"

This reverts commit b6ee841d7c.

* Revert "Update CMake configuration to add a dependency on Abseil (#9793)"

This reverts commit e9246cd789.
2022-05-26 12:13:41 -07:00
Adam Cozzette
30f446820d
Add endian.h to includes list (#10057)
Client code is breaking due to missing include.  (endian.h was added in 9e09343 but didn't make it into this list, so it wasn't getting installed)

Co-authored-by: boscosiu <boscosiu@users.noreply.github.com>
2022-05-26 12:09:49 -07:00
mkruskal-google
f2e06fe042
Migrate linux-aarch64 tests away from autotools (#10015)
Autotools support is being deprecated, so this moves some of our kokoro tests to cmake
2022-05-26 09:54:30 -07:00
Deanna Garcia
698d760f8d Update version.json to: 21.1-dev 2022-05-26 01:24:35 +00:00
deannagarcia
e7e8f04a4f
Merge pull request #10044 from protocolbuffers/21.x-202205252102
Update versions and changelog for 21.x
2022-05-25 21:50:17 +00:00
David L. Jones
0e42bf9f58
[Bazel/C++] Split apart protobuf_test rule (#10039)
This splits the `protobuf_test` target into several other test targets, and adds `lite_unittest` and `lite_arena_unittest`, which were missing previously.

[Side note:] I did a pass over the new tests to thin their dependencies, and also split out `lite_test_util` from the existing `test_util`  target. I have left the `protobuf_test` target in place (but empty) for now... it is almost certainly safe to remove, but that can be done in a follow-up to reduce risk from this commit.
2022-05-25 14:28:03 -07:00
Deanna Garcia
7062d0a2d0 Updated changelog 2022-05-25 21:15:04 +00:00
Protobuf Team Bot
59c6ff83e9 Updating version.json and repo version numbers to: 21.0 2022-05-25 13:51:01 -07:00
David L. Jones
34d749df72
Fix headers for protobuf and protobuf_lite so they are the proper lists of files, not just globs. (#10031)
This change makes the headers into actual lists of files, rather than globs. These lists are based on the current cmake definitions.
2022-05-25 12:02:31 -07:00
cjtallman
043ee2e4e6
Adding a DEPENDENCIES option to the protobuf_generate cmake function (#10014) 2022-05-25 11:00:25 -07:00
deannagarcia
6641a420ff
Merge pull request #10024 from Niranjan-B/add-header-search-paths
Add header search paths to protobuf-c++ spec
2022-05-25 10:23:18 -07:00
Joshua Haberman
ec4c19b962
Merge pull request #10036 from haberman/rollback-readonly
Revert "fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibi…lity (#9633)"
2022-05-24 16:33:50 -07:00
Adam Cozzette
5e7b709564
Revert "Various fixups to warnings flags (#9344)" (#10037)
This reverts commit 448d421250.

Unfortunately we have to revert this because we're finding that it
introduces too much new build log spam for existing proto files that are
out of compliance with the warnings. We might be able to roll it forward
again if we can figure out a way to do so without so many new log
messages.
2022-05-24 15:52:18 -07:00
Joshua Haberman
8984184e54 Revert "fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)"
This reverts commit eb27c201f1.
2022-05-24 21:06:00 +00:00
David L. Jones
586b72c1ac
[Bazel/C++] Augment cc_dist_library to generate lists of source files (#10026)
This change largely moves internal logic that creates the the `CcFileList` provider from `build_systems.bzl` to `cc_dist_library.bzl`.

There are also some associated changes to the particular `cc_dist_library` targets, since the output didn't really make sense after previous BUILD.bazel refactoring. There is also a target now for `libprotoc`.
2022-05-24 12:31:56 -07:00
Joshua Haberman
0b2cee6486
Merge pull request #10025 from haberman/fix-windows-protoc
Fixed the Windows build of protoc by statically linking deps.
2022-05-23 15:01:04 -07:00
Joshua Haberman
2dc7679cc1 Fixed the Windows build of protoc by statically linking deps. 2022-05-23 20:59:31 +00:00
Niranjan Bhaskar
a5a71fbbdf Add header search paths to protobuf-c++ spec 2022-05-23 16:04:58 -04:00
David L. Jones
bbcc459aa0
[Kokoro/Bazel] Send Bazel build results to BES. (#10008)
This change adds bazel_wrapper.sh, which uses values set by Kokoro to log remotely.
2022-05-20 19:44:51 -07:00
David L. Jones
e5e8378a62
[Bazel] Make the protobuf workspace (nearly) wildcard-buildable. (#10010)
- Add back benchmarks/datasets/BUILD.bazel to dist archive
- Change dist/build_systems.bzl to be compatible with Bazel 4.0.0.

After this, most builds can use //..., with one exception: non-Mac environments must also exclude objectivec:
`bazel build -- //... -//objectivec/...`
2022-05-20 19:33:42 -07:00
deannagarcia
6d2827b377
Merge pull request #10019 from deannagarcia/fixCocoapods
Fix podspecs
2022-05-20 15:54:24 -07:00
deannagarcia
599b08ab1c
Merge pull request #10018 from protocolbuffers/main-202205201724
Merge 21.x into Main
2022-05-20 15:54:17 -07:00
Deanna Garcia
942cec077a Fix podspecs 2022-05-20 21:43:48 +00:00
Deanna Garcia
38f0bd4d15 Fix bazel builds 2022-05-20 21:28:55 +00:00
David L. Jones
bb27447f42
[Bazel] Use pyenv to select Python 3.9.5 on our linux/bazel builds. (#10009)
We still need to use python2 when running autotools.
2022-05-20 13:04:18 -07:00
Deanna Garcia
cdfd60f63d Fix podspec errors 2022-05-20 18:03:26 +00:00
Deanna Garcia
1407efb39f Fix merge conflict 2022-05-20 17:45:47 +00:00
Deanna Garcia
da481978af Merge 21.x back to main 2022-05-20 17:39:11 +00:00
deannagarcia
6673c7c48f
Merge pull request #10006 from protocolbuffers/21.x-202205200038
Update version.json to: 21.0-dev
2022-05-20 10:17:11 -07:00
Chan Wen Xu
30f6c7851b
Add protoc-gen-xo to global extension registry (#9997) 2022-05-20 05:51:18 -07:00
David L. Jones
450d24ca82
Merge pull request #10005 from dlj-NaN/sync-stage
Integrate from Piper for C++, Java, and Python
2022-05-19 18:56:40 -07:00
Deanna Garcia
ecaeadeced Update version.json to: 21.0-dev 2022-05-20 00:38:39 +00:00
David L. Jones
42ff77e55f Restore erroneous changes to Makefile.am. 2022-05-19 17:26:06 -07:00
David L. Jones
053f698e90 Adjust constexpr qualifiers so they work in gcc < 4.9. 2022-05-19 16:57:17 -07:00
David L. Jones
7f2368933a Re-generate csharp and php golden proto files after changes to descriptor.proto. 2022-05-19 16:02:36 -07:00
David L. Jones
d0a4dc7661 Update CHANGES.txt. 2022-05-19 14:46:31 -07:00
David L. Jones
3740e6fa68 Sync from Piper @449836334
PROTOBUF_SYNC_PIPER
2022-05-19 14:43:18 -07:00
David L. Jones
d87d99d931 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-05-19 14:43:18 -07:00
David L. Jones
cd5cc37624
Fix some style/lint issues. (#10003)
- Starlark: ensure docstrings are present.
- python/setup.py: https://refex.readthedocs.io/en/latest/guide/fixers/superfluous_parens.html
2022-05-19 14:22:56 -07:00
Deanna Garcia
71271ad1f8 Edit changelog 2022-05-19 20:42:46 +00:00
Protobuf Team Bot
1fa42c4be4 Updating version.json and repo version numbers to: 21.0-rc2 2022-05-19 13:35:48 -07:00
deannagarcia
d031130582
Merge pull request #10000 from jskeet/21.x
Cherry-pick PR #9981 into 21.x branch
2022-05-19 10:38:31 -07:00
Joshua Haberman
bf771eb540
Merge pull request #9996 from haberman/cherry-pick-php-segv-fix
Fixed PHP SEGV by not writing to shared memory for zend_class_entry.
2022-05-19 08:44:28 -07:00
Jan Tattermusch
70afbd3c8d regenerate C# protos 2022-05-19 16:42:21 +01:00
James Newton-King
9806b0f57b Suppress CS8981 in generated source 2022-05-19 16:42:20 +01:00
Joshua Haberman
a04d00312f Fixed PHP SEGV by not writing to shared memory for zend_class_entry. 2022-05-19 04:15:51 +00:00
Joshua Haberman
fd3b5a36ab
Merge pull request #9995 from haberman/php-segv-fix
Fixed PHP SEGV by not writing to shared memory for zend_class_entry.
2022-05-18 21:13:47 -07:00
Joshua Haberman
8a46882bf0 Brought the comment up to date. 2022-05-19 04:13:16 +00:00
Joshua Haberman
65a2a52df3 Fixed PHP SEGV by not writing to shared memory for zend_class_entry. 2022-05-18 21:39:30 +00:00
David L. Jones
171a6b1155
[Bazel/C++] Move core C++ implementation to //src/google/protobuf package. (#9988)
This is somewhat of a rough cut, since it doesn't split apart the lite and full targets, or unit tests. However, it does split sources under src/google/protobuf into a separate package, which is a fairly impactful change.
2022-05-18 13:45:22 -07:00
Jan Tattermusch
d2292fc5f6 regenerate C# protos 2022-05-18 18:18:25 +01:00
James Newton-King
40e82cbd2a Suppress CS8981 in generated source 2022-05-18 18:18:25 +01:00
David L. Jones
07303d6f54
[Bazel/C++] Factor out util library (#9987)
This change creates new Bazel packages for the C++ util libraries (similar to #9980 and #9985).
2022-05-17 18:13:22 -07:00
Joshua Haberman
fe3d67cb8e
Merge pull request #9986 from haberman/update-upb3
Updated upb, which will give a better error message if generated code is out of date
2022-05-17 17:46:50 -07:00
David L. Jones
cbd1adc6cf
[Bazel/C++] Factor out compiler packages. (#9985)
This change adds packages for protoc sources under src/google/protobuf/compiler (this is similar to what was done in #9980).
2022-05-17 16:39:47 -07:00
Joshua Haberman
364852e829 Throw a more helpful error if generated code is out of date, and fixed two reference leaks. 2022-05-17 22:51:01 +00:00
David L. Jones
f868799366
Use cc_dist_library targets for macos release libprotobuf. (#9966) 2022-05-17 15:36:37 -07:00
deannagarcia
22067bf523
Merge pull request #9979 from deannagarcia/fixProtocRelease
Fix protoc_release target
2022-05-17 13:35:43 -07:00
David L. Jones
c2c770e7ea
[Bazel/C++] Factor out stubs, io, and testing libraries. (#9980)
This change creates packages under src/google/protobuf/{io,stubs,testing} and moves build definitions there. Future changes will handle .../util and .../compiler, and finally src/google/protobuf.
2022-05-17 13:26:46 -07:00
zhangskz
e235147407
Delete legacy update_version.py script, which is replaced with internal update_versions library (#9983) 2022-05-17 13:49:20 -04:00
David L. Jones
b3199d62be
[Python] Handle user-provided --link-objects and --library-dirs. (#9968)
If the user provides a `--link-objects` (or `-O`) flag that looks like it points to libprotobuf, use that for static linking instead of using the hard-coded path `../src/.libs/libprotobuf.a`. (Also, if we see such a flag, assume they want to link it statically, even if they don't provide `--compile_static_extension`.)

Similarly, if they provide a `--library-dirs=` (or `-L`), assume that is the location to search, and don't add the hard-coded path `../src/.libs`.
2022-05-16 17:21:28 -07:00
David L. Jones
4e5b920625
[Bazel/macOS] Use the constructed environment when running libtool. (#9965)
This fixes errors like: `SDKROOT: unbound variable` when building a cc_dist_library rule.
2022-05-16 16:11:09 -07:00
Deanna Garcia
0f3ee3b625 Fix protoc_release target 2022-05-16 22:48:41 +00:00
Joshua Haberman
cf4075ac20
Merge pull request #9969 from johnnyshields/21.x-ruby-x64-mingw-ucrt-support
21.x Backport: Ruby: Support x64-mingw-ucrt platform
2022-05-16 13:34:50 -07:00
Joshua Haberman
375b984715
Merge pull request #9976 from haberman/update-upb
Fixed win32 build and fixed str(message) on all Windows platforms.
2022-05-16 13:34:19 -07:00
Joshua Haberman
8353e19756 Updated to the newest upb, which brings many fixes for Windows builds. 2022-05-16 17:10:27 +00:00
Deanna Garcia
d3edfa29b7 Use osx-aarch_64 artifact 2022-05-16 16:44:24 +00:00
deannagarcia
088281d84b
Merge pull request #9964 from protocolbuffers/main-202205131806
Merge 21.x back to main
2022-05-16 09:06:11 -07:00
Vassil Kovatchev
9d7a449e5c Fix failing FieldMask.Merge for well-known wrapper field types 2022-05-16 15:12:19 +01:00
johnnyshields
abe77ae13e Backport: Ruby: support x64-mingw-ucrt platform, which is the new platform which Windows Ruby Installer uses as of Ruby 3.1 2022-05-14 11:41:32 +09:00
deannagarcia
6da9b69efe
Merge pull request #9967 from deannagarcia/LF
Fix c# Kokoro errors
2022-05-13 16:40:04 -07:00
Joshua Haberman
9be7dd1c81
Merge pull request #9963 from johnnyshields/ruby-x64-mingw-ucrt-support
Ruby: Support x64-mingw-ucrt platform
2022-05-13 15:04:04 -07:00
Deanna Garcia
4049efc7b0 Move to LF 2022-05-13 21:09:51 +00:00
Nikhil Benesch
448d421250
Various fixups to warnings flags (#9344)
* Don't drop parser warnings on the floor

Fix #9343.

* Convert "missing syntax" warning to an actual warning

For some reason this warning was emitted as a log message rather than a
structured warning. Convert it to use the AddWarning API so that it gets
emitted with a file and line number by protoc, and is visible via the
error collection interface during programmatic use.

* Remove CaptureTestStderr() call

CaptureTestStderr() and GetCapturedTestStderr() have to be paired with each other.

* Adjust tests for new warnings

A few tests now produce warnings that they didn't before, but were
expecting not to see any stderr output. Adjust the tests accordingly.

Co-authored-by: Adam Cozzette <acozzette@google.com>
2022-05-13 12:32:38 -07:00
Deanna Garcia
193da6c8a9 Merge release branch 21.x into main 2022-05-13 18:07:04 +00:00
deannagarcia
380a9104b0
Merge pull request #9962 from protocolbuffers/21.x-202205131655
Update version.json to: 21.0-dev
2022-05-13 10:59:04 -07:00
johnnyshields
9254853796 Ruby: support x64-mingw-ucrt platform, which is the new platform which Windows Ruby Installer uses as of Ruby 3.1 2022-05-14 02:56:12 +09:00
deannagarcia
366cb84282
Merge pull request #9959 from zyp/add_protanium
Reserve extension id for Protonium
2022-05-13 10:00:42 -07:00
Deanna Garcia
08473bbe26 Update version.json to: 21.0-dev 2022-05-13 16:56:18 +00:00
Vegard Storheil Eriksen
b23ab61719 Reserve extension id for Protonium 2022-05-13 18:54:29 +02:00
Jon Skeet
c32d7ec2ab Helper method on Any to allow an any to be unpacked more easily
We already have the TypeRegistry abstraction for JSON parsing, so it lends itself well to this.

Note that this is much more useful than it would have been before C# gained pattern matching support: it's easy to imagine a switch statement/expression using pattern matching with the result of this, with cases for a set of known message types, for example.
2022-05-13 16:09:12 +01:00
David L. Jones
b3cbea18ea
[Bazel] Move Python rules to //python (#9952) 2022-05-12 19:48:58 -07:00
Deanna Garcia
bb7e5824b2 Pin googleapis-common-protos to most recent version 2022-05-12 20:39:50 +00:00
Deanna Garcia
43b1427c18 Update python doc gen versions 2022-05-12 18:12:55 +00:00
deannagarcia
1978a6f723
Merge pull request #9946 from boscosiu/install-endian-h
Add endian.h to includes list
2022-05-12 10:44:05 -07:00
Deanna Garcia
20d9a4fed5 Update protoc version for doc publishing 2022-05-12 17:34:06 +00:00
Deanna Garcia
e9987578ac Update protoc version for doc publishing 2022-05-12 17:31:31 +00:00
David L. Jones
d60c0d2d35
Expose generated files from proto_gen via DefaultInfo, and change to new provider syntax. (#9951)
* Switch to new provider syntax instead of structs.
* Expose files via `DefaultInfo`, and use that for `py_proto_library`.
* Several changes from buildifier.
2022-05-11 19:13:56 -07:00
David L. Jones
b64cd5ac64
Switch C++ test protos to use the normal cc_proto_library rules. (#9950) 2022-05-11 16:45:17 -07:00
David L. Jones
87c5475687
[Kokoro] Add dist check build for linux+cmake (#9939)
The cmake tests are expected to fail for now due to Abseil sources missing from the distribution artifact. The tests are structured as expected failures.
2022-05-11 13:33:29 -07:00
Elliotte Rusty Harold
309e24e86a
Run kotlin tests on JDK 8 *and later* (#9949)
@deannagarcia fixes #9870
2022-05-11 16:50:10 +00:00
boscosiu
f91b078abf
Add endian.h to includes list
Client code is breaking due to missing include.  (endian.h was added in 9e09343 but didn't make it into this list, so it wasn't getting installed)
2022-05-10 18:40:36 -07:00
Deanna Garcia
3cede25cef change configure.ac to use c++ version 2022-05-10 23:41:41 +00:00
Joshua Haberman
b2a51f8525
Merge pull request #9621 from bshaffer/remove-class-aliases
feat: [PHP] remove legacy generate class file
2022-05-10 13:36:47 -07:00
Deanna Garcia
9a31dea61e update changelog 2022-05-10 18:57:45 +00:00
Protobuf Team
d259bd3287 Updating version.json and repo version numbers to: 21.0-rc1 2022-05-10 11:34:07 -07:00
Protobuf Team
bf5e800447 Updating version.json to: 22-dev 2022-05-10 11:34:06 -07:00
Joshua Haberman
7303304585
Merge pull request #9941 from haberman/toolchain-flags
Updated toolchain to support optimization flags, and updated to the latest upb
2022-05-10 10:10:34 -07:00
Joshua Haberman
6018e9edef Minor CHANGES.txt fix and pulled one more upb commit. 2022-05-10 16:28:53 +00:00
Joshua Haberman
915d439df0 Updated the release notes and the upb version.
Also removed the obsolete PROTOBUF_VERSION variable now that
upb is updated.
2022-05-10 06:31:57 +00:00
Joshua Haberman
14803e6f63 Optimization is now working. 2022-05-10 02:06:31 +00:00
Joshua Haberman
1f3c00eaac Added default flags for all of the compilation modes. 2022-05-10 00:46:34 +00:00
David L. Jones
354aba886e
Add a test for bazel-built dist archives (#9929)
This also fixes some packaging rules that are needed for the result to be buildable.
2022-05-09 16:32:59 -07:00
Adam Cozzette
b180b2809f
Use __constinit only in GCC 12.2 and up (#9936)
Fixes #9916. GCC appears to have a bug preventing our use of __constinit
from working correctly, but this bug will be fixed in GCC 12.2.
2022-05-09 13:15:44 -07:00
deannagarcia
32d99bb00a
Merge pull request #9928 from veblush/cmake-abseil
Added cmake abseil include guard
2022-05-09 09:19:12 -07:00
Esun Kim
b6ee841d7c Added cmake abseil include guard 2022-05-06 15:09:13 -07:00
David L. Jones
637a699969
[Bazel] Move conformance test targets to //conformance. (#9922) 2022-05-06 13:30:48 -07:00
David L. Jones
52655b1f5e
[Bazel] Move C++ build-related logic into //build_defs (#9921)
These are all "toolchain-y" things, like copts, link_opts, and config_settings. These are very different from what is in //toolchain, though, so I chose the somewhat common name build_defs for the package. For now, I am only using this package for purely internal things. (Most public "defs"-type things should come from rules_proto/rules_cc, anyhow.)
2022-05-06 12:11:46 -07:00
deannagarcia
e305932431
Merge pull request #9891 from deannagarcia/osx_toolchain
Add macosx action environment variable
2022-05-06 11:17:34 -07:00
Adam Cozzette
4ebe8ffef4
Merge pull request #9927 from acozzette/sync-stage
Integrate from Piper for C++, Java, and Python
2022-05-06 10:22:09 -07:00
Joshua Haberman
d8b0884442
Merge pull request #9536 from bshaffer/patch-2
chore: [PHP] fix phpdoc for MapField keys
2022-05-06 10:21:35 -07:00
Adam Cozzette
48cb9d10fe Sync from Piper @447000875
PROTOBUF_SYNC_PIPER
2022-05-06 16:14:57 +00:00
Adam Cozzette
f026a14caa Merge tag 'refs/tags/sync-piper' into sync-stage 2022-05-06 16:14:57 +00:00
zhangskz
0e6ac3d789
Increment python major version in version.json for python upb (#9926) 2022-05-06 11:47:21 -04:00
Joshua Haberman
29d5ca825a
Merge pull request #9923 from haberman/update-upb2
Updated to upb for -rc1.
2022-05-05 18:40:19 -07:00
Joshua Haberman
49d6b35576 Updated to upb for -rc1. 2022-05-06 00:15:33 +00:00
David L. Jones
5ebde5bd20
[Bazel] Expand lists of protos in BUILD files (#9915)
This unrolls several lists based on WELL_KNOWN_PROTO maps, and move internal java codegen rules next to the corresponding java_library targets that expose them.
2022-05-05 13:29:47 -07:00
Adam Cozzette
152249204b
Merge pull request #9912 from acozzette/sync-stage
Integrate from Piper for C++, Java, and Python
2022-05-05 09:23:24 -07:00
David L. Jones
67823fe8dc
[Bazel] Fix broken build rules or mark them manual (#9913)
* Fix filename for unittest_gen_import.proto.

* Add 'manual' tags to jvm_export rules so they aren't selected by wildcard

* Run buildifier
2022-05-04 17:30:23 -07:00
Adam Cozzette
df00695437 Remove unused ShouldVerifyInt32() function 2022-05-04 23:43:54 +00:00
Adam Cozzette
a3193ed5ee Fix spelling error 2022-05-04 23:17:07 +00:00
Adam Cozzette
f744bddb63 Sync from Piper @446575720
PROTOBUF_SYNC_PIPER
2022-05-04 23:10:09 +00:00
Adam Cozzette
e94aa9ff0b Merge tag 'refs/tags/sync-piper' into sync-stage 2022-05-04 23:10:09 +00:00
David L. Jones
3c5ad8c524
Remove references to //:composer.json and JS compiler. (#9910) 2022-05-04 13:38:16 -07:00
Ryan VanderMeulen
a1fca10ddc
Use PROTOBUF_CONSTEXPR instead of constexpr for kRepHeaderSize. (#9885)
Fixes "no matching function for call to 'CalculateReserveSize'" compiler errors with older clang versions.
2022-05-04 13:02:12 -07:00
deannagarcia
f2a126e349
Merge pull request #9909 from deannagarcia/ktDuplicates
Remove duplicate java generated code
2022-05-03 14:16:31 -07:00
David L. Jones
24ec0b9ffb
Add Starlark utilities to generate files with lists of files (#9882)
This adds logic to generate files with lists of files in cmake and automake syntax. This will allow Bazel to serve as the single Source of Truth for library sources, with cmake and automake using Bazel-derived definitions.

The definition files are not yet generated or checked in, but that will be a fairly straightforward set of follow-up changes.
2022-05-03 13:33:12 -07:00
Deanna Garcia
7bd1da828b Remove duplicate java generated code 2022-05-03 20:13:11 +00:00
Thomas Van Lenten
35e2f8cd5a ObjC: Revise the minimal extension deps algorithm.
When generating, it isn't uncommon to have generate >1 file at a time, and it is
likely that one file will include another. So cache the results as the
calculation is done so the work isn't repeated.

The previous pruning method didn't have any concept of tracking already done
work, this changes the algorithm to avoid the repeated work to make things more
minimal on the way up.

Some extremely deep proto graphs, this takes the generation time from around 15
min to under 45 seconds.
2022-05-03 15:55:04 -04:00
Thomas Van Lenten
0a73ec7e88 Remove the support for the kokoro cocoapods integration tests. 2022-05-03 15:34:36 -04:00
Adam Cozzette
c03eb88a87
Merge pull request #9907 from acozzette/sync-stage
Integrate from Piper for C++, Java, and Python
2022-05-03 11:42:16 -07:00
mkruskal-google
d93d6cc295
Rollforward of #9852 (#9886)
* Rollback pull request #9852, which will break clients who don't IWYU and depend on us for these STL headers

* Rolling forward https://github.com/protocolbuffers/protobuf/pull/9852 after confirming it doesn't break google internals
2022-05-03 11:35:28 -07:00
Adam Cozzette
5718cfc757 Merge tag 'refs/tags/sync-piper' into sync-stage
# Conflicts:
#	BUILD.bazel
2022-05-03 17:43:12 +00:00
Adam Cozzette
c693ba3c87 Sync from Piper @446230931
PROTOBUF_SYNC_PIPER
2022-05-03 17:41:54 +00:00
Adam Cozzette
5eafa23c98
Update CHANGES.txt (#9897) 2022-05-03 10:26:36 -07:00
zhangskz
b37b613436
Update protobuf_version.bzl to separate protoc and per-language java major version (#9900) 2022-05-03 11:58:31 -04:00
Adam Cozzette
ec91c0e929 Sync from Piper @446048300
PROTOBUF_SYNC_PIPER
2022-05-02 22:49:53 +00:00
Adam Cozzette
cdc11c2d2d
Remove cuda.list from apt sources (#9896)
This will fix the collect_all_artifacts.sh script, which was broken
recently when NVidia stopped publishing Cuda packages for Ubuntu 16.04.
2022-05-02 15:46:43 -07:00
David L. Jones
95da0ba5b4
Rename all BUILD files to BUILD.bazel (#9892)
This avoids conflicting names in a couple of cases.

1. Within google, we want to sync files but not name them BUILD (since the structure doesn't match).
2. On case-insensitive filesystems, `build` may be used for a build directory. Naming `BUILD.bazel` avoids potentioal conflicts.
2022-04-29 17:57:55 -07:00
FaBrand
cd4a8156fa
Be explicit with empty globs (#9890)
There are empty globs that prevent to use com_google_protobuf with
--incompatible_disallow_empty_glob

Introduced in https://github.com/bazelbuild/bazel/issues/8195
2022-04-29 13:12:35 -07:00
David L. Jones
7d48c4accd
Add forwarding lang_generator.h headers for cpp, java, and python. (#9883)
These filenames stutter, but are still being used by some users. So, these forward to the correct header. They should eventually be deprecated and removed.
2022-04-29 12:14:16 -07:00
Deanna Garcia
53002af603 Add macosx action env 2022-04-29 18:51:12 +00:00
FaBrand
244bbd6f95
Make genrule portable for windows (#9889)
* Make genrule portable for windows

Using this does remove a user dependency on a bash under windows

* Use portable genrule for zlib dependency
2022-04-29 10:24:10 -07:00
David L. Jones
c4ddd84918
Factor out MSVC-only version.rc logic, and ensure other variables are always initialized (#9880) 2022-04-28 15:17:51 -07:00
David L. Jones
4e5e8d325a
Specify full path to proto files. (#9881)
This makes proto path handling more uniform with other source files.
2022-04-28 14:01:34 -07:00
Elliotte Rusty Harold
e22db322e4
Fail JDK 17 build when unit tests fail (#9878) 2022-04-28 19:10:12 +00:00
Adam Cozzette
860f8ad171
Remove the JavaScript implementation (#9874)
This implementation is about to be split out into a separate Git repo.
2022-04-28 12:08:26 -07:00
Elliotte Rusty Harold
1927520278
Include JDK11 in error message on first run (#9866)
* update error message on first run
* sync braces
* grammar
* spelling
2022-04-28 15:55:28 +00:00
Elliotte Rusty Harold
868ab1469f
build_java without conformance tests (#9873)
* build_java without conformance tests
2022-04-28 11:09:39 +00:00
deannagarcia
cd1baaec08
Merge pull request #9871 from protocolbuffers/updateUPB
Update UPB version
2022-04-27 13:34:48 -07:00
Deanna Garcia
d62c6240c3 Update UPB version 2022-04-27 18:56:45 +00:00
Adam Cozzette
9c8c3dea30
Start reducing our reliance on autotools (#9824)
Start reducing our reliance on autotools

This commit updates a few of our CI scripts to build protoc using Bazel
instead of autotools. I also updated the setuptools and Rake build
configs to look for protoc under bazel-bin/ so that they will
preferentially use a Bazel-built protoc binary. The goal is to start
chipping away at our use of autotools in preparation for eventually
dropping autotools support.
2022-04-27 10:40:01 -07:00
Elliotte Rusty Harold
d2b669a4dd
more descriptive error messages and exceptions (#9868)
* more descriptive error messages and exceptions
* Travis --> Kokoro
2022-04-27 17:02:01 +00:00
Joshua Haberman
37b782198c
Merge pull request #9864 from haberman/update-upb
Updated upb.
2022-04-27 16:24:47 +00:00
Joshua Haberman
4152d8d160 Updated upb.
As of this update, you can test Python/upb with:

```
$ bazel test @upb//python/...
```
2022-04-27 00:37:30 +00:00
Elliotte Rusty Harold
ece5ef6b9b
Fail on unit tests failure (#9862)
* make sure JDK17 tests fail as needed
* set -e to fail on error
2022-04-26 22:30:07 +00:00
Joshua Haberman
ec79d0d328
Merge pull request #9859 from haberman/sync-stage
Integrate from Piper for C++, Java, and Python
2022-04-26 19:40:16 +00:00
Joshua Haberman
01691f6092
Eliminated git_repository() in favor of HTTP archives. (#9861)
* Eliminated git_repository() in favor of HTTP archives.

Also factored out logic for github archives into its own macro.

* Sorted entries and ran buildifier.

* Removed the import of git_repository.
2022-04-26 12:27:59 -07:00
Dave MacLachlan
2c5863ecde Remove a bunch of clang-tidy warnings about missing use of explicit on single arg ctors. 2022-04-26 14:38:32 -04:00
mkruskal-google
20a30c675a
Rollback pull request #9852, which will break clients who don't IWYU and depend on us for these STL headers (#9860) 2022-04-26 13:57:16 -04:00
Joshua Haberman
dc4aad931e Sync from Piper @444600173
PROTOBUF_SYNC_PIPER
2022-04-26 17:38:22 +00:00
Joshua Haberman
65236e967e Merge tag 'refs/tags/sync-piper' into sync-stage 2022-04-26 17:38:22 +00:00
cui fliter
ac25235fa7
fix some typos (#9771)
* fix some typos

Signed-off-by: cuishuang <imcusg@gmail.com>

* fix typo

Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-26 10:29:00 -07:00
Noah Dietz
4d56f2d83c
Change enum string name for reserved words (#9780)
* Change enum string name for reserved words

Update PHP descriptor protos

* conditionally generate value compat code
2022-04-26 09:44:39 -07:00
Thomas Van Lenten
35fcbfd298
Add a github action workflow to run CocoaPods validation. (#9800)
- Run for all Apple configurations/platforms.
- Limit the action to only run when the ObjC source change.
- Document why the CocoaPods doesn't run the tests during the validation.

The kokoro objectivec_cocoapods_integration configuration can likely be retired
by retiring this.
2022-04-26 09:43:54 -07:00
David L. Jones
125dfd343e
Update more code to use standard int types. (#9851) 2022-04-26 09:28:24 -07:00
David Benjamin
089e09168b
Remove various unused includes (#9852)
These headers pull in STL headers without actually using anything from
the STL.
2022-04-26 09:27:14 -07:00
Tamarous
6718fa9dcc
fix: misspelling (#9857) 2022-04-26 09:25:01 -07:00
Elliotte Rusty Harold
4f552e36bd
Fix typos (#9847)
@pzd
2022-04-26 11:18:51 +00:00
Joshua Haberman
a6901f057e
Added a Bazel dependency for upb (#9812)
* WIP.

* Restore deleted __init__.py files.

* Updated version of upb.

* Moved upb from a submodule to a Bazel dep.

* Updated to new upb which can tolerate missing system_python.

* Updated to a new upb.
2022-04-25 15:00:57 -07:00
Dave MacLachlan
6888c031a4 Remove 2 more unnecessary header includes from objectivec sources.
These were missed from #a52e5ad5bb60655c683a12072a6eb7bcb99391d2.
2022-04-25 17:17:48 -04:00
Elliotte Rusty Harold
f53fd52d7b
Add Kokoro config for JDK 17 (#9845)
* add config for OpenJDK11

* update paths

* add JDK17 build
2022-04-25 20:49:58 +00:00
Dave MacLachlan
a52e5ad5bb Remove some unnecessary header includes from objectivec sources. 2022-04-25 15:09:37 -04:00
David L. Jones
d76f8c868c
Add source distribution packaging rules (#9835)
This change adds `rules_pkg`-based targets that will produce source distribution archives, similar to `make dist`.

These rules produce nearly the same outputs as `make dist`. However, there are some differences and caveats:

1. The outputs do not contain vendored googletest sources.
2. You have to run `autogen.sh` before `blaze build pkg:all`. This produces several autotools-related files directly into the source tree.
3. The output .zip files do not have a directory prefix like `protobuf-3.20.1-rc-1` (this will be addressed after [Substitute package variables in `pkg_zip#package_dir`. bazelbuild/rules_pkg#577](https://github.com/bazelbuild/rules_pkg/pull/577); the tar files do have this prefix, though.)
4. One file is missing from the archives, which is produced during the `make` build: benchmarks/gogo/cpp_no_group/cpp_benchmark.cc
5. In several places, I have explicitly excluded some files that are not in the autotools distribution outputs. I think most of those files should probably be included, but for now, I'm aiming for parity with `make dist`. These are marked with comments, so it should be easy to clean them up later.
2022-04-22 16:58:16 -07:00
David L. Jones
5283ef4b82
Add jdk11 test. (#9843) 2022-04-22 16:44:09 -07:00
zhangskz
baca239033
Add initial version.json file for 21-dev (#9840) 2022-04-22 17:53:47 -04:00
Elliotte Rusty Harold
62e60833b8
add Kokoro config for OpenJDK11 (#9837)
* add config for OpenJDK11
2022-04-22 21:06:11 +00:00
Joshua Haberman
5b0a961188
Merge pull request #9834 from haberman/merge-to-main
Merge 3.20.x to main
2022-04-22 19:36:12 +00:00
Joshua Haberman
a2a0c3c118 Fixed some mis-merged files. 2022-04-22 17:18:36 +00:00
Elliotte Rusty Harold
bfc956bc3a
Remove old kokoro configs (#9815)
* delete unused kokoro configs
2022-04-22 10:22:24 +00:00
Joshua Haberman
16e89fce85
Merge pull request #9836 from haberman/sync-stage
Integrate from Piper for C++, Java, and Python
2022-04-22 06:45:31 +00:00
Joshua Haberman
095e4c0679 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-04-22 05:14:09 +00:00
Joshua Haberman
a27ce12d3a Sync from Piper @443569271
PROTOBUF_SYNC_PIPER
2022-04-22 05:14:08 +00:00
Joshua Haberman
f80137c46d Merge branch 'main' into merge-to-main 2022-04-22 02:44:36 +00:00
Joshua Haberman
21027a27c4
Merge pull request #9832 from haberman/php-dist
Fixed PHP release script.
2022-04-22 01:00:40 +00:00
Joshua Haberman
e81c678e7d
Merge pull request #9831 from haberman/sync-stage
Integrate from Piper for C++, Java, and Python
2022-04-22 00:55:55 +00:00
David L. Jones
83303ba906
Update rules_pkg to version 0.7.0. (#9833)
Notably, bazelbuild/rules_pkg 0.6.0 added the ability for `pkg_filegroup`s to depend on other `pkg_filegroup`s.
2022-04-21 17:38:03 -07:00
Joshua Haberman
634a5681b8 Fixed PHP release script.
Previously it was releasing content from main/master, not the
release branch!

I fixed this by not checking out a separate copy of protobuf.
Also updated the composer.json so we don't need to rewrite it with
sed.
2022-04-21 23:38:04 +00:00
Joshua Haberman
08b39f4274 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-04-21 23:11:28 +00:00
Joshua Haberman
9bd67b6aac Sync from Piper @443506199
PROTOBUF_SYNC_PIPER
2022-04-21 23:11:27 +00:00
Joshua Haberman
e4da73fab7 Updated CHANGES.txt. 2022-04-21 21:27:14 +00:00
Joshua Haberman
87edf7b558 Sync from Piper @443477877
PROTOBUF_SYNC_PIPER
2022-04-21 21:22:55 +00:00
Joshua Haberman
dcfeaf712b Merge tag 'refs/tags/sync-piper' into sync-stage 2022-04-21 21:22:55 +00:00
Jonathan Ringer
c80808ce1d
Fix cmake install targets (#9822)
* Avoid exporting build tree targets to installation directory

`export(TARGETS ...)` is meant to allow for build trees to be found
from other projects, however, writing the file to an installation
directory causes buildtree paths to be hardcoded in the installed
protobuf-targets.cmake

* Install protobuf-targets.cmake from target, not build tree

This allows for installation prefixes to match the intended
installation directories, instead of being copied from
the build tree.
2022-04-20 18:38:43 -07:00
Joshua Haberman
616a7ef54d
Updated CHANGES.txt for 3.20.1 (#9826)
* Update protobuf version

* Updated Makefile.am for composer.json move.

* Updated CHANGES.txt for 3.20.1.

* Fixed spelling.
2022-04-20 17:05:48 -07:00
David L. Jones
46710cabc4
Move rules_pkg targets into //pkg, and add experimental C++ library rules (#9823)
This change moves the `pkg_*` rules into the `//pkg` package, which cleans up the root package.

It also adds an experimental `cc_dist_library` rule, which is similar to Bazel's `cc_import` rule. The goal of `cc_dist_library` is to produce output libraries from several targets. For example, splitting `//:protobuf` into multiple targets means that `bazel-bin/libprotobuf.a` won't contain all of the objects. The `cc_dist_library` creates a single library from several different `cc_library` targets. This may be useful for future packaging targets.
2022-04-20 16:26:44 -07:00
Joshua Haberman
296c1fdaff
Update protobuf version (#9820)
* Update protobuf version

* Updated Makefile.am for composer.json move.
2022-04-20 16:00:42 -07:00
Brent Shaffer
6387f95aa9
fix: move composer.json out of root to avoid confusion (#9819)
* move composer.json out of root to avoid confusion

* fix: update php deployed json
2022-04-20 14:51:11 -07:00
Joshua Haberman
653de45a21
Disable the aarch64 build on macOS because it is broken. (#9816)
See https://github.com/protocolbuffers/protobuf/issues/9804 for details.
2022-04-20 14:32:52 -07:00
mkruskal-google
f7b9886f9d
Fix Abseil dependency in windows protoc kokoro build (#9814)
* Adding submodule update to windows protoc build which uses CMake 3.10.1
2022-04-20 13:50:13 -04:00
Neakxs
654c25352e
Apply registration for protoc-gen-authz extension (#9807) 2022-04-19 13:41:58 -07:00
Brent Shaffer
37f464590c
Merge branch 'main' into remove-class-aliases 2022-04-19 13:25:15 -05:00
Jason Lunn
3a477b1952
Improve range handling logic of RepeatedField (#9799)
Add support for negative start or ends and exclusive ends.

Includes regression tests contributed mostly by @lucthev. Fixes #9751.
2022-04-19 10:46:01 -04:00
Brent Shaffer
81e5139679
fix: phpdoc for repeatedfield (#9783)
* fix-phpdoc-for-protobuf-repeatedfield

* fix: offsetSet should accept null
2022-04-18 16:14:56 -07:00
なつき
d2fd441953
Do not use range based UTF-8 validation in truffleruby (#9769) 2022-04-18 16:12:20 -07:00
Brent Shaffer
9ba808b798
fix: phpdoc syntax for repeatedfield parameters (#9784) 2022-04-18 16:07:02 -07:00
Elliotte Rusty Harold
cc8ae4c154
Add JDK 17 target (#9802)
* add JDK 17 target
2022-04-18 19:54:42 +00:00
Elliotte Rusty Harold
46ae74c55c
Remove LAST_RELEASED variable we haven't been updating (#9803)
* Remove LAST_RELEASED variable we haven't been updating
2022-04-18 19:22:22 +00:00
Elliotte Rusty Harold
b27bf8b437
LAST_RELEASED=3.20.0 (#9741)
@acozzette We might want to add this to the release process since it seems this hasn't been updated for quite a while.
2022-04-18 17:52:12 +00:00
Elliotte Rusty Harold
bbc4f8dff8
add JDK 8 target (#9743) 2022-04-18 12:47:56 -04:00
mkruskal-google
e9246cd789
Update CMake configuration to add a dependency on Abseil (#9793)
* Proof of concept for CMake Abseil dependency

* Hooked up Abseil linking

* Adding test binaries

* Reverting absl::string view use added for testing.  This will still be broken for automake and bazel

* Adding new cmake config to dist list

* Whitespace fixes and an attempt at fix for Windows Python Release (CMake version < 3.13)

* Hook up LTS to windows cmake

* Fix 'git cd' typo

* Adding clarifying comment for fix

* Adding abseil dependency to protobuf-lite too

* Update submodules instead of cloning abseil-cpp

* Adding explicit pointer to abseil root directory

Co-authored-by: Jason Lunn <jason.lunn@gmail.com>
Co-authored-by: Jorg Brown <jorg.brown@gmail.com>
2022-04-17 22:28:01 -04:00
Joshua Haberman
6f99f12a6b
Merge pull request #9790 from dlj-NaN/sync-stage
Integrate from Piper for C++, Java, and Python
2022-04-15 11:30:44 -07:00
Yibo Cai
bba2fca119
Move private utf8 helpers to anonymous namespace (#9791)
This trivial change hints compiler to inline the utf8 helpers and
generate code with better performance.

Tested on skylake, with clang-12 and gcc-9.3. Observed about 10%
improvement from `google_message1_proto3_serialize` benchmark,
with default ./configure parameters. Similar improvement on arm.
2022-04-15 11:25:17 -07:00
David L. Jones
13f646f026 Update CHANGES.txt. 2022-04-14 17:39:00 -07:00
David L. Jones
9e09343a49 Sync from Piper @441896533
PROTOBUF_SYNC_PIPER
2022-04-14 17:36:14 -07:00
David L. Jones
119f7d7dab Merge tag 'refs/tags/sync-piper' into sync-stage 2022-04-14 17:36:14 -07:00
zhangskz
acd24bcd8d
Add disallowment of setting numpy singleton arrays and multi-dimensio… (#9788)
* Add breaking change (disallow setting numpy singleton arrays and multi-dimensional arrays to fields/repeated fields) and fix to CHANGES.txt, which was missed in a previous git sync.
2022-04-14 13:59:40 -04:00
Jon Skeet
82d04fabd9 Remove unnecessary console output from test 2022-04-14 16:14:27 +01:00
Brent Shaffer
eb27c201f1
fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)
* fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility

* typo fix - readme > readonly
2022-04-12 15:48:14 -07:00
Matt Fowles Kulukundis
8077ac24b7
Merge pull request #9777 from noahdietz/master-to-main
Replace master with main in URLs & docs
2022-04-12 13:54:12 -04:00
noahdietz
5abf802bc2 Replace master with main in URLs & docs 2022-04-12 10:25:08 -07:00
Elliotte Rusty Harold
a85bbad379
deps: update Guava to 31.1 (#9757)
@mrkruskal
2022-04-08 18:43:11 +00:00
Adam Cozzette
9bf0aca7db
Update protobuf_deps.bzl to add a dependency on Abseil (#9752)
This is the most recent Abseil LTS branch, from November 2021. We do not
yet use Abseil for anything, but this change will make it possible to
start using it in Bazel when we're ready.
2022-04-08 09:12:05 -07:00
Vasiliy Tolstov
7ffe9402db
Add micro Registered Extension Number (#9767)
unistack-org/micro (microservices framework) uses protoc-gen-go-micro generator that has extension support for additional framework related options.

It is currently not using any registered extension number, so i want to stabilise this and i think that this is a good thing.

See here for an example of the extenstion in action.

Co-authored-by: Adam Cozzette <acozzette@google.com>
2022-04-08 09:11:27 -07:00
Jeff Sawatzky
e3b00bb58a
Add Google Gnostic Registered Extension Number (#9754)
google/gnostic's protoc-gen-openapi generator has extension support for additional openapi options.
It is [currently using `1042`](https://github.com/google/gnostic/blob/master/openapiv3/annotations.proto) which is registered with grpc-gateway's protoc-gen-openapiv2 extension which probably isn't a good thing.
See [here](https://github.com/google/gnostic/blob/master/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto) for an example of the extenstion in action.
2022-04-08 09:08:38 -07:00
Elliotte Rusty Harold
26d11fdba2 -Dsurefire.failIfNoSpecifiedTests=false (#9761)
@mrkruskal

(cherry picked from commit 88eb7550a6)
2022-04-07 17:05:12 -07:00
mkruskal-google
85aa87cbc9
Merge 3.20.1-rc1 into main (#9760)
* Fix NPE during encoding and add regression test for issue 9507.

(cherry picked from commit 58e320a732)

* Implement `respond_to?` in RubyMessage (#9677)

All synthetic methods implemented by `method_missing` are now supported by `respond_to?`.

Fixes issue #9202.

* Fix null pointer exceptions exposed by new regression tests.
* Fix clear_ on oneofs so that it is safe to call repeatedly and so that respond_to? does not depend on whether the oneof is currently cleared.
* Code cleanup: reenable more tests on JRuby.
* Align JRuby behavior with CRuby by throwing a RuntimeError when attempting to assign to a oneof.

(cherry picked from commit 8e7f936696)

* Update protobuf version

* Merge pull request #9727 from mlocati/build-packaged-php-extension

Fix building packaged PHP extension

(cherry picked from commit 7f9901c5f6)

* Update protobuf version

* Update changelogs for 3.20.1-rc1

Co-authored-by: Jason Lunn <jason.lunn@gmail.com>
Co-authored-by: Jorg Brown <jorg.brown@gmail.com>
2022-04-07 18:33:58 -04:00
Elliotte Rusty Harold
88eb7550a6
-Dsurefire.failIfNoSpecifiedTests=false (#9761)
@mrkruskal
2022-04-07 22:10:09 +00:00
Elliotte Rusty Harold
044cb7fd45 -DfailIfNoSpecifiedTests=false (#9753)
@jtattermusch @mkruskal-google

(cherry picked from commit 55177c3574)
2022-04-07 08:37:31 -07:00
Elliotte Rusty Harold
55177c3574
-DfailIfNoSpecifiedTests=false (#9753)
@jtattermusch @mkruskal-google
2022-04-07 14:02:57 +00:00
deannagarcia
061dead753
Merge pull request #9750 from protocolbuffers/pythonBuilds
Add k8 toolchain
2022-04-06 16:33:24 -07:00
Jason Lunn
05df37d35c
Merge pull request #9722 from lucthev/main
[Ruby] Fix RepeatedField#last, #first inconsistencies
2022-04-06 17:37:22 -04:00
Luc Thevenard
d54cafb7c8 Avoid negative indexes for JRuby 2022-04-06 15:49:08 -04:00
Deanna Garcia
a8b12d5b6e Consistent formatting 2022-04-06 18:43:58 +00:00
Derek Perez
b55c8e4084
include gen_dir irrespsective of sources_dir in protoc_gen (#9735) 2022-04-06 11:35:10 -07:00
deannagarcia
5f920d1507
Merge pull request #9642 from j-min5u/remove-public-modifier-kotlin
[Kotlin] remove redundant public modifiers for compiled code
2022-04-06 11:26:17 -07:00
Deanna Garcia
b7980cd859 Removing comment 2022-04-06 17:44:20 +00:00
Deanna Garcia
9a4c48a566 Add k8 toolchain 2022-04-06 17:42:12 +00:00
Mike Kruskal
7db4eca77f Update changelogs for 3.20.1-rc1 2022-04-05 17:18:20 -07:00
Mike Kruskal
803e371946 Update protobuf version 2022-04-05 17:10:20 -07:00
Minsoo Cheong
464d626d1a Merge remote-tracking branch 'upstream/main' into remove-public-modifier-kotlin 2022-04-06 08:59:03 +09:00
mkruskal-google
5edc8442a4 Merge pull request #9727 from mlocati/build-packaged-php-extension
Fix building packaged PHP extension

(cherry picked from commit 7f9901c5f6)
2022-04-05 12:20:12 -07:00
mkruskal-google
7f9901c5f6
Merge pull request #9727 from mlocati/build-packaged-php-extension
Fix building packaged PHP extension
2022-04-05 12:05:32 -07:00
Thomas Van Lenten
ca30339529 Tweak how python/python3 is used.
The kokoro Mac configs seem to be pretty old without python3, tweak how things
are invoked to try and better deal with those configs.
2022-04-05 14:25:01 -04:00
Matt Fowles Kulukundis
205117c44b
Merge pull request #9738 from ronilichtman/patch-1
Remove unused `HasTopLevelEnums` function
2022-04-05 12:40:03 -04:00
Matt Fowles Kulukundis
6d068f8c6b
Merge pull request #9739 from smertnik3sh/add-getobject-def-undef
Escape GetObject macro inside protoc-generated code
2022-04-05 12:39:23 -04:00
Roni Lichtman
75dd25b0fd
Remove unused HasTopLevelEnums function
This will address the following compilation error:

```
src/google/protobuf/compiler/python/python_generator.cc:95:13: warning: unused function 'HasTopLevelEnums' [-Wunused-function]
```
2022-04-05 17:46:00 +03:00
Thomas Van Lenten
1e60bd62ed Update the mac python helper scripts to python3.
macOS 12.3 dropped shipping python2.

Update things for python3 (mostly via 2to3).
2022-04-05 10:42:12 -04:00
heretic
e1d39a744f add push/pop GetObject macro 2022-04-05 16:39:09 +03:00
Minsoo Cheong
56067d1498 Merge remote-tracking branch 'upstream/main' into remove-public-modifier-kotlin 2022-04-05 11:17:24 +09:00
Minsoo Cheong
92c11a45c6 remove public modifiers on kt variables 2022-04-05 11:16:59 +09:00
Minsoo Cheong
97533f5243 fix: restore val 2022-04-05 11:05:54 +09:00
mkruskal-google
1ac05394a5
Merge pull request #9734 from mkruskal-google/sync-stage
Integrate from Piper for C++, Java, and Python
2022-04-04 16:55:48 -07:00
Mike Kruskal
701650b7d0 Merge tag 'refs/tags/sync-piper' into sync-stage
# Conflicts:
#	csharp/src/Google.Protobuf.Test/testprotos.pb
2022-04-04 13:50:21 -07:00
Mike Kruskal
a29e0e3f44 Sync from Piper @439400376
PROTOBUF_SYNC_PIPER
2022-04-04 13:42:37 -07:00
Mike Kruskal
d24edbca53 Update protobuf version 2022-04-04 11:13:56 -07:00
Michele Locati
f0936d26e1
Fix building packaged PHP extension 2022-04-03 21:52:03 +02:00
Michele Locati
feef319e85
Test building packaged PHP extension 2022-04-03 21:40:28 +02:00
Minsoo Cheong
82ff86cb8a Merge branch 'master' into remove-public-modifier-kotlin 2022-04-03 09:42:55 +09:00
Jorg Brown
e097b36732
Merge pull request #9714 from JasonLunn/3.20.x
Cherry pick JRuby changes that fix NPE during encoding (#9507) and implements respond_to? (#9202) into 3.20.x.
2022-04-02 13:38:44 -07:00
Luc Thevenard
d85f03d66a [Ruby] Fix RepeatedField#last, #first inconsistencies 2022-04-01 17:09:22 -04:00
David L. Jones
3be07ab320
[Kokoro] Emit XML test logs on macos-next. (#9709)
This enables googletest XML output on the macos-next builders, and adds logic to collect the results.

The log collection logic is slightly complex, but it should be reusable in other contexts. The idea is to capture stdout/stderr for build steps along with googletest XML reports into a temporary directory, then stage those into paths expected for artifacts.
2022-04-01 13:49:14 -07:00
mkruskal-google
7508ae82d3
Merge pull request #9721 from mkruskal-google/3.20.x-202204011233
Merge 3.20.0 into main
2022-04-01 13:45:30 -07:00
Mike Kruskal
ffe4b0cfe6 Merge branch '3.20.x' into 3.20.x-202204011233 2022-04-01 12:34:01 -07:00
Jason Lunn
31a6482b85 Implement respond_to? in RubyMessage (#9677)
All synthetic methods implemented by `method_missing` are now supported by `respond_to?`.

Fixes issue #9202.

* Fix null pointer exceptions exposed by new regression tests.
* Fix clear_ on oneofs so that it is safe to call repeatedly and so that respond_to? does not depend on whether the oneof is currently cleared.
* Code cleanup: reenable more tests on JRuby.
* Align JRuby behavior with CRuby by throwing a RuntimeError when attempting to assign to a oneof.

(cherry picked from commit 8e7f936696)
2022-03-31 16:00:26 -04:00
Jason Lunn
7fa212bba1 Fix NPE during encoding and add regression test for issue 9507.
(cherry picked from commit 58e320a732)
2022-03-31 16:00:09 -04:00
Gary Peck
eb8976a56d
Add pbandk to list of 3rd-party Kotlin libraries (#9712) 2022-03-31 10:45:15 -04:00
Elliotte Rusty Harold
61dcf50b85
Update Guava to 31.1 (#9707)
* start work on open source build instructions

* subprojects

* JDK17

* update Guava to 30.1-jre

* pin dependencies
2022-03-30 16:52:15 -04:00
David L. Jones
5b2c7b8373
[CMake] Declare remaining tests, and add a test output option. (#9705)
The new option will allow us to generate test XML output.

CTest can discover tests from googletest, but it generates one file
per case. We have several thousand cases, so one file each would be
far from optimal. The approach in this change will generate one file
per test (executable).
2022-03-30 13:44:42 -07:00
David L. Jones
0dcf31d981
Enable builds for macos-next kokoro. (#9706)
This enables build logic on the "macos-next" flavor of Kokoro tests.

The current runners use Big Sur with Xcode 13.2.1. This build uses cmake to configure and drive the build through Xcode. Tests are run under ctest.
2022-03-30 13:09:49 -07:00
Jon Skeet
9e6e4eb425 Generated code for test protos for issue #9605 2022-03-30 16:33:00 +01:00
Jon Skeet
e2f845b2f1 Test proto and unit test for issue #9605
This doesn't test *all* possibilities (e.g. the field being a
wrapper, or a message field, etc) - but I'm fairly confident that I
found all the places referring to the case.
2022-03-30 16:33:00 +01:00
Jon Skeet
81c5e1a712 C# generator: Append _ to the oneof case enum name if it's "None"
Fixes #9605 (tests in next commit)
2022-03-30 16:33:00 +01:00
Jon Skeet
d7ef9cd2ba Make it easier to follow cmake/README.md instructions
When following the instructions directly (for developing on Windows) we should end up with a generator that's easy to run for csharp/generate_protos.sh, and we shouldn't end up trying to stage the build output.
2022-03-30 16:33:00 +01:00
David L. Jones
520c601c99
Temporary Kokoro build for macos-next. (#9693)
This build will be used to troubleshoot building on a newer macOS
image. Once it is stable, this config will replace the "macos" build.
2022-03-29 14:32:10 -07:00
Jason Lunn
5b67e77876
Merge pull request #9697 from JasonLunn/jruby_9.3.4.0
Add JRuby 9.3.4.0 to Dockerfile and use it for 9.3.x testing.
2022-03-29 16:01:51 -04:00
Adam Cozzette
faa42e900c
Revert "Use repo-relative labels wherever possible (#9187)" (#9696)
This reverts commit 11de748d66.
2022-03-29 15:50:39 -04:00
Jason Lunn
6b2627718b Add JRuby 9.3.4.0 to Dockerfile and use it for 9.3.x testing. 2022-03-29 19:01:05 +00:00
David L. Jones
a3347c27a3
Factor out test libraries in the cmake build. (#9689)
This change adds separate libraries for common test utilities and test proto definitions, which are shared by different test targets.

Without this change, cmake fails when generating Xcode files with the error:

```
CMake Error in CMakeLists.txt:
  The custom command generating

    .../protobuf/src/google/protobuf/unittest_lite.pb.cc

  is attached to multiple targets:

    tests
    lite-test
    lite-arena-test

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".
```
2022-03-29 11:48:16 -07:00
Jon Skeet
9f597a4c59 Add regression test for https://github.com/protocolbuffers/protobuf/issues/9526 2022-03-29 16:38:30 +01:00
Jon Skeet
afb0ca40b3 Change C# editor config to use LF by default 2022-03-29 16:38:30 +01:00
Jon Skeet
e1e9d3e6da Normalize all C# and .proto files to LF
This commit should have no non-whitespace changes

Fixes #9526 (in terms of content)
2022-03-29 16:38:30 +01:00
mkruskal-google
43bb1bfe42
Merge pull request #9692 from mkruskal-google/master
Reverting change to target frameworks that breaks kokoro
2022-03-28 21:00:10 -04:00
Jason Lunn
3dee6efa54
Merge pull request #9690 from JasonLunn/format_jruby_with_google-java-format
Run all JRuby source files through `google-java-format.`
2022-03-28 20:44:28 -04:00
Jason Lunn
615a8d99f8
Merge pull request #9691 from JasonLunn/fix_warnings
Cleanup warnings seen when running tests.
2022-03-28 20:43:49 -04:00
mkruskal-google
a114b008a2 Reverting change to target frameworks that breaks kokoro 2022-03-28 16:25:46 -07:00
Jason Lunn
d0fc2794c4 Cleanup warnings seen when running tests. 2022-03-28 19:00:18 -04:00
Jason Lunn
5b28ae70c0 Run all JRuby source files through google-java-format. 2022-03-28 18:58:54 -04:00
Jason Lunn
8e7f936696
Implement respond_to? in RubyMessage (#9677)
All synthetic methods implemented by `method_missing` are now supported by `respond_to?`.

Fixes issue #9202.

* Fix null pointer exceptions exposed by new regression tests.
* Fix clear_ on oneofs so that it is safe to call repeatedly and so that respond_to? does not depend on whether the oneof is currently cleared.
* Code cleanup: reenable more tests on JRuby.
* Align JRuby behavior with CRuby by throwing a RuntimeError when attempting to assign to a oneof.
2022-03-28 18:43:53 -04:00
Jensaarai
b5a35bcc7e Add C# .editorconfig to Makefile.am 2022-03-26 06:54:27 +00:00
Jensaarai
fb6016eaed Add .editorconfig for csharp directory
Nicer experience for e.g. VS Code
2022-03-26 06:54:27 +00:00
Darly Paredes
7f9f75f30e
Merge pull request #9679 from darly/3.20.x-202203251917
3.20.0
2022-03-25 16:14:44 -04:00
Darly Paredes
25045e3f69 Update protobuf version 2022-03-25 19:20:51 +00:00
Jensaarai
10df21ed5e Add .NET 6 target to Google.Protobuf test projects
* .NET 5 reaches end-of-support in May, so update the Benchmarks project
to `net6.0`
* Update some NuGet packages to latest.
2022-03-25 14:14:15 +00:00
Joshua Haberman
bc799d78f8
Added missing files and fixed file roles. (#9672) 2022-03-24 11:51:33 -07:00
David L. Jones
236d04c5b4
Merge pull request #9669 from dlj-NaN/sync-stage
Integrate from Piper for C++, Java, and Python

Note that this renames several source files under src/google/protobuf/compiler.
2022-03-24 10:25:14 -07:00
David L. Jones
75418a54ae Update ignored file paths after renaming. 2022-03-23 18:11:56 -07:00
David L. Jones
b012ef28b9 Regenerate cmake file lists. 2022-03-23 18:10:27 -07:00
David L. Jones
d06af454b5 Regenerate BUILD file lists 2022-03-23 17:44:58 -07:00
David L. Jones
40db3dabf0 Sync from Piper @436871048
PROTOBUF_SYNC_PIPER
2022-03-23 17:36:26 -07:00
Darly Paredes
744baa96ec
Merge pull request #9665 from darly/sync-stage
Integrate from Piper for C++, Java, and Python
2022-03-23 15:50:26 -04:00
Darly
d255f09036 Adding missing python files to the Makefile.am 2022-03-23 12:26:51 -04:00
Trent Houliston
85cb72481c
Fix invalid dependency manifest when using descriptor_set_out (#9647)
* Fix invalid dependency manifest when using `descriptor_set_out`

* Put the descriptor file in the temp directory so it gets deleted
2022-03-23 07:14:17 -07:00
Jason Lunn
80308c85a1
Merge pull request #9637 from JasonLunn/fix_9507
Fix NPE during encoding and add regression test for issue 9507.
2022-03-22 20:03:31 -04:00
Elliotte Rusty Harold
575d56bf85
sync JUnit version (#9662) 2022-03-22 21:54:53 +00:00
Darly Paredes
8e3746559d Merge tag 'refs/tags/sync-piper' into sync-stage 2022-03-22 18:02:12 +00:00
Darly Paredes
a4c9effec1 Sync from Piper @436517178
PROTOBUF_SYNC_PIPER
2022-03-22 18:02:10 +00:00
Elliotte Rusty Harold
8c170146ee
download_data.sh no longer exists (#9661)
@haberman download_data.sh doesn't seem to exist any more and I can't find it in the git log
2022-03-22 16:33:10 +00:00
James Newton-King
e5ae3bb763
[C#] Update GetExtension to support getting typed value (#9655) 2022-03-22 08:56:39 +00:00
Adam Cozzette
405913c712
Merge pull request #9652 from acozzette/sync-stage
Integrate from Piper for C++, Java, and Python
2022-03-21 16:37:07 -07:00
Joshua Haberman
dbb9619a9d
Cherry-pick to get Ruby 3.1 support in protobuf 3.20.0 (#9657)
* Allow pre-compiled binaries for ruby 3.1.0 (#9566)

* Allow pre-compiled binaries for ruby 3.1.1

* add comment

* fix build and use ruby 3.1.0

* add ruby31 to build CI for tests and release

* trying to fix ci

* install ruby 3.1.0 in ruby_build_environment.sh

* use head for rvm to install 3.1.0

* just install master version of rvm in prepare_build_macos_rc

* force install of master rvm in ruby_build_environment.sh

* Use coroutine=universal when compiling ruby31

* use ucontext

* fix filename

* fix coroutine name

* use git head for rake-compiler-dock

* use newest rake-compiler-dock version

* Updated CHANGES.txt for Ruby changes.

* Fixed Ruby 3.1 tests by marking intersect? as unimplemented. (#9645)

* Fixed Ruby 3.1 tests by marking intersect? as unimplemented.

* Updated compatibility tests.

Co-authored-by: Marco Concetto Rudilosso <marcoconcettorudilosso@gmail.com>
2022-03-21 15:26:27 -07:00
yeqown
a69354f31b
apply a registration for protoc-gen-fieldmask extension (#9646)
* Update options.md

* add one blank line
2022-03-19 08:46:51 -07:00
Adam Cozzette
db80d59966 Add new Python file to Makefile.am 2022-03-18 22:44:31 +00:00
Adam Cozzette
d2256ed112 Fix warning about unused variable in unit test 2022-03-18 22:34:06 +00:00
Adam Cozzette
5ead3ba171 Update CHANGES.txt with recent internal changes 2022-03-18 21:33:17 +00:00
Adam Cozzette
2f09990544 Merge tag 'refs/tags/sync-piper' into sync-stage
# Conflicts:
#	java/core/src/main/java/com/google/protobuf/Utf8.java
2022-03-18 21:26:44 +00:00
Adam Cozzette
a336ba0346 Sync from Piper @435734090
PROTOBUF_SYNC_PIPER
2022-03-18 21:25:56 +00:00
amirhadadi
46c3651c31
Implement Utf8.decodeUtf8 by using String constructor (#9415)
* Implement Utf8.decodeUtf8 by using String constructor and a search for the replacement string "\uFFFD". This greatly simplifies the implementation, speeds it up for ascii and saves in memory allocations for non ascii strings.

* Remove irrelevant comment about indexOf.

* Code style changes following review.

* Remove TODO + remove final per google style.

* Delete decodeUtf8 from UnsafeProcessor as it inherits the intended implementation from its parent.

* Move decodeUtf8 implementation from Utf8::Processor to Utf8 since it has only a single implementation which is independent of whether the processor is safe or unsafe.

* Change only the logic of UnsafeProcessor to use String constructor
This is done since some Android versions will see a performance regression if this change is applied.
So we are making this change only for UnsafeProcessor which is not used on Android.

* Remove duplicated Javadoc

Co-authored-by: ahadadi <ahadadi@outbrain.com>
2022-03-18 10:28:17 -07:00
Theodore Rose
2099298e08
Merge pull request #9650 from esorot/php-release-fix
update PHP release to not fail on existing tag
2022-03-18 11:58:24 -04:00
theodorerose
523d94a445 update PHP release to not fail on existing tag 2022-03-18 15:54:55 +00:00
Joshua Haberman
7f1acff2a4
Fixed Ruby 3.1 tests by marking intersect? as unimplemented. (#9645)
* Fixed Ruby 3.1 tests by marking intersect? as unimplemented.

* Updated compatibility tests.
2022-03-17 12:51:03 -07:00
Marco Concetto Rudilosso
abdfd093af
Allow pre-compiled binaries for ruby 3.1.0 (#9566)
* Allow pre-compiled binaries for ruby 3.1.1

* add comment

* fix build and use ruby 3.1.0

* add ruby31 to build CI for tests and release

* trying to fix ci

* install ruby 3.1.0 in ruby_build_environment.sh

* use head for rvm to install 3.1.0

* just install master version of rvm in prepare_build_macos_rc

* force install of master rvm in ruby_build_environment.sh

* Use coroutine=universal when compiling ruby31

* use ucontext

* fix filename

* fix coroutine name

* use git head for rake-compiler-dock

* use newest rake-compiler-dock version
2022-03-17 09:38:36 -07:00
Adam Cozzette
85eb57d267
Fix typo in src/README.md (#9644) 2022-03-17 09:12:51 -07:00
deannagarcia
854d86bb09
Merge pull request #9640 from protocolbuffers/toolchainCleanup
Toolchain cleanups
2022-03-17 08:28:24 -07:00
j-min5u
b04d397d04 remove redundant public modifiers 2022-03-17 14:26:29 +09:00
Jason Lunn
40cb0e43c0
Merge pull request #9638 from JasonLunn/master
Add alternative instructions for Homebrew users.
2022-03-16 22:41:08 -04:00
Deanna Garcia
faae704730 Toolchain cleanups 2022-03-16 21:07:51 +00:00
Jason Lunn
557f6fbfc8 Add alternative instructions for Homebrew users. 2022-03-16 13:48:15 -04:00
Jason Lunn
58e320a732 Fix NPE during encoding and add regression test for issue 9507. 2022-03-16 13:37:46 -04:00
Theodore Rose
a6133534e2
Merge pull request #9634 from esorot/3.20.x-202203152103
Update release version to RC2 (3.20.x 202203152103)
2022-03-15 17:47:02 -04:00
theodorerose
ebfa0d345e Update protobuf version 2022-03-15 21:12:45 +00:00
deannagarcia
178ebc179e
Merge pull request #9628 from protocolbuffers/windowsSysroot
Removing toolchain_dir variable
2022-03-15 12:12:58 -07:00
Brent Shaffer
fa11ed4719 remove unused LegacyGeneratedClassFileName 2022-03-14 21:16:12 -06:00
Theodore Rose
e0cec17c71
Merge pull request #9632 from esorot/update-python-version
update python to 3
2022-03-14 20:02:29 -04:00
theodorerose
2a9f806a69 update python to 3 2022-03-14 23:58:36 +00:00
Joshua Haberman
16dccd6820
Updated Ruby to the latest upb. (#9589) (#9630)
* Updated Ruby to the latest upb.

* Updated to newer upb.
2022-03-14 14:06:36 -07:00
Joshua Haberman
7ecf43f0ce
Updated Ruby to the latest upb. (#9589)
* Updated Ruby to the latest upb.

* Updated to newer upb.
2022-03-14 13:11:29 -07:00
Deanna Garcia
202ec9ed9b Removing toolchain_dir variable 2022-03-14 17:33:08 +00:00
Brent Shaffer
5f477fc440 remove legacy generate class file 2022-03-11 09:16:35 -06:00
Arfrever Frehtes Taifersar Arahesis
5dab09408c
Enable GeneratedDescriptorTest.EnormousDescriptor test for GCC/Clang CMake builds (#9617) 2022-03-10 16:40:07 -08:00
Arfrever Frehtes Taifersar Arahesis
bd935e101d
cmake: Call get_filename_component() with DIRECTORY mode instead of PATH mode (#9614)
PATH mode is legacy alias for DIRECTORY mode (needed only for CMake <= 2.8.11):
https://cmake.org/cmake/help/latest/command/get_filename_component.html
2022-03-10 12:05:27 -08:00
Go Kudo
1722b16e03
[PHP] fix PHP build system (#9571)
* [PHP] fix PHP extension build system

* fix year

* fix EXTRA_DIST

* remove include header

* add comment

* Revert "add comment"

This reverts commit e462966aa927b01d888527c17aaf29ea9ac6b6b4.

* add comment

* fix dangling commit

Co-authored-by: Go Kudo <g-kudo@colopl.co.jp>
2022-03-10 11:44:01 -08:00
Adam Cozzette
1ddad63dd9 Sync from Piper @acozzette/proto_github_202203101748
PROTOBUF_SYNC_PIPER
2022-03-10 18:44:16 +00:00
Adam Cozzette
b20209f321 Sync from Piper @acozzette/proto_github_202203101748
PROTOBUF_SYNC_PIPER
2022-03-10 18:36:42 +00:00
deannagarcia
f4d22f80a2
Merge pull request #9610 from protocolbuffers/manylinuxToolchains
Changing toolchain build file
2022-03-10 10:26:19 -08:00
Elliotte Rusty Harold
3adfa9afc5
clean up language (#9577)
* clean up language

@logophile

* Update lite.md
2022-03-10 13:19:07 -05:00
lzj
7d5af9d539
avoid allocating memory if all extension are cleared (#9345)
* Update extension_set.cc

avoid allocating memory if all extension are cleared

* Avoid allocating too much memory

* Accurately count flat memory size

* Update extension_set.cc

use the 4x growth.

* add unittest for ExtensionSet
2022-03-10 08:41:08 -08:00
Martin Schröder
75554b80a1
Replace gradle plugin with a live project (#9611)
Replace the link for the gradle plugin with a project that's alive.
2022-03-10 07:55:49 -08:00
Deanna Garcia
02be7a09f1 Changing toolchain build file 2022-03-09 23:34:31 +00:00
Arfrever Frehtes Taifersar Arahesis
426866285b cmake: Replace protobuf_source_dir variable with protobuf_SOURCE_DIR variable (#9596)
protobuf_source_dir variable is no longer needed and has the same value
as protobuf_SOURCE_DIR variable, which is instance of CMake-standard
<PROJECT-NAME>_SOURCE_DIR variable:
https://cmake.org/cmake/help/latest/variable/PROJECT-NAME_SOURCE_DIR.html
2022-03-09 14:55:55 -08:00
Arfrever Frehtes Taifersar Arahesis
def70d725a Add cmake/CMakeLists.txt for compatibility (#9596) 2022-03-09 14:55:55 -08:00
Arfrever Frehtes Taifersar Arahesis
14cab5b909 Rename main cmake/CMakeLists.txt to CMakeLists.txt
Fixes: #9596
2022-03-09 14:55:55 -08:00
Adam Cozzette
5ad0697c86
Merge pull request #9604 from protocolbuffers/3.20.x
Merge 3.20.x into master
2022-03-08 14:38:23 -08:00
Go Kudo
d1d13ed6fa
[PHP] Remove unnecessary zval initialization (#9600)
* [PHP] remove unneccesary zval

* fix memory leak, warning, Makefile
2022-03-08 14:35:48 -08:00
Adam Cozzette
357e71679e
Merge pull request #9588 from protocolbuffers/master
Merge master into 3.20.x
2022-03-08 12:24:24 -08:00
Luka Dornhecker
24a0659f95
[Ruby] allow encode json options to be an object that responds to to_hash (#9513)
* allow encode json options to be an object that responds to to_hash

fixes #9500

* try to convert options arg to hash if it is not a hash
2022-03-08 10:38:52 -08:00
zhangskz
276add0b5c
Add ruby_upb_alloc using xrealloc/xfree so Ruby GC is aware of allocated memory for Arenas. (#9586)
* Add ruby-specific upb_alloc using xrealloc/xfree for use in Arena_alloc so Ruby GC is aware of allocated memory.
* Add RB_GC_GUARD to DescriptorPool_add_serialized_file  to ensure ruby does not aggressively garbage collect arena_rb due to lack of references.
2022-03-08 12:05:34 -05:00
Arfrever
1cec803182
CMake fixes (#9595)
* Support older versions of CMake.

VERSION_GREATER_EQUAL is supported by CMake >=3.7:
https://cmake.org/cmake/help/latest/command/if.html#version-greater-equal

target_link_options() is supported by CMake >=3.13:
https://cmake.org/cmake/help/latest/command/target_link_options.html

* Use PROTOBUF_USE_DLLS and LIBPROTOC_EXPORTS for libprotoc.so shared library

Similar change for libprotobuf.so and libprotobuf-lite.so was made
in commit 5a0887fc65.

* Make value of PROTOC_EXPORT dependent on LIBPROTOC_EXPORTS instead of LIBPROTOBUF_EXPORTS

This was probably intention, and LIBPROTOC_EXPORTS is also used above
in _MSC_VER branch.
2022-03-07 17:03:50 -08:00
Junrou Nishida
92cdf87f1a
[C#] fix parse failure for extensions with large field numbers (#9591) 2022-03-07 10:46:21 +00:00
Brett McBride
f2002f6022
adding php81 support to release notes (#9590) 2022-03-05 16:18:07 -08:00
Joshua Haberman
349d74d92e
Updated PHP upb, and utf8_range for Ruby/PHP (#9585)
* Updated PHP to the new version of upb.

This is a large change, as the upb API surface has been
renamed to follow Google style more closely.

* Fixed utf8_range.

* Updated Ruby for new utf8_range.

* Picked up new upb for PHP, with spelling fixes.

* Fixed the 32-bit build.
2022-03-05 11:55:57 -08:00
Adam Cozzette
aff13048c5
Update CHANGES.txt for 3.20.0 release (#9581) 2022-03-04 13:13:55 -08:00
Adam Cozzette
23e7cfd54a
Lower minimum CMake version to 3.5 (#9580)
We tried increasing it to 3.10, but that turned out to be too high since
gRPC still supports 3.5.1.
2022-03-04 13:13:19 -08:00
Adam Cozzette
388df0041a Update tests.sh to locally install all Java packages, not just util
The JRuby test runs appear to be fetching the util package from Maven
Central because it is not being installed locally. This causes the tests
to fail when we upgrade to a new version that has not yet been published
to Maven Central. This commit fixes the problem by locally installing
all the protobuf packages, not just util.
2022-03-04 09:52:19 -08:00
Adam Cozzette
88a18db91e Update protobuf version 2022-03-04 09:52:19 -08:00
Adam Cozzette
0a246e23f8
Merge pull request #9576 from acozzette/sync-stage
Integrate from Piper for C++, Java, and Python
2022-03-03 18:59:20 -08:00
Adam Cozzette
f59a5845a3 Add new unit test protos to setup.py 2022-03-03 22:25:43 +00:00
Adam Cozzette
839f0f8e06 Add missing GSON dependency 2022-03-03 22:03:15 +00:00
Thomas Van Lenten
bb4302e878 Add a generation option to control use of forward declarations in headers.
Swift importing ObjC drops methods/properties if the type is only a forward
declaration since the type is incomplete. Historically the generator has always
use forward declarations to reduce how much will have rebuild when a proto file
does change; but that puts it at odds with Swift. If ObjC Protos end up spanning
Swift modules, the Swift import behavior could become a problem; so this option
provides a control for the behavior. The current behavior is to continue forward
declarations, but eventually the default will be changed.

Generate the WKTs using imports instead of forward decls.
2022-03-03 16:05:18 -05:00
Adam Cozzette
e29b4e3bc2 Update Makefile.am with new Python files 2022-03-03 17:58:57 +00:00
Adam Cozzette
615d214ade Update CHANGES.txt 2022-03-03 17:25:11 +00:00
Adam Cozzette
b0f9799a7c Sync from Piper @432209397
PROTOBUF_SYNC_PIPER
2022-03-03 17:18:16 +00:00
kunhtkun
5f632bef38
[editors/emacs] Fix protobuf-mode definition (#9572)
Fix a few issues with the Emacs mode definition.

First, in 1ab7789f3 (2021-10-13, Emacs: Protobuf mode should be derived from
prog-mode) we made `protobuf-mode' a derived mode of `prog-mode' using the
`define-derived-mode' macro[1]. However, the definition body was not updated
accordingly. So in this commit, we:

- Remove the superfluous `(interactive)' form;
- Remove the unnecessary call of `kill-all-local-variables', which is already
  handled by `define-derived-mode' and could cause a few issues, for example,
  it prevents `prog-mode-hook' from being run;
- Remove forms that set `major-mode' and `mode-name', which are automatically
  set to the first and third arguments respectively;
- Remove forms that set key map, syntax table, and abbrev table, which are
  already handled automatically;
- Do not run `protobuf-mode-hook' explicitly in the body. It is already arranged
  to be run after the body.

Second, the call to `c-make-emacs-variables-local' is removed. It is called
inside `c-init-language-vars' already. Calling it again should do no harm now,
but to be future-proof it might be better to just remove it.

Finally, we move the `c-update-modeline' form to the :after-hook argument to
ensure it is run at the very end, so that the mode line will reflect all user
customizations done in various mode hooks. Similarly, we run
`c-mode-common-hook' also at the very end to leave a place for user
customizations (for example, set `imenu-generic-expression' in
`c-mode-common-hook').

[1] https://www.gnu.org/software/emacs/manual/html_node/elisp/Derived-Modes.html

Re: https://github.com/protocolbuffers/protobuf/issues/7316
Re: https://github.com/protocolbuffers/protobuf/pull/9076
2022-03-03 09:16:46 -08:00
Adam Cozzette
038b479119
Merge pull request #9570 from acozzette/sync-stage
Integrate from Piper for C++, Java, and Python
2022-03-02 14:23:54 -08:00
Adam Cozzette
5faa6123d1 Reimplement the type sorter to avoid a ICE in gcc 4.8.2.
Thanks to @sbenzaquen for this fix.
2022-03-02 20:54:57 +00:00
Adam Cozzette
1c51f9fb39 Undo unintentional file list changes 2022-03-02 20:50:28 +00:00
Adam Cozzette
f7232f2aa3 Replace EasyMock dependency with Mockito and re-pin Bazel deps 2022-03-02 19:27:59 +00:00
Adam Cozzette
23b2fe6e39 Update CHANGES.txt 2022-03-02 17:44:18 +00:00
Adam Cozzette
76398dab31 Sync from Piper @431959314
PROTOBUF_SYNC_PIPER
2022-03-02 17:37:55 +00:00
Adam Cozzette
0ece18cf2e Merge tag 'refs/tags/sync-piper' into sync-stage 2022-03-02 17:37:55 +00:00
Arfrever
1d13b60904
cmake: Use linker version scripts (#9545)
Autotools build system already uses linker version scripts since
commit 13d165de9e.

Fixes: #6113
2022-03-01 17:06:14 -08:00
Joshua Haberman
2a001f792f
Merge pull request #9556 from ntkme/ruby-suppress-warning
Suppress warning for intentional circular require
2022-03-01 15:24:43 -08:00
Thomas Van Lenten
020e4e33d1 Simplify imports of the WKTs within the library itself.
Overdue followup to https://github.com/protocolbuffers/protobuf/pull/7173

Since all the files are at the same level as the runtime headers, there is no
need for things to be framework based imports, they should all just work like
the other headers do.

- Directly generate the bundled header imports into the preamble section when
  generating for a bundled proto.
- Update the preamble generation to skip the CPP wrapper when generating for a
  bundled proto file.
- Regenerate the WKTs.
- Update GPBProtocolBuffer.h/GPBWellKnownTypes.h to also skip the CPP wrapping.

GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS in the podspec and non bundled files still
has to exist because that comes into play for those files to find the runtime
headers.
2022-03-01 17:01:33 -05:00
deannagarcia
4b0871e205
Merge pull request #9560 from protocolbuffers/ktJvmOut
Add bazel rules to do Kotlin mvn exports
2022-03-01 10:53:24 -08:00
Thomas Van Lenten
76ba220c38 And an overload for ValidateObjCClassPrefixes().
This version defaults all the options, so folks don't have to pass it.

Since Options never had a PROTOC_EXPORT, it isn't immediately clear how well the
existing api worked for any shared lib cases, so this should give a simpler api
for the basic usage (if anyone wants to use it).
2022-03-01 10:46:27 -05:00
Thomas Van Lenten
d9048081b2 Remove the non prefix validation options from Options.
The other generation options never were in the Options structure and
ImportWriter was the only thing that needed some the non validation options and
it already required directly passing the options. So refine Options to just be
validation options and bundle all the File related generation options into
a new FileGenerator specific GenerationOptions.
2022-03-01 10:46:27 -05:00
Thomas Van Lenten
14e445bc34 Stop passing generation options thru the graph.
They never were needed below file, and they really are specific to two high
level case, so don't pass them every where else.
2022-03-01 10:46:27 -05:00
Deanna Garcia
933239f8c3 Update build files 2022-03-01 00:27:42 +00:00
deannagarcia
c578f59fc8
Merge pull request #9558 from protocolbuffers/exe-extensions
Change toolchain artifact name patterns
2022-02-28 12:51:03 -08:00
Deanna Garcia
93b4fa6fc7 Only exe extension for windows 2022-02-28 20:00:45 +00:00
Deanna Garcia
aafcb92f62 kotlin core maven export 2022-02-28 18:28:50 +00:00
なつき
6c8bda86fe Suppress warning for intentional circular require 2022-02-27 13:15:57 -08:00
Greg Miller
cbc9826db7
Merge pull request #9555 from devjgm/ignore-clangd-files 2022-02-26 15:15:52 -05:00
Greg Miller
ee429aea17 chore: gitignore ephemeral files that clangd uses
This PR tells git to ignore ephemeral files that are created when
developers use clangd.

clangd needs a `compile_commands.json` file at the root of the repo (or
in a `build/` directory) to tell it how to compile each file. CMake can
generate this file with something like the following:

```console
$ cmake -Scmake -B.build \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  -Dprotobuf_BUILD_TESTS=OFF
$ ln -sf .build/compile_commands.json .
```

Then clangd will compile and index files into the `.cache` directory.
2022-02-25 21:13:50 -05:00
Adam Cozzette
b44784cf30
Fix update_version.py script (#9554)
Two small fixes to update_version.py:
- The regex for updating SOVERSION in cmake files was not quite right. I
  fixed it to reflect that the value is a plain integer and not of the
  form x.y.z
- For some reason the code for updating PHP_PROTO_VERSION appeared 3
  times and led to a spurious warning, so I removed the extra calls
  there.
2022-02-25 15:30:07 -08:00
Jason Lunn
1a10c58c2f
Merge pull request #9549 from JasonLunn/jruby-release-bump
Update JRuby 9.2.19.0 -> 9.2.20.1 and 9.3.0.0 to 9.3.3.0.
2022-02-25 17:12:30 -05:00
deannagarcia
4738b8ee08
Merge pull request #9553 from protocolbuffers/deannagarcia-patch-2
Make protoc executable names consistent
2022-02-25 10:47:07 -08:00
deannagarcia
5b3f853d7d
Make protoc executable names consistent
Rename ppc64 cpu to ppcle_64 to match current release.
2022-02-25 10:45:28 -08:00
Dimitris Koutsogiorgas
89c40311db Rename proto_package_to_prefix_mappings_path to package_to_prefix_mappings_path. 2022-02-25 13:10:36 -05:00
deannagarcia
b9bcec8ac3
Merge pull request #9537 from protocolbuffers/deannagarcia-patch-1
Fix package naming rule
2022-02-25 09:47:41 -08:00
Jason Lunn
df0999141e Update JRuby 9.2.19.0 -> 9.2.20.1 and 9.3.0.0 to 9.3.3.0. 2022-02-25 14:11:12 +00:00
Thomas Van Lenten
6a77c9bab4 Make the ObjC support conditional to darwin.
Fixes #9392
2022-02-24 17:39:04 -05:00
Thomas Van Lenten
e8470340e0 Rename ExpectedPrefixesCollector to PackageToPrefixesCollector
Now that two files use the format, tweak the naming to the format for the file
vs. the usage(s).

Also add a "usage" param so the two places can provide a little context for any
error messages generated while parsing.
2022-02-24 16:11:10 -05:00
deannagarcia
a5168a6e96
Fix package naming rule
Remove quotes around CPU since we want the variable evaluated instead of the string. This will allow the win64 build to get the correct name.
2022-02-23 16:45:56 -08:00
Dimitris Koutsogiorgas
a112c4ab96 Add prefix_to_proto_package_mappings_path ObjC option. 2022-02-23 14:26:53 -05:00
Brent Shaffer
023fe6ff4d
chore: [PHP] fix phpdoc for MapField keys
anything other than `string|int` is not a valid offset type. `bool` may be added, but it's not a true offset because it will be cast to an `int` if used:

```php
$a = [false => '1' , true => '2'];
$a[0] = '3';
$a[1] = '4';
var_dump($a);
// array(2) {
//   [0]=>
//   string(1) "3"
//   [1]=>
//   string(1) "4"
// }
```
2022-02-23 10:26:32 -08:00
Arfrever
d0c06bcd93
cmake: Set correct sonames for libprotobuf-lite.so and libprotoc.so (#9529)
Soname was set for libprotobuf.so in commit a9cf69a0ed,
but similar changes for libprotobuf-lite.so and libprotoc.so were missed.

Fixes: #8635

Co-authored-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@GMail.Com>
2022-02-22 15:53:14 -08:00
Dimitris Koutsogiorgas
db56692883 Revert "objective-c: Add objc_class_prefix generation option."
This reverts commit b5ab0b7a18.
2022-02-22 14:24:41 -05:00
Jorg Brown
2f91da585e
Merge pull request #9528 from dlj-NaN/sync-stage
Integrate from Piper for C++, Java, and Python
2022-02-18 15:32:19 -08:00
David L. Jones
951582e893 Update changelog 2022-02-18 14:07:43 -08:00
David L. Jones
7ba5fa3d96 Merge tag 'refs/tags/sync-piper' into sync-stage 2022-02-18 14:02:13 -08:00
David L. Jones
3ab97ce830 Sync from Piper @429642851
PROTOBUF_SYNC_PIPER
2022-02-18 14:02:12 -08:00
Jorg Brown
763d85293d
Merge pull request #9525 from dlj-NaN/sync-stage
Integrate from Piper for C++, Java, and Python
2022-02-18 12:15:58 -08:00
deannagarcia
ddfc233f57
Merge pull request #9524 from protocolbuffers/sysroot
Change sysroot flags
2022-02-18 11:02:52 -08:00
David L. Jones
20c5b6fd14 Update changelog 2022-02-17 18:01:44 -08:00
David L. Jones
2fbda76fad Sync from Piper @429445371
PROTOBUF_SYNC_PIPER
2022-02-17 18:00:38 -08:00
Deanna Garcia
cf05c9f84f Change sysroot flags 2022-02-18 00:39:23 +00:00
Jorg Brown
2f7ee91e32
Merge pull request #9522 from dlj-NaN/sync-stage
Integrate from Piper for C++, Java, and Python
2022-02-17 11:38:09 -08:00
David L. Jones
a6c9a5f69d Merge tag 'refs/tags/sync-piper' into sync-stage
# Conflicts:
#	src/google/protobuf/compiler/java/java_message.cc
#	src/google/protobuf/compiler/java/java_message_lite.cc
2022-02-17 09:54:12 -08:00
David L. Jones
1ba1d73e0d Sync from Piper @429333699
PROTOBUF_SYNC_PIPER
2022-02-17 09:53:51 -08:00
deannagarcia
972b122a30
Merge pull request #9518 from alexvanyo/patch-1
Add test scope to kotlin-test for protobuf-kotlin-lite
2022-02-17 09:24:03 -08:00
Alex Vanyo
97d78281de
Add test scope to kotlin-test for protobuf-kotlin-lite 2022-02-16 23:25:12 -06:00
Joshua Haberman
b0bf163c78
Merge pull request #9510 from haberman/manylinux-aarch64
Changes to build aarch64 under manylinux.
2022-02-16 10:02:47 -08:00
Joshua Haberman
9d01899322 Changes to build aarch64 under manylinux. 2022-02-15 18:02:10 -08:00
deannagarcia
8bfa7d0083
Merge pull request #9508 from protocolbuffers/genProtoRule
Use internal kotlin gen rule
2022-02-15 16:05:21 -08:00
Deanna Garcia
0f253ca64f Remove deleted files from Makefile 2022-02-15 23:03:12 +00:00
Deanna Garcia
67b74dd169 Use internal kotlin gen rule 2022-02-15 22:45:56 +00:00
idodod
2a2a9b6e64
Update third_party.md (#9505) 2022-02-15 07:22:53 -08:00
deannagarcia
479500a091
Merge pull request #9496 from protocolbuffers/duplicates
Remove Proto3LiteTest.kt
2022-02-14 10:45:02 -08:00
deannagarcia
9eb5b19964
Merge pull request #9494 from protocolbuffers/ktExport
Fixing Kotlin tests
2022-02-14 10:44:16 -08:00
Adam Cozzette
250fafa7c4
Fix the benchmark job and delete old Python configs (#9497)
Our benchmark job starting failing when we stopped supporting Python 3.5
and 3.6, but this change fixes it by running it in our java_stretch
Docker container, which has a more recent Python version. I also deleted
all configs related to old Python versions that we no longer support.
2022-02-11 16:25:56 -08:00
ObsidianMinor
013e115231
Add an option to preserve proto names in JsonFormatter (#6307)
Co-authored-by: Adam Cozzette <acozzette@google.com>
2022-02-11 15:55:46 -08:00
Deanna Garcia
79848b5f4c Update Makefile 2022-02-11 23:41:41 +00:00
Deanna Garcia
14c62a025c Removing Proto3LiteTest 2022-02-11 23:15:08 +00:00
Deanna Garcia
f1085e9bbc Remove old import 2022-02-11 22:26:07 +00:00
Deanna Garcia
a32a2a3b57 Fix errors 2022-02-11 22:12:51 +00:00
Oleg Kolesov
fe87de31bf
#9293 - incompatible return type php 8.1 (#9301)
* #9293 - fix Missing function's return type declaration (incompatible return type php 8.1)

* #9293 - remove return type void for compatible with php 7.0

* #9293 - add todo for mixed return type

Co-authored-by: Adam Cozzette <acozzette@google.com>
2022-02-11 11:19:12 -08:00
Deanna Garcia
e760984a59 First try 2022-02-11 19:13:07 +00:00
Anthony Dmitriyev
2ce9604227
Use rb_obj_class instead of CLASS_OF in Ruby C to ignore singleton classes (#9342)
Co-authored-by: Adam Cozzette <acozzette@google.com>
2022-02-11 11:04:10 -08:00
BartH
2495d220fa
Added Embedded Proto to options.md to reserve the extenion number for the custom options. (#9493) 2022-02-11 08:08:25 -08:00
Deanna Garcia
c946f0bb70 Merge branch 'master' of github.com:protocolbuffers/protobuf into ktExport 2022-02-10 18:20:35 +00:00
Brent Shaffer
ce57b5bab6
fix: [PHP] add missing reserved classnames (#9458)
* fix: add missing reserved classnames

* Try to remove PARENT and SELF from reserved constants

* add back for tests

* add to validConstantNames

* update kReservedNamesSize
2022-02-10 09:16:20 -08:00
David Supplee
dfcbdb8ca0
fix: use E_USER_ERROR for trigger_error calls (#9462)
* fix: use E_USER_ERROR for trigger_error calls

* fix: use E_USER_ERROR for trigger_error calls
2022-02-10 09:03:34 -08:00
Adam Cozzette
d5ef16c6eb
Ruby: rename max_recursion_depth to recursion_limit (#9486)
This will help keep the terminology consistent with the other language
implementations.
2022-02-09 10:21:13 -08:00
Elliotte Rusty Harold
9748e4c52c
add Eclipse metafiles (#9485) 2022-02-09 12:19:33 -05:00
Lukas Fittl
fbe6ab2487
[Ruby] Message.decode/encode: Add max_recursion_depth option (#9218)
* Message.decode/encode: Add max_recursion_depth option

This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to encode or decode complex nested protobuf messages that otherwise
error out with a RuntimeError or "Error occurred during parsing".

Fixes #1493

* Address review comments

Co-authored-by: Adam Cozzette <acozzette@google.com>
2022-02-09 08:44:12 -08:00
Timo Lange
4ed3941e27
[CMake] Allow custom plugin options e.g. to generate mocks (#9105)
* add plugin options

* refactored comment message

* added tabs for better readability

* removed newlines as they are not working properly

* allow PROTOC_OPTIONS and EXPORT_MACRO in parallel for protobuf_generate
2022-02-09 08:21:45 -08:00
Joshua Haberman
ce731e2f52
Merge pull request #9482 from haberman/sync-stage
Integrate from Piper for C++, Java, and Python
2022-02-09 00:14:43 -08:00
Joshua Haberman
73f772b666 Added AniesTest.kt to Makefile.am. 2022-02-08 23:28:10 -08:00
Joshua Haberman
09b2c6a2b4 Removed conflicting/redundant variable declaration. 2022-02-08 23:07:12 -08:00
Joshua Haberman
5c5cd186b0 Added missing Kotlin file to EXTRA_DIST. 2022-02-08 23:06:55 -08:00
Joshua Haberman
fb9f5862d3 Fixed JavaScript conformance test and failure list. 2022-02-08 23:06:32 -08:00
Joshua Haberman
b175176124 Added changelog entries. 2022-02-08 21:01:46 -08:00
Joshua Haberman
06196e9b4c Merge tag 'refs/tags/sync-piper' into sync-stage 2022-02-08 20:53:32 -08:00
Joshua Haberman
dce403a8b3 Sync from Piper @427369078
PROTOBUF_SYNC_PIPER
2022-02-08 20:53:31 -08:00
Joshua Haberman
2d69d44cc1
Merge pull request #9479 from haberman/sync-stage-2
Integrate from Piper for C++, Java, and Python
2022-02-08 20:47:40 -08:00
Joshua Haberman
53d409ca54 Removed redundant/unnecessary variable definition. 2022-02-08 20:03:11 -08:00
Joshua Haberman
5aacba062b Resolved remaining conflict markers. 2022-02-08 18:38:48 -08:00
Joshua Haberman
42e806fbf2 Merge branch 'master' into sync-stage-2 2022-02-08 18:36:24 -08:00
Joshua Haberman
301d315dc4
Dropped support for Python < 3.7 (#9480)
* Drop Python versions <3.7.

* Updated README to clarify that Python 3.7 is the minimum.

* Removed more Python 3.5-specific code.

Also changed tests to skip missing interpreters.

* Invoke tox directly instead of through Python.

Hopefully this will pick up python3.

* Updated java_stretch image to bullseye to get Python >= 3.7.

* Use jdk11 instead of jdk8.

* Installed python2 for gtest.

* Use "python3 -m venv" instead of "virtualenv."

* Install python3-venv.
2022-02-08 18:31:50 -08:00
Joshua Haberman
f739286b1a For GCC < 4.9.0 use ::max_align_t instead of std::max_align_t. 2022-02-08 10:31:54 -08:00
Dimitris Koutsogiorgas
b5ab0b7a18 objective-c: Add objc_class_prefix generation option. 2022-02-08 08:22:51 -05:00
Florin Crișan
9ebb31726c
Add option to use external GTest in CMake (#8736)
If `-Dprotobuf_USE_EXTERNAL_GTEST=ON` is passed to CMake, it will use an external Google Test copy (i.e. by calling `find_package(GTest REQUIRED)`) rather than the one provided as a submodule.

This makes sense for larger projects that might already include Google Test and want to use a more standard CMake approach.

Also updated build instructions with this information, and more idiomatic usage.

Co-authored-by: Adam Cozzette <acozzette@google.com>
2022-02-07 20:41:29 -08:00
Florin Crișan
18c951efb1
Enable testing via CTest (#8737)
Convenience feature: enable users to test via the familiar `ctest` command rather than making the `check` target.

They would be able to use the familiar CMake pattern:
```
cmake -S source/protobuf -B build/protobuf ...
cmake --build build/protobuf
ctest --test-dir build/protobuf
cmake --install build/protobuf
```

This is a follow-up to 9f447fc9d3da93da29b8301f1a8ca57b1ea812d7
2022-02-07 17:38:38 -08:00
appledragon
5a0887fc65
for ios shared library export api visibility (#9160)
* for ios shared library export api visibility

* for shared library export api visibility

* for shared library export api visibility
2022-02-07 15:50:16 -08:00
Deanna Garcia
7f474c6c64 Change gcc version 2022-02-07 19:49:23 +00:00
Joshua Haberman
3ea30d8084
Merge pull request #9307 from owent-contrib/fix_9306
[CMAKE] `protobuf::libprotoc` and `protobuf::protoc` should be optional in legacy `protobuf-module.cmake` when crossing compiling.
2022-02-04 09:38:25 -08:00
Elliotte Rusty Harold
867436c0b8
add test for clone of non-empty message (#9193)
* add test for clone

* use var

* reorder
2022-02-04 16:54:43 +00:00
Deanna Garcia
c8b388a6cb Fixing java test 2022-02-04 00:23:34 +00:00
Deanna Garcia
8dc77b9957 Fix more tests 2022-02-03 20:46:48 +00:00
Deanna Garcia
5e0fc2f1df Fix java tests 2022-02-03 18:02:13 +00:00
Phil Clay
3be46483ba
Resolve more java field accessor name conflicts (#8198)
* Remove javanano from .gitignore.
Ignore java/lite/target

* Resolve more java field accessor name conflicts.

Previously, some proto field names would cause the java code generator to generate accessor names that conflict with method names from the message super classes/interfaces.
A list of field names that cause such conflicts previously existed, but the list did not contain every field name that would cause a conflict.
Additionally, only snake_case field names would be detected. If the field name was in camelCase, the conflict would not be detected.

This change adds the complete set of field names that will cause assessor name conflicts, and detects conflicts in both snake_case and camelCase field names.

Fixes #8142

* Prevent java accessor name conflicts for fields with leading underscores.
Previously, some protobuf field names beginning with leading underscores (e.g. _class) would cause uncompilable java code to be generated due to assessor name conflicts.
Now, non-conflicting java accessor method names are created for those fields

* Improve comments/documentation for conversion from snake case to camel case
Rename snakeCaseToCamelCase to snakeCaseToLowerCamelCase
Add snakeCaseToUpperCamelCase
Add clarifying in-line comments for field name generation
Remove explicit version numbers from references.

* Fix indents and typo

* Unnest <pre> tag

* improve grammar in comments
are colliding -> collide

* Remove ternary operator and improve comments

* Fix typo in comment
2022-02-03 12:49:57 -05:00
Nipunn Koorapati
937b56f57b
Match service argument names to abstract interface (#9418)
The base class/documentation suggest that the argument
names are `self` and `done`, while the runtime used
argument names `srvc` and `callback`.

`mypy.stubtest` was able to identify this - as it compares
the types (autogenerated by
[`mypy-protobuf`](https://github.com/dropbox/mypy-protobuf/))
to the actual code generated by protoc at runtime.

Since the stubs assume the generated code matches the abstract
interface in service.py - it saw these differences.
2022-02-03 09:14:44 -08:00
Deanna Garcia
ab2593041d Merge branch 'sync-stage' of github.com:deannagarcia/protobuf into sync-stage 2022-02-03 01:09:33 +00:00
Deanna Garcia
369388b472 More test fixes. 2022-02-03 01:09:18 +00:00
Deanna Garcia
b2ff4f82c2 Fixing tests 2022-02-03 01:05:20 +00:00
deannagarcia
fa4ba87aff
Merge branch 'master' into sync-stage 2022-02-02 15:24:33 -08:00
Stephen Kennedy
8495372e1e
[cleanup] Msvc warnings (#9263)
* Fix and reenable signed/unsigned warning C4018

* Only disable unary minus warning C4146 in tests
2022-02-02 15:10:15 -08:00
Deanna Garcia
2d87ce3cfe Fix test 2022-02-02 23:10:04 +00:00
Deanna Garcia
a2f7cfab27 Fixing more tests 2022-02-02 22:21:04 +00:00
Joshua Haberman
8c8fb0ec97
Merge pull request #9370 from brettmc/bugfix/php-8.1-deprecations
fixing php 8.1 deprecation warnings
2022-02-02 14:17:43 -08:00
Deanna Garcia
7dff52929f Fixing tests 2022-02-02 21:08:44 +00:00
Deanna Garcia
000da39ada Fix python tests 2022-02-02 19:21:42 +00:00
Deanna Garcia
d2ca349c2a Fix python tests 2022-02-02 18:48:58 +00:00
Deanna Garcia
e56d6936f3 Fix spelling 2022-02-02 18:35:49 +00:00
JCooky
55645ca513
Add cmake option protobuf_INSTALL for installation files (#7123) 2022-02-02 08:29:25 -08:00
Deanna Garcia
fc9fb726f1 Fix python and kotlin tests 2022-02-02 01:02:08 +00:00
Joel Johnson
a9cf69a0ed
Use matching soname when building with CMake as Makefile (#9178)
This updates the CMake support to additionally symlink the soversion value
to the generated shared library when so generated. This aligns the
generated soversion with that traditionally used by the Makefile build
workflow and provides cross-compatibility irrespective of build approach
used.

The primary version of the non-symlink library retains the actual
(non-SO) project version for clarity and compatibility with
installations built using prior versions of CMake support. An example of
the net resulting symlink structures is shown below, where the most
important aspect is that the symlink matching the embedded SONAME is
present (libprotobuf.so.30 in the example case).

Makefile:

    libprotobuf.so -> libprotobuf.so.30.0.0
    libprotobuf.so.30 -> libprotobuf.so.30.0.0
    libprotobuf.so.30.0.0

CMake:

    libprotobuf.so -> libprotobuf.so.30
    libprotobuf.so.30 -> libprotobuf.so.3.19.0.0
    libprotobuf.so.3.19.0.0

Fixes: #8635
2022-02-01 15:27:56 -08:00
Deanna Garcia
349738dde5 Fixing java and protoc builds 2022-02-01 23:22:23 +00:00
Biswapriyo Nath
7e5bfe8883
Fix checking Windows platform with preprocessor (#9460)
Check _WIN32 instead of _MSC_VER because the later one is for MSVC only.
This fixes building with mingw-w64 toolchain which uses GCC or Clang.
2022-02-01 13:58:39 -08:00
Deanna Garcia
b7fe12e367 Syncing from internal 2022-02-01 21:30:49 +00:00
Deanna Garcia
ab4585a695 Sync from Piper @425656941
PROTOBUF_SYNC_PIPER
2022-02-01 18:24:53 +00:00
deannagarcia
aa896f6389
Merge pull request #9459 from protocolbuffers/deannagarcia-patch-2
Update package.xml
2022-01-31 16:29:48 -08:00
deannagarcia
a6a66a9ac8
Update package.xml
Have PHP release notes link back to general release notes .
2022-01-31 16:10:49 -08:00
deannagarcia
c756e61878
Merge pull request #9430 from xoofx/fix-csharp-fielddesc-ispacked
Fixes NullReferenceException when accessing FieldDescriptor.IsPacked
2022-01-31 11:10:20 -08:00
Ivo List
15add1af49
Selectively add source or gen dir to includes. (#9438)
When both directories are added this results in protoc emitting a
"warning: directory does not exist.". This makes sense because when
there are no inputs from the other directory, it is also not present
n the sandbox where protoc is executed.
2022-01-28 16:44:42 -08:00
Adam Cozzette
fa57149caa
Merge pull request #9452 from acozzette/merge-3.19.x
Merge 3.19.x into master
2022-01-28 16:44:20 -08:00
Elliotte Rusty Harold
749243db7e
Must build project before running benchmarks (#9454)
* Must build project before running benchmarks

That is, it does not test the version downloaded from Maven central.

* Update README.md
2022-01-28 21:50:35 +00:00
Adam Cozzette
18521f6055 Merge branch '3.19.x' into merge-3.19.x 2022-01-28 17:42:21 +00:00
Jon Skeet
b926a7d209 Add ToProto() method to all C# descriptor classes
Fixes #9425.
2022-01-28 14:17:56 +00:00
Adam Cozzette
22d0e265de
Update protobuf version for 3.19.4 (#9449)
I also updated the PHP release notes in
php/ext/google/protobuf/package.xml.
2022-01-27 19:35:56 -08:00
Joshua Haberman
afeb6d8181
Merge pull request #9451 from haberman/ruby-dataloss-bugfix
Fixed data loss bug in Ruby extension
2022-01-27 18:20:42 -08:00
Joshua Haberman
98b8e055d5 Merge branch '3.19.x' into ruby-dataloss-bugfix 2022-01-27 18:17:23 -08:00
Joshua Haberman
eb301e1a33
Merge pull request #9450 from haberman/php-dataloss-bugfix
Fixed data loss bug in PHP C extension
2022-01-27 18:02:14 -08:00
Joshua Haberman
aceff710f4 Fixed data loss bug in Ruby extension. 2022-01-27 17:29:12 -08:00
Joshua Haberman
35a21c1249 Added CHANGES.txt entry. 2022-01-27 17:14:07 -08:00
Joshua Haberman
67995fb4e9 Fixed data loss bug with PHP C extension. 2022-01-27 17:06:41 -08:00
Adam Cozzette
779b97260d
Update CHANGES.txt for 3.19.4 release (#9448) 2022-01-27 16:27:45 -08:00
Joshua Haberman
b48ba578dd
Merge pull request #9422 from ngg/disable-musttail-winx86
Disable [[clang::musttail]] attribute on Windows x86
2022-01-27 13:51:31 -08:00
Elliotte Rusty Harold
a30167f016
simplify mergeable UI messages (#9445)
No "Please"

see https://docs.google.com/document/d/1mIHBZQXI3F5VEPPmR54PySixl8wSsdwVciSENJ0Unxg/edit#heading=h.vvb6vlxagbv8 for justification

also make the and clause a little simpler. That is, this is now "Include release notes: yes AND at least a language label" instead of "Please include release notes: yes AND Please include at least a language label"
2022-01-27 13:07:30 -05:00
Brett McBride
4c03fcf8fb php8.1 testing 2022-01-27 15:45:20 +11:00
Maximilian
82372d8fe6
Use proper SPDX license identifier (#9441)
The previously used term "3-Clause BSD License" is not properly
standarized. A common standard is SPDX, therefore "3-Clause BSD License"
is substituted with "BSD-3-Clause" which is a SPDX identifier.

`grep -rl "3-Clause BSD License" | xargs -n1 sed -i "s/3-Clause BSD
License/BSD-3-Clause/g"`
2022-01-27 00:23:14 +00:00
Adam Cozzette
a035bd0882
Make libprotobuf symbols local on OSX (#8346) (#9435)
@gnossen gave a great overview in https://github.com/grpc/grpc/pull/24992 of the overall problem.

If a python process using both protobuf _and_ another native library linking in libprotobuf
frequently can cause crashes.  This seems to frequently affect tensorflow as well:

tensorflow/tensorflow#8394,
tensorflow/tensorflow#9525 (comment)
tensorflow/tensorflow#24976,
tensorflow/tensorflow#35573,
https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/contrib/makefile/rename_protobuf.sh,
tensorflow/tensorflow#16104

Testing locally this fixes both crashes when linking in multiple versions of protobuf
and fixes `DescriptorPool` clashes as well (e.g. Python and Native code import different versions of the same message).

Co-authored-by: Roy Williams <roy.williams.iii@gmail.com>
2022-01-25 08:24:12 -08:00
Brett McBride
a78b89ef2a removing ext-bcmath require
I think it _should_ be required, but a test (linux, 32bit, 7.0-zts) is choking
on composer install, so putting things back to how I found them
2022-01-25 21:00:02 +11:00
Joshua Haberman
b696347f80
Merge pull request #9436 from haberman/ruby-upb2
Updated Ruby to the current version of upb
2022-01-24 20:40:12 -08:00
David Geldreich
f180289c46
link with correct C runtime on MSVC (#9437)
when using CMake >= 3.15, we use CMAKE_MSVC_RUNTIME_LIBRARY
to reproduce the /MT vs /MD when protobuf_MSVC_STATIC_RUNTIME
is TRUE or FALSE
MultiThreaded is for /MT
MultiThreadedDebug is for /MTd
MultiThreadedDLL is for /MD
MultiThreadedDebugDLL is for /MDd
2022-01-24 13:17:14 -08:00
Brett McBride
3e724d8a2e formatting 2022-01-24 23:23:40 +11:00
Brett McBride
6a3f3840f6 tidy 2022-01-24 23:17:16 +11:00
Brett McBride
110d6c10b2 polyfill ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX 2022-01-24 22:40:17 +11:00
Joshua Haberman
5ef010cb85 Fixed spelling errors in comments. 2022-01-23 16:13:12 -08:00
Joshua Haberman
012c8892ab Added utf8_range. 2022-01-21 21:01:07 -08:00
Joshua Haberman
79951dac84 Added changelog entries. 2022-01-21 20:25:32 -08:00
Joshua Haberman
90065d39a7 Fixed crash bug with proto2 enums. 2022-01-21 20:18:11 -08:00
Joshua Haberman
706ed2d17a Added utf8_range.c as a source file. 2022-01-21 17:32:34 -08:00
Joshua Haberman
c153dd9bf7 Updated to new upb APIs. 2022-01-21 15:46:56 -08:00
Gregor Jasny
e554bd6cbf
Use constexpr for FieldTypeClass (#9434)
Otherwise in C++20 / VisualStudio 2022 the following warning is emitted:

```
warning C5054: operator '*': deprecated between enumerations of different types
```
2022-01-21 15:38:59 -08:00
Joshua Haberman
f41049a0f0 Updated upb. 2022-01-21 14:41:25 -08:00
deannagarcia
a03ff9c3e8
Merge pull request #9428 from protocolbuffers/kotlinBazelTests
Migrate kotlin bazel tests from kt_jvm_test
2022-01-21 10:44:37 -08:00
deannagarcia
86bb6f9de0
Merge pull request #9429 from protocolbuffers/deannagarcia-patch-2
Update location of llvm-ar in bazel toolchain
2022-01-21 10:44:04 -08:00
Alexandre Mutel
16941420c9 Fixed NullReferenceException when accessing FieldDescriptor.IsPacked 2022-01-21 05:29:40 +01:00
Brett McBride
c62cbe97de working 7.0 extension 2022-01-21 09:59:46 +11:00
deannagarcia
70131e0495
Update location of llvm-ar in bazel toolchain
Change the location of the llvm-ar tool to match the new docker container.
2022-01-20 14:31:53 -08:00
Deanna Garcia
6e8b0dfcbf Switch to java_test 2022-01-20 22:24:59 +00:00
Brett McBride
f689268ca3 fixing typo in comment 2022-01-20 12:01:51 +11:00
Brett McBride
bfe33d7d08 php 7.0 support
instead of using the void return type, add more ReturnTypeWillChange annotations
2022-01-20 09:33:58 +11:00
Gergely Nagy
639551d445 Disable [[clang::musttail]] attribute on Windows x86 (#9421) 2022-01-18 19:15:32 +01:00
deannagarcia
41e22cde8d
Merge pull request #9408 from protocolbuffers/kotlinBazelTests
Adding kotlin bazel tests
2022-01-13 16:05:09 -08:00
Deanna Garcia
a784e515e1 fix pom errors 2022-01-13 22:50:11 +00:00
Brett McBride
9e65df20a7 bump extension min version to 7.2
The macro ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX changed in 7.2, so it cannot be used in a compatible
way with earlier versions
2022-01-13 12:50:11 +11:00
Deanna Garcia
58d22b8cac Add new files to makefile 2022-01-13 00:49:22 +00:00
Brett McBride
0476a893e2 conditionally adding mixed return type
With guidance from Remi Collet, use ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_EX macro, and use a conditional to fake that macro
for earlier php versions. Tested on 8.1 and 7.4, and deprecation notices gone plus all tests pass
2022-01-13 11:45:07 +11:00
Deanna Garcia
01f09b3425 Fixing bazel build failure 2022-01-13 00:29:28 +00:00
Deanna Garcia
7924cd6726 Addressing comments 2022-01-13 00:10:23 +00:00
Deanna Garcia
ab7cf573ab Remove unfinished release work and make names consistent 2022-01-12 21:58:46 +00:00
Deanna Garcia
dfd99e7ec0 Adding kotlin bazel tests 2022-01-12 21:54:30 +00:00
Elliotte Rusty Harold
c160ae52a9
remove Proto2MessageLiteInfoFactory and Proto3MessageLiteInfoFactory (#9407)
* remove Proto2MessageLiteInfoFactory.java=
* remove Proto3MessageLiteInfoFactory.java
2022-01-12 20:31:20 +00:00
Amin Vakil
f96050a05d
Add $(nproc) to make documentation (#9360) 2022-01-12 12:13:13 -08:00
Adam Cozzette
b3093dce58
Update CHANGES.txt to include recent Java security advisory (#9403) 2022-01-11 15:36:56 -08:00
Adam Cozzette
24a801287f
Merge pull request #9402 from acozzette/merge-3.19.x
Merge 3.19.x into master
2022-01-11 13:31:59 -08:00
Adam Cozzette
5bb34e9930 Merge branch '3.19.x' into merge-3.19.x 2022-01-11 18:07:17 +00:00
Adam Cozzette
49b184b163
Revert "Standardize on Array copyOf" (#9400)
This reverts commit 935d099ad9 from PR #9162.

While the original commit was a nice simplification, I learned from
another Googler that there is unfortunately a performance cost to this
(or at least there was last time this change was attempted). Even if it
turns out to be fast on modern Java runtimes, we still care about the
performance on old Android devices.
2022-01-11 08:47:10 -08:00
Adam Cozzette
cc7b1b5323 Update protobuf version 2022-01-10 18:08:15 -08:00
Adam Cozzette
ee432e55b8 Update CHANGES.txt for 3.19.3
The 3.19.2 release was supposed to fix the missing Python 3.10 wheel for
Windows, but this turned out to need some more fixes. This commit
updates CHANGES.txt to reflect that this fix will happen in 3.19.3
instead of 3.19.2.
2022-01-10 18:08:15 -08:00
Adam Cozzette
203c593b96 Fix build error with Python 3.10 build on Windows
The Windows build for Python 3.10 is giving us an error about ssize_t
being undefined, so this commit fixes the problem by replacing it with
Py_ssize_t, which is consistent with what we do elsewhere in the file.
2022-01-10 16:55:04 -08:00
Adam Cozzette
922a7ec189 Fix Python 3.10 C++ tests (#9128)
The first change is to make sure we always define PY_SSIZE_T_CLEAN
before including Python.h. Starting from Python 3.10 this is required.
Otherwise we get errors like this:

SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The second change is to update reflection_test.py to account for the
fact that with Python 3.10, we get a TypeError even with the C++
implementation when trying to assign a float to a bool field. I'm not
sure why this changed with Python 3.10, but it seems like a good thing
since this is the desired behavior anyway.
2022-01-10 16:55:04 -08:00
Brett McBride
558d128fc7 require bcmath
bcmath (specifically, the bccomp function) is internally required, and tests fail if it's not available
2022-01-10 11:28:45 +11:00
Gregory Haskins
3d995aaf98
Update protojure link (#9389) 2022-01-09 15:14:18 +00:00
Elliotte Rusty Harold
0ac74b8126
turn on animal-sniffer (#9383)
* turn on animal-sniffer
* allow API level 19 for util package
2022-01-07 23:45:21 +00:00
Elliotte Rusty Harold
c7808a87fa
restore even more Android API level 14 compatibility (#9388) 2022-01-07 21:27:07 +00:00
Elliotte Rusty Harold
864aa49c6d
restore Android API level 14 compatibility (#9386) 2022-01-07 20:08:45 +00:00
Elliotte Rusty Harold
d8ccfbf005
Revert "Transition to NIO StandardCharsets" (#9382) 2022-01-07 18:19:51 +00:00
Elliotte Rusty Harold
ee648b76a7
Update, fix, or delete an assortment of broken links (#9381)
* fix a few broken links and remove some dead ones

* new github repo
2022-01-07 13:42:27 +00:00
Brett McBride
fabe73db6f adding return type hints to php ext 2022-01-07 23:12:46 +11:00
LINKIWI
50b0bed121
Set protoc binary file mode to 0555 in release archive (#9354) 2022-01-06 17:22:31 -08:00
Elliotte Rusty Harold
b73f78d32c
update GSON to 2.8.9 (#9367) 2022-01-05 21:23:54 +00:00
Thomas Van Lenten
c997582f7c Default two more of the options from env variables.
For build systems that don't allow someone to easily add in generator args,
support env variables for the values.

Most the bool env var support to a helper since it is used in three places now.
2022-01-05 15:42:49 -05:00
Adam Cozzette
cb46755e64 Tweak wording of CHANGES.txt 2022-01-05 10:05:11 -08:00
Adam Cozzette
eb94f17a8b Update protobuf version 2022-01-05 10:05:11 -08:00
Adam Cozzette
ea9a01a0f5 Update CHANGES.txt for 3.19.2 release 2022-01-05 10:05:11 -08:00
Adam Cozzette
9638a5e531 Improve performance of parsing unknown fields in Java (#9371)
Credit should go to @elharo for most of these Java changes--I am just
cherry-picking them from our internal codebase. The one thing I did
change was to give the UTF-8 validation tests their own Bazel test
target. This makes it possible to give the other tests a shorter
timeout, which is important for UnknownFieldSetPerformanceTest in
particular.
2022-01-05 10:05:11 -08:00
Adam Cozzette
0e02f95b87 Fix Ruby release build by pinning rake-compiler-dock version (#9372)
Our Ruby release build broke at some point in the past day or so, and I
strongly suspect it is due to a new version (1.2.0) of
rake-compiler-dock. This commit pins the version to 1.1.0 as a temporary
fix.
2022-01-05 10:05:11 -08:00
Adam Cozzette
c555c3dd14
Improve performance of parsing unknown fields in Java (#9371)
Credit should go to @elharo for most of these Java changes--I am just
cherry-picking them from our internal codebase. The one thing I did
change was to give the UTF-8 validation tests their own Bazel test
target. This makes it possible to give the other tests a shorter
timeout, which is important for UnknownFieldSetPerformanceTest in
particular.
2022-01-05 08:50:29 -08:00
Adam Cozzette
f681c8d9e6
Fix Ruby release build by pinning rake-compiler-dock version (#9372)
Our Ruby release build broke at some point in the past day or so, and I
strongly suspect it is due to a new version (1.2.0) of
rake-compiler-dock. This commit pins the version to 1.1.0 as a temporary
fix.
2022-01-05 08:26:20 -08:00
Brett McBride
c26b1c87d7 fixing php 8.1 deprecation warnings
php 8.1 is more strict, and raises some deprecation notices with existing protobuf code. Not all of the
deprecations can be fixed without dropping support for php7.x (eg, the 'mixed' type doesn't appear until
8.1, and union types until 8.0, but as an interim solution the 'ReturnTypeWillChange' attribute can be
used to suppress the notices. In passing, also be explicit about a cast from float to int in 'zigZagEncode64'
which 8.1 also complains about when running tests.
2022-01-05 16:06:40 +11:00
Elliotte Rusty Harold
b17c8ca979
fix spelling errors (#9368)
* fix spelling errors

* outter --> outer
2022-01-04 21:50:47 +00:00
Joshua Haberman
c4bb4c9206
Merge pull request #9216 from jtattermusch/pin_multibuild_manylinux1
Pin multibuild scripts to get manylinux1 wheels back
2022-01-03 08:57:58 -08:00
Jan Tattermusch
6f8d82c2b1 fixup linux python artifact build 2022-01-03 14:59:51 +01:00
Jan Tattermusch
ea60c9cb08 use manylinux2010 for python3.10 wheel on x86_64 2022-01-03 10:54:28 +01:00
Jan Tattermusch
7857b15afc pin multibuild, set MB_ML_VER explicitly 2022-01-03 10:46:05 +01:00
Jan Tattermusch
0906af9870 pin multibuild scripts to get manylinux1 wheels back 2022-01-03 10:46:05 +01:00
Adam Cozzette
9057466a7a
Merge pull request #9336 from acozzette/merge-3.18.x
Merge 3.18.x into 3.19.x
2021-12-23 09:58:38 -08:00
Adam Cozzette
9227f60f85 Merge branch '3.18.x' into merge-3.18.x 2021-12-22 23:04:07 +00:00
Adam Cozzette
1fe07f9ce2
Cherry-pick fix from #9311 into 3.18.x (#9320)
* Dropped Ruby 2.4 support for CI and releases.

* Removed Kokoro configs for old Ruby versions.

* Update Dockerfile to allow it to be rebuilt

Co-authored-by: Joshua Haberman <jhaberman@gmail.com>
2021-12-22 15:01:34 -08:00
deannagarcia
01e84b1293
Merge pull request #9333 from protocolbuffers/test_417622470
Project import generated by Copybara
2021-12-22 13:38:56 -08:00
Mike Kruskal
b79dbb7db0 Project import generated by Copybara
PiperOrigin-RevId: 417622470
2021-12-22 10:28:56 -08:00
Protobuf Team
8f6c3c6824 Project import generated by Copybara
PiperOrigin-RevId: 417821950
2021-12-22 08:04:25 -08:00
Jie Luo
cb1f49ae73
Cherry-pick Python 3.10 fix to 3.19.x (#9323) 2021-12-17 10:50:45 -08:00
Jie Luo
bb5094881c
Update python 3.10 install MD5 Sum (#9322)
https://www.python.org/downloads/release/python-3100/
2021-12-16 21:38:42 -08:00
deannagarcia
b360b9e388
Change toolchain includes (#9318)
This fixes path resolution failures when following `#include_next` directives in headers found from paths in `extra_compiler_flags`.
2021-12-16 15:07:05 -08:00
Jie Luo
911c940569
Fix python 10 install error 2021-12-16 14:14:45 -08:00
deannagarcia
338863f043
Merge pull request #9317 from protocolbuffers/fixWindowsBuilds
Change windows cross compile includes
2021-12-16 13:24:22 -08:00
Deanna Garcia
a16629667a Removing -I include to ensure there's only one system include 2021-12-16 21:16:08 +00:00
Thomas Van Lenten
41606730da Add space to fix error message formatting. 2021-12-16 15:51:39 -05:00
Elliotte Rusty Harold
a35c973b7f
remove unused test proto (#9298)
* remove unused test proto
2021-12-16 16:50:40 +00:00
Elliotte Rusty Harold
b10578c9e5
Merge pull request #9309 from protocolbuffers/elharo-patch-1
show less log junk from Maven
2021-12-16 15:51:09 +00:00
Joshua Haberman
de5eb0a3e3
Merge pull request #9311 from haberman/fix-ruby
Dropped Ruby 2.3 and 2.4 support for CI and releases.
2021-12-15 19:12:21 -08:00
Joshua Haberman
a7089254d1 Removed Kokoro configs for old Ruby versions. 2021-12-15 16:48:01 -08:00
Joshua Haberman
214180c5a2 Dropped Ruby 2.4 support for CI and releases. 2021-12-14 16:33:16 -08:00
Elliotte Rusty Harold
5711cab189
show less log junk from Maven
@perezd turn off de bugging messages such as

```
[DEBUG]   Imported: org.codehaus.plexus.configuration < plexus.core
```
2021-12-14 23:40:36 +00:00
Alisa
8c29dc2c4d
Fix broken max macro on Windows (#9273) 2021-12-14 08:45:13 -08:00
owentou
9e896e2e92
[CMAKE] protobuf::libprotoc and protobuf::protoc should be optional in legacy protobuf-module.cmake when crossing compiling. 2021-12-14 22:34:07 +08:00
Dane Harrigan
29b3d01572
Add protoc-gen-go-svc to options.md (#9280) 2021-12-07 16:47:05 -08:00
deannagarcia
88384c99ec
Merge pull request #9278 from protocolbuffers/fixWindowsBuilds
Add comma
2021-12-07 10:36:49 -08:00
Deanna Garcia
0fba541a69 Add comma 2021-12-04 00:33:05 +00:00
deannagarcia
4812107b9d
Merge pull request #9277 from protocolbuffers/fixWindowsBuilds
Change include directories
2021-12-03 16:07:04 -08:00
Deanna Garcia
88076658f1 Change includes 2021-12-03 23:25:36 +00:00
deannagarcia
3c0bc69033
Merge pull request #9276 from protocolbuffers/fixWindowsBuilds
Fixing windows builds
2021-12-03 10:49:09 -08:00
Deanna Garcia
a863972644 Fixing windows builds 2021-12-03 18:34:37 +00:00
Adam Cozzette
9a1d5dfa4b
Small tweaks to C# unit tests (#9271)
This change includes just a couple small tweaks:
- Keep line lengths under 80 characters
- Fully qualify google::protobuf::Any so that the code still compiles
  internally where we use a different namespace.
2021-11-30 11:24:50 -08:00
Jan Tattermusch
b79ac0e6e2
Merge pull request #9182 from JamesNK/jamesnk/trimming-take3
[C#] Fix trim warnings
2021-11-30 11:57:56 +01:00
deannagarcia
d69e482e5a
Merge pull request #9267 from protocolbuffers/protocNaming
No error throwing for unknown OS
2021-11-29 16:24:27 -08:00
Deanna Garcia
667d5e9e9f No error throwing for unknown OS 2021-11-29 23:54:09 +00:00
Elliotte Rusty Harold
473ff00de3
Merge pull request #9266 from elharo/utf8utils
remove UTF8Utils class that hasn't been needed since Java 6
2021-11-29 17:57:49 -05:00
Elliotte Rusty Harold
278dfb2496 remove UTF8Utils class that hasn't been needed since Java 6 2021-11-29 16:07:20 -05:00
Elliotte Rusty Harold
19eaec02e1
delete unused files (#9262)
* delete unused files
* update Makefile
2021-11-29 17:31:46 +00:00
deannagarcia
f2ffe4fbef
Merge pull request #9252 from protocolbuffers/protocNaming
Name protoc artifacts by their cpu and os
2021-11-24 15:00:57 -08:00
Deanna Garcia
7d9c9ebd5d Add error throwing 2021-11-24 22:59:57 +00:00
Adam Cozzette
1ced82f8fd
Use C++11 integer types and fully qualify std::string (#9253) 2021-11-24 14:59:57 -08:00
Adam Cozzette
bf481851d8
Remove unused includes from unit tests (#9251) 2021-11-24 14:00:20 -08:00
Deanna Garcia
e4e26dfdf7 Name protoc artifacts by their cpu and os 2021-11-24 21:27:54 +00:00
deannagarcia
4eb8840544
Merge pull request #9250 from protocolbuffers/fixingBuilds
Adding windows toolchains
2021-11-24 12:37:34 -08:00
Deanna Garcia
b9e31eaa9d merging 2021-11-24 19:50:44 +00:00
Deanna Garcia
73c57034aa Adding windows toolchains 2021-11-24 19:48:16 +00:00
deannagarcia
61e0395c89
Merge pull request #9244 from protocolbuffers/deannagarcia-patch-2
Update toolchains.bazelrc
2021-11-22 13:13:40 -08:00
deannagarcia
221169d2ac
Update toolchains.bazelrc
One more darwin->osx rewrite.
2021-11-22 11:10:44 -08:00
deannagarcia
8f034a8d77
Merge pull request #9243 from protocolbuffers/deannagarcia-patch-2
Update BUILD
2021-11-22 10:45:27 -08:00
deannagarcia
3ad04bd4d9
Update BUILD
Change darwin to osx in two more places.
2021-11-22 10:40:37 -08:00
deannagarcia
ed10979c5e
Merge pull request #9242 from protocolbuffers/deannagarcia-patch-2
Update BUILD
2021-11-22 10:18:59 -08:00
deannagarcia
a49dbd73d6
Update BUILD
Change all the instances of "darwin" to "osx" to be consistent.
2021-11-22 10:14:26 -08:00
Thomas Van Lenten
6af72f96c5
Merge pull request #9234 from thomasvl/expect_prefix_for_no_package
Support no_package:FILE in the expected prefixes file.
2021-11-22 11:07:53 -05:00
Thomas Van Lenten
ba5eb3a7e9
Merge pull request #9233 from thomasvl/package_as_prefix_prefix
Add a envvar to provide a prefix on all proto package prefixed symbols.
2021-11-22 11:07:39 -05:00
Thomas Van Lenten
ef9b7036e7 Support no_package:FILE in the expected prefixes file.
When a file doesn't have a proto package, allow validation to still be supported
via entries with that consist of 'no_package:FILE'. This allows someone using an
expected prefixes file to also list these exceptional cases, and allows them to
becomes error cases with requiring all prefixes to be registered.
2021-11-22 11:01:43 -05:00
Thomas Van Lenten
f7a58bb060 Add a envvar to provide a prefix on all proto package prefixed symbols.
While at it, fix a header comment.
2021-11-22 09:43:43 -05:00
deannagarcia
93f7659565
Merge pull request #9235 from protocolbuffers/fixingBuilds
Change sysroot flags
2021-11-19 15:41:12 -08:00
Deanna Garcia
8608ee97da Change sysroot flags 2021-11-19 22:56:15 +00:00
James Newton-King
22462b0c52
Fix trim warnings 2021-11-17 14:01:25 +13:00
deannagarcia
edc8a31828
Merge pull request #9227 from protocolbuffers/deannagarcia-patch-2
Update include directories
2021-11-16 16:10:06 -08:00
deannagarcia
6cc68c5c59
Update include directories
Add /usr/local/include to cpp builtin include directories.
2021-11-16 16:01:15 -08:00
deannagarcia
840a4f721d
Merge pull request #9226 from protocolbuffers/deannagarcia-patch-2
Update BUILD
2021-11-16 15:18:20 -08:00
deannagarcia
25c818e3f1
Update BUILD
Change sysroot to be specific to the folder where all the include files are.
2021-11-16 15:15:46 -08:00
deannagarcia
be9fba9fd1
Merge pull request #9224 from protocolbuffers/deannagarcia-patch-2
Update BUILD paths
2021-11-16 13:08:00 -08:00
deannagarcia
a162273515
Update BUILD paths
Update paths for apple sdks
2021-11-16 11:38:16 -08:00
Jan Tattermusch
845db63ced
Fix dotnet aarch64 (#9222)
* fix C# aarch64 test after .NET SDK upgrade

* simplify C# aarch64 tests (net60 can build under emulator)

* Revert "simplify C# aarch64 tests (net60 can build under emulator)"

This reverts commit 6b2aa5f006.
2021-11-16 09:26:30 -08:00
Jan Tattermusch
83641bd36e
Merge pull request #8466 from JamesNK/jamesnk/nuget-package-update
Fix .NET SourceLink and warnings in NuGet package
2021-11-15 09:52:42 +01:00
deannagarcia
cc411dcdf8
Merge pull request #9217 from protocolbuffers/deannagarcia-patch-2
Update BUILD paths
2021-11-12 16:08:26 -08:00
deannagarcia
76f57fd6df
Update BUILD paths
Prefix all tools paths with /root/
2021-11-12 16:06:54 -08:00
deannagarcia
e75207f009
Merge pull request #9214 from protocolbuffers/fixCppVersion
Changing cpp version back to 8
2021-11-12 12:55:43 -08:00
James Newton-King
4c09e43f74
Fix .NET SourceLink and warnings in NuGet package 2021-11-13 07:46:20 +13:00
Jan Tattermusch
0ca4c1a768
Merge pull request #9205 from JamesNK/jamesnk/dotnet-sdk-update
[C#] Update .NET SDKs to LTS versions
2021-11-12 14:20:47 +01:00
Jan Tattermusch
7569df0f58 add NuGet.config to Makefile.am 2021-11-12 11:22:19 +01:00
James Newton-King
c685d79368
Fix test 2021-11-12 12:57:47 +13:00
James Newton-King
90afe0cfc6
Add nuget.config 2021-11-12 12:38:05 +13:00
Deanna Garcia
627bb4b60e Changing cpp version back to 8 2021-11-11 19:30:49 +00:00
tomerv
47e05427e3
Fix typo in docstring (#9208) 2021-11-10 17:03:55 -08:00
Rose
ef1c9fd907
[C++] Fix missing #ifdef for undefined identifiers (#9201)
* Fix #if for undefined identifiers

* port_undef.inc
2021-11-10 16:37:03 -08:00
deannagarcia
d5b7f705f3
Merge pull request #9210 from protocolbuffers/osxToolchain
Creating bazel toolchains to compile for macOS.
2021-11-10 13:54:30 -08:00
Deanna Garcia
97c901cfb6 Fixing formatting 2021-11-10 21:27:20 +00:00
Deanna Garcia
a5fa4fb019 Creating bazel toolchains to compile for macOS. 2021-11-10 21:12:44 +00:00
James Newton-King
0f33dc4380
Fix tests 2021-11-10 09:02:28 +13:00
James Newton-King
aa15931050
Update .NET SDKs to LTS versions 2021-11-10 08:49:53 +13:00
Oliver Eikemeier
d37dcf9e34
remove unnecessary dependency (#9195)
Signed-off-by: Oliver Eikemeier <eikemeier@fillmore-labs.com>
2021-11-09 05:20:11 -08:00
Adam Cozzette
13d559beb6
Update our build script to publish Mac aarch_64 binaries (#9203)
These are still x86-64 binaries at the moment (see #8557), but should be
usable on M1 Macs in the Rosetta compatibility mode. Let's start
publishing them on our GitHub release page and then eventually we can
make them into true aarch_64 binaries.

This fixes #9200.
2021-11-08 13:40:52 -08:00
Derek Perez
3a4d9316aa
Creates a protoc release zip (#9188)
* Creates a protoc release zip

Mimics what we're doing manually today but powered by Bazel.

* don't special case this.

* Addressing feedback.

* adding comment about _cc_toolchain
2021-11-04 15:57:29 -07:00
Xùdōng Yáng
11de748d66
Use repo-relative labels wherever possible (#9187)
* Use repo-relative labels wherever possible

The label `@com_google_protobuf//:foo` within the protobuf repo is often synonymous with just `//:foo`. We should prefer the latter as it allows us to use a shorter name for the module in the Bazel Central Registry (so just "protobuf" instead of "com_google_protobuf").

Note that the semantics can be subtle: in a macro, plain strings are anchored to the *calling* repo, so if we just use `//:foo` as the default value of a macro argument, it will be resolved to `@myrepo//:foo` if the macro is called from the repo `@myrepo`. In this case, it's necessary to directly call the `Label()` constructor to anchor the string label to the repo where the .bzl file lives.

See https://github.com/bazelbuild/bazel-central-registry/pull/28#issuecomment-954741081 for a bit more context.

* fix protobuf_deps.bzl
2021-11-04 07:56:32 -07:00
Kent Ross
d88c8d5d4b
Implement unambiguous comparisons for RepeatedPtrIterator in C++20 (#9139) 2021-11-04 07:16:02 -07:00
Adam Cozzette
7ccf4d8f67
Merge pull request #9169 from protocolbuffers/3.19.x
Merge 3.19.x into master
2021-11-02 10:10:47 -07:00
JongChan Choi
c4c7e2b8f9
Add pbkit to third_party.md (#9177) 2021-11-01 13:53:04 -07:00
Adam Cozzette
6a9cf18cba
Fix benchmark by making sure we use Python 3 (#9170)
The benchmark runs have been failing since we started requiring Python
3, so this changes fixes the benchmarks by ensuring we always use Python
3.
2021-11-01 09:00:31 -07:00
Thomas Hisch
26603a1466
Remove unittest2 imports (#9171)
They were only needed for python versions <= 2.6

Related: #6658
2021-10-30 11:56:40 -07:00
Elliotte Rusty Harold
201c1fc918
Merge pull request #9162 from belugabehr/ArrayList-copyof
Standardize on Array copyOf
2021-10-29 11:51:56 +00:00
deannagarcia
85c4bc4205
Merge pull request #8254 from jufemaiz/feature/ruby-better-from_-support-well_known_types
Improvement: better ruby from_* support in well_known_types.rb
2021-10-27 14:13:27 -07:00
Joel Courtney
bbdcea8547
Remove lib from require 2021-10-28 07:09:11 +11:00
Chris Bainbridge
65852d6e9c
Fix comment syntax in any.proto (#8792)
* Fix comment syntax in any.proto

Remove extra spaces which cause incorrect indentation in godoc.
Remove the "====" style title which is not rendered by godoc.

* Run ./generate_descriptor_proto.sh
2021-10-27 11:28:21 -07:00
appledragon
1d2e8d9302
for old clang build issue, related with https://reviews.llvm.org/D12375 (#9159)
This seems wrong: given [[foo]] [[bar]], we'll now parse the second one as an MS attribute in a context where both are allowed.
2021-10-27 09:45:42 -07:00
David Mollitor
935d099ad9 Standardize on Array copyOf 2021-10-27 11:08:33 -04:00
Joel Courtney
4d94a7cd93 Fixed: incorrect tests 2021-10-27 22:20:45 +11:00
Adam Cozzette
9c3af64ae4
Update checked-in C# generated code (#9158)
This change fixes the test that verifies that the checked-in generated
code for descriptor.proto is up to date.
2021-10-26 14:31:46 -07:00
deannagarcia
247649cdb0
Merge pull request #9150 from Shopify/pz-message-encode-mem-leak
[Ruby] Fix memory leak in MessageClass.encode
2021-10-26 13:01:52 -07:00
Marnix Bouhuis
e350ef8c20
JS: Fixed ReferenceError: window is not defined when getting the global object (#9156) 2021-10-26 09:48:47 -07:00
Joel Courtney
947a51a464 Test coverage: .from_ruby / #from_ruby 2021-10-26 12:43:57 +11:00
Elliotte Rusty Harold
b3b3162219
Merge pull request #9148 from belugabehr/nio-charsets
Transition to NIO StandardCharsets
2021-10-25 21:44:38 +00:00
deannagarcia
d630f96dce
Merge pull request #9144 from appledragon/master
for windows build fail issue, confliction with std max
2021-10-25 14:30:45 -07:00
Dennis Shao
2007a39db0
Merge pull request #9151 from Inconnu08/patch-1
Fix grammatical error in the descriptor protobuf definition
2021-10-25 15:46:36 -05:00
Taufiq Rahman
84c2e1e502
Fix grammatical error in comments #7603 2021-10-26 02:09:13 +06:00
Peter Zhu
3a18299cc0 Fix memory leak in MessageClass.encode
If the line above raises an exception, the upb_arena is lost and memory
is leaked.
2021-10-25 15:55:12 -04:00
David Mollitor
3370cc4456 Transition to NIO StandardCharsets 2021-10-25 13:46:34 -04:00
appledragon
02d2e5fdd7
Update stl_util.h 2021-10-25 15:31:06 +08:00
Nipunn Koorapati
0707f2e7f5
Provide a type alias field ValueType on EnumTypeWrapper (#8182)
This should provide a runtime alias, which can be
used in mypy stubs to provide better typing for enum values

Fixes #8175
2021-10-21 15:09:41 -07:00
Derek Perez
adc1f931e3
Fix wkt dupes (#8942)
* properly ignore WKTs in lang_proto_toolchain for java

We already pre-compile the well known types into the runtimes so they shouldn't be re-compiled. #8925

* remove accidental proto addition.
2021-10-21 14:17:20 -07:00
Adam Cozzette
f4af0bc931
Fix distcheck test by updating example Go file paths (#9137) 2021-10-21 14:15:54 -07:00
Damien Neil
c8dfe32b5a
examples: update Go example (#7217)
Update the Go example to use Go modules: Move the example into a
directory containing a go.mod file, change the installation instructions
to use "go install".

Update the go_package option in addressbook.proto to an actual module path.

Update examples to use the google.golang.org/protobuf/proto module.
2021-10-21 13:27:40 -07:00
Adam Cozzette
42db8a3f96
Make IsDescriptor* helpers lenient about descriptor name (#9127)
Our internal version of the codebase has a different path and package
name for descriptor.proto, so this change updates IsDescriptorProto()
and IsDescriptorOptionMessage() to be able to handle both the internal
and external descriptor types.
2021-10-21 11:47:05 -07:00
Adam Cozzette
e6430dd4a0
Merge pull request #9136 from protocolbuffers/3.19.x
Merge 3.19.x into master
2021-10-21 11:45:51 -07:00
Upils
1e1c1cd884
Reserve extension id range for protoc-gen-checker (#9133) 2021-10-21 08:24:38 -07:00
Adam Cozzette
63f952b987
Fix Python 3.10 C++ tests (#9128)
The first change is to make sure we always define PY_SSIZE_T_CLEAN
before including Python.h. Starting from Python 3.10 this is required.
Otherwise we get errors like this:

SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The second change is to update reflection_test.py to account for the
fact that with Python 3.10, we get a TypeError even with the C++
implementation when trying to assign a float to a bool field. I'm not
sure why this changed with Python 3.10, but it seems like a good thing
since this is the desired behavior anyway.
2021-10-20 14:51:07 -07:00
Joel Courtney
21478b371e
Update well_known_types_test.rb 2021-10-19 12:25:21 +11:00
Joel Courtney
e4ce58cd60
Merge branch 'master' into feature/ruby-better-from_-support-well_known_types 2021-10-17 22:58:15 +11:00
Masaki Hara
d08bc71c96
Suppress dot-delimiter warning if ruby_package consists of a single component (#7276) 2021-10-15 20:11:59 -07:00
Chris Povirk
62d59d7d4c
Update maven-surefire-plugin to 3.0.0-M5. (#7830)
This avoids https://issues.apache.org/jira/browse/SUREFIRE-1439,
which I hit while investigating
https://github.com/protocolbuffers/protobuf/issues/7827
2021-10-15 20:02:36 -07:00
Adam Cozzette
454778d011
Python: fix usages of deprecated assertRaisesRegxp (#9098)
assertRaisesRegexp has been deprecated in favor of the slightly
different spelling assertRaisesRegex. Let's fix this just to clean up a
bunch of deprecation warnings in the tests.
2021-10-15 19:00:04 -07:00
Adam Cozzette
d0a2c395e9
Merge pull request #9109 from protocolbuffers/3.18.x
Merge 3.18.x into master
2021-10-15 15:26:42 -07:00
deannagarcia
df5b7fabb8
Merge pull request #7498 from psobot/add-python-descriptor-debug-string
Add GetDebugString to Python FileDescriptor interface.
2021-10-15 15:03:02 -07:00
deannagarcia
6c0168bd65
Merge pull request #7016 from roehling/fix-6205-unknown-fields-integer-overflow
Prevent integer overflow for unknown fields in Python
2021-10-15 14:59:57 -07:00
Adam Cozzette
8a0aa4b372
Update Mac test runs to download RVM directly from GitHub (#9107)
Our Mac test runs recently started failing to download RVM. The issue
appears to be a combination of an SSL certificate expiring and old
OpenSSL versions having a bug preventing them from validating the
replacement certificate: https://github.com/rvm/rvm/issues/5133

This commit works around the problem by downloading RVM from GitHub as
suggested in one of the comments on the issue above.
2021-10-15 14:41:59 -07:00
Adam Cozzette
f367bfb13d
Use dedicated helper functions for map descriptors (#9099)
The Descriptor class now has map_key() and map_value() methods for
accessing the special key and value fields in generated map entry
messages. This commit updates all the relevant code to use these
accessors instead of the clunkier FindFieldByName("key") or
FindFieldByName("value") approach.
2021-10-15 14:26:54 -07:00
Peter Sobot
ef0bd1343b Only run GetDebugString test with cpp impl. 2021-10-15 11:39:21 -04:00
Timo Röhling
5100be2b77 Prevent integer overflow for unknown fields
The PyInt_FromLong() conversion function will truncate 64 bit integer
values on 32 bit architectures. We will now use the PyLong_* functions
with the appropriate minimum size for each field.

Note that this commit also switches to the unsigned versions, since the
unknown integer fields have been declared unsigned anyway.

Fixes #6205
2021-10-14 23:30:01 +02:00
Peter Sobot
4e176f29b4 Added GetDebugString to Python FileDescriptor interface. 2021-10-14 16:51:22 -04:00
Joel Courtney
ef70acbc03 Improvement: better ruby from_* support in well_known_types.rb
* Added capability to support from_* requests properly by adding class methods and returning self for instance methods
    * `Timestamp.from_time`
    * `Value.from_ruby`
2021-02-03 12:49:20 +11:00
1475 changed files with 89120 additions and 129673 deletions

View File

@ -16,7 +16,7 @@ Stack Overflow is also a useful if unofficial resource https://stackoverflow.com
-->
**What version of protobuf and what language are you using?**
Version: master/v3.6.0/v3.5.0 etc.
Version: main/v3.6.0/v3.5.0 etc.
Language: C++/Java/Python/C#/Ruby/PHP/Objective-C/Javascript
**What operating system (Linux, Windows, ...) and version?**

View File

@ -9,10 +9,10 @@ mergeable:
- and:
- must_include:
regex: 'release notes: yes'
message: 'Please include release notes: yes'
message: 'Include release notes: yes'
- must_include:
regex: '^(autotools|bazel|c#|c\+\+|cleanup|cmake|conformance tests|integration|go|java|javascript|objective-c|php|protoc|python|ruby|kotlin)'
message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: autotools, bazel, cmake, cleanup, conformance tests, integration, protoc.'
message: 'at least a language label (e.g., c++, java, python). Or apply one of the following labels: autotools, bazel, cmake, cleanup, conformance tests, integration, protoc.'
- must_include:
regex: 'release notes: no'
message: 'Please include release notes: no'
message: 'Include release notes: no'

View File

@ -13,4 +13,4 @@ jobs:
with:
check_filenames: true
skip: ./.git,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal,./.github/workflows/codespell.yml
ignore_words_list: "alow,alse,ba,cleare,copyable,cloneable,dedup,dur,errorprone,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,sur"
ignore_words_list: "alow,alse,ba,cleare,copyable,cloneable,dedup,dur,errorprone,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,streem,sur"

36
.github/workflows/objc_cocoapods.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: 'ObjC CocoaPods'
on:
push:
paths:
- '.github/workflows/objc_cocoapods.yml'
- 'Protobuf.podspec'
- 'objectivec/**'
- '!objectivec/DevTools/**'
- '!objectivec/ProtocolBuffers_*.xcodeproj/**'
- '!objectivec/Tests/**'
pull_request:
paths:
- '.github/workflows/objc_cocoapods.yml'
- 'Protobuf.podspec'
- 'objectivec/**'
- '!objectivec/DevTools/**'
- '!objectivec/ProtocolBuffers_*.xcodeproj/**'
- '!objectivec/Tests/**'
jobs:
pod-lib-lint:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
PLATFORM: ["ios", "macos", "tvos", "watchos"]
CONFIGURATION: ["Debug", "Release"]
steps:
- uses: actions/checkout@v2
- name: Pod lib lint
run: |
pod lib lint --verbose \
--configuration=${{ matrix.CONFIGURATION }} \
--platforms=${{ matrix.PLATFORM }} \
Protobuf.podspec

43
.github/workflows/php-ext.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: PHP extension
on:
- push
- pull_request
jobs:
build-php:
name: Build PHP extension
runs-on: ubuntu-latest
container: ${{ matrix.php-image }}
strategy:
matrix:
php-image:
- php:7.4-cli
- php:8.1-cli
steps:
- name: Install git
run: |
apt-get update -q
apt-get install -qy --no-install-recommends git
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Prepare source code
run: |
rm -rf "$GITHUB_WORKSPACE/php/ext/google/protobuf/third_party"
cp -r "$GITHUB_WORKSPACE/third_party" "$GITHUB_WORKSPACE/php/ext/google/protobuf"
cp "$GITHUB_WORKSPACE/LICENSE" "$GITHUB_WORKSPACE/php/ext/google/protobuf"
- name: Create package
run: |
cd /tmp
rm -rf protobuf-*.tgz
pecl package "$GITHUB_WORKSPACE/php/ext/google/protobuf/package.xml"
- name: Compile extension
run: |
cd /tmp
MAKE="make -j$(nproc)" pecl install protobuf-*.tgz
- name: Enable extension
run: docker-php-ext-enable protobuf
- name: Inspect extension
run: php --ri protobuf

31
.gitignore vendored
View File

@ -9,6 +9,7 @@ depcomp
install-sh
ltmain.sh
missing
configure~
aclocal.m4
m4/libtool.m4
@ -46,7 +47,7 @@ src/.libs
any_test.pb.*
map*unittest.pb.*
unittest*.pb.*
cpp_test*.pb.*
src/google/protobuf/compiler/cpp/test*.pb.*
src/google/protobuf/util/**/*.pb.cc
src/google/protobuf/util/**/*.pb.h
@ -89,6 +90,10 @@ java/**/*.iml
# Windows native output.
cmake/build
build_msvc
# Directories suggested by cmake/README.md
/debug/
/solution/
/release/
# NuGet packages: we want the repository configuration, but not the
# packages themselves.
@ -164,21 +169,6 @@ php/ext/google/protobuf/run-tests.php
php/ext/google/protobuf/third_party/
vendor/
# JavaScript artifacts
js/commonjs_out/
js/compatibility_tests/v3.0.0/commonjs_out*
js/compatibility_tests/v3.0.0/protoc
js/compatibility_tests/v3.0.0/testproto_libs1.js
js/compatibility_tests/v3.0.0/testproto_libs1_new.js
js/compatibility_tests/v3.0.0/testproto_libs2.js
js/compatibility_tests/v3.0.0/testproto_libs2_new.js
js/deps.js
js/google-protobuf.js
js/google/
js/node_modules/
js/testproto_libs1.js
js/testproto_libs2.js
# Ignore the bazel symlinks
/bazel-*
@ -215,5 +205,14 @@ _build/
.idea
*.iml
# Eclipse
**/.settings
**/.project
**/.classpath
# BenchmarkDotNet
BenchmarkDotNet.Artifacts/
# Clangd uses these common ephemeral files
.cache
compile_commands.json

1
.gitmodules vendored
View File

@ -1,6 +1,7 @@
[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://github.com/google/benchmark.git
ignore = dirty
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git

29
Aurora.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "protobuf",
"type": "generic",
"sources": ["src/google/protobuf/**.cc",
"src/google/protobuf/**.h",
"src/google/protobuf/**.inc"],
"excludes": [
"**/*_test*.*",
"**/*test*.*",
"**/testing/**",
"**/*unittest.*",
"**/mock*.*"
],
"includes": "src/",
"actions": [
{
"filter": {
"platforms": "win32"
},
"then": {
"defines": [
"PROTOBUF_FUCK_GOOGLE_IVE_YET_TO_SEE_ONE_GOOGLE_PRODUCT_THAT_BUILDS_ON_THEIR_SUPPORED_PLATFORMS",
"PROTOBUF_CONSTINIT_FORCE=",
"PROTOBUF_CONSTEXPR_FORCE=constexpr"
]
}
}
]
}

1349
BUILD

File diff suppressed because it is too large Load Diff

521
BUILD.bazel Normal file
View File

@ -0,0 +1,521 @@
# Bazel (https://bazel.build/) BUILD file for Protobuf.
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS", "PROTOC_LINK_OPTS")
load(":protobuf.bzl", "py_proto_library")
licenses(["notice"])
exports_files(["LICENSE"])
################################################################################
# Well Known Types Proto Library Rules
#
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
################################################################################
# These proto_library rules can be used with one of the language specific proto
# library rules i.e. java_proto_library:
#
# java_proto_library(
# name = "any_java_proto",
# deps = ["@com_google_protobuf//:any_proto"],
# )
################################################################################
alias(
name = "any_proto",
actual = "//src/google/protobuf:any_proto",
visibility = ["//visibility:public"],
)
alias(
name = "api_proto",
actual = "//src/google/protobuf:api_proto",
visibility = ["//visibility:public"],
)
alias(
name = "duration_proto",
actual = "//src/google/protobuf:duration_proto",
visibility = ["//visibility:public"],
)
alias(
name = "empty_proto",
actual = "//src/google/protobuf:empty_proto",
visibility = ["//visibility:public"],
)
alias(
name = "field_mask_proto",
actual = "//src/google/protobuf:field_mask_proto",
visibility = ["//visibility:public"],
)
alias(
name = "source_context_proto",
actual = "//src/google/protobuf:source_context_proto",
visibility = ["//visibility:public"],
)
alias(
name = "struct_proto",
actual = "//src/google/protobuf:struct_proto",
visibility = ["//visibility:public"],
)
alias(
name = "timestamp_proto",
actual = "//src/google/protobuf:timestamp_proto",
visibility = ["//visibility:public"],
)
alias(
name = "type_proto",
actual = "//src/google/protobuf:type_proto",
visibility = ["//visibility:public"],
)
alias(
name = "wrappers_proto",
actual = "//src/google/protobuf:wrappers_proto",
visibility = ["//visibility:public"],
)
# Source files: these are aliases to a filegroup, not a `proto_library`.
#
# (This is _probably_ not what you want.)
alias(
name = "lite_well_known_protos",
actual = "//src/google/protobuf:well_known_type_protos", # filegroup
visibility = ["//visibility:public"],
)
alias(
name = "well_known_type_protos",
actual = "//src/google/protobuf:well_known_type_protos", # filegroup
visibility = ["//visibility:public"],
)
# Built-in runtime protos: these are part of protobuf's internal
# implementation, but are not Well-Known Types.
alias(
name = "descriptor_proto",
actual = "//src/google/protobuf:descriptor_proto", # proto_library
visibility = ["//visibility:public"],
)
alias(
name = "descriptor_proto_srcs",
actual = "//src/google/protobuf:descriptor_proto_srcs", # filegroup
visibility = ["//visibility:public"],
)
alias(
name = "compiler_plugin_proto",
actual = "//src/google/protobuf/compiler:plugin_proto", # proto_library
visibility = ["//visibility:public"],
)
cc_library(
name = "cc_wkt_protos",
deprecation = "Only for backward compatibility. Do not use.",
visibility = ["//visibility:public"],
)
# Source protos that are typically part of the protobuf runtime.
#
# DEPRECATED: Prefer :well_known_type_protos for the Well-Known Types
# (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf)
# or :descriptor_proto(_srcs) for descriptor.proto (source), or
# :compiler_plugin_proto for compiler/plugin.proto.
filegroup(
name = "well_known_protos",
srcs = [
":descriptor_proto_srcs",
":well_known_type_protos",
"//src/google/protobuf/compiler:plugin.proto",
],
deprecation = "Prefer :well_known_type_protos instead.",
visibility = ["//visibility:public"],
)
################################################################################
# Protocol Buffers Compiler
################################################################################
cc_binary(
name = "protoc",
linkopts = LINK_OPTS + PROTOC_LINK_OPTS,
visibility = ["//visibility:public"],
deps = ["//src/google/protobuf/compiler:protoc_lib"],
)
################################################################################
# C++ runtime
################################################################################
# The "lite" runtime works for .proto files that specify the option:
# optimize_for = LITE_RUNTIME;
#
# The lite runtime does not include the `Reflection` APIs (including
# `Descriptor` and related types) or Well-Known Types.
#
# See also:
# https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#message
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
alias(
name = "protobuf_lite",
actual = "//src/google/protobuf:protobuf_lite",
visibility = ["//visibility:public"],
)
cc_library(
name = "protobuf",
hdrs = glob([
"src/**/*.h",
"src/**/*.inc",
]),
copts = COPTS,
include_prefix = "google/protobuf/io",
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [
"//src/google/protobuf",
"//src/google/protobuf/compiler:importer",
"//src/google/protobuf/util:delimited_message_util",
"//src/google/protobuf/util:differencer",
"//src/google/protobuf/util:field_mask_util",
"//src/google/protobuf/util:json_util",
"//src/google/protobuf/util:time_util",
"//src/google/protobuf/util:type_resolver_util",
],
)
# This provides just the header files for use in projects that need to build
# shared libraries for dynamic loading. This target is available until Bazel
# adds native support for such use cases.
# TODO(keveman): Remove this target once the support gets added to Bazel.
alias(
name = "protobuf_headers",
actual = "//src/google/protobuf:protobuf_headers",
visibility = ["//visibility:public"],
)
################################################################################
# Java support
################################################################################
alias(
name = "protobuf_java",
actual = "//java/core",
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_javalite",
actual = "//java/lite",
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_java_util",
actual = "//java/util",
visibility = ["//visibility:public"],
)
alias(
name = "java_toolchain",
actual = "//java/core:toolchain",
visibility = ["//visibility:public"],
)
alias(
name = "javalite_toolchain",
actual = "//java/lite:toolchain",
visibility = ["//visibility:public"],
)
################################################################################
# Python support
################################################################################
alias(
name = "protobuf_python",
actual = "//python:protobuf_python",
visibility = ["//visibility:public"],
)
alias(
name = "python_srcs",
actual = "//python:python_srcs",
visibility = ["@upb//:__subpackages__"],
)
alias(
name = "python_test_srcs",
actual = "//python:python_test_srcs",
visibility = ["@upb//:__subpackages__"],
)
alias(
name = "well_known_types_py_pb2",
actual = "//python:well_known_types_py_pb2",
visibility = ["@upb//:__subpackages__"],
)
alias(
name = "python_common_test_protos",
actual = "//python:python_common_test_protos",
visibility = ["//visibility:public"],
)
alias(
name = "python_specific_test_protos",
actual = "//python:python_specific_test_protos",
visibility = ["//visibility:public"],
)
proto_lang_toolchain(
name = "cc_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--cpp_out=$(OUT)",
runtime = ":protobuf",
visibility = ["//visibility:public"],
)
alias(
name = "objectivec",
actual = "//objectivec",
tags = ["manual"],
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_objc",
actual = "//objectivec",
tags = ["manual"],
visibility = ["//visibility:public"],
)
################################################################################
# Test protos
################################################################################
alias(
name = "lite_test_protos",
actual = "//src/google/protobuf:lite_test_protos", # proto_library
visibility = ["//:__subpackages__"],
)
alias(
name = "test_proto_srcs",
actual = "//src/google/protobuf:test_proto_srcs", # filegroup
visibility = ["//:__subpackages__"],
)
alias(
name = "test_protos",
actual = "//src/google/protobuf:test_protos", # proto_library
visibility = ["//:__subpackages__"],
)
# Validate generated proto source inputs:
genrule(
name = "generated_protos",
testonly = 1,
srcs = ["//src/google/protobuf:test_proto_srcs"],
outs = ["unittest_gen_import.proto"],
cmd = "cat src/google/protobuf/unittest_import.proto > $@",
)
proto_library(
name = "generated_protos_proto",
testonly = 1,
srcs = [":generated_protos"],
deps = ["//src/google/protobuf:generic_test_protos"],
)
py_proto_library(
name = "generated_protos_py",
testonly = 1,
srcs = [":generated_protos"],
default_runtime = "",
protoc = ":protoc",
deps = ["//python:python_common_test_protos"],
)
################################################################################
# Conformance tests
################################################################################
alias(
name = "conformance_test_runner",
actual = "//conformance:conformance_test_runner",
visibility = ["//visibility:public"],
)
alias(
name = "test_messages_proto2_proto",
actual = "//src/google/protobuf:test_messages_proto2_proto", # proto_library
visibility = ["//visibility:public"],
)
alias(
name = "test_messages_proto3_proto",
actual = "//src/google/protobuf:test_messages_proto3_proto", # proto_library
visibility = ["//visibility:public"],
)
# TODO: re-enable this test if appropriate, or replace with something that
# uses the new setup.
# sh_test(
# name = "build_files_updated_unittest",
# srcs = [
# "build_files_updated_unittest.sh",
# ],
# data = [
# "BUILD",
# "cmake/extract_includes.bat.in",
# "cmake/libprotobuf.cmake",
# "cmake/libprotobuf-lite.cmake",
# "cmake/libprotoc.cmake",
# "cmake/tests.cmake",
# "src/Makefile.am",
# "update_file_lists.sh",
# ],
# )
java_proto_library(
name = "test_messages_proto2_java_proto",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto2_proto"],
)
java_proto_library(
name = "test_messages_proto3_java_proto",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto3_proto"],
)
java_lite_proto_library(
name = "test_messages_proto2_java_proto_lite",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto2_proto"],
)
java_lite_proto_library(
name = "test_messages_proto3_java_proto_lite",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto3_proto"],
)
filegroup(
name = "bzl_srcs",
srcs = glob(["**/*.bzl"]),
visibility = ["//visibility:public"],
)
################################################################################
# Packaging rules
################################################################################
# Files included in all source distributions
pkg_files(
name = "common_dist_files",
srcs = glob(
[
"*.bzl",
"cmake/*.cmake",
"cmake/*.in",
"editors/*",
# Several of these files are generated by autogen.sh, so using
# glob() lets us ignore them if they are missing. (This is not good
# practice, though.)
"Makefile.in",
"aclocal.m4",
"ar-lib",
"compile",
"config*",
"depcomp",
"install-sh",
"ltmain.sh",
"m4/*.m4",
"missing",
"protobuf*.pc.in",
"test-driver",
],
allow_empty = True,
) + [
"BUILD.bazel",
"CHANGES.txt",
"CMakeLists.txt",
"CONTRIBUTORS.txt",
"LICENSE",
"Makefile.am",
"README.md",
"WORKSPACE",
"autogen.sh",
"build_files_updated_unittest.sh",
"cmake/CMakeLists.txt",
"cmake/README.md",
"generate_descriptor_proto.sh",
"maven_install.json",
"update_file_lists.sh",
"//third_party:BUILD.bazel",
"//third_party:zlib.BUILD",
"//util/python:BUILD.bazel",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
# Additional files for C#
pkg_files(
name = "csharp_dist_files",
srcs = [
"global.json",
],
visibility = ["//pkg:__pkg__"],
)
# Additional files for ObjC
pkg_files(
name = "objectivec_dist_files",
srcs = [
"Protobuf.podspec",
],
visibility = ["//pkg:__pkg__"],
)

View File

@ -1,3 +1,336 @@
Unreleased version
* Handle reflection for message splitting.
* make metadata fields lazy.
* Extend visibility of plugin library to upb
* Modernize conformance_cpp.cc.
* Don't request 64-byte alignment unless the toolchain supports it.
2022-05-27 version 21.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++
* cmake: Revert "Fix cmake install targets (#9822)" (#10060)
* Remove Abseil dependency from CMake build (#10056)
Python
* Update python wheel metadata with more information incl. required python version (#10058)
* Fix segmentation fault when instantiating field via repeated field assignment (#10066)
2022-05-25 version 21.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++
* cmake: Call get_filename_component() with DIRECTORY mode instead of PATH mode (#9614)
* Escape GetObject macro inside protoc-generated code (#9739)
* Update CMake configuration to add a dependency on Abseil (#9793)
* Fix cmake install targets (#9822)
* Use __constinit only in GCC 12.2 and up (#9936)
Java
* Update protobuf_version.bzl to separate protoc and per-language java … (#9900)
Python
* Increment python major version to 4 in version.json for python upb (#9926)
* The C extension module for Python has been rewritten to use the upb library.
This is expected to deliver significant performance benefits, especially when
parsing large payloads. There are some minor breaking changes, but these
should not impact most users. For more information see:
https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
* Fixed win32 build and fixed str(message) on all Windows platforms. (#9976)
* The binary wheel for macOS now supports Apple silicon.
PHP
* [PHP] fix PHP build system (#9571)
* Fix building packaged PHP extension (#9727)
* fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)
* fix: phpdoc syntax for repeatedfield parameters (#9784)
* fix: phpdoc for repeatedfield (#9783)
* Change enum string name for reserved words (#9780)
* chore: [PHP] fix phpdoc for MapField keys (#9536)
* Fixed PHP SEGV by not writing to shared memory for zend_class_entry. (#9996)
Ruby
* Allow pre-compiled binaries for ruby 3.1.0 (#9566)
* Implement `respond_to?` in RubyMessage (#9677)
* [Ruby] Fix RepeatedField#last, #first inconsistencies (#9722)
* Do not use range based UTF-8 validation in truffleruby (#9769)
* Improve range handling logic of `RepeatedField` (#9799)
* Support x64-mingw-ucrt platform
Other
* [Kotlin] remove redundant public modifiers for compiled code (#9642)
* [C#] Update GetExtension to support getting typed value (#9655)
* Fix invalid dependency manifest when using `descriptor_set_out` (#9647)
* Fix C# generator handling of a field named "none" in a oneof (#9636)
* Add initial version.json file for 21-dev (#9840)
* Remove duplicate java generated code (#9909)
* Cherry-pick PR #9981 into 21.x branch (#10000)
2022-05-19 version 21.0-rc2(C++/Java/Python/PHP/Objective-C/C#/Ruby)
Python
* Fix windows builds
* Throw more helpful error if generated code is out of date
* Fixed two reference leaks
Ruby
* Support x64-mingw-ucrt platform
PHP
* Fix SEGV by not writing to shared memory for zend_class_entry
C#
* Suppress warning CS8981
Other
* Fix Maven release to release actual osx_aarch64 binary
* Fix protoc zips to have the proto files for well known types
2022-05-10 version 21.0-rc1 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++
* Rename main cmake/CMakeLists.txt to CMakeLists.txt (#9603)
* avoid allocating memory if all extension are cleared (#9345)
* cmake: Call get_filename_component() with DIRECTORY mode instead of PATH mode (#9614)
* Escape GetObject macro inside protoc-generated code (#9739)
* Update CMake configuration to add a dependency on Abseil (#9793)
* Use __constinit only in GCC 12.2 and up (#9936)
* Refactor generated message class layout
* Optimize tokenizer ParseInteger by removing division
* Reserve exactly the right amount of capacity in ExtensionSet::MergeFrom
* Parse FLT_MAX correctly when represented in JSON
Java
* Update protobuf_version.bzl to separate protoc and per-language java … (#9900)
* 6x speedup in ArrayEncoder.writeUInt32NotTag
* Java generated code is no longer compatible with runtimes 2.6.1 and earlier
Python
* Increment python major version to 4 in version.json for python upb (#9926)
* The C extension module for Python has been rewritten to use the upb library.
This is expected to deliver significant performance benefits, especially when
parsing large payloads. There are some minor breaking changes, but these
should not impact most users. For more information see:
https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
* Due to the breaking changes for Python, the major version number for Python
has been incremented.
* The binary wheel for macOS now supports Apple silicon.
* In TextFormat, transform UnicodeDecodeError into ParseError.
PHP
* chore: [PHP] fix phpdoc for MapField keys (#9536)
* [PHP] Remove unnecessary zval initialization (#9600)
* [PHP] fix PHP build system (#9571)
* Fix building packaged PHP extension (#9727)
* fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)
* fix: phpdoc syntax for repeatedfield parameters (#9784)
* fix: phpdoc for repeatedfield (#9783)
* Change enum string name for reserved words (#9780)
* Fixed composer.json to only advertise compatibility with PHP 7.0+. (#9819)
Ruby
* Allow pre-compiled binaries for ruby 3.1.0 (#9566)
* Implement `respond_to?` in RubyMessage (#9677)
* [Ruby] Fix RepeatedField#last, #first inconsistencies (#9722)
* Do not use range based UTF-8 validation in truffleruby (#9769)
* Improve range handling logic of `RepeatedField` (#9799)
* Disable the aarch64 build on macOS until it can be fixed. (#9816)
Other
* [Kotlin] remove redundant public modifiers for compiled code (#9642)
* [C#] Update GetExtension to support getting typed value (#9655)
* Fix invalid dependency manifest when using `descriptor_set_out` (#9647)
* Fix C# generator handling of a field named "none" in a oneof (#9636)
* Add initial version.json file for 21-dev (#9840)
* Remove duplicate java generated code (#9909)
* Fix versioning issues in 3.20.0
Compiler
* Protoc outputs the list of suggested field numbers when invalid field
numbers are specified in the .proto file.
* Require package names to be less than 512 bytes in length
2022-04-21 version 3.20.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
PHP
* Fix building packaged PHP extension (#9727)
Other
* Fix versioning issues in 3.20.0
2022-03-04 version 3.20.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Ruby
* Dropped Ruby 2.3 and 2.4 support for CI and releases. (#9311)
* Added Ruby 3.1 support for CI and releases (#9566).
* Message.decode/encode: Add recursion_limit option (#9218/#9486)
* Allocate with xrealloc()/xfree() so message allocation is visible to the
Ruby GC. In certain tests this leads to much lower memory usage due to more
frequent GC runs (#9586).
* Fix conversion of singleton classes in Ruby (#9342)
* Suppress warning for intentional circular require (#9556)
* JSON will now output shorter strings for double and float fields when possible
without losing precision.
* Encoding and decoding of binary format will now work properly on big-endian
systems.
* UTF-8 verification was fixed to properly reject surrogate code points.
* Unknown enums for proto2 protos now properly implement proto2's behavior of
putting such values in unknown fields.
Java
* Revert "Standardize on Array copyOf" (#9400)
* Resolve more java field accessor name conflicts (#8198)
* Don't support map fields in DynamicMessage.Builder.{getFieldBuilder,getRepeatedFieldBuilder}
* Fix parseFrom to only throw InvalidProtocolBufferException
* InvalidProtocolBufferException now allows arbitrary wrapped Exception types.
* Fix bug in `FieldSet.Builder.mergeFrom`
* Flush CodedOutputStream also flushes underlying OutputStream
* When oneof case is the same and the field type is Message, merge the
subfield. (previously it was replaced.)
* Add @CheckReturnValue to some protobuf types
* Report original exceptions when parsing JSON
* Add more info to @deprecated javadoc for set/get/has methods
* Fix initialization bug in doc comment line numbers
* Fix comments for message set wire format.
Kotlin
* Add test scope to kotlin-test for protobuf-kotlin-lite (#9518)
* Add orNull extensions for optional message fields.
* Add orNull extensions to all proto3 message fields.
Python
* Dropped support for Python < 3.7 (#9480)
* Protoc is now able to generate python stubs (.pyi) with --pyi_out
* Pin multibuild scripts to get manylinux1 wheels back (#9216)
* Fix type annotations of some Duration and Timestamp methods.
* Repeated field containers are now generic in field types and could be used
in type annotations.
* Protobuf python generated codes are simplified. Descriptors and message
classes' definitions are now dynamic created in internal/builder.py.
Insertion Points for messages classes are discarded.
* has_presence is added for FieldDescriptor in python
* Loosen indexing type requirements to allow valid __index__() implementations
rather than only PyLongObjects.
* Fix the deepcopy bug caused by not copying message_listener.
* Added python JSON parse recursion limit (default 100)
* Path info is added for python JSON parse errors
* Pure python repeated scalar fields will not able to pickle. Convert to list
first.
* Timestamp.ToDatetime() now accepts an optional tzinfo parameter. If
specified, the function returns a timezone-aware datetime in the given time
zone. If omitted or None, the function returns a timezone-naive UTC datetime
(as previously).
* Adds client_streaming and server_streaming fields to MethodDescriptor.
* Add "ensure_ascii" parameter to json_format.MessageToJson. This allows smaller
JSON serializations with UTF-8 or other non-ASCII encodings.
* Added experimental support for directly assigning numpy scalars and array.
* Improve the calculation of public_dependencies in DescriptorPool.
* [Breaking Change] Disallow setting fields to numpy singleton arrays or repeated fields to numpy
multi-dimensional arrays. Numpy arrays should be indexed or flattened explicitly before assignment.
Compiler
* Migrate IsDefault(const std::string*) and UnsafeSetDefault(const std::string*)
* Implement strong qualified tags for TaggedPtr
* Rework allocations to power-of-two byte sizes.
* Migrate IsDefault(const std::string*) and UnsafeSetDefault(const std::string*)
* Implement strong qualified tags for TaggedPtr
* Make TaggedPtr Set...() calls explicitly spell out the content type.
* Check for parsing error before verifying UTF8.
* Enforce a maximum message nesting limit of 32 in the descriptor builder to
guard against stack overflows
* Fixed bugs in operators for RepeatedPtrIterator
* Assert a maximum map alignment for allocated values
* Fix proto1 group extension protodb parsing error
* Do not log/report the same descriptor symbol multiple times if it contains
more than one invalid character.
* Add UnknownFieldSet::SerializeToString and SerializeToCodedStream.
* Remove explicit default pointers and deprecated API from protocol compiler
Arenas
* Change Repeated*Field to reuse memory when using arenas.
* Implements pbarenaz for profiling proto arenas
* Introduce CreateString() and CreateArenaString() for cleaner semantics
* Fix unreferenced parameter for MSVC builds
* Add UnsafeSetAllocated to be used for one-of string fields.
* Make Arena::AllocateAligned() a public function.
* Determine if ArenaDtor related code generation is necessary in one place.
* Implement on demand register ArenaDtor for InlinedStringField
C++
* Enable testing via CTest (#8737)
* Add option to use external GTest in CMake (#8736)
* CMake: Set correct sonames for libprotobuf-lite.so and libprotoc.so (#8635) (#9529)
* Add cmake option `protobuf_INSTALL` to not install files (#7123)
* CMake: Allow custom plugin options e.g. to generate mocks (#9105)
* CMake: Use linker version scripts (#9545)
* Manually *struct Cord fields to work better with arenas.
* Manually destruct map fields.
* Generate narrower code
* Fix https://github.com/protocolbuffers/protobuf/issues/9378 by removing
shadowed _cached_size_ field
* Remove GetPointer() and explicit nullptr defaults.
* Add proto_h flag for speeding up large builds
* Add missing overload for reference wrapped fields.
* Add MergedDescriptorDatabase::FindAllFileNames()
* RepeatedField now defines an iterator type instead of using a pointer.
* Remove obsolete macros GOOGLE_PROTOBUF_HAS_ONEOF and GOOGLE_PROTOBUF_HAS_ARENAS.
PHP
* Fix: add missing reserved classnames (#9458)
* PHP 8.1 compatibility (#9370)
C#
* Fix trim warnings (#9182)
* Fixes NullReferenceException when accessing FieldDescriptor.IsPacked (#9430)
* Add ToProto() method to all descriptor classes (#9426)
* Add an option to preserve proto names in JsonFormatter (#6307)
Objective-C
* Add prefix_to_proto_package_mappings_path option. (#9498)
* Rename `proto_package_to_prefix_mappings_path` to `package_to_prefix_mappings_path`. (#9552)
* Add a generation option to control use of forward declarations in headers. (#9568)
2022-01-28 version 3.19.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Python
* Make libprotobuf symbols local on OSX to fix issue #9395 (#9435)
Ruby
* Fixed a data loss bug that could occur when the number of `optional`
fields in a message is an exact multiple of 32. (#9440).
PHP
* Fixed a data loss bug that could occur when the number of `optional`
fields in a message is an exact multiple of 32. (#9440).
2022-01-10 version 3.19.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Python
* Fix missing Windows wheel for Python 3.10 on PyPI
2022-01-05 version 3.19.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Java
* Improve performance characteristics of UnknownFieldSet parsing (#9371)
* This release addresses a Security Advisory for Java users
(https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-wrvw-hg22-4m67)
2022-01-05 version 3.18.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Java
* Improve performance characteristics of UnknownFieldSet parsing (#9371)
* This release addresses a Security Advisory for Java users
(https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-wrvw-hg22-4m67)
2022-01-05 version 3.16.1 (Java)
Java
* Improve performance characteristics of UnknownFieldSet parsing (#9371)
* This release addresses a Security Advisory for Java users
(https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-wrvw-hg22-4m67)
2021-10-28 version 3.19.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Bazel

351
CMakeLists.txt Normal file
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" ON)
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

@ -53,11 +53,11 @@ conforming.
## Contributing Process
Most pull requests should go to the master branch and the change will be
Most pull requests should go to the main branch and the change will be
included in the next major/minor version release (e.g., 3.6.0 release). If you
need to include a bug fix in a patch release (e.g., 3.5.2), make sure its
already merged to master, and then create a pull request cherry-picking the
commits from master branch to the release branch (e.g., branch 3.5.x).
already merged to main, and then create a pull request cherry-picking the
commits from main branch to the release branch (e.g., branch 3.5.x).
For each pull request, a protobuf team member will be assigned to review the
pull request. For minor cleanups, the pull request may be merged right away
@ -96,9 +96,9 @@ the final release.
of inactivity.
* Maintain clean commit history and use meaningful commit messages. PRs with
messy commit history are difficult to review and won't be merged. Use rebase
-i upstream/master to curate your commit history and/or to bring in latest
changes from master (but avoid rebasing in the middle of a code review).
* Keep your PR up to date with upstream/master (if there are merge conflicts,
-i upstream/main to curate your commit history and/or to bring in latest
changes from main (but avoid rebasing in the middle of a code review).
* Keep your PR up to date with upstream/main (if there are merge conflicts,
we can't really merge your change).
* All tests need to be passing before your change can be merged. We recommend
you run tests locally before creating your PR to catch breakages early on.

View File

@ -100,3 +100,8 @@ Patch contributors:
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

@ -9,6 +9,9 @@ AUTOMAKE_OPTIONS = foreign
SUBDIRS = . src
# Always include third_party directories in distributions.
#
# Note that distribution artifacts will be produced by Bazel in the future.
# See pkg/BUILD.bazel for overall definitions.
DIST_SUBDIRS = src conformance benchmarks third_party/googletest
# Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS
@ -48,12 +51,15 @@ clean-local:
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = protobuf.pc protobuf-lite.pc
# Note: please keep this in sync with the dist_files rule in csharp/BUILD.bazel.
csharp_EXTRA_DIST= \
global.json \
csharp/.editorconfig \
csharp/.gitignore \
csharp/CHANGES.txt \
csharp/Google.Protobuf.Tools.targets \
csharp/Google.Protobuf.Tools.nuspec \
csharp/NuGet.Config \
csharp/README.md \
csharp/build_packages.bat \
csharp/build_tools.sh \
@ -86,6 +92,7 @@ csharp_EXTRA_DIST= \
csharp/src/AddressBook/ListPeople.cs \
csharp/src/AddressBook/Program.cs \
csharp/src/AddressBook/SampleUsage.cs \
csharp/src/Directory.Build.props \
csharp/src/Google.Protobuf.Benchmarks/BenchmarkDatasetConfig.cs \
csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs \
csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs \
@ -113,7 +120,6 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs \
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs \
csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \
csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs \
csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs \
csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs \
csharp/src/Google.Protobuf.Test/EqualityTester.cs \
@ -179,12 +185,13 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/Collections/Lists.cs \
csharp/src/Google.Protobuf/Collections/MapField.cs \
csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs \
csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \
csharp/src/Google.Protobuf/Collections/RepeatedField.cs \
csharp/src/Google.Protobuf/Compatibility/MethodInfoExtensions.cs \
csharp/src/Google.Protobuf/Compatibility/DynamicallyAccessedMembersAttribute.cs \
csharp/src/Google.Protobuf/Compatibility/DynamicallyAccessedMemberTypes.cs \
csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs \
csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs \
csharp/src/Google.Protobuf/Compatibility/RequiresUnreferencedCodeAttribute.cs \
csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs \
csharp/src/Google.Protobuf/Compatibility/UnconditionalSuppressMessageAttribute.cs \
csharp/src/Google.Protobuf/Extension.cs \
csharp/src/Google.Protobuf/ExtensionRegistry.cs \
csharp/src/Google.Protobuf/ExtensionSet.cs \
@ -273,10 +280,11 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/UnknownFieldSet.cs \
csharp/src/Google.Protobuf/UnsafeByteOperations.cs
# Note: please keep this in sync with the dist_files rules under java/.../BUILD.bazel.
java_EXTRA_DIST= \
java/README.md \
java/bom/pom.xml \
java/core/BUILD \
java/core/BUILD.bazel \
java/core/generate-sources-build.xml \
java/core/generate-test-sources-build.xml \
java/core/pom.xml \
@ -303,6 +311,7 @@ java_EXTRA_DIST=
java/core/src/main/java/com/google/protobuf/CodedInputStreamReader.java \
java/core/src/main/java/com/google/protobuf/CodedOutputStream.java \
java/core/src/main/java/com/google/protobuf/CodedOutputStreamWriter.java \
java/core/src/main/java/com/google/protobuf/CompileTimeConstant.java \
java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java \
java/core/src/main/java/com/google/protobuf/Descriptors.java \
java/core/src/main/java/com/google/protobuf/DiscardUnknownFieldsParser.java \
@ -326,6 +335,7 @@ java_EXTRA_DIST=
java/core/src/main/java/com/google/protobuf/GeneratedMessageInfoFactory.java \
java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java \
java/core/src/main/java/com/google/protobuf/InlineMe.java \
java/core/src/main/java/com/google/protobuf/IntArrayList.java \
java/core/src/main/java/com/google/protobuf/Internal.java \
java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
@ -437,9 +447,9 @@ java_EXTRA_DIST=
java/core/src/test/java/com/google/protobuf/ExtensionRegistryFactoryTest.java \
java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java \
java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java \
java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \
java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java \
java/core/src/test/java/com/google/protobuf/IntArrayListTest.java \
java/core/src/test/java/com/google/protobuf/InvalidProtocolBufferExceptionTest.java \
java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java \
java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java \
java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java \
@ -464,15 +474,12 @@ java_EXTRA_DIST=
java/core/src/test/java/com/google/protobuf/Proto2ExtensionLookupSchemaTest.java \
java/core/src/test/java/com/google/protobuf/Proto2LiteSchemaTest.java \
java/core/src/test/java/com/google/protobuf/Proto2MessageFactory.java \
java/core/src/test/java/com/google/protobuf/Proto2MessageInfoFactory.java \
java/core/src/test/java/com/google/protobuf/Proto2MessageLiteFactory.java \
java/core/src/test/java/com/google/protobuf/Proto2SchemaTest.java \
java/core/src/test/java/com/google/protobuf/Proto2UnknownEnumValueTest.java \
java/core/src/test/java/com/google/protobuf/Proto3LiteSchemaTest.java \
java/core/src/test/java/com/google/protobuf/Proto3MessageFactory.java \
java/core/src/test/java/com/google/protobuf/Proto3MessageInfoFactory.java \
java/core/src/test/java/com/google/protobuf/Proto3MessageLiteFactory.java \
java/core/src/test/java/com/google/protobuf/Proto3MessageLiteInfoFactory.java \
java/core/src/test/java/com/google/protobuf/Proto3SchemaTest.java \
java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java \
java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderV3Test.java \
@ -493,9 +500,9 @@ java_EXTRA_DIST=
java/core/src/test/java/com/google/protobuf/TypeRegistryTest.java \
java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \
java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \
java/core/src/test/java/com/google/protobuf/UnknownFieldSetPerformanceTest.java \
java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \
java/core/src/test/java/com/google/protobuf/Utf8Test.java \
java/core/src/test/java/com/google/protobuf/Utf8Utils.java \
java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java \
java/core/src/test/java/com/google/protobuf/WireFormatLiteTest.java \
java/core/src/test/java/com/google/protobuf/WireFormatTest.java \
@ -504,6 +511,7 @@ java_EXTRA_DIST=
java/core/src/test/proto/com/google/protobuf/any_test.proto \
java/core/src/test/proto/com/google/protobuf/cached_field_size_test.proto \
java/core/src/test/proto/com/google/protobuf/deprecated_file.proto \
java/core/src/test/proto/com/google/protobuf/dynamic_message_test.proto \
java/core/src/test/proto/com/google/protobuf/field_presence_test.proto \
java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto \
java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto \
@ -512,7 +520,6 @@ java_EXTRA_DIST=
java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto \
java/core/src/test/proto/com/google/protobuf/map_lite_test.proto \
java/core/src/test/proto/com/google/protobuf/map_test.proto \
java/core/src/test/proto/com/google/protobuf/message_lite_extension_util_test.proto\
java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto \
java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto \
java/core/src/test/proto/com/google/protobuf/nested_extension.proto \
@ -533,21 +540,24 @@ java_EXTRA_DIST=
java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \
java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \
java/core/src/test/proto/com/google/protobuf/wrappers_test.proto \
java/internal/BUILD \
java/internal/BUILD.bazel \
java/internal/testing.bzl \
java/kotlin/BUILD.bazel \
java/kotlin/generate-sources-build.xml \
java/kotlin/generate-test-sources-build.xml \
java/kotlin/pom.xml \
java/kotlin/pom_template.xml \
java/kotlin/src/main/kotlin/com/google/protobuf/Anies.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/ByteStrings.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/DslList.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/DslMap.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/DslProxy.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/ExtendableMessageExtensions.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/ExtendableMessageLiteExtensions.kt\
java/kotlin/src/main/kotlin/com/google/protobuf/ExtensionList.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/OnlyForUseByGeneratedProtoCode.kt\
java/kotlin/src/main/kotlin/com/google/protobuf/ProtoDslMarker.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/UnmodifiableCollections.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/AniesTest.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/ByteStringsTest.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/DslListTest.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/DslMapTest.kt \
@ -559,15 +569,18 @@ java_EXTRA_DIST=
java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto3.proto \
java/kotlin/src/test/proto/com/google/protobuf/example_extensible_message.proto \
java/kotlin/src/test/proto/com/google/protobuf/multiple_files_proto3.proto \
java/kotlin-lite/BUILD.bazel \
java/kotlin-lite/generate-sources-build.xml \
java/kotlin-lite/generate-test-sources-build.xml \
java/kotlin-lite/lite.awk \
java/kotlin-lite/pom.xml \
java/kotlin-lite/pom_template.xml \
java/kotlin-lite/process-lite-sources-build.xml \
java/kotlin-lite/src/main/kotlin/com/google/protobuf/ExtendableMessageLiteExtensions.kt\
java/kotlin-lite/src/test/kotlin/com/google/protobuf/ExtendableMessageLiteExtensionsTest.kt\
java/kotlin-lite/src/test/kotlin/com/google/protobuf/Proto2LiteTest.kt \
java/lite.md \
java/lite/BUILD \
java/lite/BUILD.bazel \
java/lite/generate-sources-build.xml \
java/lite/generate-test-sources-build.xml \
java/lite/lite.awk \
@ -575,10 +588,9 @@ java_EXTRA_DIST=
java/lite/pom_template.xml \
java/lite/process-lite-sources-build.xml \
java/lite/src/test/java/com/google/protobuf/LiteTest.java \
java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java \
java/BUILD \
java/BUILD.bazel \
java/pom.xml \
java/util/BUILD \
java/util/BUILD.bazel \
java/util/pom.xml \
java/util/pom_template.xml \
java/util/src/main/java/com/google/protobuf/util/Durations.java \
@ -588,16 +600,19 @@ java_EXTRA_DIST=
java/util/src/main/java/com/google/protobuf/util/Structs.java \
java/util/src/main/java/com/google/protobuf/util/Timestamps.java \
java/util/src/main/java/com/google/protobuf/util/Values.java \
java/util/src/test/java/com/google/protobuf/util/DurationsTest.java \
java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \
java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \
java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \
java/util/src/test/java/com/google/protobuf/util/StructsTest.java \
java/util/src/test/java/com/google/protobuf/util/TimestampsTest.java \
java/util/src/test/java/com/google/protobuf/util/ValuesTest.java \
java/util/src/test/proto/com/google/protobuf/util/json_test.proto
# Note: please keep this in sync with the dist_files rule in objectivec/BUILD.bazel.
objectivec_EXTRA_DIST= \
objectivec/.clang-format \
objectivec/BUILD \
objectivec/BUILD.bazel \
objectivec/DevTools/check_version_stamps.sh \
objectivec/DevTools/compile_testing_protos.sh \
objectivec/DevTools/full_mac_build.sh \
@ -696,33 +711,6 @@ objectivec_EXTRA_DIST= \
objectivec/ProtocolBuffers_tvOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
objectivec/ProtocolBuffers_tvOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
objectivec/README.md \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework \
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static \
objectivec/Tests/CocoaPods/README.md \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m \
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m \
objectivec/Tests/CocoaPods/run_tests.sh \
objectivec/Tests/golden_message \
objectivec/Tests/golden_packed_fields_message \
objectivec/Tests/GPBARCUnittestProtos.m \
@ -803,11 +791,12 @@ objectivec_EXTRA_DIST= \
objectivec/Tests/UnitTests-Info.plist \
Protobuf.podspec
# Note: please keep this in sync with the dist_files rule in php/BUILD.bazel.
php_EXTRA_DIST= \
composer.json \
php/README.md \
php/REFCOUNTING.md \
php/composer.json \
php/composer.json.dist \
php/ext/google/protobuf/arena.c \
php/ext/google/protobuf/arena.h \
php/ext/google/protobuf/array.c \
@ -826,9 +815,11 @@ php_EXTRA_DIST= \
php/ext/google/protobuf/package.xml \
php/ext/google/protobuf/php-upb.c \
php/ext/google/protobuf/php-upb.h \
php/ext/google/protobuf/php_protobuf.h \
php/ext/google/protobuf/protobuf.c \
php/ext/google/protobuf/protobuf.h \
php/ext/google/protobuf/wkt.inc \
php/ext/google/protobuf/tests/unnecessary_zval.phpt \
php/generate_descriptor_protos.sh \
php/generate_test_protos.sh \
php/release.sh \
@ -997,7 +988,9 @@ php_EXTRA_DIST= \
php/tests/WellKnownTest.php \
php/tests/WrapperTypeSettersTest.php
# Note: please keep this in sync with the python_dist_files rule in BUILD.bazel.
python_EXTRA_DIST= \
python/BUILD.bazel \
python/MANIFEST.in \
python/google/__init__.py \
python/google/protobuf/__init__.py \
@ -1011,6 +1004,7 @@ python_EXTRA_DIST= \
python/google/protobuf/internal/any_test.proto \
python/google/protobuf/internal/api_implementation.cc \
python/google/protobuf/internal/api_implementation.py \
python/google/protobuf/internal/builder.py \
python/google/protobuf/internal/containers.py \
python/google/protobuf/internal/decoder.py \
python/google/protobuf/internal/descriptor_database_test.py \
@ -1025,7 +1019,10 @@ python_EXTRA_DIST= \
python/google/protobuf/internal/factory_test2.proto \
python/google/protobuf/internal/file_options_test.proto \
python/google/protobuf/internal/generator_test.py \
python/google/protobuf/internal/import_test.py \
python/google/protobuf/internal/import_test_package/__init__.py \
python/google/protobuf/internal/import_test_package/import_public.proto \
python/google/protobuf/internal/import_test_package/import_public_nested.proto \
python/google/protobuf/internal/import_test_package/inner.proto \
python/google/protobuf/internal/import_test_package/outer.proto \
python/google/protobuf/internal/json_format_test.py \
@ -1097,6 +1094,8 @@ python_EXTRA_DIST= \
python/google/protobuf/pyext/repeated_scalar_container.h \
python/google/protobuf/pyext/safe_numerics.h \
python/google/protobuf/pyext/scoped_pyobject_ptr.h \
python/google/protobuf/pyext/unknown_field_set.cc \
python/google/protobuf/pyext/unknown_field_set.h \
python/google/protobuf/python_protobuf.h \
python/google/protobuf/reflection.py \
python/google/protobuf/service.py \
@ -1104,7 +1103,9 @@ python_EXTRA_DIST= \
python/google/protobuf/symbol_database.py \
python/google/protobuf/text_encoding.py \
python/google/protobuf/text_format.py \
python/google/protobuf/unknown_fields.py \
python/google/protobuf/util/__init__.py \
python/internal.bzl \
python/release.sh \
python/mox.py \
python/setup.cfg \
@ -1113,6 +1114,7 @@ python_EXTRA_DIST= \
python/tox.ini \
python/README.md
# Note: please keep this in sync with the dist_files rule in ruby/BUILD.bazel.
ruby_EXTRA_DIST= \
ruby/Gemfile \
ruby/.gitignore \
@ -1188,250 +1190,79 @@ ruby_EXTRA_DIST= \
ruby/tests/type_errors.rb \
ruby/travis-test.sh
js_EXTRA_DIST= \
js/README.md \
js/binary/arith.js \
js/binary/arith_test.js \
js/binary/constants.js \
js/binary/decoder.js \
js/binary/decoder_test.js \
js/binary/encoder.js \
js/binary/message_test.js \
js/binary/proto_test.js \
js/binary/reader.js \
js/binary/reader_test.js \
js/binary/utils.js \
js/binary/utils_test.js \
js/binary/writer.js \
js/binary/writer_test.js \
js/commonjs/export.js \
js/commonjs/export_asserts.js \
js/commonjs/export_testdeps.js \
js/commonjs/import_test.js \
js/commonjs/jasmine.json \
js/commonjs/rewrite_tests_for_commonjs.js \
js/commonjs/strict_test.js \
js/commonjs/test6/test6.proto \
js/commonjs/test7/test7.proto \
js/compatibility_tests/v3.0.0/binary/arith_test.js \
js/compatibility_tests/v3.0.0/binary/decoder_test.js \
js/compatibility_tests/v3.0.0/binary/proto_test.js \
js/compatibility_tests/v3.0.0/binary/reader_test.js \
js/compatibility_tests/v3.0.0/binary/utils_test.js \
js/compatibility_tests/v3.0.0/binary/writer_test.js \
js/compatibility_tests/v3.0.0/commonjs/export_asserts.js \
js/compatibility_tests/v3.0.0/commonjs/export_testdeps.js \
js/compatibility_tests/v3.0.0/commonjs/import_test.js \
js/compatibility_tests/v3.0.0/commonjs/jasmine.json \
js/compatibility_tests/v3.0.0/commonjs/rewrite_tests_for_commonjs.js \
js/compatibility_tests/v3.0.0/commonjs/test6/test6.proto \
js/compatibility_tests/v3.0.0/commonjs/test7/test7.proto \
js/compatibility_tests/v3.0.0/data.proto \
js/compatibility_tests/v3.0.0/debug_test.js \
js/compatibility_tests/v3.0.0/jasmine1.json \
js/compatibility_tests/v3.0.0/jasmine2.json \
js/compatibility_tests/v3.0.0/jasmine3.json \
js/compatibility_tests/v3.0.0/message_test.js \
js/compatibility_tests/v3.0.0/proto3_test.js \
js/compatibility_tests/v3.0.0/proto3_test.proto \
js/compatibility_tests/v3.0.0/test2.proto \
js/compatibility_tests/v3.0.0/test3.proto \
js/compatibility_tests/v3.0.0/test4.proto \
js/compatibility_tests/v3.0.0/test5.proto \
js/compatibility_tests/v3.0.0/testbinary.proto \
js/compatibility_tests/v3.0.0/testempty.proto \
js/compatibility_tests/v3.0.0/test.proto \
js/compatibility_tests/v3.0.0/test.sh \
js/compatibility_tests/v3.1.0/testempty.proto \
js/compatibility_tests/v3.1.0/testbinary.proto \
js/compatibility_tests/v3.1.0/test5.proto \
js/compatibility_tests/v3.1.0/test4.proto \
js/compatibility_tests/v3.1.0/test3.proto \
js/compatibility_tests/v3.1.0/test2.proto \
js/compatibility_tests/v3.1.0/test.proto \
js/compatibility_tests/v3.1.0/proto3_test.proto \
js/compatibility_tests/v3.1.0/proto3_test.js \
js/compatibility_tests/v3.1.0/message_test.js \
js/compatibility_tests/v3.1.0/maps_test.js \
js/compatibility_tests/v3.1.0/debug_test.js \
js/compatibility_tests/v3.1.0/data.proto \
js/compatibility_tests/v3.1.0/commonjs/test7/test7.proto \
js/compatibility_tests/v3.1.0/commonjs/test6/test6.proto \
js/compatibility_tests/v3.1.0/binary/writer_test.js \
js/compatibility_tests/v3.1.0/binary/utils_test.js \
js/compatibility_tests/v3.1.0/binary/reader_test.js \
js/compatibility_tests/v3.1.0/binary/proto_test.js \
js/compatibility_tests/v3.1.0/binary/decoder_test.js \
js/compatibility_tests/v3.1.0/binary/arith_test.js \
js/data.proto \
js/debug.js \
js/debug_test.js \
js/experimental/runtime/kernel/message_set.js \
js/experimental/runtime/kernel/message_set_test.js \
js/experimental/runtime/kernel/tag.js \
js/experimental/runtime/kernel/tag_test.js \
js/gulpfile.js \
js/jasmine.json \
js/map.js \
js/maps_test.js \
js/message.js \
js/message_test.js \
js/node_loader.js \
js/package.json \
js/proto3_test.js \
js/proto3_test.proto \
js/test.proto \
js/test2.proto \
js/test3.proto \
js/test4.proto \
js/test5.proto \
js/test8.proto \
js/test9.proto \
js/test10.proto \
js/test11.proto \
js/test12.proto \
js/test13.proto \
js/test14.proto \
js/test15.proto \
js/test_bootstrap.js \
js/testbinary.proto \
js/testempty.proto \
js/testlargenumbers.proto \
js/experimental/runtime/testing/jasmine_protobuf.js \
js/experimental/runtime/testing/ensure_custom_equality_test.js \
js/experimental/runtime/testing/binary/test_message.js \
js/experimental/runtime/kernel/writer_test.js \
js/experimental/runtime/kernel/writer.js \
js/experimental/runtime/kernel/wire_type.js \
js/experimental/runtime/kernel/uint8arrays_test.js \
js/experimental/runtime/kernel/uint8arrays.js \
js/experimental/runtime/kernel/uint32_test_pairs.js \
js/experimental/runtime/kernel/typed_arrays_test.js \
js/experimental/runtime/kernel/typed_arrays.js \
js/experimental/runtime/kernel/textencoding_test.js \
js/experimental/runtime/kernel/textencoding.js \
js/experimental/runtime/kernel/storage.js \
js/experimental/runtime/kernel/sint64_test_pairs.js \
js/experimental/runtime/kernel/sint32_test_pairs.js \
js/experimental/runtime/kernel/sfixed64_test_pairs.js \
js/experimental/runtime/kernel/sfixed32_test_pairs.js \
js/experimental/runtime/kernel/reader_test.js \
js/experimental/runtime/kernel/reader.js \
js/experimental/runtime/kernel/packed_uint32_test_pairs.js \
js/experimental/runtime/kernel/packed_sint64_test_pairs.js \
js/experimental/runtime/kernel/packed_sint32_test_pairs.js \
js/experimental/runtime/kernel/packed_sfixed64_test_pairs.js \
js/experimental/runtime/kernel/packed_sfixed32_test_pairs.js \
js/experimental/runtime/kernel/packed_int64_test_pairs.js \
js/experimental/runtime/kernel/packed_int32_test_pairs.js \
js/experimental/runtime/kernel/packed_float_test_pairs.js \
js/experimental/runtime/kernel/packed_fixed32_test_pairs.js \
js/experimental/runtime/kernel/packed_double_test_pairs.js \
js/experimental/runtime/kernel/packed_bool_test_pairs.js \
js/experimental/runtime/kernel/kernel_test.js \
js/experimental/runtime/kernel/kernel_repeated_test.js \
js/experimental/runtime/kernel/kernel_compatibility_test.js \
js/experimental/runtime/kernel/kernel.js \
js/experimental/runtime/kernel/internal_message.js \
js/experimental/runtime/kernel/int64_test_pairs.js \
js/experimental/runtime/kernel/int32_test_pairs.js \
js/experimental/runtime/kernel/indexer_test.js \
js/experimental/runtime/kernel/indexer.js \
js/experimental/runtime/kernel/float_test_pairs.js \
js/experimental/runtime/kernel/fixed32_test_pairs.js \
js/experimental/runtime/kernel/field.js \
js/experimental/runtime/kernel/double_test_pairs.js \
js/experimental/runtime/kernel/conformance/wire_format.js \
js/experimental/runtime/kernel/conformance/test_all_types_proto3.js \
js/experimental/runtime/kernel/conformance/test_all_types_proto2.js \
js/experimental/runtime/kernel/conformance/conformance_testee_runner_node.js \
js/experimental/runtime/kernel/conformance/conformance_testee.js \
js/experimental/runtime/kernel/conformance/conformance_response.js \
js/experimental/runtime/kernel/conformance/conformance_request.js \
js/experimental/runtime/kernel/buffer_decoder_test.js \
js/experimental/runtime/kernel/buffer_decoder_helper.js \
js/experimental/runtime/kernel/buffer_decoder.js \
js/experimental/runtime/kernel/bool_test_pairs.js \
js/experimental/runtime/kernel/binary_storage_test.js \
js/experimental/runtime/kernel/binary_storage.js \
js/experimental/runtime/internal/checks_test.js \
js/experimental/runtime/internal/checks.js \
js/experimental/runtime/int64_test.js \
js/experimental/runtime/int64.js \
js/experimental/runtime/bytestring_test.js \
js/experimental/runtime/bytestring_internal.js \
js/experimental/runtime/bytestring.js \
js/experimental/benchmarks/code_size/kernel/popular_types.js \
js/experimental/benchmarks/code_size/kernel/all_types.js \
js/experimental/benchmarks/code_size/code_size_base.js \
js/experimental/benchmarks/code_size/apps_jspb/popular_types_proto3.js \
js/experimental/benchmarks/code_size/apps_jspb/popular_types_proto2.js \
js/experimental/benchmarks/code_size/apps_jspb/all_types_proto3.js \
js/experimental/benchmarks/code_size/apps_jspb/all_types_proto2.js
all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(php_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST)
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
autogen.sh \
generate_descriptor_proto.sh \
README.md \
LICENSE \
CONTRIBUTORS.txt \
CHANGES.txt \
update_file_lists.sh \
BUILD \
WORKSPACE \
cmake/CMakeLists.txt \
cmake/README.md \
cmake/conformance.cmake \
cmake/examples.cmake \
cmake/extract_includes.bat.in \
cmake/install.cmake \
cmake/libprotobuf.cmake \
cmake/libprotobuf-lite.cmake \
cmake/libprotoc.cmake \
cmake/protobuf-config-version.cmake.in \
cmake/protobuf-config.cmake.in \
cmake/protobuf-lite.pc.cmake \
cmake/protobuf-module.cmake.in \
cmake/protobuf-options.cmake \
cmake/protobuf.pc.cmake \
cmake/protoc.cmake \
cmake/tests.cmake \
cmake/version.rc.in \
compiler_config_setting.bzl \
build_files_updated_unittest.sh \
cc_proto_blacklist_test.bzl \
editors/README.txt \
editors/proto.vim \
editors/protobuf-mode.el \
examples/AddPerson.java \
examples/BUILD \
examples/CMakeLists.txt \
examples/ListPeople.java \
examples/Makefile \
examples/README.md \
examples/WORKSPACE \
examples/add_person.cc \
examples/add_person.dart \
examples/add_person.go \
examples/add_person.py \
examples/add_person_test.go \
examples/addressbook.proto \
examples/list_people.cc \
examples/list_people.dart \
examples/list_people.go \
examples/list_people.py \
examples/list_people_test.go \
examples/pubspec.yaml \
maven_install.json \
protobuf.bzl \
protobuf_deps.bzl \
protobuf_version.bzl \
third_party/zlib.BUILD \
util/python/BUILD \
internal.bzl
all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(php_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)
# Note: please keep this in sync with the common_dist_files rule in BUILD.bazel.
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
autogen.sh \
generate_descriptor_proto.sh \
README.md \
LICENSE \
CONTRIBUTORS.txt \
CHANGES.txt \
update_file_lists.sh \
BUILD.bazel \
WORKSPACE \
CMakeLists.txt \
build_defs/BUILD.bazel \
build_defs/cc_proto_blacklist_test.bzl \
build_defs/compiler_config_setting.bzl \
build_defs/cpp_opts.bzl \
build_files_updated_unittest.sh \
cmake/CMakeLists.txt \
cmake/README.md \
cmake/conformance.cmake \
cmake/examples.cmake \
cmake/extract_includes.bat.in \
cmake/install.cmake \
cmake/libprotobuf-lite.cmake \
cmake/libprotobuf.cmake \
cmake/libprotoc.cmake \
cmake/protobuf-config-version.cmake.in \
cmake/protobuf-config.cmake.in \
cmake/protobuf-lite.pc.cmake \
cmake/protobuf-module.cmake.in \
cmake/protobuf-options.cmake \
cmake/protobuf.pc.cmake \
cmake/protoc.cmake \
cmake/tests.cmake \
cmake/version.rc.in \
csharp/BUILD.bazel \
editors/README.txt \
editors/proto.vim \
editors/protobuf-mode.el \
examples/AddPerson.java \
examples/BUILD.bazel \
examples/CMakeLists.txt \
examples/ListPeople.java \
examples/Makefile \
examples/README.md \
examples/WORKSPACE \
examples/add_person.cc \
examples/add_person.dart \
examples/add_person.py \
examples/addressbook.proto \
examples/go/cmd/add_person/add_person.go \
examples/go/cmd/add_person/add_person_test.go \
examples/go/cmd/list_people/list_people.go \
examples/go/cmd/list_people/list_people_test.go \
examples/go/go.sum \
examples/go/go.mod \
examples/list_people.cc \
examples/list_people.dart \
examples/list_people.py \
examples/pubspec.yaml \
conformance/BUILD.bazel \
conformance/defs.bzl \
maven_install.json \
php/BUILD.bazel \
protobuf.bzl \
protobuf_deps.bzl \
protobuf_release.bzl \
protobuf_version.bzl \
ruby/BUILD.bazel \
third_party/zlib.BUILD \
util/python/BUILD.bazel
# Deletes all the files generated by autogen.sh.
MAINTAINERCLEANFILES = \

View File

@ -1,9 +1,9 @@
Pod::Spec.new do |s|
s.name = 'Protobuf-C++'
s.version = '3.19.1'
s.version = '3.21.1'
s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License'
s.license = 'BSD-3-Clause'
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
s.cocoapods_version = '>= 1.0'
@ -35,6 +35,7 @@ Pod::Spec.new do |s|
# Do not let src/google/protobuf/stubs/time.h override system API
'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => 'NO',
'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/src"'
}
end

View File

@ -5,10 +5,10 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
s.version = '3.19.1'
s.version = '3.21.1'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = '3-Clause BSD License'
s.license = 'BSD-3-Clause'
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
s.cocoapods_version = '>= 1.0'
@ -39,4 +39,12 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = '9.0'
s.watchos.deployment_target = '2.0'
s.requires_arc = false
# The unittest need the generate sources from the testing related .proto
# files. So to add a `test_spec`, there would also need to be something like a
# `script_phases` to generate them, but there would also need to be a way to
# ensure `protoc` had be built. Another option would be to move to a model
# where the needed files are always generated and checked in. Neither of these
# seem that great at the moment, so the tests have *not* been wired into here
# at this time.
end

View File

@ -38,7 +38,7 @@ 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 master version at HEAD, or you need to modify protobuf code,
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.
@ -59,7 +59,6 @@ how to install protobuf runtime for that specific language:
| Python | [python](python) |
| Objective-C | [objectivec](objectivec) |
| C# | [csharp](csharp) |
| JavaScript | [js](js) |
| Ruby | [ruby](ruby) |
| Go | [protocolbuffers/protobuf-go](https://github.com/protocolbuffers/protobuf-go)|
| PHP | [php](php) |

View File

@ -56,3 +56,16 @@ pinned_maven_install()
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()

View File

@ -38,7 +38,7 @@ dotnet restore
dotnet build -c %configuration% || goto error
echo Testing C#
dotnet test -c %configuration% -f netcoreapp2.1 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
dotnet test -c %configuration% -f netcoreapp3.1 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
dotnet test -c %configuration% -f net451 Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
goto :EOF

View File

@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
proto_library(
@ -63,3 +64,35 @@ java_proto_library(
"google_size_proto",
],
)
pkg_files(
name = "dist_files",
srcs = glob(
[
"*",
"python/*.cc",
"util/*.cc",
],
exclude = [
"__init__.py", # not in autotools dist
"go/*",
],
),
strip_prefix = strip_prefix.from_root(""),
)
# Convenience filegroup for all files that should be packaged.
pkg_filegroup(
name = "all_dist_files",
srcs = [
":dist_files",
"//benchmarks/cpp:dist_files",
"//benchmarks/datasets:dist_files", # not in autotools dist
"//benchmarks/datasets/google_message1/proto2:dist_files",
"//benchmarks/datasets/google_message1/proto3:dist_files",
"//benchmarks/datasets/google_message2:dist_files",
"//benchmarks/datasets/google_message3:dist_files",
"//benchmarks/datasets/google_message4:dist_files",
],
visibility = ["//pkg:__pkg__"],
)

View File

@ -4,8 +4,8 @@
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 support languages, see [here](
https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md)
numbers of officially supported languages, see [Protobuf Performance](
https://github.com/protocolbuffers/protobuf/blob/main/docs/performance.md).
## Prerequisite
@ -61,7 +61,7 @@ PHP benchmark's requirement is the same as PHP protobuf's requirements. The benc
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/master/js), which needn't to manually install either
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
@ -69,25 +69,23 @@ solution. It requires the .NET Core SDK, and depends on
[BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet), which
will be downloaded automatically.
### Big data
There's some optional big testing data which is not included in the directory
initially, you need to run the following command to download the testing data:
```
$ ./download_data.sh
```
After doing this the big data file will automatically generated in the
benchmark directory.
## 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
```

View File

@ -1,4 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
cc_binary(
name = "cpp",
@ -13,3 +14,13 @@ cc_binary(
"@com_github_google_benchmark//:benchmark_main",
],
)
pkg_files(
name = "dist_files",
srcs = [
"BUILD.bazel",
"cpp_benchmark.cc",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)

View File

@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
filegroup(
@ -57,3 +58,10 @@ java_library(
"//benchmarks/datasets/google_message4:benchmark_message4_java_proto",
],
)
pkg_files(
name = "dist_files",
srcs = ["BUILD.bazel"],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)

View File

@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
filegroup(
@ -42,3 +43,10 @@ java_proto_library(
"benchmark_message1_proto2_proto",
],
)
pkg_files(
name = "dist_files",
srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)

View File

@ -1,6 +1,7 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
filegroup(
name = "datasets",
@ -42,3 +43,10 @@ java_proto_library(
"benchmark_message1_proto3_proto",
],
)
pkg_files(
name = "dist_files",
srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)

View File

@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
filegroup(
@ -42,3 +43,10 @@ java_proto_library(
"benchmark_message2_proto",
],
)
pkg_files(
name = "dist_files",
srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)

View File

@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
filegroup(
@ -48,3 +49,10 @@ java_proto_library(
"benchmark_message3_proto",
],
)
pkg_files(
name = "dist_files",
srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)

View File

@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
filegroup(
@ -43,3 +44,10 @@ java_proto_library(
"benchmark_message4_proto",
],
)
pkg_files(
name = "dist_files",
srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)

View File

@ -1,38 +1,27 @@
package com.google.protobuf;
import com.google.caliper.BeforeExperiment;
import com.google.caliper.AfterExperiment;
import com.google.caliper.Benchmark;
import com.google.caliper.Param;
import com.google.caliper.api.VmOptions;
import com.google.protobuf.ByteString;
import com.google.protobuf.CodedOutputStream;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.Message;
import com.google.protobuf.benchmarks.Benchmarks.BenchmarkDataset;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
// Caliper set CICompilerCount to 1 for making sure compilation doesn't run in parallel with itself,
// This makes TieredCompilation not working. We just disable TieredCompilation by default. In master
// branch this has been disabled by default in caliper:
// https://github.com/google/caliper/blob/master/caliper-runner/src/main/java/com/google/caliper/runner/target/Jvm.java#L38:14
// But this haven't been added into most recent release.
@VmOptions("-XX:-TieredCompilation")
/**
* Basic benchmarks for Java protobuf parsing.
*/
public class ProtoCaliperBenchmark {
public enum BenchmarkMessageType {
GOOGLE_MESSAGE1_PROTO3 {
@Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); }
@Override
ExtensionRegistry getExtensionRegistry() {
return ExtensionRegistry.newInstance();
}
@Override
Message getDefaultInstance() {
return com.google.protobuf.benchmarks.BenchmarkMessage1Proto3.GoogleMessage1
@ -40,7 +29,9 @@ public class ProtoCaliperBenchmark {
}
},
GOOGLE_MESSAGE1_PROTO2 {
@Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); }
@Override ExtensionRegistry getExtensionRegistry() {
return ExtensionRegistry.newInstance();
}
@Override
Message getDefaultInstance() {
return com.google.protobuf.benchmarks.BenchmarkMessage1Proto2.GoogleMessage1
@ -48,7 +39,10 @@ public class ProtoCaliperBenchmark {
}
},
GOOGLE_MESSAGE2 {
@Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); }
@Override
ExtensionRegistry getExtensionRegistry() {
return ExtensionRegistry.newInstance();
}
@Override
Message getDefaultInstance() {
return com.google.protobuf.benchmarks.BenchmarkMessage2.GoogleMessage2.getDefaultInstance();
@ -157,7 +151,7 @@ public class ProtoCaliperBenchmark {
}
}
@SuppressWarnings({"IgnoredPureGetter", "CheckReturnValue"})
@Benchmark
void serializeToByteArray(int reps) throws IOException {
if (sampleMessageList.size() == 0) {

View File

@ -18,8 +18,7 @@ static struct PyModuleDef _module = {PyModuleDef_HEAD_INIT,
NULL};
extern "C" {
PyMODINIT_FUNC
PyInit_libbenchmark_messages() {
PyMODINIT_FUNC PyInit_libbenchmark_messages() {
benchmarks::BenchmarkDataset().descriptor();
benchmarks::proto3::GoogleMessage1().descriptor();
benchmarks::proto2::GoogleMessage1().descriptor();

173
build_defs/BUILD.bazel Normal file
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

@ -14,14 +14,14 @@ def _cc_proto_blacklist_test_impl(ctx):
env = unittest.begin(ctx)
for dep in ctx.attr.deps:
files = len(dep.files.to_list())
files = dep.files.to_list()
asserts.equals(
env,
0,
[],
files,
"Expected that target '{}' does not provide files, got {}".format(
dep.label,
files,
len(files),
),
)

47
build_defs/cpp_opts.bzl Normal file
View File

@ -0,0 +1,47 @@
"""C++ compile/link options for Protobuf libraries."""
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

@ -1,312 +1,9 @@
# Minimum CMake required
cmake_minimum_required(VERSION 3.1.3)
cmake_minimum_required(VERSION 3.5)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring...")
endif()
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.")
# 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)
# 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()
set(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE TRUE)
# 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
if(WITH_PROTOC)
set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE)
endif()
option(protobuf_BUILD_TESTS "Build tests" ON)
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-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 "../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()
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)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
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(
/wd4018 # 'expression' : signed/unsigned mismatch
/wd4065 # switch statement contains 'default' but no 'case' labels
/wd4146 # unary minus operator applied to unsigned type, result still unsigned
/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(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()
configure_file(version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
endif (MSVC)
get_filename_component(protobuf_source_dir ${protobuf_SOURCE_DIR} PATH)
include_directories(
${ZLIB_INCLUDE_DIRECTORIES}
${protobuf_BINARY_DIR}
${protobuf_source_dir}/src)
if (MSVC)
# Add the "lib" prefix for generated .lib outputs.
set(LIB_PREFIX lib)
else (MSVC)
# When building with "make", "lib" prefix will be added automatically by
# the build tool.
set(LIB_PREFIX)
endif (MSVC)
if (protobuf_UNICODE)
add_definitions(-DUNICODE -D_UNICODE)
endif (protobuf_UNICODE)
include(libprotobuf-lite.cmake)
include(libprotobuf.cmake)
if (protobuf_BUILD_LIBPROTOC)
include(libprotoc.cmake)
endif (protobuf_BUILD_LIBPROTOC)
if (protobuf_BUILD_PROTOC_BINARIES)
include(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)
include(tests.cmake)
endif (protobuf_BUILD_TESTS)
if (protobuf_BUILD_CONFORMANCE)
include(conformance.cmake)
endif (protobuf_BUILD_CONFORMANCE)
include(install.cmake)
if (protobuf_BUILD_EXAMPLES)
include(examples.cmake)
endif (protobuf_BUILD_EXAMPLES)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring done")
endif(protobuf_VERBOSE)
include(../CMakeLists.txt)

View File

@ -36,6 +36,10 @@ If *git* command is not available from *Command Prompt*, add it to system *PATH*
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
@ -52,29 +56,25 @@ download `protobuf-all-[VERSION].tar.gz`.
Or you can use git to clone from protobuf git repository.
C:\Path\to> git clone -b [release_tag] https://github.com/protocolbuffers/protobuf.git
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 *master*
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>cd protobuf
C:\Path\to\protobuf>
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> git submodule update --init --recursive
C:\Path\to\src\protobuf> git submodule update --init --recursive
```
Now go to *cmake* folder in protobuf sources:
C:\Path\to\protobuf>cd cmake
C:\Path\to\protobuf\cmake>
Good. Now you are ready to *CMake* configuration.
Good. Now you are ready for *CMake* configuration.
CMake Configuration
===================
@ -82,71 +82,119 @@ 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.
We are only interested in
[Makefile](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#makefile-generators)
and
[Visual Studio](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators)
generators.
We will use shadow building to separate the temporary files from the protobuf source code.
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:
C:\Path\to\protobuf\cmake>mkdir build & cd build
C:\Path\to\protobuf\cmake\build>
mkdir C:\Path\to\build\protobuf
cd C:\Path\to\build\protobuf
C:\Path\to\build\protobuf>
The *Makefile* generator can build the project in only one configuration, so you need to build
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:
To start using a *Release* configuration via the *NMmake* generator:
C:\Path\to\protobuf\cmake\build>mkdir release & cd release
C:\Path\to\protobuf\cmake\build\release>cmake -G "NMake Makefiles" ^
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=../../../../install ^
../..
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install ^
C:\Path\to\src\protobuf
It will generate *nmake* *Makefile* in current directory.
It will generate a *NMake* *Makefile* in the current directory.
To use *Debug* configuration:
To use *Debug* configuration using *Ninja*:
C:\Path\to\protobuf\cmake\build>mkdir debug & cd debug
C:\Path\to\protobuf\cmake\build\debug>cmake -G "NMake Makefiles" ^
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=../../../../install ^
../..
-DCMAKE_INSTALL_PREFIX=C:\Path\to\install ^
C:\Path\to\src\protobuf
It will generate *nmake* *Makefile* in current directory.
It will generate *Ninja* build scripts in current directory.
To create *Visual Studio* solution file:
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\protobuf\cmake\build>mkdir solution & cd solution
C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 16 2019" ^
-DCMAKE_INSTALL_PREFIX=../../../../install ^
../..
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.
If the *gmock* directory does not exist, and you do not want to build protobuf unit tests,
you need to add *cmake* command argument `-Dprotobuf_BUILD_TESTS=OFF` to disable testing.
Unit Tests
----------
To make a *Visual Studio* file for Visual Studio 16 2019, create the *Visual Studio*
solution file above and edit the CMakeCache file.
Unit tests are being built along with the rest of protobuf. The unit tests require Google Mock (now a part of Google Test).
C:Path\to\protobuf\cmake\build\solution\CMakeCache
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.)
Then create the *Visual Studio* solution file again
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
=========
To compile protobuf:
The standard way to compile a *CMake* project is `cmake --build <directory>`.
C:\Path\to\protobuf\cmake\build\release>nmake
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\protobuf\cmake\build\debug>nmake
C:\Path\to\build\protobuf\debug>ninja
And wait for the compilation to finish.
@ -164,11 +212,15 @@ Testing
To run unit-tests, first you must compile protobuf as described above.
Then run:
C:\Path\to\protobuf\cmake\build\release>nmake check
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\protobuf\cmake\build\debug>nmake check
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.
@ -183,9 +235,9 @@ You should see output similar to:
[==========] 1546 tests from 165 test cases ran. (2529 ms total)
[ PASSED ] 1546 tests.
To run specific tests:
To run specific tests, you need to pass some command line arguments to the test program itself:
C:\Path\to\protobuf>cmake\build\release\tests.exe --gtest_filter=AnyTest*
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.
@ -210,13 +262,17 @@ If all tests are passed, safely continue.
Installing
==========
To install protobuf to the specified *install* folder:
To install protobuf to the *install* folder you've specified in the configuration step, you need to build the `install` target:
C:\Path\to\protobuf\cmake\build\release>nmake install
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\protobuf\cmake\build\debug>nmake install
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.
@ -280,16 +336,16 @@ You can also compile it from source by yourself.
Getting sources:
C:\Path\to>git clone -b v1.2.8 https://github.com/madler/zlib.git
C:\Path\to>cd zlib
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\zlib>mkdir build & cd build
C:\Path\to\zlib\build>mkdir release & cd release
C:\Path\to\zlib\build\release>cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=../../../install ../..
C:\Path\to\zlib\build\release>nmake & nmake install
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.
@ -308,8 +364,8 @@ 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>
-DZLIB_INCLUDE_DIR=<path to dir containing zlib headers>
-DZLIB_LIB=<path to dir containing zlib>
Build and testing protobuf as usual.
@ -320,8 +376,6 @@ 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.
* C4018 - 'expression' : signed/unsigned mismatch
* C4146 - unary minus operator applied to unsigned type, result still unsigned
* 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'

View File

@ -1,49 +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
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
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
${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
${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)
PUBLIC ${protobuf_SOURCE_DIR}/conformance)
target_include_directories(
conformance_cpp
PUBLIC ${protobuf_source_dir}/conformance)
PUBLIC ${protobuf_SOURCE_DIR}/conformance)
target_link_libraries(conformance_test_runner libprotobuf)
target_link_libraries(conformance_cpp libprotobuf)

View File

@ -2,7 +2,7 @@ if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Examples Configuring...")
endif()
get_filename_component(examples_dir "../examples" ABSOLUTE)
get_filename_component(examples_dir "${protobuf_SOURCE_DIR}/examples" ABSOLUTE)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Examples Configuring done")

View File

@ -5,7 +5,6 @@ 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\js
mkdir include\google\protobuf\compiler\objectivec
mkdir include\google\protobuf\compiler\php
mkdir include\google\protobuf\compiler\python
@ -19,27 +18,31 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h" include\goo
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\cpp_file.h" include\google\protobuf\compiler\cpp\cpp_file.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\cpp_helpers.h" include\google\protobuf\compiler\cpp\cpp_helpers.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_names.h" include\google\protobuf\compiler\cpp\cpp_names.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\java_kotlin_generator.h" include\google\protobuf\compiler\java\java_kotlin_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h" include\google\protobuf\compiler\java\java_names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h" include\google\protobuf\compiler\js\js_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
@ -48,6 +51,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\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
@ -57,11 +61,8 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflec
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_table_driven.h" include\google\protobuf\generated_message_table_driven.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven_lite.h" include\google\protobuf\generated_message_table_driven_lite.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_tctable_impl.inc" include\google\protobuf\generated_message_tctable_impl.inc
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

View File

@ -1,8 +1,8 @@
include(GNUInstallDirs)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf.pc.cmake
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf-lite.pc.cmake
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)
@ -13,7 +13,7 @@ endif (protobuf_BUILD_LIBPROTOC)
foreach(_library ${_protobuf_libraries})
set_property(TARGET ${_library}
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${protobuf_source_dir}/src>
$<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
if (UNIX AND NOT APPLE)
set_property(TARGET ${_library}
@ -43,15 +43,15 @@ 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 extract_includes.bat.in _extract_strings
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_from "${protobuf_SOURCE_DIR}/src/${_header}" ABSOLUTE)
get_filename_component(_extract_name ${_header} NAME)
get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" PATH)
get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" DIRECTORY)
if(EXISTS "${_extract_from}")
install(FILES "${_extract_from}"
DESTINATION "${_extract_to}"
@ -84,65 +84,73 @@ function(_protobuf_auto_list FILE_NAME VARIABLE)
endfunction()
# Install well-known type proto files
_protobuf_auto_list("../src/Makefile.am" nobase_dist_proto_DATA)
_protobuf_auto_list("${protobuf_SOURCE_DIR}/src/Makefile.am" nobase_dist_proto_DATA)
foreach(_file ${nobase_dist_proto_DATA})
get_filename_component(_file_from "../src/${_file}" ABSOLUTE)
get_filename_component(_file_from "${protobuf_SOURCE_DIR}/src/${_file}" ABSOLUTE)
get_filename_component(_file_name ${_file} NAME)
get_filename_component(_file_path ${_file} PATH)
get_filename_component(_dir ${_file} DIRECTORY)
if(EXISTS "${_file_from}")
install(FILES "${_file_from}"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_file_path}"
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 "
"\"${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(_install_cmakedir_desc "Directory relative to CMAKE_INSTALL to install the cmake configuration files")
set(_build_cmakedir_desc "Directory relative to CMAKE_CURRENT_BINARY_DIR for cmake configuration files")
set(_exampledir_desc "Directory relative to CMAKE_INSTALL_DATA to install examples")
set(_protobuf_subdir_desc "Subdirectory in which to install cmake configuration files")
if(NOT MSVC)
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/protobuf" CACHE STRING "${_cmakedir_desc}")
set(protobuf_CMAKE_SUBDIR "cmake/protobuf" CACHE STRING "${_protobuf_subdir_desc}")
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/${protobuf_CMAKE_SUBDIR}" CACHE STRING "${_install_cmakedir_desc}")
set(CMAKE_INSTALL_EXAMPLEDIR "${CMAKE_INSTALL_DATADIR}/protobuf/examples" CACHE STRING "${_exampledir_desc}")
else()
set(protobuf_CMAKE_SUBDIR "cmake" CACHE STRING "${_protobuf_subdir_desc}")
set(CMAKE_INSTALL_CMAKEDIR "cmake" CACHE STRING "${_cmakedir_desc}")
set(CMAKE_INSTALL_EXAMPLEDIR "examples" CACHE STRING "${_exampledir_desc}")
endif()
set(CMAKE_BUILD_CMAKEDIR "${CMAKE_CURRENT_BINARY_DIR}/${protobuf_CMAKE_SUBDIR}" CACHE STRING "${_build_cmakedir_desc}")
mark_as_advanced(protobuf_CMAKE_SUBDIR)
mark_as_advanced(CMAKE_BUILD_CMAKEDIR)
mark_as_advanced(CMAKE_INSTALL_CMAKEDIR)
mark_as_advanced(CMAKE_INSTALL_EXAMPLEDIR)
configure_file(protobuf-config.cmake.in
${CMAKE_INSTALL_CMAKEDIR}/protobuf-config.cmake @ONLY)
configure_file(protobuf-config-version.cmake.in
${CMAKE_INSTALL_CMAKEDIR}/protobuf-config-version.cmake @ONLY)
configure_file(protobuf-module.cmake.in
${CMAKE_INSTALL_CMAKEDIR}/protobuf-module.cmake @ONLY)
configure_file(protobuf-options.cmake
${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-config.cmake.in
${CMAKE_BUILD_CMAKEDIR}/protobuf-config.cmake @ONLY)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-config-version.cmake.in
${CMAKE_BUILD_CMAKEDIR}/protobuf-config-version.cmake @ONLY)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-module.cmake.in
${CMAKE_BUILD_CMAKEDIR}/protobuf-module.cmake @ONLY)
configure_file(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake
${CMAKE_BUILD_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
FILE ${CMAKE_BUILD_CMAKEDIR}/protobuf-targets.cmake
)
else (protobuf_BUILD_PROTOC_BINARIES)
export(TARGETS libprotobuf-lite libprotobuf
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
FILE ${CMAKE_BUILD_CMAKEDIR}/protobuf-targets.cmake
)
endif (protobuf_BUILD_PROTOC_BINARIES)
install(EXPORT protobuf-targets
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
NAMESPACE protobuf::
COMPONENT protobuf-export)
COMPONENT protobuf-export
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/
install(DIRECTORY ${CMAKE_BUILD_CMAKEDIR}/
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
COMPONENT protobuf-export
PATTERN protobuf-targets.cmake EXCLUDE
@ -150,7 +158,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/
option(protobuf_INSTALL_EXAMPLES "Install the examples folder" OFF)
if(protobuf_INSTALL_EXAMPLES)
install(DIRECTORY ../examples/
install(DIRECTORY examples/
DESTINATION "${CMAKE_INSTALL_EXAMPLEDIR}"
COMPONENT protobuf-examples)
endif()

View File

@ -1,115 +1,36 @@
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/extension_set.cc
${protobuf_source_dir}/src/google/protobuf/generated_enum_util.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.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
)
# CMake definitions for libprotobuf_lite (the "lite" C++ protobuf runtime).
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/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_table_driven.h
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.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_tctable_impl.inc
${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
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(libprotobuf_lite_rc_files
${CMAKE_CURRENT_BINARY_DIR}/version.rc
)
endif()
include(${protobuf_SOURCE_DIR}/src/file_lists.cmake)
add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_files} ${libprotobuf_lite_includes} ${libprotobuf_lite_rc_files})
target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT})
${libprotobuf_lite_srcs}
${libprotobuf_lite_hdrs}
${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 atomic)
target_link_libraries(libprotobuf-lite PRIVATE atomic)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
target_link_libraries(libprotobuf-lite log)
target_link_libraries(libprotobuf-lite PRIVATE log)
endif()
target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src)
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
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

@ -1,130 +1,39 @@
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_table_driven.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
)
# CMake definitions for libprotobuf (the "full" C++ protobuf runtime).
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_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
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(libprotobuf_rc_files
${CMAKE_CURRENT_BINARY_DIR}/version.rc
)
endif()
include(${protobuf_SOURCE_DIR}/src/file_lists.cmake)
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes} ${libprotobuf_rc_files})
target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
${libprotobuf_srcs}
${libprotobuf_hdrs}
${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 ${ZLIB_LIBRARIES})
target_link_libraries(libprotobuf PRIVATE ${ZLIB_LIBRARIES})
endif()
if(protobuf_LINK_LIBATOMIC)
target_link_libraries(libprotobuf atomic)
target_link_libraries(libprotobuf PRIVATE atomic)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
target_link_libraries(libprotobuf log)
target_link_libraries(libprotobuf PRIVATE log)
endif()
target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
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

@ -1,125 +1,22 @@
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/cpp_enum.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_extension.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_file.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_helpers.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_map_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/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/java_context.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_file.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_kotlin_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_name_resolver.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_service.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_shared_code_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.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/python_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
)
# CMake definitions for libprotoc (the protobuf compiler library).
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_file.h
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_helpers.h
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/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/importer.h
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_kotlin_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_names.h
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.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/parser.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/plugin.pb.h
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.h
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.h
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(libprotoc_rc_files
${CMAKE_CURRENT_BINARY_DIR}/version.rc
)
endif()
include(${protobuf_SOURCE_DIR}/src/file_lists.cmake)
add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
${libprotoc_files} ${libprotoc_headers} ${libprotoc_rc_files})
target_link_libraries(libprotoc libprotobuf)
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
${libprotoc_srcs}
${libprotoc_hdrs}
${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)
@ -127,6 +24,7 @@ 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

@ -11,7 +11,7 @@ function(protobuf_generate)
include(CMakeParseArguments)
set(_options APPEND_PATH)
set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN)
set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN PLUGIN_OPTIONS DEPENDENCIES)
if(COMMAND target_sources)
list(APPEND _singleargs TARGET)
endif()
@ -39,9 +39,18 @@ function(protobuf_generate)
endif()
if(protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp)
set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}:")
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()
@ -75,10 +84,10 @@ function(protobuf_generate)
# Create an include path for each file specified
foreach(_file ${protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_file} ABSOLUTE)
get_filename_component(_abs_path ${_abs_file} PATH)
list(FIND _protobuf_include_path ${_abs_path} _contains_already)
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_path})
list(APPEND _protobuf_include_path -I ${_abs_dir})
endif()
endforeach()
endif()
@ -127,12 +136,20 @@ function(protobuf_generate)
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 ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file}
DEPENDS ${_abs_file} protobuf::protoc
COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}. Custom options: ${protobuf_generate_PROTOC_OPTIONS}"
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 ${protobuf_generate_DEPENDENCIES}
COMMENT ${_comment}
VERBATIM )
endforeach()

View File

@ -94,7 +94,7 @@ function(_protobuf_find_libraries name filename)
elseif(${name}_LIBRARY)
# Honor cache entry used by CMake 3.5 and lower.
set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE)
else()
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}
@ -134,23 +134,25 @@ get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
INTERFACE_INCLUDE_DIRECTORIES)
# Set the protoc Executable
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
IMPORTED_LOCATION_RELEASE)
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
if(NOT Protobuf_PROTOC_EXECUTABLE AND TARGET protobuf::protoc)
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)
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

View File

@ -1,15 +1,12 @@
set(protoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/main.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/main.cc
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(protoc_rc_files
${CMAKE_CURRENT_BINARY_DIR}/version.rc
add_executable(protoc ${protoc_files} ${protobuf_version_rc_file})
target_link_libraries(protoc
libprotoc
libprotobuf
)
endif()
add_executable(protoc ${protoc_files} ${protoc_rc_files})
target_link_libraries(protoc libprotoc libprotobuf)
add_executable(protobuf::protoc ALIAS protoc)
set_target_properties(protoc PROPERTIES

View File

@ -1,96 +1,64 @@
if (NOT EXISTS "${PROJECT_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()
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)
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
)
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()
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)
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()
include(${protobuf_SOURCE_DIR}/src/file_lists.cmake)
set(lite_test_protos
google/protobuf/map_lite_unittest.proto
google/protobuf/unittest_import_lite.proto
google/protobuf/unittest_import_public_lite.proto
google/protobuf/unittest_lite.proto
${protobuf_lite_test_protos_proto_srcs}
)
set(tests_protos
google/protobuf/any_test.proto
google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto
google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto
google/protobuf/map_proto2_unittest.proto
google/protobuf/map_unittest.proto
google/protobuf/unittest.proto
google/protobuf/unittest_arena.proto
google/protobuf/unittest_custom_options.proto
google/protobuf/unittest_drop_unknown_fields.proto
google/protobuf/unittest_embed_optimize_for.proto
google/protobuf/unittest_empty.proto
google/protobuf/unittest_import.proto
google/protobuf/unittest_import_public.proto
google/protobuf/unittest_lazy_dependencies.proto
google/protobuf/unittest_lazy_dependencies_custom_option.proto
google/protobuf/unittest_lazy_dependencies_enum.proto
google/protobuf/unittest_lite_imports_nonlite.proto
google/protobuf/unittest_mset.proto
google/protobuf/unittest_mset_wire_format.proto
google/protobuf/unittest_no_field_presence.proto
google/protobuf/unittest_no_generic_services.proto
google/protobuf/unittest_optimize_for.proto
google/protobuf/unittest_preserve_unknown_enum.proto
google/protobuf/unittest_preserve_unknown_enum2.proto
google/protobuf/unittest_proto3.proto
google/protobuf/unittest_proto3_arena.proto
google/protobuf/unittest_proto3_arena_lite.proto
google/protobuf/unittest_proto3_lite.proto
google/protobuf/unittest_proto3_optional.proto
google/protobuf/unittest_well_known_types.proto
google/protobuf/util/internal/testdata/anys.proto
google/protobuf/util/internal/testdata/books.proto
google/protobuf/util/internal/testdata/default_value.proto
google/protobuf/util/internal/testdata/default_value_test.proto
google/protobuf/util/internal/testdata/field_mask.proto
google/protobuf/util/internal/testdata/maps.proto
google/protobuf/util/internal/testdata/oneofs.proto
google/protobuf/util/internal/testdata/proto3.proto
google/protobuf/util/internal/testdata/struct.proto
google/protobuf/util/internal/testdata/timestamp_duration.proto
google/protobuf/util/internal/testdata/wrappers.proto
google/protobuf/util/json_format.proto
google/protobuf/util/json_format_proto3.proto
google/protobuf/util/message_differencer_unittest.proto
${protobuf_test_protos_proto_srcs}
${compiler_test_protos_files}
${util_test_protos_files}
)
macro(compile_proto_file filename)
get_filename_component(dirname ${filename} PATH)
get_filename_component(basename ${filename} NAME_WE)
string(REPLACE .proto .pb.cc pb_file ${filename})
add_custom_command(
OUTPUT ${protobuf_source_dir}/src/${dirname}/${basename}.pb.cc
DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/src/${dirname}/${basename}.proto
COMMAND ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/src/${dirname}/${basename}.proto
--proto_path=${protobuf_source_dir}/src
--cpp_out=${protobuf_source_dir}/src
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)
@ -98,112 +66,38 @@ endmacro(compile_proto_file)
set(lite_test_proto_files)
foreach(proto_file ${lite_test_protos})
compile_proto_file(${proto_file})
string(REPLACE .proto .pb.cc pb_file ${proto_file})
set(lite_test_proto_files ${lite_test_proto_files}
${protobuf_source_dir}/src/${pb_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})
string(REPLACE .proto .pb.cc pb_file ${proto_file})
set(tests_proto_files ${tests_proto_files}
${protobuf_source_dir}/src/${pb_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
${lite_test_util_srcs} ${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/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/test_util.inc
${protobuf_source_dir}/src/google/protobuf/testing/file.cc
${protobuf_source_dir}/src/google/protobuf/testing/googletest.cc
${lite_test_util_srcs}
${test_util_hdrs}
${test_util_srcs}
${mock_code_generator_srcs}
${testing_srcs}
)
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/compiler/annotation_test_util.cc
${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.inc
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/metadata_test.cc
${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/java_doc_comment_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_plugin_unittest.cc
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.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/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/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
${protobuf_test_files}
${compiler_test_files}
${annotation_test_util_srcs}
${io_test_files}
${util_test_files}
${stubs_test_files}
)
if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
@ -221,32 +115,43 @@ if(MINGW)
endif()
add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files})
target_link_libraries(tests libprotoc libprotobuf gmock_main)
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
${test_plugin_files}
${mock_code_generator_srcs}
${testing_srcs}
)
add_executable(test_plugin ${test_plugin_files})
target_link_libraries(test_plugin libprotoc libprotobuf gmock)
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} ${common_lite_test_files} ${lite_test_proto_files})
target_link_libraries(lite-test libprotobuf-lite gmock_main)
add_executable(lite-test ${protobuf_lite_test_files})
target_link_libraries(lite-test protobuf-lite-test-common libprotobuf-lite GTest::gmock_main)
set(lite_arena_test_files
${protobuf_source_dir}/src/google/protobuf/lite_arena_unittest.cc
)
add_executable(lite-arena-test ${lite_arena_test_files} ${common_lite_test_files} ${lite_test_proto_files})
target_link_libraries(lite-arena-test libprotobuf-lite gmock_main)
add_test(NAME lite-test
COMMAND lite-test ${protobuf_GTEST_ARGS})
add_custom_target(check
COMMAND tests
DEPENDS tests test_plugin
WORKING_DIRECTORY ${protobuf_source_dir})
WORKING_DIRECTORY ${protobuf_SOURCE_DIR})
add_test(NAME check
COMMAND tests ${protobuf_GTEST_ARGS}
WORKING_DIRECTORY "${protobuf_SOURCE_DIR}")

View File

@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# 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.19.1],[protobuf@googlegroups.com],[protobuf])
AC_INIT([Protocol Buffers],[3.21.1],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])
@ -31,7 +31,7 @@ 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 | js | php) ;;
all | cpp | csharp | java | python | javanano | objectivec | ruby | php) ;;
*) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
esac
AC_SUBST(DIST_LANG)
@ -80,7 +80,7 @@ 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
AC_PROG_OBJC
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...])

183
conformance/BUILD.bazel Normal file
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 = ["//src/google/protobuf/compiler/csharp:__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

@ -229,11 +229,12 @@ class ConformanceJava {
}
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
com.google.protobuf.AbstractMessage testMessage;
AbstractMessage testMessage;
String messageType = request.getMessageType();
boolean isProto3 =
request.getMessageType().equals("protobuf_test_messages.proto3.TestAllTypesProto3");
messageType.equals("protobuf_test_messages.proto3.TestAllTypesProto3");
boolean isProto2 =
request.getMessageType().equals("protobuf_test_messages.proto2.TestAllTypesProto2");
messageType.equals("protobuf_test_messages.proto2.TestAllTypesProto2");
switch (request.getPayloadCase()) {
case PROTOBUF_PAYLOAD:
@ -263,7 +264,8 @@ class ConformanceJava {
.build();
}
} else {
throw new RuntimeException("Protobuf request doesn't have specific payload type.");
throw new IllegalArgumentException(
"Protobuf request has unexpected payload type: " + messageType);
}
break;
}
@ -286,7 +288,8 @@ class ConformanceJava {
parser.merge(request.getJsonPayload(), builder);
testMessage = builder.build();
} else {
throw new RuntimeException("Protobuf request doesn't have specific payload type.");
throw new IllegalArgumentException(
"Protobuf request has unexpected payload type: " + messageType);
}
} catch (InvalidProtocolBufferException e) {
return Conformance.ConformanceResponse.newBuilder()
@ -320,24 +323,25 @@ class ConformanceJava {
.build();
}
} else {
throw new RuntimeException("Protobuf request doesn't have specific payload type.");
throw new IllegalArgumentException(
"Protobuf request has unexpected payload type: " + messageType);
}
break;
}
case PAYLOAD_NOT_SET:
{
throw new RuntimeException("Request didn't have payload.");
throw new IllegalArgumentException("Request didn't have payload.");
}
default:
{
throw new RuntimeException("Unexpected payload case.");
throw new IllegalArgumentException("Unexpected payload case.");
}
}
switch (request.getRequestedOutputFormat()) {
case UNSPECIFIED:
throw new RuntimeException("Unspecified output format.");
throw new IllegalArgumentException("Unspecified output format.");
case PROTOBUF:
{
@ -361,12 +365,12 @@ class ConformanceJava {
case TEXT_FORMAT:
return Conformance.ConformanceResponse.newBuilder()
.setTextPayload(TextFormat.printToString(testMessage))
.setTextPayload(TextFormat.printer().printToString(testMessage))
.build();
default:
{
throw new RuntimeException("Unexpected request output.");
throw new IllegalArgumentException("Unexpected request output.");
}
}
}

View File

@ -260,9 +260,9 @@ 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=. --js_out=import_style=commonjs,binary:. $(conformance_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --js_out=import_style=commonjs,binary:. $(conformance_proto2_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --js_out=import_style=commonjs,binary:google-protobuf $(well_known_type_protoc_inputs)
$(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
@ -272,9 +272,9 @@ else
# 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 --js_out=import_style=commonjs,binary:$$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 --js_out=import_style=commonjs,binary:$$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 --js_out=import_style=commonjs,binary:$$oldpwd/google-protobuf $(well_known_type_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 --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
@ -316,7 +316,7 @@ conformance-java-lite: javac_middleman_lite
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/netcoreapp2.1/Google.Protobuf.Conformance.dll "$$@"' >> 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:
@ -364,9 +364,6 @@ test_python: protoc_middleman conformance-test-runner
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
test_nodejs: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
NODE_PATH=../js:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_js.txt ./conformance_nodejs.js
if OBJC_CONFORMANCE_TEST
test_objc: protoc_middleman conformance-test-runner conformance-objc

View File

@ -49,7 +49,7 @@ 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
Travis runs the tests.
Kokoro runs the tests.
Testing other Protocol Buffer implementations
---------------------------------------------
@ -57,10 +57,10 @@ 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/master/conformance/conformance.proto).
[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/master/conformance/conformance_cpp.cc)).
(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

View File

@ -2226,11 +2226,11 @@ void BinaryAndJsonConformanceSuite::RunJsonTestsForNonRepeatedTypes() {
"optional_aliased_enum: ALIAS_BAZ");
RunValidJsonTest(
"EnumFieldWithAliasUseAlias", REQUIRED,
R"({"optionalAliasedEnum": "QUX"})",
R"({"optionalAliasedEnum": "MOO"})",
"optional_aliased_enum: ALIAS_BAZ");
RunValidJsonTest(
"EnumFieldWithAliasLowerCase", REQUIRED,
R"({"optionalAliasedEnum": "qux"})",
R"({"optionalAliasedEnum": "moo"})",
"optional_aliased_enum: ALIAS_BAZ");
RunValidJsonTest(
"EnumFieldWithAliasDifferentCase", REQUIRED,

View File

@ -32,165 +32,176 @@
#include <stdarg.h>
#include <unistd.h>
#include <memory>
#include <string>
#include <utility>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.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 <google/protobuf/stubs/statusor.h>
#include "conformance.pb.h"
#include "conformance.pb.h"
#include <google/protobuf/test_messages_proto2.pb.h>
#include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/status_macros.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;
// Must be included last.
#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
namespace {
using ::conformance::ConformanceRequest;
using ::conformance::ConformanceResponse;
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::proto2::TestAllTypesProto2;
using ::protobuf_test_messages::proto3::TestAllTypesProto3;
using util::Status;
bool CheckedRead(int fd, void *buf, size_t len) {
size_t ofs = 0;
util::Status ReadFd(int fd, char* buf, size_t len) {
while (len > 0) {
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
ssize_t bytes_read = read(fd, buf, len);
if (bytes_read == 0) return false;
if (bytes_read == 0) {
return util::DataLossError("unexpected EOF");
}
if (bytes_read < 0) {
GOOGLE_LOG(FATAL) << "Error reading from test runner: " << strerror(errno);
return util::ErrnoToStatus(errno, "error reading from test runner");
}
len -= bytes_read;
ofs += bytes_read;
buf += bytes_read;
}
return true;
return util::OkStatus();
}
void CheckedWrite(int fd, const void *buf, size_t len) {
util::Status WriteFd(int fd, const void* buf, size_t len) {
if (write(fd, buf, len) != len) {
GOOGLE_LOG(FATAL) << "Error writing to test runner: " << strerror(errno);
return util::ErrnoToStatus(errno, "error reading to test runner");
}
return util::OkStatus();
}
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();
class Harness {
public:
Harness() {
google::protobuf::LinkMessageReflection<TestAllTypesProto2>();
google::protobuf::LinkMessageReflection<TestAllTypesProto3>();
resolver_.reset(NewTypeResolverForDescriptorPool(
"type.googleapis.com", DescriptorPool::generated_pool()));
type_url_ = StrCat("type.googleapis.com/",
TestAllTypesProto3::GetDescriptor()->full_name());
}
test_message = MessageFactory::generated_factory()->GetPrototype(descriptor)->New();
util::StatusOr<ConformanceResponse> RunTest(
const ConformanceRequest& request);
// Returns Ok(true) if we're done processing requests.
util::StatusOr<bool> ServeConformanceRequest();
private:
bool verbose_ = false;
std::unique_ptr<TypeResolver> resolver_;
std::string type_url_;
};
util::StatusOr<ConformanceResponse> Harness::RunTest(
const ConformanceRequest& request) {
const Descriptor* descriptor =
DescriptorPool::generated_pool()->FindMessageTypeByName(
request.message_type());
if (descriptor == nullptr) {
return util::NotFoundError(
StrCat("No such message type: ", request.message_type()));
}
std::unique_ptr<Message> test_message(
MessageFactory::generated_factory()->GetPrototype(descriptor)->New());
ConformanceResponse response;
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;
response.set_parse_error("parse error (no more details available)");
return response;
}
break;
}
case ConformanceRequest::kJsonPayload: {
string proto_binary;
JsonParseOptions options;
options.ignore_unknown_fields =
(request.test_category() ==
conformance::JSON_IGNORE_UNKNOWN_PARSING_TEST);
conformance::JSON_IGNORE_UNKNOWN_PARSING_TEST);
std::string proto_binary;
util::Status status =
JsonToBinaryString(type_resolver, *type_url, request.json_payload(),
JsonToBinaryString(resolver_.get(), type_url_, request.json_payload(),
&proto_binary, options);
if (!status.ok()) {
response->set_parse_error(string("Parse error: ") +
std::string(status.message()));
return;
response.set_parse_error(
StrCat("parse error: ", status.message()));
return response;
}
if (!test_message->ParseFromString(proto_binary)) {
response->set_runtime_error(
"Parsing JSON generates invalid proto output.");
return;
response.set_runtime_error(
"parsing JSON generated invalid proto output");
return response;
}
break;
}
case ConformanceRequest::kTextPayload: {
if (!TextFormat::ParseFromString(request.text_payload(), test_message)) {
response->set_parse_error("Parse error");
return;
if (!TextFormat::ParseFromString(request.text_payload(),
test_message.get())) {
response.set_parse_error("parse error (no more details available)");
return response;
}
break;
}
case ConformanceRequest::PAYLOAD_NOT_SET:
GOOGLE_LOG(FATAL) << "Request didn't have payload.";
break;
return util::InvalidArgumentError("request didn't have payload");
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;
return util::InvalidArgumentError(
StrCat("unknown payload type", request.payload_case()));
}
switch (request.requested_output_format()) {
case conformance::UNSPECIFIED:
GOOGLE_LOG(FATAL) << "Unspecified output format";
break;
return util::InvalidArgumentError("unspecified output format");
case conformance::PROTOBUF: {
GOOGLE_CHECK(test_message->SerializeToString(
response->mutable_protobuf_payload()));
GOOGLE_CHECK(
test_message->SerializeToString(response.mutable_protobuf_payload()));
break;
}
case conformance::JSON: {
string proto_binary;
std::string proto_binary;
GOOGLE_CHECK(test_message->SerializeToString(&proto_binary));
util::Status status =
BinaryToJsonString(type_resolver, *type_url, proto_binary,
response->mutable_json_payload());
BinaryToJsonString(resolver_.get(), 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;
response.set_serialize_error(StrCat(
"failed to serialize JSON output: ", status.message()));
}
break;
}
@ -199,70 +210,66 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
TextFormat::Printer printer;
printer.SetHideUnknownFields(!request.print_unknown_fields());
GOOGLE_CHECK(printer.PrintToString(*test_message,
response->mutable_text_payload()));
response.mutable_text_payload()));
break;
}
default:
GOOGLE_LOG(FATAL) << "Unknown output format: "
<< request.requested_output_format();
return util::InvalidArgumentError(StrCat(
"unknown output format", request.requested_output_format()));
}
return response;
}
bool DoTestIo() {
string serialized_input;
string serialized_output;
util::StatusOr<bool> Harness::ServeConformanceRequest() {
uint32_t in_len;
if (!ReadFd(STDIN_FILENO, reinterpret_cast<char*>(&in_len), sizeof(in_len))
.ok()) {
// EOF means we're done.
return true;
}
std::string serialized_input;
serialized_input.resize(in_len);
RETURN_IF_ERROR(ReadFd(STDIN_FILENO, serialized_input.data(), in_len));
ConformanceRequest request;
ConformanceResponse response;
uint32_t bytes;
GOOGLE_CHECK(request.ParseFromString(serialized_input));
if (!CheckedRead(STDIN_FILENO, &bytes, sizeof(uint32_t))) {
// EOF.
return false;
util::StatusOr<ConformanceResponse> response = RunTest(request);
RETURN_IF_ERROR(response.status());
std::string serialized_output;
response->SerializeToString(&serialized_output);
uint32_t out_len = static_cast<uint32_t>(serialized_output.size());
RETURN_IF_ERROR(WriteFd(STDOUT_FILENO, &out_len, sizeof(out_len)));
RETURN_IF_ERROR(WriteFd(STDOUT_FILENO, serialized_output.data(), out_len));
if (verbose_) {
GOOGLE_LOG(INFO) << "conformance-cpp: request=" << request.ShortDebugString()
<< ", response=" << response->ShortDebugString();
}
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;
return false;
}
} // namespace
} // 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;
google::protobuf::Harness harness;
int total_runs = 0;
while (true) {
auto is_done = harness.ServeConformanceRequest();
if (!is_done.ok()) {
GOOGLE_LOG(FATAL) << is_done.status();
}
if (*is_done) {
break;
}
total_runs++;
}
GOOGLE_LOG(INFO) << "conformance-cpp: received EOF from test runner after "
<< total_runs << " tests";
}

View File

@ -41,11 +41,17 @@ function doTest(request) {
var response = new conformance.ConformanceResponse();
try {
if (request.getRequestedOutputFormat() === conformance.WireFormat.JSON) {
if (request.getRequestedOutputFormat() == conformance.WireFormat.JSON) {
response.setSkipped("JSON not supported.");
return response;
}
if (request.getRequestedOutputFormat() ==
conformance.WireFormat.TEXT_FORMAT) {
response.setSkipped('Text format is not supported as output format.');
return response;
}
switch (request.getPayloadCase()) {
case conformance.ConformanceRequest.PayloadCase.PROTOBUF_PAYLOAD: {
if (request.getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") {
@ -67,7 +73,7 @@ function doTest(request) {
} else {
throw "Protobuf request doesn\'t have specific payload type";
}
}
} break;
case conformance.ConformanceRequest.PayloadCase.JSON_PAYLOAD:
response.setSkipped("JSON not supported.");

View File

@ -350,7 +350,17 @@ bool ConformanceTestSuite::CheckSetEmpty(
StringAppendF(&output_, "\n");
if (!write_to_file.empty()) {
std::ofstream os(write_to_file);
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) {
@ -358,7 +368,7 @@ bool ConformanceTestSuite::CheckSetEmpty(
}
} else {
StringAppendF(&output_, "Failed to open file: %s\n",
write_to_file.c_str());
filename->c_str());
}
}

View File

@ -174,6 +174,11 @@ class ConformanceTestSuite {
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".
//
@ -296,6 +301,7 @@ class ConformanceTestSuite {
bool verbose_;
bool enforce_recommended_;
std::string output_;
std::string output_dir_;
std::string failure_list_flag_name_;
std::string failure_list_filename_;

View File

@ -141,6 +141,9 @@ void UsageError() {
" strictly conforming to protobuf\n");
fprintf(stderr,
" spec.\n");
fprintf(stderr,
" --output_dir <dirname> Directory to write\n"
" output files.\n");
exit(1);
}
@ -162,7 +165,7 @@ void ForkPipeRunner::RunTest(
// 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;
int status = 0;
waitpid(child_pid_, &status, WEXITED);
string error_msg;
@ -208,6 +211,9 @@ int ForkPipeRunner::Run(
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) {

View File

@ -40,7 +40,7 @@ while [[ -n "$@" ]]; do
esac
done
conformance_test_runner=$(rlocation com_google_protobuf/conformance_test_runner)
conformance_test_runner=$(rlocation com_google_protobuf/conformance/conformance_test_runner)
conformance_testee=$(rlocation $TESTEE)
args=(--enforce_recommended)

44
conformance/defs.bzl Normal file
View File

@ -0,0 +1,44 @@
"""Starlark definitions for Protobuf conformance tests.
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):
"""Conformance test runner.
Args:
name: the name for the test.
testee: a conformance test client binary.
failure_list: a text file with known failures, one per line.
text_format_failure_list: a text file with known failures (one per line)
for the text format conformance suite.
"""
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,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

17
csharp/.editorconfig Normal file
View File

@ -0,0 +1,17 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
indent_style = space
tab_width = 4
# New line preferences
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true

1
csharp/.gitignore vendored
View File

@ -18,6 +18,7 @@ lib/NUnit
# Untracked files
#
.vs
.cr
*.user
*.suo
*.nupkg

53
csharp/BUILD.bazel Normal file
View File

@ -0,0 +1,53 @@
# Protobuf C# runtime
#
# See also code generation logic under /src/google/protobuf/compiler/csharp.
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
filegroup(
name = "wkt_cs_srcs",
data = [
"src/Google.Protobuf.Conformance/Conformance.cs",
"src/Google.Protobuf/Reflection/Descriptor.cs",
"src/Google.Protobuf/WellKnownTypes/Any.cs",
"src/Google.Protobuf/WellKnownTypes/Api.cs",
"src/Google.Protobuf/WellKnownTypes/Duration.cs",
"src/Google.Protobuf/WellKnownTypes/Empty.cs",
"src/Google.Protobuf/WellKnownTypes/FieldMask.cs",
"src/Google.Protobuf/WellKnownTypes/SourceContext.cs",
"src/Google.Protobuf/WellKnownTypes/Struct.cs",
"src/Google.Protobuf/WellKnownTypes/Timestamp.cs",
"src/Google.Protobuf/WellKnownTypes/Type.cs",
"src/Google.Protobuf/WellKnownTypes/Wrappers.cs",
],
visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"],
)
pkg_files(
name = "dist_files",
srcs = glob([
"keys/*",
"protos/*",
"src/**/*.cs*", # .cs and .csproj
]) + [
".editorconfig",
".gitignore",
"BUILD.bazel",
"CHANGES.txt",
"Google.Protobuf.Tools.nuspec",
"Google.Protobuf.Tools.targets",
"NuGet.Config",
"README.md",
"build_packages.bat",
"build_tools.sh",
"buildall.bat",
"buildall.sh",
"generate_protos.sh",
"install_dotnet_sdk.ps1",
"src/Google.Protobuf.Benchmarks/wrapper_benchmark_messages.proto",
"src/Google.Protobuf.Test/testprotos.pb",
"src/Google.Protobuf.sln",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)

View File

@ -5,10 +5,10 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
<version>3.19.1</version>
<version>3.21.1</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>
<projectUrl>https://github.com/protocolbuffers/protobuf</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>Tools for Protocol Buffers</releaseNotes>

8
csharp/NuGet.Config Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="NuGet.org (v3)" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

View File

@ -23,6 +23,7 @@ The runtime library is built as a portable class library, supporting:
- Windows Phone Silverlight 8
- Windows Phone 8.1
- .NET Core
- .NET 5
You should be able to use Protocol Buffers in Visual Studio 2012 and
all later versions. This includes all code generated by `protoc`,
@ -31,15 +32,15 @@ which only uses features from C# 3 and earlier.
Building
========
Open the `src/Google.Protobuf.sln` solution in Visual Studio 2017 or
Open the `src/Google.Protobuf.sln` solution in Visual Studio 2022 or
later.
Although *users* of this project are only expected to have Visual
Studio 2012 or later, *developers* of the library are required to
have Visual Studio 2017 or later, as the library uses C# 6 features
in its implementation, as well as the new Visual Studio 2017 csproj
format. These features have no impact when using the compiled code -
they're only relevant when building the `Google.Protobuf` assembly.
have Visual Studio 2022 or later, as the library uses C# 10 features
in its implementation and runs tests under .NET 6. These features
have no impact when using the compiled code - they're only relevant
when building the `Google.Protobuf` assembly.
In order to run and debug the AddressBook example in the IDE, you must
install the optional component, ".Net Core 1.0 - 1.1 development tools

View File

@ -1,7 +1,7 @@
@rem Builds Google.Protobuf NuGet packages
dotnet restore src/Google.Protobuf.sln
dotnet pack -c Release src/Google.Protobuf.sln || goto :error
dotnet pack -c Release src/Google.Protobuf.sln -p:ContinuousIntegrationBuild=true || goto :error
goto :EOF

View File

@ -10,8 +10,8 @@ dotnet restore $SRC/Google.Protobuf.sln
dotnet build -c $CONFIG $SRC/Google.Protobuf.sln
echo Running tests.
# Only test netcoreapp2.1, which uses the .NET Core runtime.
# Only test netcoreapp3.1, which uses the .NET Core runtime.
# If we want to test the .NET 4.5 version separately, we could
# run Mono explicitly. However, we don't have any differences between
# the .NET 4.5 and netstandard2.1 assemblies.
dotnet test -c $CONFIG -f netcoreapp2.1 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj
dotnet test -c $CONFIG -f netcoreapp3.1 $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj

View File

@ -1,171 +1,171 @@
#region Copyright notice and license
// 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.
#endregion
using System;
using System.Text;
using NUnit.Framework;
namespace Google.Protobuf
{
public class ByteStringTest
{
[Test]
public void Equality()
{
ByteString b1 = ByteString.CopyFrom(1, 2, 3);
ByteString b2 = ByteString.CopyFrom(1, 2, 3);
ByteString b3 = ByteString.CopyFrom(1, 2, 4);
ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4);
EqualityTester.AssertEquality(b1, b1);
EqualityTester.AssertEquality(b1, b2);
EqualityTester.AssertInequality(b1, b3);
EqualityTester.AssertInequality(b1, b4);
EqualityTester.AssertInequality(b1, null);
#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1)
Assert.IsTrue(b1 == b1);
Assert.IsTrue(b1 == b2);
Assert.IsFalse(b1 == b3);
Assert.IsFalse(b1 == b4);
Assert.IsFalse(b1 == null);
Assert.IsTrue((ByteString) null == null);
Assert.IsFalse(b1 != b1);
Assert.IsFalse(b1 != b2);
#pragma warning disable 1718
Assert.IsTrue(b1 != b3);
Assert.IsTrue(b1 != b4);
Assert.IsTrue(b1 != null);
Assert.IsFalse((ByteString) null != null);
}
[Test]
public void EmptyByteStringHasZeroSize()
{
Assert.AreEqual(0, ByteString.Empty.Length);
}
[Test]
public void CopyFromStringWithExplicitEncoding()
{
ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode);
Assert.AreEqual(4, bs.Length);
Assert.AreEqual(65, bs[0]);
Assert.AreEqual(0, bs[1]);
Assert.AreEqual(66, bs[2]);
Assert.AreEqual(0, bs[3]);
}
[Test]
public void IsEmptyWhenEmpty()
{
Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty);
}
[Test]
public void IsEmptyWhenNotEmpty()
{
Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty);
}
[Test]
public void CopyFromByteArrayCopiesContents()
{
byte[] data = new byte[1];
data[0] = 10;
ByteString bs = ByteString.CopyFrom(data);
Assert.AreEqual(10, bs[0]);
data[0] = 5;
Assert.AreEqual(10, bs[0]);
}
[Test]
public void ToByteArrayCopiesContents()
{
ByteString bs = ByteString.CopyFromUtf8("Hello");
byte[] data = bs.ToByteArray();
Assert.AreEqual((byte)'H', data[0]);
Assert.AreEqual((byte)'H', bs[0]);
data[0] = 0;
Assert.AreEqual(0, data[0]);
Assert.AreEqual((byte)'H', bs[0]);
}
[Test]
public void CopyFromUtf8UsesUtf8()
{
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
Assert.AreEqual(3, bs.Length);
Assert.AreEqual(0xe2, bs[0]);
Assert.AreEqual(0x82, bs[1]);
Assert.AreEqual(0xac, bs[2]);
}
[Test]
public void CopyFromPortion()
{
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
ByteString bs = ByteString.CopyFrom(data, 2, 3);
Assert.AreEqual(3, bs.Length);
Assert.AreEqual(2, bs[0]);
Assert.AreEqual(3, bs[1]);
}
[Test]
public void ToStringUtf8()
{
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
Assert.AreEqual("\u20ac", bs.ToStringUtf8());
}
[Test]
public void ToStringWithExplicitEncoding()
{
ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode);
Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode));
}
[Test]
public void FromBase64_WithText()
{
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
string base64 = Convert.ToBase64String(data);
ByteString bs = ByteString.FromBase64(base64);
Assert.AreEqual(data, bs.ToByteArray());
}
[Test]
public void FromBase64_Empty()
{
// Optimization which also fixes issue 61.
Assert.AreSame(ByteString.Empty, ByteString.FromBase64(""));
}
}
#region Copyright notice and license
// 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.
#endregion
using System;
using System.Text;
using NUnit.Framework;
namespace Google.Protobuf
{
public class ByteStringTest
{
[Test]
public void Equality()
{
ByteString b1 = ByteString.CopyFrom(1, 2, 3);
ByteString b2 = ByteString.CopyFrom(1, 2, 3);
ByteString b3 = ByteString.CopyFrom(1, 2, 4);
ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4);
EqualityTester.AssertEquality(b1, b1);
EqualityTester.AssertEquality(b1, b2);
EqualityTester.AssertInequality(b1, b3);
EqualityTester.AssertInequality(b1, b4);
EqualityTester.AssertInequality(b1, null);
#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1)
Assert.IsTrue(b1 == b1);
Assert.IsTrue(b1 == b2);
Assert.IsFalse(b1 == b3);
Assert.IsFalse(b1 == b4);
Assert.IsFalse(b1 == null);
Assert.IsTrue((ByteString) null == null);
Assert.IsFalse(b1 != b1);
Assert.IsFalse(b1 != b2);
#pragma warning disable 1718
Assert.IsTrue(b1 != b3);
Assert.IsTrue(b1 != b4);
Assert.IsTrue(b1 != null);
Assert.IsFalse((ByteString) null != null);
}
[Test]
public void EmptyByteStringHasZeroSize()
{
Assert.AreEqual(0, ByteString.Empty.Length);
}
[Test]
public void CopyFromStringWithExplicitEncoding()
{
ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode);
Assert.AreEqual(4, bs.Length);
Assert.AreEqual(65, bs[0]);
Assert.AreEqual(0, bs[1]);
Assert.AreEqual(66, bs[2]);
Assert.AreEqual(0, bs[3]);
}
[Test]
public void IsEmptyWhenEmpty()
{
Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty);
}
[Test]
public void IsEmptyWhenNotEmpty()
{
Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty);
}
[Test]
public void CopyFromByteArrayCopiesContents()
{
byte[] data = new byte[1];
data[0] = 10;
ByteString bs = ByteString.CopyFrom(data);
Assert.AreEqual(10, bs[0]);
data[0] = 5;
Assert.AreEqual(10, bs[0]);
}
[Test]
public void ToByteArrayCopiesContents()
{
ByteString bs = ByteString.CopyFromUtf8("Hello");
byte[] data = bs.ToByteArray();
Assert.AreEqual((byte)'H', data[0]);
Assert.AreEqual((byte)'H', bs[0]);
data[0] = 0;
Assert.AreEqual(0, data[0]);
Assert.AreEqual((byte)'H', bs[0]);
}
[Test]
public void CopyFromUtf8UsesUtf8()
{
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
Assert.AreEqual(3, bs.Length);
Assert.AreEqual(0xe2, bs[0]);
Assert.AreEqual(0x82, bs[1]);
Assert.AreEqual(0xac, bs[2]);
}
[Test]
public void CopyFromPortion()
{
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
ByteString bs = ByteString.CopyFrom(data, 2, 3);
Assert.AreEqual(3, bs.Length);
Assert.AreEqual(2, bs[0]);
Assert.AreEqual(3, bs[1]);
}
[Test]
public void ToStringUtf8()
{
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
Assert.AreEqual("\u20ac", bs.ToStringUtf8());
}
[Test]
public void ToStringWithExplicitEncoding()
{
ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode);
Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode));
}
[Test]
public void FromBase64_WithText()
{
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
string base64 = Convert.ToBase64String(data);
ByteString bs = ByteString.FromBase64(base64);
Assert.AreEqual(data, bs.ToByteArray());
}
[Test]
public void FromBase64_Empty()
{
// Optimization which also fixes issue 61.
Assert.AreSame(ByteString.Empty, ByteString.FromBase64(""));
}
}
}

View File

@ -1,419 +1,419 @@
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
using Google.Protobuf.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
public class CodedOutputStreamTest
{
/// <summary>
/// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and
/// checks that the result matches the given bytes
/// </summary>
private static void AssertWriteVarint(byte[] data, ulong value)
{
// Only do 32-bit write if the value fits in 32 bits.
if ((value >> 32) == 0)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawVarint32((uint) value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Also try computing size.
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value));
}
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawVarint64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Also try computing size.
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value));
}
// Try different buffer sizes.
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
{
// Only do 32-bit write if the value fits in 32 bits.
if ((value >> 32) == 0)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output =
new CodedOutputStream(rawOutput, bufferSize);
output.WriteRawVarint32((uint) value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize);
output.WriteRawVarint64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
}
}
/// <summary>
/// Tests WriteRawVarint32() and WriteRawVarint64()
/// </summary>
[Test]
public void WriteVarint()
{
AssertWriteVarint(new byte[] {0x00}, 0);
AssertWriteVarint(new byte[] {0x01}, 1);
AssertWriteVarint(new byte[] {0x7f}, 127);
// 14882
AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7));
// 2961488830
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b},
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
(0x0bL << 28));
// 64-bit
// 7256456126
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b},
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
(0x1bL << 28));
// 41256202580718336
AssertWriteVarint(
new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49},
(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
(0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49));
// 11964378330978735131
AssertWriteVarint(
new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01},
unchecked((ulong)
((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
(0x3bL << 28) | (0x56L << 35) | (0x00L << 42) |
(0x05L << 49) | (0x26L << 56) | (0x01L << 63))));
}
/// <summary>
/// Parses the given bytes using WriteRawLittleEndian32() and checks
/// that the result matches the given value.
/// </summary>
private static void AssertWriteLittleEndian32(byte[] data, uint value)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawLittleEndian32(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Try different buffer sizes.
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
{
rawOutput = new MemoryStream();
output = new CodedOutputStream(rawOutput, bufferSize);
output.WriteRawLittleEndian32(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
}
/// <summary>
/// Parses the given bytes using WriteRawLittleEndian64() and checks
/// that the result matches the given value.
/// </summary>
private static void AssertWriteLittleEndian64(byte[] data, ulong value)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawLittleEndian64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Try different block sizes.
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
{
rawOutput = new MemoryStream();
output = new CodedOutputStream(rawOutput, blockSize);
output.WriteRawLittleEndian64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
}
/// <summary>
/// Tests writeRawLittleEndian32() and writeRawLittleEndian64().
/// </summary>
[Test]
public void WriteLittleEndian()
{
AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678);
AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0);
AssertWriteLittleEndian64(
new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12},
0x123456789abcdef0L);
AssertWriteLittleEndian64(
new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a},
0x9abcdef012345678UL);
}
[Test]
public void WriteWholeMessage_VaryingBlockSizes()
{
TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
byte[] rawBytes = message.ToByteArray();
// Try different block sizes.
for (int blockSize = 1; blockSize < 256; blockSize *= 2)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize);
message.WriteTo(output);
output.Flush();
Assert.AreEqual(rawBytes, rawOutput.ToArray());
}
}
[Test]
public void EncodeZigZag32()
{
Assert.AreEqual(0u, WritingPrimitives.EncodeZigZag32(0));
Assert.AreEqual(1u, WritingPrimitives.EncodeZigZag32(-1));
Assert.AreEqual(2u, WritingPrimitives.EncodeZigZag32(1));
Assert.AreEqual(3u, WritingPrimitives.EncodeZigZag32(-2));
Assert.AreEqual(0x7FFFFFFEu, WritingPrimitives.EncodeZigZag32(0x3FFFFFFF));
Assert.AreEqual(0x7FFFFFFFu, WritingPrimitives.EncodeZigZag32(unchecked((int) 0xC0000000)));
Assert.AreEqual(0xFFFFFFFEu, WritingPrimitives.EncodeZigZag32(0x7FFFFFFF));
Assert.AreEqual(0xFFFFFFFFu, WritingPrimitives.EncodeZigZag32(unchecked((int) 0x80000000)));
}
[Test]
public void EncodeZigZag64()
{
Assert.AreEqual(0u, WritingPrimitives.EncodeZigZag64(0));
Assert.AreEqual(1u, WritingPrimitives.EncodeZigZag64(-1));
Assert.AreEqual(2u, WritingPrimitives.EncodeZigZag64(1));
Assert.AreEqual(3u, WritingPrimitives.EncodeZigZag64(-2));
Assert.AreEqual(0x000000007FFFFFFEuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL)));
Assert.AreEqual(0x000000007FFFFFFFuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL)));
Assert.AreEqual(0x00000000FFFFFFFEuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL)));
Assert.AreEqual(0x00000000FFFFFFFFuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL)));
Assert.AreEqual(0xFFFFFFFFFFFFFFFEL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL)));
Assert.AreEqual(0xFFFFFFFFFFFFFFFFL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x8000000000000000UL)));
}
[Test]
public void RoundTripZigZag32()
{
// Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
// were chosen semi-randomly via keyboard bashing.
Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(0)));
Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(1)));
Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(-1)));
Assert.AreEqual(14927, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(14927)));
Assert.AreEqual(-3612, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(-3612)));
}
[Test]
public void RoundTripZigZag64()
{
Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(0)));
Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(1)));
Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(-1)));
Assert.AreEqual(14927, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(14927)));
Assert.AreEqual(-3612, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(-3612)));
Assert.AreEqual(856912304801416L,
ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(856912304801416L)));
Assert.AreEqual(-75123905439571256L,
ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(-75123905439571256L)));
}
[Test]
public void TestNegativeEnumNoTag()
{
Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2));
Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue));
byte[] bytes = new byte[10];
CodedOutputStream output = new CodedOutputStream(bytes);
output.WriteEnum((int) SampleEnum.NegativeValue);
Assert.AreEqual(0, output.SpaceLeft);
Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes));
}
[Test]
public void TestCodedInputOutputPosition()
{
byte[] content = new byte[110];
for (int i = 0; i < content.Length; i++)
content[i] = (byte)i;
byte[] child = new byte[120];
{
MemoryStream ms = new MemoryStream(child);
CodedOutputStream cout = new CodedOutputStream(ms, 20);
// Field 11: numeric value: 500
cout.WriteTag(11, WireFormat.WireType.Varint);
Assert.AreEqual(1, cout.Position);
cout.WriteInt32(500);
Assert.AreEqual(3, cout.Position);
//Field 12: length delimited 120 bytes
cout.WriteTag(12, WireFormat.WireType.LengthDelimited);
Assert.AreEqual(4, cout.Position);
cout.WriteBytes(ByteString.CopyFrom(content));
Assert.AreEqual(115, cout.Position);
// Field 13: fixed numeric value: 501
cout.WriteTag(13, WireFormat.WireType.Fixed32);
Assert.AreEqual(116, cout.Position);
cout.WriteSFixed32(501);
Assert.AreEqual(120, cout.Position);
cout.Flush();
}
byte[] bytes = new byte[130];
{
CodedOutputStream cout = new CodedOutputStream(bytes);
// Field 1: numeric value: 500
cout.WriteTag(1, WireFormat.WireType.Varint);
Assert.AreEqual(1, cout.Position);
cout.WriteInt32(500);
Assert.AreEqual(3, cout.Position);
//Field 2: length delimited 120 bytes
cout.WriteTag(2, WireFormat.WireType.LengthDelimited);
Assert.AreEqual(4, cout.Position);
cout.WriteBytes(ByteString.CopyFrom(child));
Assert.AreEqual(125, cout.Position);
// Field 3: fixed numeric value: 500
cout.WriteTag(3, WireFormat.WireType.Fixed32);
Assert.AreEqual(126, cout.Position);
cout.WriteSFixed32(501);
Assert.AreEqual(130, cout.Position);
cout.Flush();
}
// Now test Input stream:
{
CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false);
Assert.AreEqual(0, cin.Position);
// Field 1:
uint tag = cin.ReadTag();
Assert.AreEqual(1, tag >> 3);
Assert.AreEqual(1, cin.Position);
Assert.AreEqual(500, cin.ReadInt32());
Assert.AreEqual(3, cin.Position);
//Field 2:
tag = cin.ReadTag();
Assert.AreEqual(2, tag >> 3);
Assert.AreEqual(4, cin.Position);
int childlen = cin.ReadLength();
Assert.AreEqual(120, childlen);
Assert.AreEqual(5, cin.Position);
int oldlimit = cin.PushLimit((int)childlen);
Assert.AreEqual(5, cin.Position);
// Now we are reading child message
{
// Field 11: numeric value: 500
tag = cin.ReadTag();
Assert.AreEqual(11, tag >> 3);
Assert.AreEqual(6, cin.Position);
Assert.AreEqual(500, cin.ReadInt32());
Assert.AreEqual(8, cin.Position);
//Field 12: length delimited 120 bytes
tag = cin.ReadTag();
Assert.AreEqual(12, tag >> 3);
Assert.AreEqual(9, cin.Position);
ByteString bstr = cin.ReadBytes();
Assert.AreEqual(110, bstr.Length);
Assert.AreEqual((byte) 109, bstr[109]);
Assert.AreEqual(120, cin.Position);
// Field 13: fixed numeric value: 501
tag = cin.ReadTag();
Assert.AreEqual(13, tag >> 3);
// ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit
Assert.AreEqual(121, cin.Position);
Assert.AreEqual(501, cin.ReadSFixed32());
Assert.AreEqual(125, cin.Position);
Assert.IsTrue(cin.IsAtEnd);
}
cin.PopLimit(oldlimit);
Assert.AreEqual(125, cin.Position);
// Field 3: fixed numeric value: 501
tag = cin.ReadTag();
Assert.AreEqual(3, tag >> 3);
Assert.AreEqual(126, cin.Position);
Assert.AreEqual(501, cin.ReadSFixed32());
Assert.AreEqual(130, cin.Position);
Assert.IsTrue(cin.IsAtEnd);
}
}
[Test]
public void Dispose_DisposesUnderlyingStream()
{
var memoryStream = new MemoryStream();
Assert.IsTrue(memoryStream.CanWrite);
using (var cos = new CodedOutputStream(memoryStream))
{
cos.WriteRawBytes(new byte[] {0});
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
}
Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream
Assert.IsFalse(memoryStream.CanWrite); // Disposed
}
[Test]
public void Dispose_WithLeaveOpen()
{
var memoryStream = new MemoryStream();
Assert.IsTrue(memoryStream.CanWrite);
using (var cos = new CodedOutputStream(memoryStream, true))
{
cos.WriteRawBytes(new byte[] {0});
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
}
Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
}
}
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
using Google.Protobuf.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
public class CodedOutputStreamTest
{
/// <summary>
/// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and
/// checks that the result matches the given bytes
/// </summary>
private static void AssertWriteVarint(byte[] data, ulong value)
{
// Only do 32-bit write if the value fits in 32 bits.
if ((value >> 32) == 0)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawVarint32((uint) value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Also try computing size.
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value));
}
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawVarint64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Also try computing size.
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value));
}
// Try different buffer sizes.
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
{
// Only do 32-bit write if the value fits in 32 bits.
if ((value >> 32) == 0)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output =
new CodedOutputStream(rawOutput, bufferSize);
output.WriteRawVarint32((uint) value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize);
output.WriteRawVarint64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
}
}
/// <summary>
/// Tests WriteRawVarint32() and WriteRawVarint64()
/// </summary>
[Test]
public void WriteVarint()
{
AssertWriteVarint(new byte[] {0x00}, 0);
AssertWriteVarint(new byte[] {0x01}, 1);
AssertWriteVarint(new byte[] {0x7f}, 127);
// 14882
AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7));
// 2961488830
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b},
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
(0x0bL << 28));
// 64-bit
// 7256456126
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b},
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
(0x1bL << 28));
// 41256202580718336
AssertWriteVarint(
new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49},
(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
(0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49));
// 11964378330978735131
AssertWriteVarint(
new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01},
unchecked((ulong)
((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
(0x3bL << 28) | (0x56L << 35) | (0x00L << 42) |
(0x05L << 49) | (0x26L << 56) | (0x01L << 63))));
}
/// <summary>
/// Parses the given bytes using WriteRawLittleEndian32() and checks
/// that the result matches the given value.
/// </summary>
private static void AssertWriteLittleEndian32(byte[] data, uint value)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawLittleEndian32(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Try different buffer sizes.
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
{
rawOutput = new MemoryStream();
output = new CodedOutputStream(rawOutput, bufferSize);
output.WriteRawLittleEndian32(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
}
/// <summary>
/// Parses the given bytes using WriteRawLittleEndian64() and checks
/// that the result matches the given value.
/// </summary>
private static void AssertWriteLittleEndian64(byte[] data, ulong value)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput);
output.WriteRawLittleEndian64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
// Try different block sizes.
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
{
rawOutput = new MemoryStream();
output = new CodedOutputStream(rawOutput, blockSize);
output.WriteRawLittleEndian64(value);
output.Flush();
Assert.AreEqual(data, rawOutput.ToArray());
}
}
/// <summary>
/// Tests writeRawLittleEndian32() and writeRawLittleEndian64().
/// </summary>
[Test]
public void WriteLittleEndian()
{
AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678);
AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0);
AssertWriteLittleEndian64(
new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12},
0x123456789abcdef0L);
AssertWriteLittleEndian64(
new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a},
0x9abcdef012345678UL);
}
[Test]
public void WriteWholeMessage_VaryingBlockSizes()
{
TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
byte[] rawBytes = message.ToByteArray();
// Try different block sizes.
for (int blockSize = 1; blockSize < 256; blockSize *= 2)
{
MemoryStream rawOutput = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize);
message.WriteTo(output);
output.Flush();
Assert.AreEqual(rawBytes, rawOutput.ToArray());
}
}
[Test]
public void EncodeZigZag32()
{
Assert.AreEqual(0u, WritingPrimitives.EncodeZigZag32(0));
Assert.AreEqual(1u, WritingPrimitives.EncodeZigZag32(-1));
Assert.AreEqual(2u, WritingPrimitives.EncodeZigZag32(1));
Assert.AreEqual(3u, WritingPrimitives.EncodeZigZag32(-2));
Assert.AreEqual(0x7FFFFFFEu, WritingPrimitives.EncodeZigZag32(0x3FFFFFFF));
Assert.AreEqual(0x7FFFFFFFu, WritingPrimitives.EncodeZigZag32(unchecked((int) 0xC0000000)));
Assert.AreEqual(0xFFFFFFFEu, WritingPrimitives.EncodeZigZag32(0x7FFFFFFF));
Assert.AreEqual(0xFFFFFFFFu, WritingPrimitives.EncodeZigZag32(unchecked((int) 0x80000000)));
}
[Test]
public void EncodeZigZag64()
{
Assert.AreEqual(0u, WritingPrimitives.EncodeZigZag64(0));
Assert.AreEqual(1u, WritingPrimitives.EncodeZigZag64(-1));
Assert.AreEqual(2u, WritingPrimitives.EncodeZigZag64(1));
Assert.AreEqual(3u, WritingPrimitives.EncodeZigZag64(-2));
Assert.AreEqual(0x000000007FFFFFFEuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL)));
Assert.AreEqual(0x000000007FFFFFFFuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL)));
Assert.AreEqual(0x00000000FFFFFFFEuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL)));
Assert.AreEqual(0x00000000FFFFFFFFuL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL)));
Assert.AreEqual(0xFFFFFFFFFFFFFFFEL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL)));
Assert.AreEqual(0xFFFFFFFFFFFFFFFFL,
WritingPrimitives.EncodeZigZag64(unchecked((long) 0x8000000000000000UL)));
}
[Test]
public void RoundTripZigZag32()
{
// Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
// were chosen semi-randomly via keyboard bashing.
Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(0)));
Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(1)));
Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(-1)));
Assert.AreEqual(14927, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(14927)));
Assert.AreEqual(-3612, ParsingPrimitives.DecodeZigZag32(WritingPrimitives.EncodeZigZag32(-3612)));
}
[Test]
public void RoundTripZigZag64()
{
Assert.AreEqual(0, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(0)));
Assert.AreEqual(1, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(1)));
Assert.AreEqual(-1, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(-1)));
Assert.AreEqual(14927, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(14927)));
Assert.AreEqual(-3612, ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(-3612)));
Assert.AreEqual(856912304801416L,
ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(856912304801416L)));
Assert.AreEqual(-75123905439571256L,
ParsingPrimitives.DecodeZigZag64(WritingPrimitives.EncodeZigZag64(-75123905439571256L)));
}
[Test]
public void TestNegativeEnumNoTag()
{
Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2));
Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue));
byte[] bytes = new byte[10];
CodedOutputStream output = new CodedOutputStream(bytes);
output.WriteEnum((int) SampleEnum.NegativeValue);
Assert.AreEqual(0, output.SpaceLeft);
Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes));
}
[Test]
public void TestCodedInputOutputPosition()
{
byte[] content = new byte[110];
for (int i = 0; i < content.Length; i++)
content[i] = (byte)i;
byte[] child = new byte[120];
{
MemoryStream ms = new MemoryStream(child);
CodedOutputStream cout = new CodedOutputStream(ms, 20);
// Field 11: numeric value: 500
cout.WriteTag(11, WireFormat.WireType.Varint);
Assert.AreEqual(1, cout.Position);
cout.WriteInt32(500);
Assert.AreEqual(3, cout.Position);
//Field 12: length delimited 120 bytes
cout.WriteTag(12, WireFormat.WireType.LengthDelimited);
Assert.AreEqual(4, cout.Position);
cout.WriteBytes(ByteString.CopyFrom(content));
Assert.AreEqual(115, cout.Position);
// Field 13: fixed numeric value: 501
cout.WriteTag(13, WireFormat.WireType.Fixed32);
Assert.AreEqual(116, cout.Position);
cout.WriteSFixed32(501);
Assert.AreEqual(120, cout.Position);
cout.Flush();
}
byte[] bytes = new byte[130];
{
CodedOutputStream cout = new CodedOutputStream(bytes);
// Field 1: numeric value: 500
cout.WriteTag(1, WireFormat.WireType.Varint);
Assert.AreEqual(1, cout.Position);
cout.WriteInt32(500);
Assert.AreEqual(3, cout.Position);
//Field 2: length delimited 120 bytes
cout.WriteTag(2, WireFormat.WireType.LengthDelimited);
Assert.AreEqual(4, cout.Position);
cout.WriteBytes(ByteString.CopyFrom(child));
Assert.AreEqual(125, cout.Position);
// Field 3: fixed numeric value: 500
cout.WriteTag(3, WireFormat.WireType.Fixed32);
Assert.AreEqual(126, cout.Position);
cout.WriteSFixed32(501);
Assert.AreEqual(130, cout.Position);
cout.Flush();
}
// Now test Input stream:
{
CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false);
Assert.AreEqual(0, cin.Position);
// Field 1:
uint tag = cin.ReadTag();
Assert.AreEqual(1, tag >> 3);
Assert.AreEqual(1, cin.Position);
Assert.AreEqual(500, cin.ReadInt32());
Assert.AreEqual(3, cin.Position);
//Field 2:
tag = cin.ReadTag();
Assert.AreEqual(2, tag >> 3);
Assert.AreEqual(4, cin.Position);
int childlen = cin.ReadLength();
Assert.AreEqual(120, childlen);
Assert.AreEqual(5, cin.Position);
int oldlimit = cin.PushLimit((int)childlen);
Assert.AreEqual(5, cin.Position);
// Now we are reading child message
{
// Field 11: numeric value: 500
tag = cin.ReadTag();
Assert.AreEqual(11, tag >> 3);
Assert.AreEqual(6, cin.Position);
Assert.AreEqual(500, cin.ReadInt32());
Assert.AreEqual(8, cin.Position);
//Field 12: length delimited 120 bytes
tag = cin.ReadTag();
Assert.AreEqual(12, tag >> 3);
Assert.AreEqual(9, cin.Position);
ByteString bstr = cin.ReadBytes();
Assert.AreEqual(110, bstr.Length);
Assert.AreEqual((byte) 109, bstr[109]);
Assert.AreEqual(120, cin.Position);
// Field 13: fixed numeric value: 501
tag = cin.ReadTag();
Assert.AreEqual(13, tag >> 3);
// ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit
Assert.AreEqual(121, cin.Position);
Assert.AreEqual(501, cin.ReadSFixed32());
Assert.AreEqual(125, cin.Position);
Assert.IsTrue(cin.IsAtEnd);
}
cin.PopLimit(oldlimit);
Assert.AreEqual(125, cin.Position);
// Field 3: fixed numeric value: 501
tag = cin.ReadTag();
Assert.AreEqual(3, tag >> 3);
Assert.AreEqual(126, cin.Position);
Assert.AreEqual(501, cin.ReadSFixed32());
Assert.AreEqual(130, cin.Position);
Assert.IsTrue(cin.IsAtEnd);
}
}
[Test]
public void Dispose_DisposesUnderlyingStream()
{
var memoryStream = new MemoryStream();
Assert.IsTrue(memoryStream.CanWrite);
using (var cos = new CodedOutputStream(memoryStream))
{
cos.WriteRawBytes(new byte[] {0});
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
}
Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream
Assert.IsFalse(memoryStream.CanWrite); // Disposed
}
[Test]
public void Dispose_WithLeaveOpen()
{
var memoryStream = new MemoryStream();
Assert.IsTrue(memoryStream.CanWrite);
using (var cos = new CodedOutputStream(memoryStream, true))
{
cos.WriteRawBytes(new byte[] {0});
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
}
Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
}
}
}

View File

@ -1,55 +1,55 @@
#region Copyright notice and license
// 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.
#endregion
using System;
using System.Reflection;
using Google.Protobuf.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
public class DeprecatedMemberTest
{
private static void AssertIsDeprecated(MemberInfo member)
{
Assert.NotNull(member);
Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member);
}
[Test]
public void TestDepreatedPrimitiveValue()
{
AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32"));
}
}
}
#region Copyright notice and license
// 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.
#endregion
using System;
using System.Reflection;
using Google.Protobuf.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
public class DeprecatedMemberTest
{
private static void AssertIsDeprecated(MemberInfo member)
{
Assert.NotNull(member);
Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member);
}
[Test]
public void TestDepreatedPrimitiveValue()
{
AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32"));
}
}
}

View File

@ -2,10 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net451;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net451;netcoreapp3.1</TargetFrameworks>
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<IsPackable>False</IsPackable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -1,82 +1,82 @@
#region Copyright notice and license
// 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.
#endregion
using Google.Protobuf.Reflection;
using UnitTest.Issues.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
/// <summary>
/// Tests for issues which aren't easily compartmentalized into other unit tests.
/// </summary>
public class IssuesTest
{
// Issue 45
[Test]
public void FieldCalledItem()
{
ItemField message = new ItemField { Item = 3 };
FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item");
Assert.NotNull(field);
Assert.AreEqual(3, (int)field.Accessor.GetValue(message));
}
[Test]
public void ReservedNames()
{
var message = new ReservedNames { Types_ = 10, Descriptor_ = 20 };
// Underscores aren't reflected in the JSON.
Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString());
}
[Test]
public void JsonNameParseTest()
{
var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor));
var parser = new JsonParser(settings);
// It is safe to use either original field name or explicitly specified json_name
Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" },
parser.Parse<TestJsonName>("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }"));
}
[Test]
public void JsonNameFormatTest()
{
var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" };
Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }",
JsonFormatter.Default.Format(message));
}
}
}
#region Copyright notice and license
// 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.
#endregion
using Google.Protobuf.Reflection;
using UnitTest.Issues.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
/// <summary>
/// Tests for issues which aren't easily compartmentalized into other unit tests.
/// </summary>
public class IssuesTest
{
// Issue 45
[Test]
public void FieldCalledItem()
{
ItemField message = new ItemField { Item = 3 };
FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item");
Assert.NotNull(field);
Assert.AreEqual(3, (int)field.Accessor.GetValue(message));
}
[Test]
public void ReservedNames()
{
var message = new ReservedNames { Types_ = 10, Descriptor_ = 20 };
// Underscores aren't reflected in the JSON.
Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString());
}
[Test]
public void JsonNameParseTest()
{
var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor));
var parser = new JsonParser(settings);
// It is safe to use either original field name or explicitly specified json_name
Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" },
parser.Parse<TestJsonName>("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }"));
}
[Test]
public void JsonNameFormatTest()
{
var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" };
Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }",
JsonFormatter.Default.Format(message));
}
}
}

View File

@ -1,62 +1,62 @@
#region Copyright notice and license
// 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.
#endregion
using UnitTest.Issues.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
public class TestCornerCases
{
[Test]
public void TestRoundTripNegativeEnums()
{
NegativeEnumMessage msg = new NegativeEnumMessage
{
Value = NegativeEnum.MinusOne,
Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow },
PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }
};
Assert.AreEqual(58, msg.CalculateSize());
byte[] bytes = new byte[58];
CodedOutputStream output = new CodedOutputStream(bytes);
msg.WriteTo(output);
Assert.AreEqual(0, output.SpaceLeft);
NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes);
Assert.AreEqual(msg, copy);
}
}
}
#region Copyright notice and license
// 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.
#endregion
using UnitTest.Issues.TestProtos;
using NUnit.Framework;
namespace Google.Protobuf
{
public class TestCornerCases
{
[Test]
public void TestRoundTripNegativeEnums()
{
NegativeEnumMessage msg = new NegativeEnumMessage
{
Value = NegativeEnum.MinusOne,
Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow },
PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }
};
Assert.AreEqual(58, msg.CalculateSize());
byte[] bytes = new byte[58];
CodedOutputStream output = new CodedOutputStream(bytes);
msg.WriteTo(output);
Assert.AreEqual(0, output.SpaceLeft);
NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes);
Assert.AreEqual(msg, copy);
}
}
}

View File

@ -22,7 +22,7 @@ function run_test() {
dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj
dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
dotnet run -c Release -f netcoreapp2.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
dotnet run -c Release -f netcoreapp3.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
}
set -ex

View File

@ -13,7 +13,9 @@ pushd $(dirname $0)/..
# Windows and Unix.
if [ -z "$PROTOC" ]; then
# TODO(jonskeet): Use an array and a for loop instead?
if [ -x cmake/build/Debug/protoc.exe ]; then
if [ -x solution/Debug/protoc.exe ]; then
PROTOC=solution/Debug/protoc.exe
elif [ -x cmake/build/Debug/protoc.exe ]; then
PROTOC=cmake/build/Debug/protoc.exe
elif [ -x cmake/build/Release/protoc.exe ]; then
PROTOC=cmake/build/Release/protoc.exe

View File

@ -16,5 +16,5 @@ Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath
# The SDK versions to install should be kept in sync with versions
# installed by kokoro/linux/dockerfile/test/csharp/Dockerfile
&$InstallScriptPath -Version 2.1.802
&$InstallScriptPath -Version 5.0.102
&$InstallScriptPath -Version 3.1.415
&$InstallScriptPath -Version 6.0.100

View File

@ -156,3 +156,17 @@ message MixedRegularAndOptional {
string regular_field = 1;
optional string optional_field = 2;
}
message OneofWithNoneField {
oneof test {
string x = 1;
string none = 2;
}
}
message OneofWithNoneName {
oneof none {
string x = 1;
string y = 2;
}
}

View File

@ -1,132 +1,130 @@
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
namespace Google.Protobuf.Examples.AddressBook
{
internal class AddPerson
{
/// <summary>
/// Builds a person based on user input
/// </summary>
private static Person PromptForAddress(TextReader input, TextWriter output)
{
Person person = new Person();
output.Write("Enter person ID: ");
person.Id = int.Parse(input.ReadLine());
output.Write("Enter name: ");
person.Name = input.ReadLine();
output.Write("Enter email address (blank for none): ");
string email = input.ReadLine();
if (email.Length > 0)
{
person.Email = email;
}
while (true)
{
output.Write("Enter a phone number (or leave blank to finish): ");
string number = input.ReadLine();
if (number.Length == 0)
{
break;
}
Person.Types.PhoneNumber phoneNumber = new Person.Types.PhoneNumber { Number = number };
output.Write("Is this a mobile, home, or work phone? ");
String type = input.ReadLine();
switch (type)
{
case "mobile":
phoneNumber.Type = Person.Types.PhoneType.Mobile;
break;
case "home":
phoneNumber.Type = Person.Types.PhoneType.Home;
break;
case "work":
phoneNumber.Type = Person.Types.PhoneType.Work;
break;
default:
output.Write("Unknown phone type. Using default.");
break;
}
person.Phones.Add(phoneNumber);
}
return person;
}
/// <summary>
/// Entry point - loads an existing addressbook or creates a new one,
/// then writes it back to the file.
/// </summary>
public static int Main(string[] args)
{
if (args.Length != 1)
{
Console.Error.WriteLine("Usage: AddPerson ADDRESS_BOOK_FILE");
return -1;
}
AddressBook addressBook;
if (File.Exists(args[0]))
{
using (Stream file = File.OpenRead(args[0]))
{
addressBook = AddressBook.Parser.ParseFrom(file);
}
}
else
{
Console.WriteLine("{0}: File not found. Creating a new file.", args[0]);
addressBook = new AddressBook();
}
// Add an address.
addressBook.People.Add(PromptForAddress(Console.In, Console.Out));
// Write the new address book back to disk.
using (Stream output = File.OpenWrite(args[0]))
{
addressBook.WriteTo(output);
}
return 0;
}
}
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
namespace Google.Protobuf.Examples.AddressBook
{
internal class AddPerson
{
/// <summary>
/// Builds a person based on user input
/// </summary>
private static Person PromptForAddress(TextReader input, TextWriter output)
{
Person person = new Person();
output.Write("Enter person ID: ");
person.Id = int.Parse(input.ReadLine());
output.Write("Enter name: ");
person.Name = input.ReadLine();
output.Write("Enter email address (blank for none): ");
string email = input.ReadLine();
if (email.Length > 0)
{
person.Email = email;
}
while (true)
{
output.Write("Enter a phone number (or leave blank to finish): ");
string number = input.ReadLine();
if (number.Length == 0)
{
break;
}
Person.Types.PhoneNumber phoneNumber = new Person.Types.PhoneNumber { Number = number };
output.Write("Is this a mobile, home, or work phone? ");
String type = input.ReadLine();
switch (type)
{
case "mobile":
phoneNumber.Type = Person.Types.PhoneType.Mobile;
break;
case "home":
phoneNumber.Type = Person.Types.PhoneType.Home;
break;
case "work":
phoneNumber.Type = Person.Types.PhoneType.Work;
break;
default:
output.Write("Unknown phone type. Using default.");
break;
}
person.Phones.Add(phoneNumber);
}
return person;
}
/// <summary>
/// Entry point - loads an existing addressbook or creates a new one,
/// then writes it back to the file.
/// </summary>
public static int Main(string[] args)
{
if (args.Length != 1)
{
Console.Error.WriteLine("Usage: AddPerson ADDRESS_BOOK_FILE");
return -1;
}
AddressBook addressBook;
if (File.Exists(args[0]))
{
using Stream file = File.OpenRead(args[0]);
addressBook = AddressBook.Parser.ParseFrom(file);
}
else
{
Console.WriteLine("{0}: File not found. Creating a new file.", args[0]);
addressBook = new AddressBook();
}
// Add an address.
addressBook.People.Add(PromptForAddress(Console.In, Console.Out));
// Write the new address book back to disk.
using (Stream output = File.OpenWrite(args[0]))
{
addressBook.WriteTo(output);
}
return 0;
}
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<OutputType>Exe</OutputType>
<StartupObject>Google.Protobuf.Examples.AddressBook.Program</StartupObject>
<IsPackable>False</IsPackable>

View File

@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: addressbook.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
@ -32,9 +32,10 @@ namespace Google.Protobuf.Examples.AddressBook {
"Eg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3JpYWwuUGVy",
"c29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAASCAoESE9N",
"RRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZW9wbGUYASADKAsy",
"EC50dXRvcmlhbC5QZXJzb25CZgobY29tLmV4YW1wbGUudHV0b3JpYWwucHJv",
"dG9zQhFBZGRyZXNzQm9va1Byb3Rvc1ABWgsuLi90dXRvcmlhbKoCJEdvb2ds",
"ZS5Qcm90b2J1Zi5FeGFtcGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z"));
"EC50dXRvcmlhbC5QZXJzb25ClQEKG2NvbS5leGFtcGxlLnR1dG9yaWFsLnBy",
"b3Rvc0IRQWRkcmVzc0Jvb2tQcm90b3NQAVo6Z2l0aHViLmNvbS9wcm90b2Nv",
"bGJ1ZmZlcnMvcHJvdG9idWYvZXhhbXBsZXMvZ28vdHV0b3JpYWxwYqoCJEdv",
"b2dsZS5Qcm90b2J1Zi5FeGFtcGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {

View File

@ -1,99 +1,99 @@
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
namespace Google.Protobuf.Examples.AddressBook
{
internal class ListPeople
{
/// <summary>
/// Iterates though all people in the AddressBook and prints info about them.
/// </summary>
private static void Print(AddressBook addressBook)
{
foreach (Person person in addressBook.People)
{
Console.WriteLine("Person ID: {0}", person.Id);
Console.WriteLine(" Name: {0}", person.Name);
if (person.Email != "")
{
Console.WriteLine(" E-mail address: {0}", person.Email);
}
foreach (Person.Types.PhoneNumber phoneNumber in person.Phones)
{
switch (phoneNumber.Type)
{
case Person.Types.PhoneType.Mobile:
Console.Write(" Mobile phone #: ");
break;
case Person.Types.PhoneType.Home:
Console.Write(" Home phone #: ");
break;
case Person.Types.PhoneType.Work:
Console.Write(" Work phone #: ");
break;
}
Console.WriteLine(phoneNumber.Number);
}
}
}
/// <summary>
/// Entry point - loads the addressbook and then displays it.
/// </summary>
public static int Main(string[] args)
{
if (args.Length != 1)
{
Console.Error.WriteLine("Usage: ListPeople ADDRESS_BOOK_FILE");
return 1;
}
if (!File.Exists(args[0]))
{
Console.WriteLine("{0} doesn't exist. Add a person to create the file first.", args[0]);
return 0;
}
// Read the existing address book.
using (Stream stream = File.OpenRead(args[0]))
{
AddressBook addressBook = AddressBook.Parser.ParseFrom(stream);
Print(addressBook);
}
return 0;
}
}
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
namespace Google.Protobuf.Examples.AddressBook
{
internal class ListPeople
{
/// <summary>
/// Iterates though all people in the AddressBook and prints info about them.
/// </summary>
private static void Print(AddressBook addressBook)
{
foreach (Person person in addressBook.People)
{
Console.WriteLine("Person ID: {0}", person.Id);
Console.WriteLine(" Name: {0}", person.Name);
if (person.Email != "")
{
Console.WriteLine(" E-mail address: {0}", person.Email);
}
foreach (Person.Types.PhoneNumber phoneNumber in person.Phones)
{
switch (phoneNumber.Type)
{
case Person.Types.PhoneType.Mobile:
Console.Write(" Mobile phone #: ");
break;
case Person.Types.PhoneType.Home:
Console.Write(" Home phone #: ");
break;
case Person.Types.PhoneType.Work:
Console.Write(" Work phone #: ");
break;
}
Console.WriteLine(phoneNumber.Number);
}
}
}
/// <summary>
/// Entry point - loads the addressbook and then displays it.
/// </summary>
public static int Main(string[] args)
{
if (args.Length != 1)
{
Console.Error.WriteLine("Usage: ListPeople ADDRESS_BOOK_FILE");
return 1;
}
if (!File.Exists(args[0]))
{
Console.WriteLine("{0} doesn't exist. Add a person to create the file first.", args[0]);
return 0;
}
// Read the existing address book.
using (Stream stream = File.OpenRead(args[0]))
{
AddressBook addressBook = AddressBook.Parser.ParseFrom(stream);
Print(addressBook);
}
return 0;
}
}
}

View File

@ -1,95 +1,95 @@
#region Copyright notice and license
// 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.
#endregion
using System;
namespace Google.Protobuf.Examples.AddressBook
{
/// <summary>
/// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour
/// to individual actions. Each action has its own Main method, so that it can be used as an
/// individual complete program.
/// </summary>
internal class Program
{
private static int Main(string[] args)
{
if (args.Length > 1)
{
Console.Error.WriteLine("Usage: AddressBook [file]");
Console.Error.WriteLine("If the filename isn't specified, \"addressbook.data\" is used instead.");
return 1;
}
string addressBookFile = args.Length > 0 ? args[0] : "addressbook.data";
bool stopping = false;
while (!stopping)
{
Console.WriteLine("Options:");
Console.WriteLine(" L: List contents");
Console.WriteLine(" A: Add new person");
Console.WriteLine(" Q: Quit");
Console.Write("Action? ");
Console.Out.Flush();
char choice = Console.ReadKey().KeyChar;
Console.WriteLine();
try
{
switch (choice)
{
case 'A':
case 'a':
AddPerson.Main(new string[] {addressBookFile});
break;
case 'L':
case 'l':
ListPeople.Main(new string[] {addressBookFile});
break;
case 'Q':
case 'q':
stopping = true;
break;
default:
Console.WriteLine("Unknown option: {0}", choice);
break;
}
}
catch (Exception e)
{
Console.WriteLine("Exception executing action: {0}", e);
}
Console.WriteLine();
}
return 0;
}
}
#region Copyright notice and license
// 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.
#endregion
using System;
namespace Google.Protobuf.Examples.AddressBook
{
/// <summary>
/// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour
/// to individual actions. Each action has its own Main method, so that it can be used as an
/// individual complete program.
/// </summary>
internal class Program
{
private static int Main(string[] args)
{
if (args.Length > 1)
{
Console.Error.WriteLine("Usage: AddressBook [file]");
Console.Error.WriteLine("If the filename isn't specified, \"addressbook.data\" is used instead.");
return 1;
}
string addressBookFile = args.Length > 0 ? args[0] : "addressbook.data";
bool stopping = false;
while (!stopping)
{
Console.WriteLine("Options:");
Console.WriteLine(" L: List contents");
Console.WriteLine(" A: Add new person");
Console.WriteLine(" Q: Quit");
Console.Write("Action? ");
Console.Out.Flush();
char choice = Console.ReadKey().KeyChar;
Console.WriteLine();
try
{
switch (choice)
{
case 'A':
case 'a':
AddPerson.Main(new string[] {addressBookFile});
break;
case 'L':
case 'l':
ListPeople.Main(new string[] {addressBookFile});
break;
case 'Q':
case 'q':
stopping = true;
break;
default:
Console.WriteLine("Unknown option: {0}", choice);
break;
}
}
catch (Exception e)
{
Console.WriteLine("Exception executing action: {0}", e);
}
Console.WriteLine();
}
return 0;
}
}
}

View File

@ -1,73 +1,73 @@
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
namespace Google.Protobuf.Examples.AddressBook
{
internal class SampleUsage
{
private static void Main()
{
byte[] bytes;
// Create a new person
Person person = new Person
{
Id = 1,
Name = "Foo",
Email = "foo@bar",
Phones = { new Person.Types.PhoneNumber { Number = "555-1212" } }
};
using (MemoryStream stream = new MemoryStream())
{
// Save the person to a stream
person.WriteTo(stream);
bytes = stream.ToArray();
}
Person copy = Person.Parser.ParseFrom(bytes);
AddressBook book = new AddressBook
{
People = { copy }
};
bytes = book.ToByteArray();
// And read the address book back again
AddressBook restored = AddressBook.Parser.ParseFrom(bytes);
// The message performs a deep-comparison on equality:
if (restored.People.Count != 1 || !person.Equals(restored.People[0]))
{
throw new Exception("There is a bad person in here!");
}
}
}
#region Copyright notice and license
// 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.
#endregion
using System;
using System.IO;
namespace Google.Protobuf.Examples.AddressBook
{
internal class SampleUsage
{
private static void Main()
{
byte[] bytes;
// Create a new person
Person person = new Person
{
Id = 1,
Name = "Foo",
Email = "foo@bar",
Phones = { new Person.Types.PhoneNumber { Number = "555-1212" } }
};
using (MemoryStream stream = new MemoryStream())
{
// Save the person to a stream
person.WriteTo(stream);
bytes = stream.ToArray();
}
Person copy = Person.Parser.ParseFrom(bytes);
AddressBook book = new AddressBook
{
People = { copy }
};
bytes = book.ToByteArray();
// And read the address book back again
AddressBook restored = AddressBook.Parser.ParseFrom(bytes);
// The message performs a deep-comparison on equality:
if (restored.People.Count != 1 || !person.Equals(restored.People[0]))
{
throw new Exception("There is a bad person in here!");
}
}
}
}

View File

@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
</Project>

View File

@ -72,16 +72,14 @@ namespace Google.Protobuf.Benchmarks
private static byte[] LoadData(string resource)
{
using (var stream = typeof(GoogleMessageBenchmark).Assembly.GetManifestResourceStream($"Google.Protobuf.Benchmarks.{resource}"))
using var stream = typeof(GoogleMessageBenchmark).Assembly.GetManifestResourceStream($"Google.Protobuf.Benchmarks.{resource}");
if (stream == null)
{
if (stream == null)
{
throw new ArgumentException($"Unable to load embedded resource {resource}");
}
var copy = new MemoryStream();
stream.CopyTo(copy);
return copy.ToArray();
throw new ArgumentException($"Unable to load embedded resource {resource}");
}
var copy = new MemoryStream();
stream.CopyTo(copy);
return copy.ToArray();
}
public override string ToString() => Name;

View File

@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: datasets/google_message1/proto3/benchmark_message1_proto3.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;

View File

@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: benchmarks.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<IsPackable>False</IsPackable>
@ -15,7 +15,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj" />
</ItemGroup>

View File

@ -41,8 +41,8 @@ namespace Google.Protobuf.Benchmarks
/// Benchmark for serializing and deserializing of standard datasets that are also
/// measured by benchmarks in other languages.
/// Over time we may wish to test the various different approaches to serialization and deserialization separately.
/// See https://github.com/protocolbuffers/protobuf/blob/master/benchmarks/README.md
/// See https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md
/// See https://github.com/protocolbuffers/protobuf/blob/main/benchmarks/README.md
/// See https://github.com/protocolbuffers/protobuf/blob/main/docs/performance.md
/// </summary>
[MemoryDiagnoser]
public class GoogleMessageBenchmark

View File

@ -49,10 +49,10 @@ namespace Google.Protobuf.Benchmarks
{
const int MaxMessages = 100;
SubTest manyWrapperFieldsTest = new SubTest(CreateManyWrapperFieldsMessage(), ManyWrapperFieldsMessage.Parser, () => new ManyWrapperFieldsMessage(), MaxMessages);
SubTest manyPrimitiveFieldsTest = new SubTest(CreateManyPrimitiveFieldsMessage(), ManyPrimitiveFieldsMessage.Parser, () => new ManyPrimitiveFieldsMessage(), MaxMessages);
SubTest repeatedFieldTest = new SubTest(CreateRepeatedFieldMessage(), GoogleMessage1.Parser, () => new GoogleMessage1(), MaxMessages);
SubTest emptyMessageTest = new SubTest(new Empty(), Empty.Parser, () => new Empty(), MaxMessages);
private readonly SubTest manyWrapperFieldsTest = new(CreateManyWrapperFieldsMessage(), ManyWrapperFieldsMessage.Parser, () => new ManyWrapperFieldsMessage(), MaxMessages);
private readonly SubTest manyPrimitiveFieldsTest = new(CreateManyPrimitiveFieldsMessage(), ManyPrimitiveFieldsMessage.Parser, () => new ManyPrimitiveFieldsMessage(), MaxMessages);
private readonly SubTest repeatedFieldTest = new(CreateRepeatedFieldMessage(), GoogleMessage1.Parser, () => new GoogleMessage1(), MaxMessages);
private readonly SubTest emptyMessageTest = new(new Empty(), Empty.Parser, () => new Empty(), MaxMessages);
public IEnumerable<int> MessageCountValues => new[] { 10, 100 };
@ -204,8 +204,8 @@ namespace Google.Protobuf.Benchmarks
private readonly byte[] data;
private readonly byte[] multipleMessagesData;
private ReadOnlySequence<byte> dataSequence;
private ReadOnlySequence<byte> multipleMessagesDataSequence;
private readonly ReadOnlySequence<byte> dataSequence;
private readonly ReadOnlySequence<byte> multipleMessagesDataSequence;
public SubTest(IMessage message, MessageParser parser, Func<IMessage> factory, int maxMessageCount)
{

View File

@ -418,7 +418,7 @@ namespace Google.Protobuf.Benchmarks
private static byte[] CreateBufferWithRandomData(Random random, int valueCount, int encodedSize, int paddingValueCount)
{
int bufferSize = (valueCount + paddingValueCount) * encodedSize;
byte[] buffer = new byte[bufferSize];
var buffer = new byte[bufferSize];
random.NextBytes(buffer);
return buffer;
}

View File

@ -36,7 +36,7 @@ namespace Google.Protobuf.Benchmarks
{
class Program
{
// typical usage: dotnet run -c Release -f netcoreapp2.1
// typical usage: dotnet run -c Release -f netcoreapp3.1
// (this can profile both .net core and .net framework; for some reason
// if you start from "-f net461", it goes horribly wrong)
public static void Main(string[] args)
@ -44,6 +44,4 @@ namespace Google.Protobuf.Benchmarks
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
}

View File

@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: wrapper_benchmark_messages.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;

View File

@ -32,10 +32,7 @@
using BenchmarkDotNet.Attributes;
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.IO;
using System.Buffers;
using System.Text;
namespace Google.Protobuf.Benchmarks

View File

@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: conformance.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;

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