wscript 4.66 KB
Newer Older
1
2
#!/usr/bin/env python
# encoding: utf-8
3
4
import sys
sys.path.insert(0, './waf_tools')
5

6
7
VERSION = '0.0.1'
APPNAME = 'limbo'
8
9
10
11

srcdir = '.'
blddir = 'build'

12
import glob
13
14
import os
import subprocess
15
import limbo
16
from waflib.Build import BuildContext
17
from waflib.Tools import waf_unit_test
18

Federico Allocati's avatar
Federico Allocati committed
19
20
import inspect

21

22
23
24
25
26
def options(opt):
        opt.load('compiler_cxx boost waf_unit_test')
        opt.load('compiler_c')
        opt.load('eigen')
        opt.load('tbb')
27
        opt.load('mkl')
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
28
        opt.load('sferes')
29
        opt.load('limbo')
30
        opt.load('openmp')
31
        opt.load('nlopt')
32
33
        opt.load('libcmaes')

34
        opt.add_option('--exp', type='string', help='exp(s) to build, separate by comma', dest='exp')
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
35
36
        opt.add_option('--qsub', type='string', help='config file (json) to submit to torque', dest='qsub')
        opt.add_option('--oar', type='string', help='config file (json) to submit to oar', dest='oar')
37
        opt.add_option('--experimental', action='store_true', help='specify to compile the experimental examples', dest='experimental')
38
39
        # tests
        opt.add_option('--tests', action='store_true', help='compile tests or not', dest='tests')
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
40
        opt.load('xcode')
41
        for i in glob.glob('exp/*'):
Federico Allocati's avatar
Federico Allocati committed
42
43
                if os.path.isdir(i):
                    opt.recurse(i)
44

45

46
def configure(conf):
47
        conf.load('compiler_cxx boost waf_unit_test')
48
49
50
        conf.load('compiler_c')
        conf.load('eigen')
        conf.load('tbb')
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
51
        conf.load('sferes')
52
        conf.load('openmp')
53
        conf.load('mkl')
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
54
        conf.load('xcode')
55
        conf.load('nlopt')
56
        conf.load('libcmaes')
57

58
59
60
        if conf.env.CXX_NAME in ["icc", "icpc"]:
            common_flags = "-Wall -std=c++11"
            opt_flags = " -O3 -xHost  -march=native -mtune=native -unroll -fma -g"
61
        else:
62
63
64
65
            if int(conf.env['CC_VERSION'][0]+conf.env['CC_VERSION'][1]) < 47:
                common_flags = "-Wall -std=c++0x"
            else:
                common_flags = "-Wall -std=c++11"
66
            common_flags += " -fdiagnostics-color"
67
            opt_flags = " -O3 -march=native -g"
68

69
        conf.check_boost(lib='serialization filesystem \
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
70
            system unit_test_framework program_options \
71
            graph thread', min_version='1.39')
72
73
        conf.check_eigen()
        conf.check_tbb()
74
        conf.check_sferes()
75
76
        conf.check_openmp()
        conf.check_mkl()
77
        conf.check_nlopt()
78
        conf.check_libcmaes()
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
79

Federico Allocati's avatar
Federico Allocati committed
80
81
        conf.env.INCLUDES_LIMBO = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + "/src"

82
        if conf.env['CXXFLAGS_ODE']:
83
                common_flags += ' ' + conf.env['CXXFLAGS_ODE']
84

85
86
        all_flags = common_flags + opt_flags
        conf.env['CXXFLAGS'] = conf.env['CXXFLAGS'] + all_flags.split(' ')
87
88
        print conf.env['CXXFLAGS']

Jean-Baptiste Mouret's avatar
misc    
Jean-Baptiste Mouret committed
89
90
91
92
93
        if conf.options.exp:
                for i in conf.options.exp.split(','):
                        print 'configuring for exp: ' + i
                        conf.recurse('exp/' + i)

94
95
96
97
98
99
100
101
102
103
104
def summary(bld):
    lst = getattr(bld, 'utest_results', [])
    total = 0
    tfail = 0
    if lst:
        total = len(lst)
        tfail = len([x for x in lst if x[1]])
    waf_unit_test.summary(bld)
    if tfail > 0:
        bld.fatal("Build failed, because some tests failed!")

105
def build(bld):
106
107
108
109
110
    bld.recurse('src/')
    if bld.options.exp:
        for i in bld.options.exp.split(','):
            print 'Building exp: ' + i
            bld.recurse('exp/' + i)
111
    bld.add_post_fun(summary)
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
112

113

114
def build_extensive_tests(ctx):
115
    ctx.recurse('src/')
116
117
    ctx.recurse('src/tests')

118
119
120
121
122
123
124
def run_extensive_tests(ctx):
    for fullname in glob.glob('build/src/tests/combinations/*'):
        if os.path.isfile(fullname) and os.access(fullname, os.X_OK):
            fpath, fname = os.path.split(fullname)
            print "Running: " + fname
            s = "cd " + fpath + "; ./" + fname
            retcode = subprocess.call(s, shell=True, env=None)
125

126
127
128
129
def submit_extensive_tests(ctx):
    for fullname in glob.glob('build/src/tests/combinations/*'):
        if os.path.isfile(fullname) and os.access(fullname, os.X_OK):
            fpath, fname = os.path.split(fullname)
130
            s = "cd " + fpath + ";oarsub -l /nodes=1/core=2,walltime=00:15:00 -n " + fname + " -O " + fname + ".stdout.%jobid%.log -E " + fname + ".stderr.%jobid%.log ./" + fname
131
132
133
134
            retcode = subprocess.call(s, shell=True, env=None)
            print "oarsub returned:" + str(retcode)


135
def shutdown(ctx):
136
137
    if ctx.options.qsub:
        limbo.qsub(ctx.options.qsub)
Jean-Baptiste Mouret's avatar
Jean-Baptiste Mouret committed
138
139
    if ctx.options.oar:
        limbo.oar(ctx.options.oar)
140
141
142
143
144


class BuildExtensiveTestsContext(BuildContext):
    cmd = 'build_extensive_tests'
    fun = 'build_extensive_tests'