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