SConstruct 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # -*- coding: utf-8; mode: Python -*-
  2. # SConstruct for ra/test
  3. # (c) Daniel Llorens - 2015-2016, 2018
  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. # FIXME Shared pieces with {examples,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=string.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. if arch.find('apple-darwin') >= 0:
  34. archflags=['-march=native', '-Wa,-q']
  35. ld_blas = {'LINKFLAGS': ' -framework Accelerate ', 'LIBS': []}
  36. else:
  37. archflags=['-march=native']
  38. ld_blas = {'LINKFLAGS': '', 'LIBS': ['blas']}
  39. env.Prepend(CPPPATH=['..', '.'],
  40. CCFLAGS=archflags if str(env['CCFLAGS']).strip()=='' else '',
  41. CXXFLAGS=['-std=c++17', '-Wall', '-Werror', '-fdiagnostics-color=always', '-Wno-unknown-pragmas',
  42. '-finput-charset=UTF-8', '-fextended-identifiers',
  43. '-Wno-error=strict-overflow', '-Werror=zero-as-null-pointer-constant',
  44. #'-Wconversion',
  45. # '-funsafe-math-optimizations', # TODO Test with this.
  46. ])
  47. env_blas = env.Clone()
  48. if 'RA_USE_BLAS' in env['ENV'] and env['ENV']['RA_USE_BLAS']=='1':
  49. print("[%s] BLAS will be used." % Dir('.').path)
  50. env_blas.Append(CPPDEFINES={'RA_USE_BLAS': 1})
  51. env_blas.Append(LINKFLAGS=ld_blas['LINKFLAGS'])
  52. env_blas.Append(LIBS=ld_blas['LIBS'])
  53. else:
  54. print("[%s] BLAS won't be used." % Dir('.').path)
  55. tester = ra.to_test_ra(env, variant_dir)
  56. [tester(test)
  57. for test in ['old', 'ra-0', 'ra-1', 'ra-2', 'ra-3', 'ra-4', 'ra-5', 'ra-6', 'ra-7', 'ra-8', 'ra-9',
  58. 'ra-11', 'types', 'io', 'from', 'nested-0', 'owned', 'ownership', 'ply',
  59. 'small-0', 'small-1', 'big-0', 'big-1',
  60. 'return-expr', 'reduction', 'frame-old', 'frame-new', 'compatibility',
  61. 'dual', 'ra-dual', 'mem-fn', 'stl-compat', 'where', 'tuplelist', 'wedge',
  62. 'operators', 'tensorindex', 'explode-0', 'wrank', 'optimize', 'reshape', 'concrete',
  63. 'bench', 'iterator-small', 'const', 'tensor-indices', 'list9', 'early', 'macros',
  64. # 'end'
  65. ]]
  66. tester('ra-10', target='ra-10a', cxxflags=['-O3'], cppdefines={'RA_CHECK_BOUNDS': '0'})
  67. tester('ra-10', target='ra-10b', cxxflags=['-O1'], cppdefines={'RA_CHECK_BOUNDS': '0'})
  68. tester('ra-10', target='ra-10c', cxxflags=['-O3'], cppdefines={'RA_CHECK_BOUNDS': '1'})
  69. tester('ra-10', target='ra-10d', cxxflags=['-O1'], cppdefines={'RA_CHECK_BOUNDS': '1'})
  70. if 'skip_summary' not in top:
  71. atexit.register(lambda: ra.print_summary(GetBuildFailures, 'ra/test'))