Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make the zipfile distributions build within a variant directory and

avoid including build-related files.
  • Loading branch information...
commit f01b4b5c99611a2111dc744ffbcd8ae17f53fc22 1 parent a8745e8
@jaredhoberock jaredhoberock authored
View
39 SConscript
@@ -1,24 +1,39 @@
+import os
import re
-Import('RecursiveGlob')
+Import('env')
+
+# clone the environment so as not to pollute the parent
+my_env = env.Clone()
# divine the version number from thrust/version.h
-version = int(re.search('THRUST_VERSION ([0-9]+)', open('thrust/version.h').read()).group(1))
+version = int(re.search('THRUST_VERSION ([0-9]+)', File('#thrust/version.h').get_contents()).group(1))
major = int(version / 100000)
minor = int(version / 100) % 1000
subminor = version % 100
-# create the zip distribution
-# note that we package the CHANGELOG with the headers
-installation_nodes = Install('thrust', 'CHANGELOG')
-Zip('thrust-{0}.{1}.{2}.zip'.format(major,minor,subminor), 'thrust')
+# create the Thrust zip
+for item in my_env.RecursiveGlob('*', '#thrust'):
+ my_env.InstallAs(os.path.join('thrust', Dir('#thrust').rel_path(item)), item)
+# grab the CHANGELOG as well
+my_env.Install('thrust', '#CHANGELOG')
+
+# make sure to change directory into the variant dir to ensure the paths are correct in the zipfile
+# note Zip uses the special site_scons/site_tools/zip.py to WAR an issue with the chdir parameter
+my_env.Zip('thrust-{0}.{1}.{2}.zip'.format(major,minor,subminor), 'thrust', chdir = 1)
+
# create the examples zip
-# XXX we shouldn't include build files in the zip
-# XXX this should be rewritten
-Zip('examples-{0}.{1}.zip'.format(major,minor), 'examples')
+# do not recurse into the 'targets' directory, should it exist
+for item in my_env.RecursiveGlob('*', '#examples', 'targets'):
+ # avoid included SCons-related files in the distribution
+ # XXX would be nice if we could ignore all dotfiles and anything in .gitignore
+ if item.get_path(item.get_dir()) not in ['SConscript','.sconsign.dblite']:
+ my_env.InstallAs(os.path.join('examples', Dir('#examples').rel_path(item)), item)
+# make sure to change directory into the variant dir to ensure the paths are correct in the zipfile
+# note Zip uses the special site_scons/site_tools/zip.py to WAR an issue with the chdir parameter
+my_env.Zip('examples-{0}.{1}.zip'.format(major,minor), 'examples', chdir = 1)
# generate documentation
-public_headers = RecursiveGlob(Environment(), '*.h', '#thrust', exclude='detail')
-Command('doc/html', public_headers, 'doxygen doc/thrust.dox')
-Clean('doc', 'doc/html')
+public_headers = my_env.RecursiveGlob('*.h', '#thrust', exclude='detail')
+my_env.Command('doc/html', public_headers, 'doxygen doc/thrust.dox')
View
7 SConstruct
@@ -305,7 +305,7 @@ def command_line_variables():
# create a master Environment
vars = command_line_variables()
-master_env = Environment(variables = vars, tools = ['default', 'nvcc'])
+master_env = Environment(variables = vars, tools = ['default', 'nvcc', 'zip'])
# XXX it might be a better idea to harvest help text from subsidiary
# SConscripts and only add their help text if one of their targets
@@ -356,7 +356,6 @@ for (host,device) in itertools.product(host_backends, device_backends):
env.SConscript('testing/SConscript', exports='env', variant_dir = 'testing/' + targets_dir, duplicate = 0)
env.SConscript('performance/SConscript', exports='env', variant_dir = 'performance/' + targets_dir, duplicate = 0)
-# the top-level SConscript doesn't need a variant directory as it has no build variation
-# pass RecursiveGlob to the SConscript as it needs to find all public Thrust headers
-master_env.SConscript('SConscript', exports='RecursiveGlob')
+env = master_env
+master_env.SConscript('SConscript', exports='env', variant_dir = 'targets', duplicate = False)
View
21 examples/cpp_integration/README.txt
@@ -1,21 +0,0 @@
-This example shows how to link a Thrust program contained in
-a .cu file with a C++ program contained in a .cpp file. Note
-that device_vector only appears in the .cu file while host_vector
-appears in both. This relects the fact that algorithms on device
-vectors are only available when the contents of the program are
-located in a .cu file and compiled with the nvcc compiler.
-
-On a Linux system where Thrust is installed in the default location
-we can use the following procedure to compile the two parts of the
-program and link them together.
-
- $ nvcc -O2 -c device.cu
- $ g++ -O2 -c host.cpp -I/usr/local/cuda/include/
- $ nvcc -o tester device.o host.o
-
-Alternatively, we can use g++ to perform final linking step.
-
- $ nvcc -O2 -c device.cu
- $ g++ -O2 -c host.cpp -I/usr/local/cuda/include/
- $ g++ -o tester device.o host.o -L/usr/local/cuda/lib64 -lcudart
-
View
101 site_scons/site_tools/zip.py
@@ -0,0 +1,101 @@
+"""SCons.Tool.zip
+
+Tool-specific initialization for zip.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+This version applies the patch from scons.tigris.org/issues/show_bug.cgi?id=2575
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "src/engine/SCons/Tool/zip.py 5134 2010/08/16 23:02:40 bdeegan"
+
+import os.path
+
+import SCons.Builder
+import SCons.Defaults
+import SCons.Node.FS
+import SCons.Util
+
+try:
+ import zipfile
+ internal_zip = 1
+except ImportError:
+ internal_zip = 0
+
+if internal_zip:
+ zipcompression = zipfile.ZIP_DEFLATED
+ def zip(target, source, env):
+ compression = env.get('ZIPCOMPRESSION', 0)
+ zf = zipfile.ZipFile(target[0].abspath, 'w', compression)
+ for s in source:
+ if s.isdir():
+ for dirpath, dirnames, filenames in os.walk(os.path.relpath(s.abspath)):
+ for fname in filenames:
+ path = os.path.join(dirpath, fname)
+ if os.path.isfile(path):
+ zf.write(path)
+ else:
+ zf.write(os.path.relpath(s.abspath))
+ zf.close()
+else:
+ zipcompression = 0
+ zip = "$ZIP $ZIPFLAGS ${TARGET.abspath} $SOURCES"
+
+
+zipAction = SCons.Action.Action(zip, varlist=['ZIPCOMPRESSION'])
+
+ZipBuilder = SCons.Builder.Builder(action = SCons.Action.Action('$ZIPCOM', '$ZIPCOMSTR'),
+ source_factory = SCons.Node.FS.Entry,
+ source_scanner = SCons.Defaults.DirScanner,
+ suffix = '$ZIPSUFFIX',
+ multi = 1)
+
+
+def generate(env):
+ """Add Builders and construction variables for zip to an Environment."""
+ try:
+ bld = env['BUILDERS']['Zip']
+ except KeyError:
+ bld = ZipBuilder
+ env['BUILDERS']['Zip'] = bld
+
+ env['ZIP'] = 'zip'
+ env['ZIPFLAGS'] = SCons.Util.CLVar('')
+ env['ZIPCOM'] = zipAction
+ env['ZIPCOMPRESSION'] = zipcompression
+ env['ZIPSUFFIX'] = '.zip'
+
+def exists(env):
+ return internal_zip or env.Detect('zip')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
Please sign in to comment.
Something went wrong with that request. Please try again.