1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
import os
import inspect
# try to import an environment first
try:
Import('env')
except:
exec open("../build/build-env.py")
env = Environment()
# on mac we have to tell the linker to link against the C++ library
if env['PLATFORM'] == "darwin":
env.Append(LINKFLAGS = "-lstdc++")
# on windows we have to do /bigobj
if env['PLATFORM'] == "win32" or env['PLATFORM'] == "win64":
env.Append(CPPFLAGS = "/bigobj")
# find all .cus & .cpps in the current and backend/ directories
sources = []
directories = ['.', 'backend']
extensions = ['*.cu', '*.cpp']
# finall all backend-specific files
if env['backend'] == 'cuda' or env['backend'] == 'ocelot':
directories.append(os.path.join('backend','cuda'))
elif env['backend'] == 'omp':
directories.append(os.path.join('backend','omp'))
for dir in directories:
for ext in extensions:
regexp = os.path.join(dir, ext)
sources.extend(env.Glob(regexp))
# filter test files using a regular expression
if 'tests' in env:
import re
pattern = re.compile(env['tests'])
necessary_sources = set(['testframework.cu'])
filtered_sources = []
for f in sources:
if str(f) in necessary_sources or pattern.search(f.get_contents()):
filtered_sources.append(f)
sources = filtered_sources
# add the directory containing this file to the include path
this_file = inspect.currentframe().f_code.co_filename
this_dir = os.path.dirname(this_file)
env.Append(CPPPATH = [this_dir])
tester = env.Program('tester', sources)
|