/[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 553 by johnpye, Sat Apr 29 10:01:54 2006 UTC revision 554 by johnpye, Tue May 2 00:51:02 2006 UTC
# Line 1  Line 1 
1  # vim: set et sw=3 tw=0 fo=awqorc ft=python:  # DistTarBuilder: tool to generate tar files using SCons
 #  
 # Astxx, the Asterisk C++ API and Utility Library.  
2  # Copyright (C) 2005, 2006  Matthew A. Nicholson  # Copyright (C) 2005, 2006  Matthew A. Nicholson
3  #  #
4  # This library is free software; you can redistribute it and/or  # This file is free software; you can redistribute it and/or
5  # modify it under the terms of the GNU Lesser General Public  # modify it under the terms of the GNU Lesser General Public
6  # License version 2.1 as published by the Free Software Foundation.  # License version 2.1 as published by the Free Software Foundation.
7  #  #
8  # This library is distributed in the hope that it will be useful,  # This file is distributed in the hope that it will be useful,
9  # but WITHOUT ANY WARRANTY; without even the implied warranty of  # but WITHOUT ANY WARRANTY; without even the implied warranty of
10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  # Lesser General Public License for more details.  # Lesser General Public License for more details.
# Line 15  Line 13 
13  # You should have received a copy of the GNU Lesser General Public  # You should have received a copy of the GNU Lesser General Public
14  # License along with this library; if not, write to the Free Software  # License along with this library; if not, write to the Free Software
15  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16    #
17    # vim: set et sw=3 tw=0 fo=awqorc ft=python:
18    
19  def DistTar(target, source, env):  def DistTar(target, source, env):
20      """tar archive builder"""      """tar archive builder"""
# Line 24  def DistTar(target, source, env): Line 24  def DistTar(target, source, env):
24    
25      env_dict = env.Dictionary()      env_dict = env.Dictionary()
26    
27      if env_dict.has_key("DISTTAR_FORMAT") and env_dict["DISTTAR_FORMAT"] in ["gz", "bz2"]:      if env_dict.get("DISTTAR_FORMAT") in ["gz", "bz2"]:
28          tar_format = env_dict["DISTTAR_FORMAT"]          tar_format = env_dict["DISTTAR_FORMAT"]
29      else:      else:
30          tar_format = ""          tar_format = ""
# Line 40  def DistTar(target, source, env): Line 40  def DistTar(target, source, env):
40      # open our tar file for writing      # open our tar file for writing
41      tar = tarfile.open(str(target[0]), "w:%s" % (tar_format,))      tar = tarfile.open(str(target[0]), "w:%s" % (tar_format,))
42    
43        excludeexts = env_dict.get('DISTTAR_EXCLUDEEXTS',[])
44        excludedirs = env_dict.get('DISTTAR_EXCLUDEDIRS',[])
45    
46      # write sources to our tar file      # write sources to our tar file
47      for item in source:      for item in source:
48          item = str(item)          for root, dirs, files in os.walk(str(item)):
49          print "Adding '%s/%s'" % (dir_name, item)              for name in files:
50          tar.add(item, '%s/%s' % (dir_name, item))                  ext = os.path.splitext(name)
51                    if not ext[1] in excludeexts:
52                        relpath = os.path.join(root,name)
53                        #print "Adding %s/%s" %(dir_name,relpath)
54                        tar.add(os.path.join(root,name),'%s/%s' % (dir_name,relpath))
55                for d in excludedirs:
56                    if d in dirs:
57                        dirs.remove(d)  # don't visit CVS directories etc
58    
59      # all done      # all done
60        print "Closing TAR file"
61      tar.close()      tar.close()
62    
63  def DistTarSuffix(env, sources):  def DistTarSuffix(env, sources):
# Line 71  def generate(env): Line 82  def generate(env):
82      })      })
83    
84      env.AppendUnique(      env.AppendUnique(
85          DISTTAR_FORMAT = 'gz',          DISTTAR_FORMAT = 'gz'
86            , DISTTAR_EXCLUDEEXTS = ['.o','.os','.so','.a','.dll','.lib']
87            , DISTTAR_EXCLUDEDIRS = ['CVS','.svn']
88      )      )
89    
90  def exists(env):  def exists(env):

Legend:
Removed from v.553  
changed lines
  Added in v.554

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