2
0

SConscript 1.1 KB

12345678910111213141516171819202122232425262728
  1. Import('env')
  2. import os
  3. base_env = env.Clone()
  4. base_env.Replace(NANOPBFLAGS = '--cpp-descriptor')
  5. base_env.NanopbProtoCpp('message')
  6. # not enabled for "c++03", which fails with "warning: offset of on non-POD type 'TestMessage'"
  7. # 'offsetof' in C++98 requires POD type, C++11 standard relaxes that to standard-layout class.
  8. # see: http://www.cplusplus.com/reference/cstddef/offsetof/
  9. for std in ["c++11", "c++14", "c++17", "c++20"]:
  10. e = base_env.Clone()
  11. e.Append(CXXFLAGS = '-std={}'.format(std))
  12. # Make sure compiler supports this version of C++ before we actually run the
  13. # test.
  14. conf = Configure(e)
  15. compiler_valid = conf.CheckCXX() and conf.CheckCXXHeader('vector')
  16. e = conf.Finish()
  17. if not compiler_valid:
  18. print("Skipping {} test - compiler doesn't support it".format(std))
  19. continue
  20. sources = [ 'cxx_callback_datatype.cpp', 'message.pb.cpp', '$NANOPB/pb_decode.c', '$NANOPB/pb_encode.c', '$NANOPB/pb_common.c' ]
  21. objects = [ e.Object('{}_{}'.format(os.path.basename(s), std), s) for s in sources ]
  22. p = e.Program(target = 'cxx_callback_datatype_{}'.format(std), source = objects)
  23. e.RunTest(p)