56 Commits

Author SHA1 Message Date
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
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
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
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
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
883b1acc1b
protoc-c: add no_generate option
Allows suppression of .pb-c.{c,h} file generation on a .proto file
basis.

protobuf-c.proto: Use the new option in itself, because the options are
never used by protobuf-c runtime, only by the protoc-gen-c compiler.

t/test-full.proto: import protobuf-c.proto to test that
protobuf-c.pb-c.h dependency does not get included in test-full.pb-c.h.
2021-03-21 21:11:49 -07:00
Ilya Lipnitskiy
0e060260f0
protoc-c: add custom options support 2021-03-21 20:28:33 -07:00
Ilya Lipnitskiy
4c86c6b333 Add test for #389 2020-05-13 13:20:48 -07:00
Robert Edmonds
dc3057c840 Makefile.am: Only enable the Issue #330 test case when building against protobuf 3.x
Issue #330 is a bug in proto3 behavior and the test case handling it
needs a 'syntax = "proto3";' line in its .proto file, which is not
supported by the protobuf 2 implementation.

Since we still support building against protobuf 2, this commit
conditionalizes the Issue #330 test case so that it is only built when
protobuf-c is being built against protobuf 3.
2019-10-17 19:01:35 -04:00
Robert Edmonds
ffe38d4df5
Merge branch 'next' into ilya/issue330 2019-05-18 17:02:29 -04:00
Ilya Lipnitskiy
6aa7dc7a10 Add test case for #330 2019-05-17 13:29:06 -07:00
Adam Cozzette
d58d7ca271 Fixed out-of-bounds read
The scan_length_prefixed_data() function returns the number of bytes
taken up by a varint length delimiter, plus the actual value of that
delimiter. Since it returns a uint32_t, a delimiter of 2^32 - 1 (or
close to that) could cause the return value to overflow and result in an
incorrect value.

At first I tried to fix it by making scan_length_prefixed_data() use a
size_t for its result, but I realized this would have no effect on
32-bit systems. To fix the problem for 32-bit, I changed the function to
return early if the length is 2 GiB or more (protobuf messages are not
allowed to be that large). I kept the size_t change anyway, since the
result will ultimately be stored in a size_t (ScannedMember.len) and we
might as well stay consistent with that.

Signed-off-by: Adam Cozzette <acozzette@google.com>
2019-05-16 12:30:08 -07:00
Matthias Dittrich
71273f3919 fix mingw compilation 2017-09-25 18:38:24 +02:00
Paolo Borelli
13b6e1fd00 Improve proto3 unit test
Make sure we actually include the proto3 generated header and
test nested submessages
2017-04-09 10:54:58 +02:00
Robert Edmonds
c48d932003 Merge pull request #228 from pbor/wip/proto3
proto3 support
2017-02-25 14:20:04 -08:00
Robert Edmonds
1442642234 t/issue251/: Add test case for #251 2017-02-25 15:52:39 -05:00
Robert Edmonds
d89895de3c t/issue220/: Add test case for #220 2017-02-25 14:49:09 -05:00
Paolo Borelli
2f22519f58 Add basic proto3 test
Same code of the proto2 test but with the corresponding proto3 file
2016-10-30 10:06:52 +01:00
Thomas Köckerbauer
3ddc7c62ca rm argument fix for solaris 2016-09-07 10:33:38 +02:00
Robert Edmonds
d6ede8125e Merge pull request #232 from gdetal/master
protobuf-c: fix: make dist
2016-08-24 20:20:50 -07:00
Gregory Detal
5306fc9329 protobuf-c: fix: make dist
remove .pb.{cc,h} in distdir instead of top_distdir in order to
prevent removing files from other projects when protobuf-c is
included as an autotools subproject.

Signed-off-by: Gregory Detal <gregory.detal@tessares.net>
2016-08-24 14:38:49 +02:00
Paolo Borelli
af2120aa55 Turn the compiler into a protoc plugin
Using the old "protoc-c" command directly is still supported
through a symlink.
2016-02-17 10:58:43 +01:00
Zex
d6ac08c8ba skip protoc-c tests on cross-compiling 2016-01-29 18:53:04 -05:00
Ilya Lipnitskiy
be99a7ac31 t: Add tests for the LITE_RUNTIME optimization option 2015-03-15 20:01:03 -07:00
Robert Edmonds
cb7498b0a7 Makefile.am: distribute build-cmake/CMakeLists.txt
Ironically, we need to tell automake to distribute the CMakeLists.txt
file in the tarball...
2014-09-08 17:05:05 -04:00
Natanael Copa
b0bb563033 Makefile.am: fix parallel build of t/generated-code2/cxx-generate-packed-data
The object file name is not what is expected when building with
automake's "subdir-objects" option. Rather than expecting automake to
generate a specific filename, we simply make the generated header a
dependency of all objects for cxx-generate-packed-data.

(Issue #156, #169.)
2014-09-08 17:04:39 -04:00
Robert Edmonds
0df53ea0c5 switch to a more automake-ish method of generating the html doxygen documentation 2014-06-03 17:30:13 -04:00
Robert Edmonds
e72e7e7e81 add code coverage option to the build system
configure now has a "--enable-code-coverage" option, and if the
lcov/gcov tools are available a code coverage report can be built with
"make check-code-coverage".

this is mostly based on the AX_CODE_COVERAGE / GNOME_CODE_COVERAGE
macro:

    http://savannah.gnu.org/patch/?8451

but i also looked at knot-dns's code coverage implementation:

    https://github.com/CZNIC-Labs/knot/blob/master/m4/code-coverage.m4

and kevin lyda's pull request:

    https://github.com/protobuf-c/protobuf-c/pull/131/files
2014-06-02 17:56:41 -04:00
Robert Edmonds
5353ba7432 Makefile.am: ship LICENSE and README.md in the tarball 2014-04-03 19:08:21 -04:00
Robert Edmonds
626b138fa6 t/: add new test program 'version' 2014-04-03 17:09:39 -04:00
Robert Edmonds
66005093be Makefile.am: use CXXFLAGS instead of CFLAGS for protoc-c/protoc-c, t/generated_code2_cxx_generate_packed_data
these are C++ programs, not C programs, so use CXXFLAGS instead of
CFLAGS.

based on a patch from Andrei Nigmatulin.
2014-03-28 14:03:59 -04:00
Robert Edmonds
daad5868cf version the libprotobuf-c symbols on compatible linkers (Issue #116)
this is conditional on whether the linker supports version scripts, for
which we use the gl_LD_VERSION_SCRIPT macro from the gnulib project.

on platforms without version scripts, we fall back to libtool's
-export-symbols-regex.
2014-03-27 15:22:55 -04:00
Kevin Lyda
369f7e58a1 Default doxygen-doc to not enabled.
Also, don't default dot support to on and emit something to say if
the dogygen-doc target is enabled.
2014-02-17 09:24:51 +00:00
Kevin Lyda
b9f94db3cc Autoconf configuration for doxygen.
Still need to add the comments in the source code. Currently I've
seeded it with the libprotobuf-c files.  I've configured it
to make man pages and html pages.  Might not be ideal, but makes it easy
for me to check things (html is nicer, but man pages are handier for
remote servers).
2014-02-16 21:45:02 +00:00
Kevin Lyda
f52f500995 Autoconf portability tweaks.
Use MKDIR_P and LN_S rather than their usual expansions.
2014-01-25 15:56:40 +00:00
Robert Edmonds
ed036b769f Revert "protobuf-c/libprotobuf-c.sym: new" (fixes #116)
This reverts commit aaa40c5881f12877cca63c06a798d8422f9470de.
2014-01-17 11:10:39 -05:00
Robert Edmonds
dd0f0ea3ef Makefile.am: AM_TESTS_ENVIRONMENT -> LOG_COMPILER
It’s important to note that, differently from what we’ve seen for
    the serial test harness (see Parallel Test Harness), the
    AM_TESTS_ENVIRONMENT and TESTS_ENVIRONMENT variables cannot be use
    to define a custom test runner; the LOG_COMPILER and LOG_FLAGS (or
    their extension-specific counterparts) should be used instead:

    ## This is WRONG!
    AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib' $(PERL) -Mstrict -w

    ## Do this instead.
    AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib'; export PERL5LIB;
    LOG_COMPILER = $(PERL)
    AM_LOG_FLAGS = -Mstrict -w

(http://www.gnu.org/software/automake/manual/html_node/Parallel-Test-Harness.html)
2014-01-14 13:46:19 -05:00
Ilya Lipnitskiy
baa3ab296d .travis.yml: add a travis build entry to run tests under valgrind
Makefile.am: add valgrind to the AM_TESTS_ENVIRONMENT
configure.ac: enable valgrind testing option for ./configure
m4/valgrind-tests.m4: enable tracing children for libtool wrapper
script compatibility, but ignore standard binaries in /usr or /bin
2014-01-14 00:20:05 -08:00
Robert Edmonds
aaa40c5881 protobuf-c/libprotobuf-c.sym: new
use a linker script rather than relying on libtool's
-export-symbols-regex. this lets us start versioning the library's
exported symbols.
2014-01-13 20:17:39 -05:00
Robert Edmonds
677c3f0bdf remove protobuf-c-private.h
there's not much point to having the "private" definitions split out
into a separate header file. they're still in the namespace and there's
nothing that can be done to prevent "unauthorized" uses. just integrate
the definitions into the main header file but put them in the bottom and
note that they're "private".

this makes it very slightly easier to copy the protobuf-c support
library into another project wholesale, since one less file is required.
2014-01-13 19:53:41 -05:00
Robert Edmonds
5a026769e6 Makefile.am: set up a compatibility symlink for include paths that use <google/protobuf-c>
it might be premature to remove the <google/> prefix from the include
path. set up a compatibility symlink so that old code continues to
compile.
2014-01-13 19:53:41 -05:00
Robert Edmonds
a2fb294a22 build system: add back the --disable-protoc option to configure 2014-01-13 19:53:41 -05:00
Robert Edmonds
e8a55cf186 Makefile.am: remove protobuf-c-rpc 2014-01-10 13:25:11 -05:00
Robert Edmonds
3b3f78ce5d Makefile.am: bump libprotobuf-c SONAME 2013-11-20 15:04:24 -05:00
Robert Edmonds
9e86cda282 Makefile.am: protobuf-c-rpc/: make sure that the gsk* header files get distributed 2013-11-18 14:32:57 -05:00
Robert Edmonds
4142d7e92e build system: remove --disable-protoc option
for some reason, "make distcheck" fails when the build is configured
with --disable-protoc. i haven't been able to track down the root cause
(it appears the build is trying to generate the generated pb-c files for
the test cases, but the test cases should be disabled when
--disable-protoc is specified). so, remove the --disable-protoc option.
libprotobuf-c should always be tested as part of a build, and this can't
be done unless protoc-c is built. this also reduces the number of build
combinations that need to be tested.
2013-11-18 14:24:05 -05:00
Robert Edmonds
43b94a4bc4 fix VPATH builds
this commit fixes VPATH builds where the build tree is separate from the
source tree. this will allow us to run "make distcheck".
2013-11-18 13:53:28 -05:00
Robert Edmonds
40f31f2aff new build system 2013-11-16 18:08:40 -05:00
Robert Edmonds
12215b4774 remove the current build system 2013-11-15 21:49:56 -05:00
lahiker42@gmail.com
b0d7d4a023 Add version macros and library globals.
git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@324 00440858-1255-0410-a3e6-75ea37f81c3a
2011-11-02 03:45:35 +00:00