SConstruct 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # -*- mode: Python -*-
  2. # -*- coding: utf-8 -*-
  3. # (c) Daniel Llorens - 2015-2016
  4. # This library is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU Lesser General Public License as published by the Free
  6. # Software Foundation; either version 3 of the License, or (at your option) any
  7. # later version.
  8. # SConstruct for ra/test
  9. # FIXME Shared pieces with {examples,bench,doc}/SConstruct
  10. import os, string, atexit
  11. from colorama import Fore, Back, Style
  12. from os.path import join, abspath
  13. import imp
  14. ra = imp.load_source('ra', '../ra.py')
  15. # FIXME pick BLAS flags from here.
  16. try:
  17. Import('top')
  18. except:
  19. top = {}
  20. vars = Variables()
  21. vars.AddVariables(PathVariable('variant_dir', 'build directory', '.', PathVariable.PathIsDirCreate))
  22. env = Environment(options=vars,
  23. ENV=dict([(k, os.environ[k] if k in os.environ else '')
  24. for k in ['PATH', 'HOME', 'TERM', 'LD_RUN_PATH', 'DYLD_LIBRARY_PATH',
  25. 'RPATH', 'LIBRARY_PATH', 'TEXINPUTS', 'GCC_COLORS', 'BOOST_ROOT',
  26. 'RA_USE_BLAS']]))
  27. variant_dir = env['variant_dir']
  28. for var, default in [('CC', 'gcc'), ('CXX', 'g++'), ('FORTRAN', 'gfortran')]:
  29. ra.take_from_environ(env, var, default=default)
  30. for var in ['FORTRANFLAGS', 'LINKFLAGS', 'CCFLAGS', 'CXXFLAGS']:
  31. ra.take_from_environ(env, var, wrapper=string.split)
  32. for var in ['RPATH', 'LIBPATH']:
  33. ra.take_from_environ(env, var, wrapper=lambda x: [x])
  34. arch = os.popen('../config.guess').read()
  35. if arch.find('86-apple-darwin') >= 0:
  36. archflags=['-march=native', '-Wa,-q']
  37. ld_blas = {'LINKFLAGS': ' -framework vecLib ', 'LIBS': []}
  38. else:
  39. archflags=['-march=native']
  40. ld_blas = {'LINKFLAGS': '', 'LIBS': ['blas']}
  41. env.Append(CPPPATH=['..', '.'],
  42. CCFLAGS=archflags if str(env['CCFLAGS']).strip()=='' else '',
  43. CXXFLAGS=['-std=c++1z', '-Wall', '-Werror', '-fdiagnostics-color=always', '-Wno-unknown-pragmas',
  44. '-finput-charset=UTF-8', '-fextended-identifiers',
  45. '-Wno-error=strict-overflow',
  46. #'-Wconversion',
  47. # '-funsafe-math-optimizations', # TODO Test with this.
  48. ])
  49. env_blas = env.Clone()
  50. if 'RA_USE_BLAS' in env['ENV'] and env['ENV']['RA_USE_BLAS']=='1':
  51. print("[%s] BLAS will be used." % Dir('.').path)
  52. env_blas.Append(CPPDEFINES={'RA_USE_BLAS': 1})
  53. env_blas.Append(LINKFLAGS=ld_blas['LINKFLAGS'])
  54. env_blas.Append(LIBS=ld_blas['LIBS'])
  55. else:
  56. print("[%s] BLAS won't be used." % Dir('.').path)
  57. if 'skip_summary' not in top:
  58. atexit.register(lambda: ra.print_summary(GetBuildFailures, 'ra/test'))
  59. tester = ra.to_test_ra(env, variant_dir)
  60. [tester(test)
  61. for test in ['test-ra-0', 'test-ra-1', 'test-ra-2', 'test-ra-3', 'test-ra-4',
  62. 'test-ra-6', 'test-ra-8', 'test-ra-9',
  63. 'test-types', 'test-io', 'test-from', 'test-nested', 'test-owned',
  64. 'test-ownership', 'test-ply', 'test-small', 'test-large',
  65. 'test-return-expr', 'test-reduction', 'test-frame-match',
  66. 'test-compatibility', 'test-dual', 'test-ra-dual', 'test-stl-compat',
  67. 'test-where', 'test-tuplelist', 'test-wedge-product', 'test-operators',
  68. 'test-tensorindex', 'test-explode-collapse', 'test-wrank',
  69. 'test-optimize', 'test-reshape', 'test-concrete', 'test-bench',
  70. # 'test-small-iterator',
  71. # 'test-end'
  72. ]]
  73. tester('test-ra-10', target='test-ra-10a', cxxflags=['-O3'], cppdefines={'RA_CHECK_BOUNDS': '0'})
  74. tester('test-ra-10', target='test-ra-10b', cxxflags=['-O1'], cppdefines={'RA_CHECK_BOUNDS': '0'})
  75. tester('test-ra-10', target='test-ra-10c', cxxflags=['-O3'], cppdefines={'RA_CHECK_BOUNDS': '1'})
  76. tester('test-ra-10', target='test-ra-10d', cxxflags=['-O1'], cppdefines={'RA_CHECK_BOUNDS': '1'})