2 env = Environment(ENV = {'PATH': os.environ['PATH']})
4 # Add the builders defined in site_init.py
5 add_nanopb_builders(env)
7 # Path to the files shared by tests, and to the nanopb core.
8 env.Append(CPPPATH = ["#../", "#common"])
10 # Path for finding nanopb.proto
11 env.Append(PROTOCPATH = '#../generator')
13 # Check the compilation environment, unless we are just cleaning up.
14 if not env.GetOption('clean'):
17 # If the platform doesn't support C99, use our own header file instead.
18 stdbool = conf.CheckCHeader('stdbool.h')
19 stdint = conf.CheckCHeader('stdint.h')
20 stddef = conf.CheckCHeader('stddef.h')
21 string = conf.CheckCHeader('string.h')
22 if not stdbool or not stdint or not stddef or not string:
23 conf.env.Append(CPPDEFINES = {'PB_SYSTEM_HEADER': '\\"pb_syshdr.h\\"'})
24 conf.env.Append(CPPPATH = "#../compat")
26 if stdbool: conf.env.Append(CPPDEFINES = {'HAVE_STDBOOL_H': 1})
27 if stdint: conf.env.Append(CPPDEFINES = {'HAVE_STDINT_H': 1})
28 if stddef: conf.env.Append(CPPDEFINES = {'HAVE_STDDEF_H': 1})
29 if string: conf.env.Append(CPPDEFINES = {'HAVE_STRING_H': 1})
31 # Check if we can use pkg-config to find protobuf include path
32 status, output = conf.TryAction('pkg-config protobuf --variable=includedir > $TARGET')
34 conf.env.Append(PROTOCPATH = output.strip())
36 conf.env.Append(PROTOCPATH = '/usr/include')
38 # End the config stuff
41 # Initialize the CCFLAGS according to the compiler
43 # Microsoft Visual C++
45 # Debug info on, warning level 2 for tests, warnings as errors
46 env.Append(CCFLAGS = '/Zi /W2 /WX')
47 env.Append(LINKFLAGS = '/DEBUG')
49 # PB_RETURN_ERROR triggers C4127 because of while(0)
50 env.Append(CCFLAGS = '/wd4127')
54 # Now include the SConscript files from all subdirectories
55 SConscript(Glob('*/SConscript'), exports = 'env')