8f634bd7a211221deb559275408a1c1458cd90b3
[apps/agl-service-can-low-level.git] / tests / anonymous_oneof / SConscript
1 # Test anonymous_oneof generator option
2
3 Import('env')
4
5 import re
6
7 match = None
8 if 'PROTOC_VERSION' in env:
9     match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION'])
10
11 if match:
12     version = map(int, match.groups())
13
14 # Oneof is supported by protoc >= 2.6.0
15 if env.GetOption('clean') or (match and (version[0] > 2 or (version[0] == 2 and version[1] >= 6))):
16     # Anonymous oneofs are supported by clang and gcc
17     if 'clang' in env['CC'] or 'gcc' in env['CC']:
18         env2 = env.Clone()
19         env2.Append(CFLAGS = "-Wno-pedantic")
20         env2.NanopbProto('oneof')
21
22         dec = env2.Program(['decode_oneof.c',
23                             'oneof.pb.c',
24                             '$COMMON/pb_decode.o',
25                             '$COMMON/pb_common.o'])
26
27         env2.RunTest("message1.txt", [dec, '$BUILD/oneof/message1.pb'], ARGS = ['1'])
28         env2.RunTest("message2.txt", [dec, '$BUILD/oneof/message2.pb'], ARGS = ['2'])
29         env2.RunTest("message3.txt", [dec, '$BUILD/oneof/message3.pb'], ARGS = ['3'])