SConscript 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Run the alltypes test case, but compile with PB_WITHOUT_64BIT.
  2. Import("env")
  3. env.NanopbProto(["alltypes", "alltypes.options"])
  4. # Define the compilation options
  5. opts = env.Clone()
  6. opts.Append(CPPDEFINES = {'PB_WITHOUT_64BIT': 1, 'HAVE_STDINT_H': 0, 'PB_SYSTEM_HEADER': '\\"no_64bit_syshdr.h\\"'})
  7. opts.Append(CPPPATH = "#without_64bit")
  8. if 'SYSHDR' in opts:
  9. opts.Append(CPPDEFINES = {'PB_OLD_SYSHDR': opts['SYSHDR']})
  10. # Build new version of core
  11. strict = opts.Clone()
  12. strict.Append(CFLAGS = strict['CORECFLAGS'])
  13. strict.Object("pb_decode_no64bit.o", "$NANOPB/pb_decode.c")
  14. strict.Object("pb_encode_no64bit.o", "$NANOPB/pb_encode.c")
  15. strict.Object("pb_common_no64bit.o", "$NANOPB/pb_common.c")
  16. # Now build and run the test normally.
  17. enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_no64bit.o", "pb_common_no64bit.o"])
  18. dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_no64bit.o", "pb_common_no64bit.o"])
  19. env.RunTest(enc)
  20. env.RunTest([dec, "encode_alltypes.output"])
  21. # Re-encode the data using protoc, and check that the results from nanopb
  22. # match byte-per-byte to the protoc output.
  23. env.Decode("encode_alltypes.output.decoded",
  24. ["encode_alltypes.output", "alltypes.proto"],
  25. MESSAGE='AllTypes')
  26. env.Encode("encode_alltypes.output.recoded",
  27. ["encode_alltypes.output.decoded", "alltypes.proto"],
  28. MESSAGE='AllTypes')
  29. env.Compare(["encode_alltypes.output", "encode_alltypes.output.recoded"])
  30. # Do the same checks with the optional fields present.
  31. env.RunTest("optionals.output", enc, ARGS = ['1'])
  32. env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1'])
  33. env.Decode("optionals.output.decoded",
  34. ["optionals.output", "alltypes.proto"],
  35. MESSAGE='AllTypes')
  36. env.Encode("optionals.output.recoded",
  37. ["optionals.output.decoded", "alltypes.proto"],
  38. MESSAGE='AllTypes')
  39. env.Compare(["optionals.output", "optionals.output.recoded"])