SConscript 784 B

123456789101112131415161718192021222324
  1. # Test proto3 "optional" field types.
  2. # This is supported in protoc 3.12 and newer.
  3. Import('env')
  4. import re
  5. version = None
  6. if 'PROTOC_VERSION' in env:
  7. match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION'])
  8. version = (int(match.group(1)), int(match.group(2)), int(match.group(3)))
  9. # Oneof is supported by protoc >= 3.12.0
  10. if env.GetOption('clean') or (version and (version[0] > 3 or (version[0] == 3 and version[1] >= 12))):
  11. env2 = env.Clone()
  12. env2.Append(PROTOCFLAGS = "--experimental_allow_proto3_optional")
  13. env2.NanopbProto("optional.proto")
  14. opt = env2.Program(["optional.c", "optional.pb.c",
  15. "$COMMON/pb_decode.o", "$COMMON/pb_encode.o",
  16. "$COMMON/pb_common.o"])
  17. env2.RunTest(opt)