From 0b29baf5deaa4213c08ee71fa55d3d0b2ed709e4 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Sat, 12 Sep 2015 15:45:37 +0300 Subject: Make the generator understand included files (issue #165). This will allow message sizes and enum options to be available across the include files. Currently searching for .options files for included files may not work for all path combinations, this is related to issue #116. Should probably make a pull request to protoc about that. --- tests/multiple_files/SConscript | 2 +- tests/multiple_files/multifile1.options | 1 + tests/multiple_files/multifile1.proto | 4 ++++ tests/multiple_files/multifile2.proto | 3 +-- tests/multiple_files/test_multiple_files.c | 8 ++++---- 5 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 tests/multiple_files/multifile1.options (limited to 'tests') diff --git a/tests/multiple_files/SConscript b/tests/multiple_files/SConscript index c3a82eb4..1689f482 100644 --- a/tests/multiple_files/SConscript +++ b/tests/multiple_files/SConscript @@ -5,7 +5,7 @@ Import("env") incpath = env.Clone() incpath.Append(PROTOCPATH = '#multiple_files') -incpath.NanopbProto("multifile1") +incpath.NanopbProto(["multifile1", "multifile1.options"]) incpath.NanopbProto("multifile2") test = incpath.Program(["test_multiple_files.c", "multifile1.pb.c", "multifile2.pb.c"]) diff --git a/tests/multiple_files/multifile1.options b/tests/multiple_files/multifile1.options new file mode 100644 index 00000000..c44d2669 --- /dev/null +++ b/tests/multiple_files/multifile1.options @@ -0,0 +1 @@ +StaticMessage.repint32 max_count:5 diff --git a/tests/multiple_files/multifile1.proto b/tests/multiple_files/multifile1.proto index 79cf0387..d804b67d 100644 --- a/tests/multiple_files/multifile1.proto +++ b/tests/multiple_files/multifile1.proto @@ -14,6 +14,10 @@ message TestMessage { repeated string repeatedstring = 6; } +message StaticMessage { + repeated fixed32 repint32 = 1; +} + enum SignedEnum { SE_MIN = -128; SE_MAX = 127; diff --git a/tests/multiple_files/multifile2.proto b/tests/multiple_files/multifile2.proto index c5dcd406..66cb8a0b 100644 --- a/tests/multiple_files/multifile2.proto +++ b/tests/multiple_files/multifile2.proto @@ -9,8 +9,7 @@ message Callback2Message { message OneofMessage { oneof msgs { - TestMessage tstmsg = 1; - SubMessage submsg = 2; + StaticMessage tstmsg = 1; } } diff --git a/tests/multiple_files/test_multiple_files.c b/tests/multiple_files/test_multiple_files.c index 5134f03f..292b8d7c 100644 --- a/tests/multiple_files/test_multiple_files.c +++ b/tests/multiple_files/test_multiple_files.c @@ -7,16 +7,16 @@ #include "unittests.h" #include "multifile2.pb.h" -/* Check that the size definition is obtained properly */ -static const int foo = OneofMessage_size; - int main() { int status = 0; + /* Test that included file options are properly loaded */ + TEST(OneofMessage_size == 27); + /* Check that enum signedness is detected properly */ TEST(PB_LTYPE(Enums_fields[0].type) == PB_LTYPE_VARINT); - TEST(PB_LTYPE(Enums_fields[0].type) == PB_LTYPE_UVARINT); + TEST(PB_LTYPE(Enums_fields[1].type) == PB_LTYPE_UVARINT); return status; } -- cgit 1.2.3-korg