diff --git a/examples/SConstruct b/examples/SConstruct index 0dd887e..c871980 100644 --- a/examples/SConstruct +++ b/examples/SConstruct @@ -1,12 +1,12 @@ import os env = Environment(CC = 'g++', CXXFLAGS = ['-std=c++11', '-g', '-fopenmp', '-O3'], TOOLS = ['default', tamaas], - TAMAAS_PATH = ['..'], + TAMAAS_PATH = '..', TAMAAS_BUILD_TYPE = 'debug', LIBS = ['gomp', 'Tamaas'], ENV = os.environ) env.Program('rough_surface.cc') diff --git a/examples/site_scons/site_init.py b/examples/site_scons/site_init.py index a95334d..61d748e 100644 --- a/examples/site_scons/site_init.py +++ b/examples/site_scons/site_init.py @@ -1,32 +1,34 @@ from SCons.Script import * from os.path import * +import os + 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 - build_type = "release" - if 'TAMAAS_BUILD_TYPE' in env: + try: build_type = env['TAMAAS_BUILD_TYPE'] - path = findPath(env['TAMAAS_PATH'], build_type) + except: + build_type = "release" - if not path: - print "Tamaas ({}) not found in {}".format(build_type, env['TAMAAS_PATH']) + if 'TAMAAS_PATH' not in env: + print "Please set the 'TAMAAS_PATH' variable in your scons environement" Exit(1) - env.AppendUnique(CPPPATH = [abspath(join(path, 'src'))]) - env.AppendUnique(LIBPATH = [abspath(join(path, 'build-{}/src'.format(build_type)))]) - env.AppendUnique(RPATH = [abspath(join(path, 'build-{}/src'.format(build_type)))]) + tm_path = env['TAMAAS_PATH'] + include_dir = tm_path + '/src' + lib_dir = join(tm_path, 'build-{}/src'.format(build_type)) -def findPath(search, build_type): - trial = Environment() - conf = Configure(trial) - for path in search: - trial['CPPPATH'] = join(path, 'src') - trial['LIBPATH'] = join(path, 'build-{}/src'.format(build_type)) - trial['RPATH'] = join(path, 'build-{}/src'.format(build_type)) + env.AppendUnique(CPPPATH = [abspath(include_dir)]) + env.AppendUnique(LIBPATH = [abspath(lib_dir)]) + env.AppendUnique(RPATH = [abspath(lib_dir)]) - if conf.CheckLib("Tamaas", language="CXX"): - return path + 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()