Page MenuHomec4science

site_init.py
No OneTemporary

File Metadata

Created
Sat, Oct 23, 21:00

site_init.py

from SCons.Script import *
from os.path import *
import os
def fftw(env):
"""A Tool to search for fftw headers and libraries"""
if env.GetOption('clean'):
return
env.SetDefault(FFTW_VERSION='3')
env.SetDefault(FFTW_LIBRARY_WISH=[])
print("Building for fftw version {}".format(env['FFTW_VERSION']))
if 'FFTW_INCLUDE_DIR' in env:
env.AppendUnique(CPPPATH=env['FFTW_INCLUDE_DIR'])
if 'FFTW_LIBRARY_DIR' in env:
env.AppendUnique(LIBPATH=env['FFTW_LIBRARY_DIR'])
version = env['FFTW_VERSION']
if version == "2":
lib_names = {'main': 'fftw'}
inc_names = ['fftw.h']
else:
lib_names = {'main': 'fftw3',
'thread': 'fftw3_threads',
'omp': 'fftw3_omp'}
inc_names = ['fftw3.h']
try:
libs = [lib_names[i] for i in env['FFTW_LIBRARY_WISH']]
except:
raise SCons.Errors.StopError(
'Incompatible wishlist {0} from version {1}'.format(
env['FFTW_LIBRARY_WISH'], env['FFTW_VERSION']))
env.AppendUnique(LIBS=libs)
if version == "2":
env.Append(LIBS='m')
conf = Configure(env)
if not conf.CheckLibWithHeader(libs, inc_names, 'c++'):
raise SCons.Errors.StopError(
'Failed to find libraries {0} or '
'headers {1}.'.format(str(lib_names), str(inc_names)))
env = conf.Finish()
def criterion(env):
"""A tool to configure for Criterion (test suite)"""
if env.GetOption('clean'):
return
env.AppendUnique(CPPPATH=[Dir("#third-party/Criterion/include")],
LIBPATH=[abspath(str(Dir("#third-party/Criterion/build")))])
conf = Configure(env)
if not conf.CheckLibWithHeader('criterion',
'criterion/criterion.h',
'c++'):
raise SCons.Errors.StopError(
'Failed to find library Criterion or criterion.h header in third-party')
env = conf.Finish()
def tamaas(env):
"""Sets correct environement variables for Tamaas.
- 'TAMAAS_PATH' is list of potential tamaas repositories
- 'TAMAAS_BUILD_TYPE' is the build type of tamaas (release, debug, profiling)"""
if env.GetOption("clean"):
return
try:
build_type = env['TAMAAS_BUILD_TYPE']
except:
build_type = "release"
if 'TAMAAS_PATH' not in env:
print("Please set the 'TAMAAS_PATH' variable in your scons environment")
Exit(1)
tm_path = env['TAMAAS_PATH']
include_dir = tm_path + '/src'
subdirs = "core model bem surface".split(" ")
include_dirs = [abspath(join(include_dir, x)) for x in subdirs]
lib_dir = join(tm_path, 'build-{}/src'.format(build_type))
env.AppendUnique(CPPPATH = include_dirs)
env.AppendUnique(LIBPATH = [abspath(lib_dir)])
env.AppendUnique(RPATH = [abspath(lib_dir)])
env.AppendUnique(CXXFLAGS = ["-std=c++14"])
conf = Configure(env)
if not conf.CheckLibWithHeader("Tamaas", "tamaas.hh", language="CXX"):
raise SCons.Errors.StopError(
"Tamaas ({}) not found in {}".format(build_type, abspath(tm_path)))
env['TAMAAS_PATH'] = abspath(tm_path)
env = conf.Finish()

Event Timeline