731 Commits

Author SHA1 Message Date
Robert Edmonds
86a89d1e75 cmake: cxx-generate-packed-data: Link against protobuf::libprotobuf
Apparently ${PROTOBUF_LIBRARY} is empty?
2024-04-22 02:34:32 -04:00
Robert Edmonds
035e780f6a cmake: Print the protobuf version that was found 2024-04-22 02:34:16 -04:00
Robert Edmonds
b92dabc1a5 cmake: Invert the "if(NOT Protobuf_FOUND)" conditional for readability 2024-04-22 02:33:30 -04:00
Robert Edmonds
d4408ba690 Revert "cmake: fix warning about policy CMP0145"
This reverts commit 1faae3a1ec2bfea3f4d9fe3858f013f6a7405b41.
2024-04-22 02:32:50 -04:00
Robert Edmonds
9bdd24f975 build.yml: Add a "cmake-linux-latest" job
This job builds abseil-cpp and protobuf from source using Cmake and
tries to build protobuf-c against those dependencies using Cmake.

The "latest" build dependencies are being targeted, currently Ubuntu
22.04, abseil-cpp from the lts_2024_01_16 branch, protobuf from the 27.x
branch. Update as newer versions become available.

This uses Cmake's Ninja generator which should be equivalent to the
legacy makefiles that it generates. The Cmake Ninja generator is useful
primarily because it automatically compiles using the maximum amount
of concurrency and it actually shows you the command that failed by
default.
2024-04-21 23:36:20 -04:00
Robert Edmonds
969aa0c99c build.yml: Set "fail-fast: false" so we can tell which jobs are failing 2024-04-21 20:17:21 -04:00
Robert Edmonds
63e891b4b9 Merge branch 'clementperon-fix_cmake' into edmonds/test/google-protobuf-26-fixes_plus_pull-714 2024-04-21 20:15:28 -04:00
Clément Péron
b8a812c8fb cmake: keep compatibility with CMake FindProtobuf module
PROTOBUF_PROTOC_EXECUTABLE is not set in the Protobuf CMake config file.
Set it properly in case we use CMake protobuf config file.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2024-04-21 15:07:00 +02:00
Clément Péron
1faae3a1ec cmake: fix warning about policy CMP0145
Keep the DART compatibility enabled until test are moved
to CTest.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2024-04-21 15:01:36 +02:00
Clément Péron
05f9112acd ci: build: always update cache to avoid out of date packages
APT cache could be out of date leading to a:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Fix this by always calling apt-get update before an apt-get install.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2024-04-21 14:57:31 +02:00
Clément Péron
be2c33276b cmake: fix recent protobuf build with cmake
The CMake module is used by default but isn't compatible with
recent protobuf version.

Try to first look for a protobuf config then fallback to legacy
cmake module.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2024-04-21 14:57:31 +02:00
Robert Edmonds
d95aced22d CGenerator: Protect against being invoked against "edition" syntax .proto files
The Google protobuf project is currently experimenting with a new syntax
for .proto files called "editions". Since protobuf-c is a proto2/proto3
compiler, after the previous commit reimplementing `FieldSyntax()`, the
protobuf compiler will abort like this if presented with an "editions"
syntax .proto file due to the safety check in `FieldSyntax()`:

    $ protoc --experimental_editions --c_out=. test.proto
    protoc-gen-c: ./protoc-c/c_helpers.h:178: int google::protobuf::compiler::c::FieldSyntax(const google::protobuf::FieldDescriptor*): Assertion `syntax == "proto2" || syntax == "proto3"' failed.
    --c_out: protoc-gen-c: Plugin killed by signal 6.

On protobuf 26, our `CodeGenerator` can implement certain methods to
declare that we "support" editions, and then reject any other edition
except proto2 and proto3, which have apparently been retroactively
declared to be "editions". Of course this needs to be wrapped in a
version guard.

With this protection in place, the protobuf compiler cleanly exits with
a nice error message like this:

    $ protoc --experimental_editions --c_out=. test.proto
    WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
    E0000 00:00:1710988958.296200   20022 descriptor.cc:4620] Invalid proto descriptor for file "test.proto":
    E0000 00:00:1710988958.296239   20022 descriptor.cc:4623]   test.proto: Edition 2023 is later than the maximum supported edition PROTO3
    --c_out: protoc-gen-c: Plugin failed with status code 1.
2024-03-20 23:33:33 -04:00
Robert Edmonds
1b4b205d87 Reimplement FieldSyntax() to maximize compatibility across protobuf versions
Recent versions of Google protobuf have broken the interfaces for
determining the syntax version of a .proto file. The current protobuf-c
1.5.0 release does not compile with Google protobuf 26.0 due to the most
recentage breakage. There is a possible workaround involving the Google
protobuf `FileDescriptorLegacy` class, which is documented as:

// TODO Remove this deprecated API entirely.

So we probably shouldn't rely on it.

Instead, this commit obtains the `FileDescriptorProto` corresponding
to the passed in `FieldDescriptor` and interrogates the `syntax` field
directly. This is a single implementation with no version-specific
workarounds. Hopefully this won't break in the next Google protobuf
release.

I tested the `FieldSyntax()` implementation in this commit across a
number of different Google protobuf releases and found that it worked
(`make && make check`) on all of them:

- Google protobuf 3.6.1.3 (Ubuntu 20.04)
- Google protobuf 3.12.4 (Ubuntu 22.04)
- Google protobuf 3.21.12 (Debian 12 + Debian unstable)
- Google protobuf 3.25.2 (Debian experimental)
- Google protobuf 26.1-dev
2024-03-20 23:33:33 -04:00
Robert Edmonds
e3acc96ca2 FileGenerator::GenerateHeader(): Set min_header_version unconditionally
Previously, we were conditionally trying to set `min_header_version` to
the lowest possible value, and relying on a "legacy" Google interface to
determine the file descriptor's syntax version as part of that
determination.

Instead, simply bump the minimum version to 1003000 (1.3.0). This
release was almost 7 years ago. In practice protobuf-c users should not
be shipping pre-compiled .pb-c.c/.pb-c.h files, anyway.
2024-03-20 23:33:33 -04:00
Robert Edmonds
5c13d7dfe9
Merge pull request #703 from smuellerDD/fix_corruption
protobuf_c_message_unpack(): Fix memory corruption by initializing unknown_fields pointer
2024-03-21 03:30:39 +00:00
Diego Elio Pettenò
7765485b6b Update link to Autotools Mythbuster.
The canonical doman is no longer dot-io, though both work.
2024-03-20 23:25:03 -04:00
Robert Edmonds
6bafe333f8
Merge pull request #700 from AlessandroBono/wip/abono/config-cmake-in
Makefile.am: Distribute missing Config.cmake.in
2024-03-21 03:21:08 +00:00
Robert Edmonds
8b3207c4e6
Merge pull request #699 from AlessandroBono/wip/abono/double-hyphens
CMakeLists.txt: Remove double hyphens
2024-03-21 03:19:02 +00:00
Stephan Mueller
55c8b0dc68 Fix memory corruption by initlizalizing pointer
A memory corruption in protobuf_c_message_free_unpacked happens at the
following line:

        if (message->unknown_fields != NULL)
                do_free(allocator, message->unknown_fields);

The do_free will free ->unknown_fields. This is may be wrong, because
protobuf_c_message_unpack uses malloc as the default allocator, allocates
rv with malloc. At the end, however, ->unknown_fields is only initialized
if there are some. That means if there are no such fields ->unknown_fields
is an uninitialized pointer.

The patch initializes the pointer to NULL to ensure the check before free
is performed on initialized memory in case there is no unknown_field.

This fixes https://github.com/protobuf-c/protobuf-c/issues/690

Signed-off-by: Stephan Mueller <smueller@chronox.de>
2024-01-21 11:10:25 +01:00
Alessandro Bono
493b379966 Makefile.am: Distribute missing Config.cmake.in
Closes: https://github.com/protobuf-c/protobuf-c/issues/698
2023-12-16 10:41:54 +01:00
Alessandro Bono
9b1d4a355b CMakeList.txt: Remove double hyphens
Otherwise cmake won't reconize the command.

With double hyphens:
```
$ cmake -E env TESTENV=value -- env | grep TESTENV
cmake -E env: unknown option '--'
```

Without double hyphens:
```
$ cmake -E env TESTENV=value env | grep TESTENV
TESTENV=value
```
2023-12-15 19:49:09 +01:00
Dimitri Papadopoulos
67b1c3535d Remove the executable bits from protobuf-c/protobuf-c.h
[edmonds: Adjust commit message.]
2023-11-29 21:56:22 -05:00
Robert Edmonds
86a692922b Makefile.am: Distribute the missing changelog files (CHANGELOG.md, ChangeLog.old) 2023-11-25 19:05:15 -05:00
Robert Edmonds
8c201f6e47 CHANGELOG.md: 1.5.0 v1.5.0 2023-11-25 18:21:08 -05:00
Robert Edmonds
6600fd55b9 Bump version to 1.5.0 2023-11-25 18:21:08 -05:00
Robert Edmonds
a15d80a136 Bump copyright years to 2023 2023-11-25 18:04:11 -05:00
Robert Edmonds
ba4c55f0e6
Merge pull request #685 from MiguelBarro/static_msvc_fix
Fixing MSVC build for Msbuild and Makefile generators
2023-09-21 17:00:11 -04:00
Guybrush
5db0ca5a28 enforcing reviewers comments
Signed-off-by: Guybrush <miguel.barro@live.com>
2023-09-18 18:37:01 +02:00
Guybrush
aee40e9569 Setting default repos on msvc binary generator
Signed-off-by: Guybrush <miguel.barro@live.com>
2023-09-15 12:12:15 +02:00
Guybrush
6ad31f8d43 Dispatch workflow to generate binaries.
Led to some fixes in the CMake too.

Signed-off-by: Guybrush <miguel.barro@live.com>
2023-09-15 12:04:00 +02:00
MiguelBarro
61933280db Fix tests on windows by adding plugin dir to environment PATH
Signed-off-by: MiguelBarro <miguelbarro@eprosima.com>
2023-09-11 10:09:15 +02:00
MiguelBarro
01bd9bed77
Fixing static lib generation on MSVC
Signed-off-by: MiguelBarro <miguelbarro@eprosima.com>
2023-09-11 00:06:48 +02:00
Robert Edmonds
fa86fddbd0
Merge pull request #677 from protobuf-c/edmonds/compiler-diagnostics
Silence some compiler diagnostics
2023-07-09 00:39:00 -04:00
Robert Edmonds
a255fb20ae test-generated-code2: Ignore -Wdeclaration-after-statement
This file uses declarations after statements and fixing it would make
the code less readable, so silence this particular diagnostic in this
particular file.
2023-07-09 00:00:12 -04:00
Robert Edmonds
7f006f8ad5 configure.ac: Drop -Wc99-c11-compat
This diagnostic isn't particularly useful since it fires on generated
.pb-c.h files.
2023-07-09 00:00:12 -04:00
Robert Edmonds
94d8a28db5
Merge pull request #676 from protobuf-c/edmonds/protobuf2-removal
Remove protobuf 2.x support
2023-07-08 23:59:41 -04:00
Robert Edmonds
20d45b1179 t/: Add syntax = "proto2"; where necessary to silence protoc
Since we now require protobuf >= 3.0.0, we don't have to support older
protobuf versions that don't recognize the `syntax` syntax, so we can
put `syntax = "proto2";` on these proto files to silence the protoc
compiler's diagnostic "No syntax specified for the proto file".
2023-07-08 23:19:16 -04:00
Robert Edmonds
824a7fed75 cmake: Remove BUILD_PROTO3, HAVE_PROTO3 2023-07-08 23:15:14 -04:00
Robert Edmonds
e08fe62565 protoc-c/c_helpers.h: Remove HAVE_PROTO3 conditional 2023-07-08 23:14:23 -04:00
Robert Edmonds
7ed03a715b protoc-c/c_file.cc: Remove HAVE_PROTO3 conditional 2023-07-08 23:13:59 -04:00
Robert Edmonds
5c4be20f1b Makefile.am: Remove conditional BUILD_PROTO3 rules
Now that we require protobuf >= 3.0.0, we are always building with
proto3 syntax support.

Note that the test-generated-code3 test keeps `-DPROTO3` which is
separate from the HAVE_PROTO3 identifier. This test is building built
from the same source file as test-generated-code but the source file
supports proto2 and proto3 syntax depending on how it's compiled.
2023-07-08 23:11:54 -04:00
Robert Edmonds
7dca1c382c configure.ac: Remove proto3_supported, BUILD_PROTO3
Since we require protobuf >= 3.0.0 now, the proto3 syntax is always
supported.
2023-07-08 23:11:03 -04:00
Robert Edmonds
f46c1fd603
Merge pull request #675 from protobuf-c/edmonds/misc-fixes
Miscellaneous fixes
2023-07-08 22:40:07 -04:00
Robert Edmonds
cda9f84752 protoc-c: Silence compilers that complain about sprintf() 2023-07-08 21:45:14 -04:00
Robert Edmonds
951a5278e0 protobuf-c: pack_buffer_packed_payload(): Remove unused increment
Since this case immediately returns, the `rv` variable is not used.

See https://github.com/protobuf-c/protobuf-c/issues/517.
2023-07-08 21:34:09 -04:00
Robert Edmonds
bee044643e protobuf-c: parse_required_member(): Remove duplicate NULL check
`*pstr != NULL` was already checked here.

See https://github.com/protobuf-c/protobuf-c/issues/517.
2023-07-08 21:31:23 -04:00
Robert Edmonds
0ce231b16d cmake: Add -I${PROTOBUF_INCLUDE_DIR} to protoc invocation
Apparently in some cases the protobuf compiler is unable to find its own
files, and this fix has been reported to work.

See https://github.com/protobuf-c/protobuf-c/issues/491.
2023-07-08 21:18:06 -04:00
Daniel Egger
d465ae9d44 Fix codesmell "or with 0" in generated flags
Signed-off-by: Daniel Egger <daniel@eggers-club.de>

[edmonds: From https://github.com/protobuf-c/protobuf-c/pull/523.]

[edmonds: Adjust find string from "0 |" to "0 | ", test against `== 0`
rather than `!= std::string::npos` so that the find/erase calls are
anchored to the same portion of the string.]
2023-07-08 21:00:36 -04:00
Robert Edmonds
5312647592 protoc-c: Rename 'legacy_name' to 'standalone_name' 2023-07-08 20:52:25 -04:00
Robert Edmonds
de5ea41b4f t/: Use "int main(void)" for the main C signature
This commit updates a few tests where we aren't using the correct C
signature for main() or are not using any of its parameters (in the
case of t/version/version.c.)
2023-07-08 20:52:09 -04:00
Robert Edmonds
2c63d76205 protoc-c: Fix -Wsign-compare diagnostics
This commit fixes the following compiler diagnostics:

    ../protoc-c/c_helpers.cc: In function ‘void google::protobuf::compiler::c::PrintComment(google::protobuf::io::Printer*, std::__cxx11::string)’:
    ../protoc-c/c_helpers.cc:221:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
           for (int i = 0; i < comment_lines.size(); i++)
                           ~~^~~~~~~~~~~~~~~~~~~~~~
    ../protoc-c/c_helpers.cc: In function ‘std::set<std::__cxx11::basic_string<char> > google::protobuf::compiler::c::MakeKeywordsMap()’:
    ../protoc-c/c_helpers.cc:273:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
       for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) {
                         ^
2023-07-08 20:50:57 -04:00
Robert Edmonds
69fc2f13bb
Merge pull request #673 from protobuf-c/edmonds/new-google-support
Support for new Google protobuf 22.x, 23.x releases
2023-07-08 20:17:30 -04:00
Robert Edmonds
5b0661f1e8 configure.ac: Require C++17
There are some recent reports of strange build failures that might have
been fixed by compiling in C++17 mode, so it might be a good idea to use
C++17 in general, and not just when building against very recent
protobuf versions.

Since it looks like we've lost protobuf < 3.0.0 support, configure.ac
can be simplified a bit if we just use C++17 by default.
2023-07-03 01:10:28 -04:00
Robert Edmonds
7582b6e7d6 cmake: Require C++17
Newer versions of protobuf apparently don't build with older versions of
the C++ standard.
2023-07-02 22:58:48 -04:00
Robert Edmonds
1937ba946b protoc-c: Use FileDescriptorLegacy to obtain proto syntax version on protobuf >= 23.0
Use the newer "legacy" way of determining whether a file descriptor is
using proto2 or proto3 syntax on protobuf >= 23.0.

Based on
66574f3fd8
but continues to support older versions of protobuf.

Unfortunately, since this is a "deprecated", "legacy" API it'll probably
disappear in about five seconds.
2023-07-02 22:57:57 -04:00
Robert Edmonds
23d2246e0f configure.ac: Require C++17 when building against protobuf >= 4.22.0
It's unclear from looking at the online protobuf documentation whether
C++14 or C++17 is now required when building against newer versions of
protobuf (or perhaps I'm looking in the wrong place), but experimentally
it did not work for me with C++14.

This commit rewrites the versioned PKG_CHECK_MODULES checks in
configure.ac to enforce the following policies:

 * Require protobuf >= 2.6.0.
 * On protobuf >= 3.0.0, require C++11.
 * On protobuf >= 4.22.0, require C++17.
2023-07-02 22:45:44 -04:00
Robert Edmonds
8d334a7204 Work around GOOGLE_* changes in protobuf >= 22.0
According to the protobuf migration guide as of June 2023 [0], protobuf
22.0 (aka 4.22.0) took a dependency on something called "abseil" and as
a result the "stubs" have been removed. This apparently caused all the
uses of GOOGLE_* identifiers in protoc-c to fail when building against
newer versions of protobuf.

This commit introduces compatibility definitions when building against
protobuf >= 4.22.0 so that protobuf-c can build against older and newer
versions of protobuf.

[0] https://web.archive.org/web/20230611151200/https://protobuf.dev/support/migration/#abseil
2023-07-02 19:42:19 -04:00
Robert Edmonds
7b90330bff Use GOOGLE_LOG(FATAL) instead of GOOGLE_LOG(DFATAL)
Looking at where these identifiers are ultimately defined [0], it looks
like "DFATAL" means either "ERROR" or "FATAL" depending on whether
NDEBUG is defined. However, looking at the actual code sites in protoc-c
where DFATAL is used, it's not clear why we couldn't just use FATAL
unconditionally.

This is aimed at supporting newer versions of protobuf where the DFATAL
identifier apparently no longer exists.

[0] https://github.com/protocolbuffers/protobuf/blob/v21.12/src/google/protobuf/stubs/logging.h#L61-L65
2023-07-02 19:35:43 -04:00
Robert Edmonds
ad48868dfe protoc-c: Remove GOOGLE_DISALLOW_EVIL_CONSTRUCTORS macro invocations
protobuf has removed the definition of this macro as of commit
1595417dd3859bbff7d3d61ad0b6e39044d47489, so the invocation of this
macro in protobuf-c breaks the build when building agaist the protobuf
22.x or 23.x series.

Simply removing the macro invocations seems to be safe and doesn't break
the build on Debian's protobuf 3.21.12 nor Debian's protobuf 3.6.1.3.
2023-07-02 17:48:18 -04:00
Robert Edmonds
c3f525da36
Merge pull request #550 from AtariDreams/fixup
Update autotools
2023-07-02 02:55:13 -04:00
Robert Edmonds
cdab7b8a1a
Merge pull request #545 from rgriege/fix-clang-warning
Avoid "unused variable" compiler warning
2023-07-02 02:46:50 -04:00
aviborg
8fd6cf4b88
remove deprecated functionality (#542)
Co-authored-by: Andreas Viborg <andreas.viborg@maxar.com>
Co-authored-by: Robert Edmonds <edmonds@users.noreply.github.com>
2023-07-02 02:39:10 -04:00
Robert Edmonds
5f2aa966de
Merge pull request #482 from KivApple/master
Use CMAKE_CURRENT_BINARY_DIR instead of CMAKE_BINARY_DIR
2023-07-02 02:19:16 -04:00
Robert Edmonds
484e6b98b2
Merge pull request #472 from morrisonlevi/cmake-targets
Export and install CMake targets
2023-07-02 02:11:05 -04:00
Robert Edmonds
0c5f04555a
Merge pull request #525 from defold/fix-unzip-on-windows
GitHub actions fail on Windows due to missing unzip command
2023-07-02 01:37:51 -04:00
Rose
59a3f1925e Update autotools
AC_PROG_CC_STDC is obsolete. Instead, AC_PROG_CC is recommended.
2023-05-06 19:18:26 -04:00
Ryan Griege
aebf3a0b60 Avoid "unused variable" compiler warning 2023-03-12 21:03:31 -05:00
Robert Edmonds
5c5a9981c0
Merge pull request #486 from franksinankaya/frkaya/linkorder
Makefile.am: change link order
2023-01-04 23:45:17 -05:00
Björn Ritzl
182953ead0 Use 7zip instead
7zip is installed on the GitHub runners: https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md#tools
2022-10-01 22:00:23 +02:00
Robert Edmonds
abc67a11c6 ChangeLog: 1.4.1 v1.4.1 2022-07-10 21:33:59 -04:00
Robert Edmonds
471aaa5f6d Bump copyright years to 2022 2022-07-10 21:33:59 -04:00
Robert Edmonds
a0a0131c89 Bump version to 1.4.1 2022-07-10 21:33:59 -04:00
Robert Edmonds
6d4eafd55f
Merge pull request #514 from protobuf-c/edmonds/issue512
Fix issue #512: clang analyzer 14 warning about a possible NULL deref.
2022-07-10 21:12:43 -04:00
Todd C. Miller
ab5f76a52b Fix a clang analyzer 14 warning about a possible NULL deref.
[edmonds: Import commit from
bfc6249902.patch.]
2022-07-10 20:39:06 -04:00
Robert Edmonds
ec3d900001
Merge pull request #513 from protobuf-c/edmonds/issue499
Fix issue #499: unsigned integer overflow
2022-07-10 20:37:15 -04:00
Todd C. Miller
0d1fd124a4 Fix regression with zero-length messages introduced in protobuf-c PR 500.
[edmonds: Import bugfix from
b6a6451482.patch.]
2022-07-10 20:09:23 -04:00
10054172
289f5c18b1 Fix issue #499: unsigned integer overflow
Signed-off-by: 10054172 <hui.zhang@thalesgroup.com>
2022-07-10 20:02:21 -04:00
Robert Edmonds
fc9b2b2ea9
Merge pull request #508 from millert/master
Only shift unsigned values to avoid implementation-specific behavior.
2022-07-10 19:57:15 -04:00
Todd C. Miller
6e389ce2c3 Only shift unsigned values to avoid implementation-specific behavior.
This converts the arithmetic shifts to logical shifts.
It is based in part on a stackoverflow answer by John Schultz,
https://stackoverflow.com/questions/4533076/google-protocol-buffers-zigzag-encoding
2022-06-06 13:57:38 -06:00
Sinan Kaya
d3651a3c50 Makefile.am: change link order
protoc depends on protobuf libraries for execution. Order libraries
accordingly. Observing link errors with yocto's meta-mingw project
during static linkage.

Signed-off-by: Sinan Kaya <sinan.kaya@microsoft.com>
2021-08-11 14:49:42 +03:00
Ivan KOLESNIKOV
500256bb37 Replace more CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR 2021-07-28 14:26:58 +02:00
Ivan KOLESNIKOV
6957eb54eb Use CMAKE_CURRENT_BINARY_DIR instead of CMAKE_BINARY_DIR to improve compatibility (especially with building using add_subdirectory) 2021-07-28 13:36:37 +02:00
Robert Edmonds
f224ab2eeb ChangeLog: 1.4.0 v1.4.0 2021-05-18 20:45:28 -04:00
Robert Edmonds
a124b38608 Bump version to 1.4.0 2021-05-18 20:28:48 -04:00
Levi Morrison
9fd8df92ca Export and install CMake targets
The steps to add this functionality are from the cmake tutorial:
https://cmake.org/cmake/help/latest/guide/tutorial/index.html

The include directories being set on the targets is necessary
for dependent targets. There is some redundancy with the
INCLUDE_DIRECTORIES calls alreday present, but I left it alone
to make the PR smaller and more approachable.

The project currently uses mixed cases in functions. This uses
lowercase on calls I touched, as this is what CMake documentation
uses and seems to be the preferred way.

I also started wrapping long lines, as some of the lines I touched
were over 170 characters.

I tested this on both Mac OS 10.15 Catalina and CentOS 7 (with
devtoolset-7) with CMake 3.10.3.
Will work on tests in CI next.
2021-04-12 18:42:47 -06:00
Ilya Lipnitskiy
9c0fdd12c3
Merge pull request #471 from protobuf-c/ga-pr
Run GitHub actions also on pull requests
2021-04-09 20:00:55 -07:00
Ilya Lipnitskiy
50851e47bc
Run GitHub actions also on pull requests
The push trigger didn't seem to work for PRs based in outside repos. So
limit the push trigger to master and next and enable a PR trigger.
2021-04-09 19:48:17 -07:00
Robert Edmonds
7c6b54b162
Merge pull request #467 from protobuf-c/issue-440
protobuf-c.c: fix packed repeated bool parsing
2021-04-06 20:18:34 -04:00
Robert Edmonds
1b6519e4a8
Merge pull request #466 from protobuf-c/options
protoc-c: add custom options support
2021-04-06 20:16:02 -04:00
Robert Edmonds
5ae0762b85
Merge branch 'next' into options 2021-04-06 19:57:36 -04:00
Robert Edmonds
53004955b0
Merge pull request #463 from protobuf-c/wiretype
protobuf-c: don't use ProtobufCWireType internally
2021-04-06 19:12:44 -04:00
Robert Edmonds
760c5daf03
Merge pull request #459 from protobuf-c/issue-458
protoc-c: fix shared lib build on windows, migrate from Travis CI to GitHub Actions
2021-04-06 18:31:47 -04:00
Ilya Lipnitskiy
733ae77e23
protobuf-c.c: fix packed repeated bool parsing
From https://developers.google.com/protocol-buffers/docs/proto3#updating:
  int32, uint32, int64, uint64, and bool are all compatible – this means
  you can change a field from one of these types to another without
  breaking forwards- or backwards-compatibility. If a number is parsed
  from the wire which doesn't fit in the corresponding type, you will
  get the same effect as if you had cast the number to that type in C++
  (e.g. if a 64-bit number is read as an int32, it will be truncated to
  32 bits).

Until this fix, protobuf-c did not conform to the rule above when it
came to deserializing non-boolean packed repeated data into a
protobuf_c_boolean array. Fully scan the varint and use parse_boolean to
truncate the resulting value.

Fixes #440
2021-03-28 12:27:51 -07:00
Ilya Lipnitskiy
7df109917a
protoc-c: add c_package option
This option allows to override the top-level 'package' setting, or even
remove the package prefix altogether (if set to "").

Fixes #322
2021-03-21 21:11:51 -07:00
Ilya Lipnitskiy
4f39ca6e0c
protoc-c: don't use FullName helpers for non-full names
FullName* methods are designed to split a full name based on '.' in the
name. name() does not have '.' separators, so call CamelToLower and
CamelToUpper in place of FullNameToLower and FullNameToUpper.
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
1b4e45e445
protoc-c: remove dead code 2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
f486c8ed66
protoc-c: add use_oneof_field_name option
Allows for generic oneof offset lookups based on the name of the oneof,
instead of having to know the field name. All oneof fields should have
the same offset, since they are members of a union.

Fixes #204
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
dfb6e300fa
protoc-c: add const_strings option
Keep default as false to preserve backwards compatibility.

Fixes #239
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
cebe3d03f9
protoc-c: add string as bytes option
Allows treating proto strings as ProtobufCBinaryData to work around
limitations such as NULL characters in strings, which are allowed in
protobuf, but not allowed in 'char *' types.

Fixes #203
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
6962695641
protoc-c: add option to customize base field name
Fixes #287
2021-03-21 21:11:50 -07:00