• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Version of AllTypes test case for protobuf 3 file format.
2
3Import("env")
4
5import re
6match = None
7if 'PROTOC_VERSION' in env:
8    match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION'])
9
10if match:
11    version = list(map(int, match.groups()))
12
13# proto3 syntax is supported by protoc >= 3.0.0
14if env.GetOption('clean') or (match and version[0] >= 3):
15
16    env.NanopbProto(["alltypes", "alltypes.options"])
17
18    # Define the compilation options
19    opts = env.Clone()
20    opts.Append(CPPDEFINES = {'PB_FIELD_16BIT': 1})
21
22    # Build new version of core
23    strict = opts.Clone()
24    strict.Append(CFLAGS = strict['CORECFLAGS'])
25    strict.Object("pb_decode_fields16.o", "$NANOPB/pb_decode.c")
26    strict.Object("pb_encode_fields16.o", "$NANOPB/pb_encode.c")
27    strict.Object("pb_common_fields16.o", "$NANOPB/pb_common.c")
28
29    # Now build and run the test normally.
30    enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_fields16.o", "pb_common_fields16.o"])
31    dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_fields16.o", "pb_common_fields16.o"])
32
33    env.RunTest(enc)
34    env.RunTest([dec, "encode_alltypes.output"])
35