/[ascend]/trunk/scons/disttar.py
ViewVC logotype

Diff of /trunk/scons/disttar.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 560 by johnpye, Tue May 2 01:57:49 2006 UTC revision 561 by johnpye, Thu May 4 07:35:43 2006 UTC
# Line 16  Line 16 
16  #  #
17  # vim: set et sw=3 tw=0 fo=awqorc ft=python:  # vim: set et sw=3 tw=0 fo=awqorc ft=python:
18    
19  import os  import os,sys
20    from SCons.Script import *
21    
22  def disttar_modify_sources(target,source,env):  def disttar_emitter(target,source,env):
23    
24      source,origsource = [], source      source,origsource = [], source
25    
# Line 48  def disttar_modify_sources(target,source Line 49  def disttar_modify_sources(target,source
49    
50      return target, source      return target, source
51    
52  def DistTar(target, source, env):  def disttar_string(target, source, env):
53        """This is what gets printed on the console. We'll strip out the list
54        or source files, since it tends to get very long. If you want to see the
55        contents, the easiest way is to uncomment the line 'Adding to TAR file'
56        below. """
57        return 'DistTar(%s,...)' % str(target[0])
58    
59    def disttar(target, source, env):
60      """tar archive builder"""      """tar archive builder"""
61    
62      import tarfile      import tarfile
# Line 69  def DistTar(target, source, env): Line 77  def DistTar(target, source, env):
77          os.makedirs(target_dir)          os.makedirs(target_dir)
78    
79      # open our tar file for writing      # open our tar file for writing
80        sys.stderr.write("DistTar: Writing "+str(target[0]))
81      tar = tarfile.open(str(target[0]), "w:%s" % (tar_format,))      tar = tarfile.open(str(target[0]), "w:%s" % (tar_format,))
82    
83      # write sources to our tar file      # write sources to our tar file
84      for item in source:      for item in source:
85          item = str(item)          item = str(item)
86          print "Adding to TAR file: %s/%s" % (dir_name,item)          sys.stderr.write(".")
87            #print "Adding to TAR file: %s/%s" % (dir_name,item)
88          tar.add(item,'%s/%s' % (dir_name,item))          tar.add(item,'%s/%s' % (dir_name,item))
89    
90      # all done      # all done
91      print "Closing TAR file"      sys.stderr.write("\n") #print "Closing TAR file"
92      tar.close()      tar.close()
93    
94  def DistTarSuffix(env, sources):  def disttar_suffix(env, sources):
95      """tar archive suffix generator"""      """tar archive suffix generator"""
96    
97      env_dict = env.Dictionary()      env_dict = env.Dictionary()
# Line 94  def generate(env): Line 104  def generate(env):
104      """      """
105      Add builders and construction variables for the DistTar builder.      Add builders and construction variables for the DistTar builder.
106      """      """
107      env.Append(BUILDERS = {  
108          'DistTar': env.Builder(      disttar_action=SCons.Action.Action(disttar, disttar_string)
109              action = DistTar,      env['BUILDERS']['DistTar'] =  Builder(
110              suffix = DistTarSuffix,          action=disttar_action
111              target_factory = env.fs.Entry,          , emitter=disttar_emitter
112              emitter = disttar_modify_sources          , suffix = disttar_suffix
113          ),          , target_factory = env.fs.Entry
114      })      )
115    
116      env.AppendUnique(      env.AppendUnique(
117          DISTTAR_FORMAT = 'gz'          DISTTAR_FORMAT = 'gz'
         , DISTTAR_EXCLUDEEXTS = ['.o','.os','.so','.a','.dll','.lib']  
         , DISTTAR_EXCLUDEDIRS = ['CVS','.svn','.sconf_temp']  
118      )      )
119    
120  def exists(env):  def exists(env):

Legend:
Removed from v.560  
changed lines
  Added in v.561

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22