Build fixes for Windows/Visual C++
[apps/low-level-can-service.git] / tests / SConstruct
1 import os
2 env = Environment(ENV = {'PATH': os.environ['PATH']})
3
4 # Add the builders defined in site_init.py
5 add_nanopb_builders(env)
6
7 # Path to the files shared by tests, and to the nanopb core.
8 env.Append(CPPPATH = ["#../", "#common"])
9
10 # Path for finding nanopb.proto
11 env.Append(PROTOCPATH = '#../generator')
12
13 # Check the compilation environment, unless we are just cleaning up.
14 if not env.GetOption('clean'):
15     conf = Configure(env)
16
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")
25         
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})
30         
31     # Check if we can use pkg-config to find protobuf include path
32     status, output = conf.TryAction('pkg-config protobuf --variable=includedir > $TARGET')
33     if status:
34         conf.env.Append(PROTOCPATH = output.strip())
35     else:
36         conf.env.Append(PROTOCPATH = '/usr/include')
37         
38     # End the config stuff
39     env = conf.Finish()
40
41 # Initialize the CCFLAGS according to the compiler
42 if 'cl' in env['CC']:
43     # Microsoft Visual C++
44     
45     # Debug info on, warning level 2 for tests, warnings as errors
46     env.Append(CCFLAGS = '/Zi /W2 /WX')
47     env.Append(LINKFLAGS = '/DEBUG')
48     
49     # PB_RETURN_ERROR triggers C4127 because of while(0)
50     env.Append(CCFLAGS = '/wd4127')
51     
52     
53     
54 # Now include the SConscript files from all subdirectories
55 SConscript(Glob('*/SConscript'), exports = 'env')
56