Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F107361434
SConstruct
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Apr 7, 11:21
Size
3 KB
Mime Type
text/x-python
Expires
Wed, Apr 9, 11:21 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25353984
Attached To
rTAMAAS tamaas
SConstruct
View Options
import os,sys
#path = '/usr/lib/scons/'
#sys.path.append(path)
#from SCons import *
#from SCons.Environment import *
#from SCons.Variables import *
#from SCons.Util import *
#script_dir = GetOption('file')
#if script_dir == []:
# script_dir = '.'
#else:
# script_dir = script_dir[0]
colors = {}
colors['cyan'] = ''
colors['purple'] = ''
colors['blue'] = ''
colors['green'] = ''
colors['yellow'] = ''
colors['red'] = ''
colors['end'] = ''
#colors['cyan'] = '\033[96m'
#colors['purple'] = '\033[95m'
#colors['blue'] = '\033[94m'
#colors['green'] = '\033[92m'
#colors['yellow'] = '\033[93m'
#colors['red'] = '\033[91m'
#colors['end'] = '\033[0m'
main_env = Environment(ENV = os.environ)
vars = Variables('build-setup.conf')
vars.Add(EnumVariable('build_type', 'Build type', 'release',
allowed_values=('release', 'profiling', 'debug'),
ignorecase=2))
vars.Add('prefix', 'Prefix where to install', '/usr/local')
vars.Add('CXX', 'Compiler', 'g++')
vars.Add(BoolVariable('timer', 'Activate the timer possibilities', False))
vars.Add(BoolVariable('verbose', 'Activate verbosity', False))
vars.Update(main_env)
Help(vars.GenerateHelpText(main_env))
build_type = main_env['build_type']
build_dir = 'build-' + main_env['build_type']
print "Building in ", build_dir
timer_flag = main_env['timer']
verbose = main_env['verbose']
if not verbose:
main_env['SHCXXCOMSTR'] = unicode('{0}[Compiling] {1}$SOURCE{2}'.format(colors['green'],colors['blue'],colors['end']))
main_env['SHLINKCOMSTR'] = unicode('{0}[Linking] {1}$TARGET{2}'.format(colors['purple'],colors['blue'],colors['end']))
main_env['SWIGCOMSTR'] = unicode('{0}[Swig] {1}$SOURCE{2}'.format(colors['yellow'],colors['blue'],colors['end']))
main_env.AppendUnique(CPPPATH=['#/src', '#/python'])
main_env.AppendUnique(LIBS='gomp')
# Flags and options
main_env.AppendUnique(CXXFLAGS=['-std=c++11',
'-Wall',
'-fopenmp'])
main_env.AppendUnique(SHLINKFLAGS=['-fopenmp'])
if timer_flag:
main_env.AppendUnique(CPPDEFINES=['USING_TIMER'])
cxxflags_dict = {
"debug":Split("-g -O0 -DTAMAAS_DEBUG"),
"profiling":Split("-g -pg -O2"),
"release":Split("-O3")
}
shlinkflags_dict = {
"debug":[],
"profiling":['-pg'],
"release":[]
}
main_env.AppendUnique(CXXFLAGS=cxxflags_dict[build_type])
main_env.AppendUnique(SHLINKFLAGS=shlinkflags_dict[build_type])
main_env['LIBPATH'] = [os.path.abspath(os.path.join(build_dir,'src'))]
main_env['RPATH'] = "$LIBPATH"
fftw_include = ""
fftw_library = ""
if 'FFTW_INCLUDE' in main_env['ENV']:
fftw_include = main_env['ENV']['FFTW_INCLUDE']
if 'FFTW_LIBRARY' in main_env['ENV']:
fftw_library = main_env['ENV']['FFTW_LIBRARY']
main_env = main_env.Clone(
tools = [fftw],
FFTW_LIBRARY_WISH = ['main', 'omp'],
FFTW_INCLUDE_DIR = fftw_include,
FFTW_LIBRARY_DIR = fftw_library,
)
# save new values
vars.Save('build-setup.conf', main_env)
Export('main_env')
SConscript('src/SConscript',variant_dir=os.path.join(build_dir,'src'),duplicate=False)
SConscript('python/SConscript',variant_dir=os.path.join(build_dir,'python'),duplicate=False)
SConscript('tests/SConscript',variant_dir=os.path.join(build_dir,'tests'),duplicate=False)
# saving the env file
try:
env_file = open(os.path.join(build_dir,'tamaas_environement.sh'),'w')
env_file.write("""
export PYTHONPATH=$PYTHONPATH:{0}/python
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{0}/src
""".format(os.path.abspath(build_dir)))
env_file.close()
except:
pass
Event Timeline
Log In to Comment