SConscript 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Build the common files needed by multiple test cases
  2. Import('env')
  3. # Protocol definitions for the encode/decode_unittests
  4. env.NanopbProto("unittestproto")
  5. # Protocol definitions for basic_buffer/stream tests
  6. env.NanopbProto("person")
  7. #--------------------------------------------
  8. # Binaries of the pb_decode.c and pb_encode.c
  9. # These are built using more strict warning flags.
  10. strict = env.Clone()
  11. strict.Append(CFLAGS = strict['CORECFLAGS'])
  12. strict.Object("pb_decode.o", "$NANOPB/pb_decode.c")
  13. strict.Object("pb_encode.o", "$NANOPB/pb_encode.c")
  14. strict.Object("pb_common.o", "$NANOPB/pb_common.c")
  15. #-----------------------------------------------
  16. # Binaries of pb_decode etc. with malloc support
  17. # Uses malloc_wrappers.c to count allocations.
  18. malloc_env = env.Clone()
  19. malloc_env.Append(CPPDEFINES = {'PB_ENABLE_MALLOC': 1,
  20. 'PB_SYSTEM_HEADER': '\\"malloc_wrappers_syshdr.h\\"'})
  21. malloc_env.Append(CPPPATH = ["$COMMON"])
  22. if 'SYSHDR' in malloc_env:
  23. malloc_env.Append(CPPDEFINES = {'PB_OLD_SYSHDR': malloc_env['SYSHDR']})
  24. # Disable libmudflap, because it will confuse valgrind
  25. # and other memory leak detection tools.
  26. if '-fmudflap' in env["CCFLAGS"]:
  27. malloc_env["CCFLAGS"].remove("-fmudflap")
  28. malloc_env["LINKFLAGS"].remove("-fmudflap")
  29. malloc_env["LIBS"].remove("mudflap")
  30. malloc_strict = malloc_env.Clone()
  31. malloc_strict.Append(CFLAGS = malloc_strict['CORECFLAGS'])
  32. malloc_strict.Object("pb_decode_with_malloc.o", "$NANOPB/pb_decode.c")
  33. malloc_strict.Object("pb_encode_with_malloc.o", "$NANOPB/pb_encode.c")
  34. malloc_strict.Object("pb_common_with_malloc.o", "$NANOPB/pb_common.c")
  35. malloc_env.Object("malloc_wrappers.o", "malloc_wrappers.c")
  36. malloc_env.Depends("$NANOPB/pb.h", ["malloc_wrappers_syshdr.h", "malloc_wrappers.h"])
  37. Export("malloc_env")