SConstruct 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- coding: utf-8; mode: Python -*-
  2. # (c) Daniel Llorens - 2015-2016, 2018-2019
  3. # This library is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU Lesser General Public License as published by the Free
  5. # Software Foundation; either version 3 of the License, or (at your option) any
  6. # later version.
  7. # SConstruct for ra/examples
  8. # FIXME Shared pieces with {test,bench,docs}/SConstruct
  9. import os, string, atexit
  10. from os.path import join, abspath
  11. import imp
  12. ra = imp.load_source('ra', '../config/ra.py')
  13. # FIXME pick BLAS flags from here.
  14. try:
  15. Import('top')
  16. except:
  17. top = {}
  18. vars = Variables()
  19. vars.AddVariables(PathVariable('variant_dir', 'build directory', '.', PathVariable.PathIsDirCreate))
  20. env = Environment(options=vars,
  21. ENV=dict([(k, os.environ[k] if k in os.environ else '')
  22. for k in ['PATH', 'HOME', 'TERM', 'LD_RUN_PATH', 'DYLD_LIBRARY_PATH',
  23. 'RPATH', 'LIBRARY_PATH', 'TEXINPUTS', 'GCC_COLORS', 'BOOST_ROOT',
  24. 'RA_USE_BLAS']]))
  25. variant_dir = env['variant_dir']
  26. for var, default in [('CC', 'gcc'), ('CXX', 'g++'), ('FORTRAN', 'gfortran')]:
  27. ra.take_from_environ(env, var, default=default)
  28. for var in ['FORTRANFLAGS', 'LINKFLAGS', 'CCFLAGS', 'CXXFLAGS']:
  29. ra.take_from_environ(env, var, wrapper=lambda x: x.split())
  30. for var in ['RPATH', 'LIBPATH']:
  31. ra.take_from_environ(env, var, wrapper=lambda x: [x])
  32. arch = os.popen('../config/config.guess').read()
  33. cppcomp = os.popen('%s --version' % env['CXX']).read()
  34. if (arch.find('apple-darwin') >= 0) and (cppcomp.find('g++') >= 0):
  35. archflags=['-march=native', '-Wa,-q']
  36. else:
  37. archflags=['-march=native']
  38. env.Prepend(CPPPATH=['..', '.'],
  39. CCFLAGS=archflags if str(env['CCFLAGS']).strip()=='' else '',
  40. CXXFLAGS=ra.CXXFLAGS,
  41. LINKFLAGS=ra.LINKFLAGS)
  42. [ra.to_test_ra(env, variant_dir)(example)
  43. for example in ['agreement', 'cast', 'deriv', 'explode-collapse', 'indirect',
  44. 'laplace2d', 'laplace3d', 'maxwell', 'nested', 'newton', 'outer',
  45. 'pitfall', 'rangexpr', 'read-me', 'slicing', 'small', 'throw',
  46. 'useret', 'view', 'where-pick']]
  47. if 'skip_summary' not in top:
  48. atexit.register(lambda: ra.print_summary(GetBuildFailures, 'ra/examples'))