forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have the testing build build the trivial_tests as well Add a 'run_tests' alias which builds and runs all the tests, trivial & otherwise.
- Loading branch information
1 parent
0c4a9c7
commit bc4b1d6
Showing
4 changed files
with
89 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.cu | ||
*.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import os | ||
from warnings import warn | ||
|
||
Import('env') | ||
my_env = env.Clone() | ||
|
||
thrust_abspath = os.path.abspath("../../thrust/") | ||
|
||
# this function builds a trivial source file from a Thrust header | ||
def trivial_source_from_header(source, target, env): | ||
target_filename = str(target[0]) | ||
fid = open(target_filename, 'w') | ||
|
||
# make sure we don't trip over <windows.h> when compiling with cl.exe | ||
if my_env.subst('$CXX') == 'cl': | ||
fid.write('#include <windows.h>\n') | ||
|
||
for src in source: | ||
src_abspath = str(src) | ||
src_relpath = os.path.relpath(src_abspath, thrust_abspath) | ||
include = os.path.join('thrust', src_relpath) | ||
|
||
fid.write('#include <' + include + '>\n') | ||
fid.close() | ||
|
||
|
||
# CUFile builds a trivial .cu file from a Thrust header | ||
cu_from_header_builder = Builder(action = trivial_source_from_header, | ||
suffix = '.cu', | ||
src_suffix = '.h') | ||
my_env.Append(BUILDERS = {'CUFile' : cu_from_header_builder}) | ||
|
||
# CPPFile builds a trivial .cpp file from a Thrust header | ||
cpp_from_header_builder = Builder(action = trivial_source_from_header, | ||
suffix = '.cpp', | ||
src_suffix = '.h') | ||
my_env.Append(BUILDERS = {'CPPFile' : cpp_from_header_builder}) | ||
|
||
# gather all public thrust headers | ||
public_thrust_headers = my_env.RecursiveGlob('*.h', '#thrust', exclude='detail') | ||
|
||
sources = [] | ||
|
||
for hdr in public_thrust_headers: | ||
rel_path = Dir('#thrust').rel_path(hdr) | ||
|
||
# replace slashes with '_slash_' | ||
src_filename = rel_path.replace('/', '_slash_').replace('\\', '_slash_') | ||
|
||
cu = my_env.CUFile(src_filename.replace('.h', '.cu'), hdr) | ||
cpp = my_env.CPPFile(src_filename.replace('.h', '_cpp.cpp'), hdr) | ||
|
||
sources.extend([cu,cpp]) | ||
|
||
# ensure that all files #include <thrust/detail/config.h> | ||
if '#include <thrust/detail/config.h>' not in hdr.get_contents(): | ||
warn('Header ' + str(hdr) + ' does not include <thrust/detail/config.h>') | ||
|
||
# generate source files which #include all headers | ||
all_headers_cu = my_env.CUFile('all_headers.cu', public_thrust_headers) | ||
all_headers_cpp = my_env.CUFile('all_headers_cpp.cpp', public_thrust_headers) | ||
|
||
sources.append(all_headers_cu) | ||
sources.append(all_headers_cpp) | ||
|
||
# and the file with main() | ||
sources.append('main.cu') | ||
|
||
# build the tester | ||
tester = my_env.Program('tester', sources) | ||
|
||
# add the tester to the 'run_tests' alias | ||
tester_alias = my_env.Alias('run_tests', [tester], tester[0].abspath) | ||
|
||
# always build the 'run_tests' target whether or not it needs it | ||
my_env.AlwaysBuild(tester_alias) | ||
|
This file was deleted.
Oops, something went wrong.