summaryrefslogtreecommitdiffstats
path: root/tests/SConstruct
blob: 8bbb31d157fa7bc106605f248a379b0481488692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
env = Environment(ENV = {'PATH': os.environ['PATH']})

# Add the builders defined in site_init.py
add_nanopb_builders(env)

# Path to the files shared by tests, and to the nanopb core.
env.Append(CPPPATH = ["#../", "#common"])

# Path for finding nanopb.proto
env.Append(PROTOCPATH = '#../generator')

# Check the compilation environment, unless we are just cleaning up.
if not env.GetOption('clean'):
    conf = Configure(env)

    # If the platform doesn't support C99, use our own header file instead.
    stdbool = conf.CheckCHeader('stdbool.h')
    stdint = conf.CheckCHeader('stdint.h')
    stddef = conf.CheckCHeader('stddef.h')
    string = conf.CheckCHeader('string.h')
    if not stdbool or not stdint or not stddef or not string:
        conf.env.Append(CPPDEFINES = {'PB_SYSTEM_HEADER': '\\"pb_syshdr.h\\"'})
        conf.env.Append(CPPPATH = "#../compat")
        
        if stdbool: conf.env.Append(CPPDEFINES = {'HAVE_STDBOOL_H': 1})
        if stdint: conf.env.Append(CPPDEFINES = {'HAVE_STDINT_H': 1})
        if stddef: conf.env.Append(CPPDEFINES = {'HAVE_STDDEF_H': 1})
        if string: conf.env.Append(CPPDEFINES = {'HAVE_STRING_H': 1})
        
    # Check if we can use pkg-config to find protobuf include path
    status, output = conf.TryAction('pkg-config protobuf --variable=includedir > $TARGET')
    if status:
        conf.env.Append(PROTOCPATH = output.strip())
    else:
        conf.env.Append(PROTOCPATH = '/usr/include')
        
    # End the config stuff
    env = conf.Finish()

# Initialize the CCFLAGS according to the compiler
if 'cl' in env['CC']:
    # Microsoft Visual C++
    
    # Debug info on, warning level 2 for tests, warnings as errors
    env.Append(CCFLAGS = '/Zi /W2 /WX')
    env.Append(LINKFLAGS = '/DEBUG')
    
    # PB_RETURN_ERROR triggers C4127 because of while(0)
    env.Append(CCFLAGS = '/wd4127')
    
    
    
# Now include the SConscript files from all subdirectories
SConscript(Glob('*/SConscript'), exports = 'env')