1# Test anonymous_oneof generator option 2 3Import('env') 4 5import re 6 7match = None 8if 'PROTOC_VERSION' in env: 9 match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION']) 10 11if match: 12 version = map(int, match.groups()) 13 14# Oneof is supported by protoc >= 2.6.0 15if 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 if '-pedantic' in env2['CFLAGS']: 20 env2['CFLAGS'].remove('-pedantic') 21 env2.NanopbProto('oneof') 22 23 dec = env2.Program(['decode_oneof.c', 24 'oneof.pb.c', 25 '$COMMON/pb_decode.o', 26 '$COMMON/pb_common.o']) 27 28 env2.RunTest("message1.txt", [dec, '$BUILD/oneof/message1.pb'], ARGS = ['1']) 29 env2.RunTest("message2.txt", [dec, '$BUILD/oneof/message2.pb'], ARGS = ['2']) 30 env2.RunTest("message3.txt", [dec, '$BUILD/oneof/message3.pb'], ARGS = ['3']) 31