810 Commits

Author SHA1 Message Date
Robert Edmonds
4719fdd776 CHANGELOG.md: 1.5.2 v1.5.2 2025-04-06 21:16:14 -04:00
Robert Edmonds
dd9b35d819 Bump version to 1.5.2 2025-04-06 21:14:19 -04:00
Robert Edmonds
63dee70373 Merge pull request #768 from protobuf-c/edmonds/more-google-protobuf-30-fixes
protoc-gen-c: Explicitly construct strings where needed for protobuf 30.x
2025-03-16 23:41:32 -04:00
Robert Edmonds
9f1e80e275 protoc-gen-c: Explicitly construct strings where needed for protobuf 30.x
protobuf 30.x changes various APIs to return string_view's rather than
string&'s. This broke protobuf-c, since we were relying on the implicit
construction of strings from string&'s in various places.

This commit explicitly constructs strings from the string_view's
returned by the protobuf 30.x API when we need to store an owned string
(e.g. in a hash map). This maintains compatibility with older versions
of protobuf such as 3.21 in Debian/Ubuntu while extending compatibility
to the latest protobuf 30.x.

Without this commit we get lots of errors like this when compiling
against protobuf 30.x:

    protoc-gen-c/c_field.cc:119:43: error: no match for 'operator=' (operand types are 'std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >::mapped_type' {aka 'std::__cxx11::basic_string<char>'} and 'google::protobuf::internal::DescriptorStringView' {aka 'absl::debian7::string_view'})
2025-03-16 23:15:16 -04:00
Robert Edmonds
2517481817 Merge pull request #762 from protobuf-c/edmonds/google-protobuf-30-fixes
Chase compatibility issues with Google protobuf 30.0-rc1
2025-03-08 14:06:57 -05:00
Robert Edmonds
9a6b35e1e6 Cater to Microsoft Visual C++
Apparently MSVC doesn't support designated initializers for some reason.
2025-02-08 21:44:42 -05:00
Robert Edmonds
4ebd5cd823 compat: Conditionalize the include of <string>
It is only needed on older protobuf versions where absl::string_view is
not being used.
2025-02-08 21:38:07 -05:00
Robert Edmonds
9c56038fd9 Makefile.am: Add compat.h to protoc_gen_c_protoc_gen_c_SOURCES 2025-02-08 21:37:30 -05:00
Robert Edmonds
c59b146aee compat: Use absl::string_view instead of google::protobuf::internal::DescriptorStringView
Even though google::protobuf::internal::DescriptorStringView is exposed
in public protobuf headers, it's probably not a good idea to rely on an
"internal" typedef.

According to https://protobuf.dev/news/2024-10-02/#descriptor-apis:

    v30 will update return types in descriptor (such as full_name) to be
    absl::string_view.

So `absl::string_view` is probably the right type to use here.
2025-02-08 21:10:37 -05:00
Robert Edmonds
ebeddac1a7 Fix indentation of MessageGenerator::GenerateMessageDescriptor() 2025-02-08 20:58:26 -05:00
Robert Edmonds
0edca93db3 Convert various uses of const char * to compat::StringView
Also replace some uses of arrays manually allocated with new/delete with
uses of `std::vector`.
2025-02-08 20:58:23 -05:00
Robert Edmonds
75f1c32cc4 Convert string views to owned strings where necessary 2025-02-08 20:57:26 -05:00
Robert Edmonds
bc2cb66d90 Use compat::StringView type across various function signatures 2025-02-08 20:57:26 -05:00
Robert Edmonds
db5252c131 Remove some unused functions 2025-02-08 20:57:26 -05:00
Robert Edmonds
1678f1fba6 protoc-gen-c/compat.h: Add compat::StringView type
protobuf >= 30.x replaces `const std::string&` in various APIs with
its own string view type that may actually be a `absl::string_view`.
Introduce our own `compat::StringView` type that we can use instead
of `const std::string&` in order to support compiling across multiple
protobuf versions.
2025-02-08 20:09:03 -05:00
Robert Edmonds
b28683f802 protoc-gen-c/c_helpers.h: Move compat defines into new header file compat.h 2025-02-08 18:18:33 -05:00
Robert Edmonds
185beed28e CHANGELOG.md: 1.5.1 v1.5.1 2025-02-01 23:06:44 -05:00
Robert Edmonds
51e4f9506c Bump version to 1.5.1 2025-02-01 23:04:03 -05:00
Robert Edmonds
bf7e18f9f5 Merge pull request #759 from protobuf-c/edmonds/ci/multiarch-debian
build.yml: Try running multiarch builds on Debian bookworm
2025-01-26 19:23:06 -05:00
Robert Edmonds
93a7227b00 build.yml: Try running multiarch builds on Debian bookworm 2025-01-26 14:12:24 -05:00
Robert Edmonds
53e0b201db LICENSE: 2025 2025-01-26 01:51:00 -05:00
Robert Edmonds
0ed9476226 Merge pull request #758 from protobuf-c/edmonds/protoc-gen-c/deprecation-warning
protoc-gen-c: Log a deprecation warning when invoked as `protoc-c`
2025-01-26 01:46:12 -05:00
Robert Edmonds
cf1f264032 protoc-gen-c: Log a deprecation warning when invoked as protoc-c 2025-01-25 23:53:07 -05:00
Robert Edmonds
2e26a84a1b Merge pull request #757 from protobuf-c/edmonds/cmake-ninja-build-fix
cmake: Fix build when using ninja and protobuf-c already installed
2025-01-25 22:54:41 -05:00
Robert Edmonds
417c759bbd cmake: Fix build when using ninja and protobuf-c already installed
If protobuf-c is already installed on the system, the cmake build can
generate an error like the following when using the ninja backend:

    edmonds@chase{0}:/tmp/protobuf-c$ cmake -S build-cmake -B build -G Ninja
    [...]

    edmonds@chase{0}:/tmp/protobuf-c$ ninja -v -C build
    ninja: Entering directory `build'
    [1/19] cd /tmp/protobuf-c/build && /usr/bin/cmake -E env PATH="/tmp/protobuf-c/build:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/edmonds/bin:/home/edmonds/.cargo/bin:/sbin:/bin:/usr/games" /usr/bin/protoc --cpp_out /tmp/protobuf-c/build -I/usr/include -I/tmp/protobuf-c /tmp/protobuf-c/protobuf-c/protobuf-c.proto
    FAILED: CMakeFiles/protoc-generated-files protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h /tmp/protobuf-c/build/CMakeFiles/protoc-generated-files /tmp/protobuf-c/build/protobuf-c/protobuf-c.pb.cc /tmp/protobuf-c/build/protobuf-c/protobuf-c.pb.h
    cd /tmp/protobuf-c/build && /usr/bin/cmake -E env PATH="/tmp/protobuf-c/build:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/edmonds/bin:/home/edmonds/.cargo/bin:/sbin:/bin:/usr/games" /usr/bin/protoc --cpp_out /tmp/protobuf-c/build -I/usr/include -I/tmp/protobuf-c /tmp/protobuf-c/protobuf-c/protobuf-c.proto
    /tmp/protobuf-c/protobuf-c/protobuf-c.proto: Input is shadowed in the --proto_path by "/usr/include/protobuf-c/protobuf-c.proto".  Either use the latter file as your input or reorder the --proto_path so that the former file's location comes first.
    [2/19] /usr/bin/cc -DPACKAGE_STRING="\"protobuf-c 1.5.0\"" -DPACKAGE_VERSION=\"1.5.0\" -I/tmp/protobuf-c -I/tmp/protobuf-c/protobuf-c -I/tmp/protobuf-c/build  -MD -MT CMakeFiles/protobuf-c.dir/tmp/protobuf-c/protobuf-c/protobuf-c.c.o -MF CMakeFiles/protobuf-c.dir/tmp/protobuf-c/protobuf-c/protobuf-c.c.o.d -o CMakeFiles/protobuf-c.dir/tmp/protobuf-c/protobuf-c/protobuf-c.c.o -c /tmp/protobuf-c/protobuf-c/protobuf-c.c
    ninja: build stopped: subcommand failed.
2025-01-25 22:31:34 -05:00
Robert Edmonds
f981c8d7ae Merge pull request #756 from protobuf-c/edmonds/more-renaming-protoc-c-to-protoc-gen-c
More renaming of `protoc-c` to `protoc-gen-c`
2025-01-25 22:25:33 -05:00
Robert Edmonds
51c5685896 README.md: Replace instances of "protoc-c" 2025-01-25 22:04:01 -05:00
Robert Edmonds
5cd4d5c453 protoc-gen-c: FileGenerator::GenerateHeader(): "protoc-c" → "protobuf-c" 2025-01-25 22:01:37 -05:00
Robert Edmonds
c4e17a9247 protobuf-c: "protoc-c" → "protoc-gen-c" 2025-01-25 21:51:37 -05:00
Robert Edmonds
4a3ebd7195 protoc-gen-c/: Rename namespace google::protobuf::compiler::c → protobuf_c
Also rename GOOGLE_PROTOBUF_* include guard defines.
2025-01-25 21:14:44 -05:00
Robert Edmonds
44b909351b protoc-gen-c/: Update #include's, copyright years 2025-01-25 20:49:02 -05:00
Robert Edmonds
773d337b86 .gitignore: protoc-c/ → protoc-gen-c/ 2025-01-25 20:49:02 -05:00
Robert Edmonds
cf8f97b5ba cmake: protoc-c/ → protoc-gen-c/ 2025-01-25 20:49:02 -05:00
Robert Edmonds
9b667aed3d Makefile.am: protoc-c/ → protoc-gen-c/ 2025-01-25 20:49:02 -05:00
Robert Edmonds
4b3f45b0f6 Rename protoc-c/ → protoc-gen-c/ 2025-01-25 18:34:35 -05:00
Robert Edmonds
66ff44fc15 Merge pull request #755 from protobuf-c/edmonds/gcc15-union-initialization-changes
Order oneof union members from largest to smallest
2025-01-25 12:59:25 -05:00
Robert Edmonds
cecf01e67d protoc-c: c_message: Add extra braces to initialize a oneof union containing a ProtobufCBinaryData
Certain compilers (e.g. [0]) incorrectly generate warning messages
when the universal zero initializer is used by the protobuf-c generated
code to initialize a protobuf object containing a oneof that contains a
ProtobufCBinaryData field as the first member. This is now much more
likely due to the change in the previous commit ("protoc-c: c_message:
Order oneof union members from largest to smallest") which will now
always cause a ProtobufCBinaryData field to be placed as the first
member of the union, if one is present in the oneof.

In this situation, we need to add an extraneous pair of braces around
the universal zero initializer in the generated initialization code.

The former behavior of using the universal zero initializer by itself is
kept for oneof unions that do not contain a ProtobufCBinaryData member.

[0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80454
2025-01-20 19:34:37 -05:00
Robert Edmonds
3648538712 protoc-c: c_message: Order oneof union members from largest to smallest
This commit changes the code generator to output the members of a oneof
union from largest to smallest, rather than in field descriptor order.

This is necessary on certain compilers such as gcc >= 15 which do not
guarantee that initializing a union with the universal zero initializer
actually initializes all the bits of the object representation of the
members of the union, unless the largest union member is the first
member of the union.
2025-01-20 19:28:51 -05:00
Robert Edmonds
040e9eb0c5 t/issue745/: Add test case for #745
This currently fails on gcc 15 but succeeds on gcc 14, as expected.
2025-01-20 19:18:26 -05:00
Robert Edmonds
67eef00207 Makefile.am: Fix ordering of issue440 test definitions 2025-01-20 15:09:50 -05:00
Robert Edmonds
be364aa09f Merge pull request #754 from protobuf-c/edmonds/ci/ubuntu-updates
build.yml: Ubuntu: Add 22.04, 24.04
2025-01-18 21:44:33 -05:00
Robert Edmonds
fd07ca75c7 build.yml: Reformat 2025-01-18 21:05:33 -05:00
Robert Edmonds
1739815485 build.yml: Ubuntu: Drop 20.04 ahead of EOL 2025-01-18 20:51:46 -05:00
Robert Edmonds
0211069d55 build.yml: Ubuntu: Add 22.04, 24.04
- Add Ubuntu 22.04, 24.04 to the standard distcheck job.
- Add Ubuntu 22.04, 24.04 to the CMake job.
- Convert Valgrind job from Ubuntu 20.04 to 24.04.
- Convert coverage job from Ubuntu 20.04 to 24.04.
- Convert the run-on-arch-action job to run on Ubuntu 24.04 (base) and
Ubuntu 22.04 (the arch-specific actions; Ubuntu 24.04 not available).
- Add riscv64 to the list of architectures for the run-on-arch-action
job to run on.
2025-01-18 20:29:45 -05:00
Robert Edmonds
6efd7db3b3 Merge pull request #753 from protobuf-c/edmonds/ci/windows-dependency-updates
build.yml: Update Windows dependencies (abseil, protobuf)
2025-01-18 19:31:26 -05:00
Robert Edmonds
f902dccbbe fixup! build.yml: Disable building Windows with static libraries 2025-01-18 19:01:32 -05:00
Robert Edmonds
e1b26d0ab2 build.yml: Windows: protobuf: Drop -DABSL_PROPAGATE_CXX_STD=ON
This flag is not used by the protobuf build system:

    CMake Warning:
      Manually-specified variables were not used by the project:

        ABSL_PROPAGATE_CXX_STD
2025-01-18 18:35:36 -05:00
Robert Edmonds
030a424469 build.yml: Disable building Windows with static libraries
The static library builds on Windows are throwing obscure linker errors,
but the shared library builds are succeeding, so turn off the static
library builds for now.
2025-01-18 18:33:20 -05:00
Robert Edmonds
5a8cf4c20e build.yml: Use Ninja on Windows to speed up the build
Microsoft refuses to ship Ninja in the Windows image so a third-party
script is needed.
2025-01-18 18:07:31 -05:00
Robert Edmonds
ae987b4bb4 build.yml: Try setting -DCMAKE_MSVC_RUNTIME_LIBRARY for abseil, protobuf, protobuf-c builds on Windows 2025-01-18 17:45:30 -05:00