-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSConstruct
More file actions
59 lines (48 loc) · 2.42 KB
/
SConstruct
File metadata and controls
59 lines (48 loc) · 2.42 KB
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
57
58
59
# -*- coding: utf-8; mode: Python -*-
# SConstruct for ra/examples
# (c) Daniel Llorens - 2015-2016, 2018-2019
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version.
# FIXME Shared pieces with {test,bench,docs}/SConstruct
import os, string, atexit
from os.path import join, abspath
from importlib.machinery import SourceFileLoader
ra = SourceFileLoader('ra', '../config/ra.py').load_module()
# FIXME pick BLAS flags from here.
try:
Import('top')
except:
top = { 'skip_summary': False, 'sanitize': False, 'use_blas': False }
raflags = ra.flags(top['sanitize'])
vars = Variables()
vars.AddVariables(PathVariable('variant_dir', 'build directory', '.', PathVariable.PathIsDirCreate))
env = Environment(options=vars,
ENV=dict([(k, os.environ[k] if k in os.environ else '')
for k in ['PATH', 'HOME', 'TERM', 'LD_RUN_PATH', 'DYLD_LIBRARY_PATH',
'RPATH', 'LIBRARY_PATH', 'TEXINPUTS', 'GCC_COLORS', 'BOOST_ROOT']]))
variant_dir = env['variant_dir']
for var, default in [('CC', 'gcc'), ('CXX', 'g++'), ('FORTRAN', 'gfortran')]:
ra.take_from_environ(env, var, default=default)
for var in ['FORTRANFLAGS', 'LINKFLAGS', 'CCFLAGS', 'CXXFLAGS']:
ra.take_from_environ(env, var, wrapper=lambda x: x.split())
for var in ['RPATH', 'LIBPATH']:
ra.take_from_environ(env, var, wrapper=lambda x: [x])
arch = os.popen('../config/config.guess').read()
cppcomp = os.popen('%s --version' % env['CXX']).read()
if (arch.find('apple-darwin') >= 0) and (cppcomp.find('g++') >= 0):
archflags=['-march=native', '-Wa,-q']
else:
archflags=['-march=native']
env.Prepend(CPPPATH=['..', '.'],
CCFLAGS=archflags if str(env['CCFLAGS']).strip()=='' else '',
CXXFLAGS=raflags['CXXFLAGS'],
LINKFLAGS=raflags['LINKFLAGS'])
[ra.to_test_ra(env, variant_dir)(example)
for example in ['agreement', 'cast', 'deriv', 'explode-collapse', 'indirect',
'laplace2d', 'laplace3d', 'maxwell', 'nested', 'newton', 'outer',
'pitfall', 'rangexpr', 'read-me', 'slicing', 'small', 'throw',
'useret', 'view', 'where-pick']]
if not top['skip_summary']:
atexit.register(lambda: ra.print_summary(GetBuildFailures, 'ra/examples'))