Add 'CAN-binder/libs/nanopb/' from commit '278ffb890e3d8722e4c7d824baaf221a1e375fc4'
[apps/agl-service-can-low-level.git] / CAN-binder / libs / nanopb / tests / field_size_16_proto3 / SConscript
1 # Version of AllTypes test case for protobuf 3 file format.
2
3 Import("env")
4
5 import re
6 match = None
7 if 'PROTOC_VERSION' in env:
8     match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION'])
9
10 if match:
11     version = map(int, match.groups())
12
13 # proto3 syntax is supported by protoc >= 3.0.0
14 if 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"])