Changeset 1184 for trunk/scons


Ignore:
Timestamp:
08/25/06 16:34:59 (18 years ago)
Author:
mar637
Message:

complete rework of install target, added data install, and also building a distribution archive

Location:
trunk/scons
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scons/utils.py

    r1178 r1184  
    1515    env.AddCustomPath = AddCustomPath
    1616
    17     def CreateDist(target, sources, descend="stage"):
    18         import tarfile
    19         base_name = str(target).split('.tar')[0]
    20         (target_dir, dir_name) = os.path.split(base_name)
    21         # create the target directory if it does not exist
    22         if target_dir and not os.path.exists(target_dir):
    23             os.makedirs(target_dir)
    24         tar_format = "bz2"
    25         tar = tarfile.open(str(target)+".tar.bz2", "w:%s" % (tar_format,))
    26         if os.path.exists(descend): os.chdir(descend)
    27         taritems = []
    28         excludedirs = [".svn"]
    29         for item in sources:
    30             if os.path.isdir(item):
    31                 for root, dirs, files in os.walk(str(item)):
    32                     if not root in excludedirs:
    33                         for name in files:
    34                             if not name.startswith("."):
    35                                 taritems.append(os.path.join(root, name))
    36             else:
    37                 taritems.append(item)
    38         for item in taritems:
    39             print "Adding to archive: %s/%s" % (dir_name, item)
    40             tar.add(item,'%s/%s' % (dir_name, item))
    41         tar.close()
     17    def WalkDirTree(targetroot, sourceroot, sources):
     18        ifiles = []
     19        ofiles = []
     20        for s in sources:
     21            if os.path.isdir(os.path.join(sourceroot ,s)):
     22                for d,ld,f in os.walk(os.path.join(sourceroot ,s)):
     23                    for fl in f:
     24                        ifile = os.path.join(d, fl)
     25                        ifiles.append(ifile)
     26                        ofile = ifile.replace(sourceroot, targetroot)
     27                        ofiles.append(ofile)
     28        return ofiles, ifiles
     29    env.WalkDirTree = WalkDirTree
    4230
    43     env.CreateDist = CreateDist
     31    def null_action(target, source, env): return 0
     32
     33    def message(target, source, env):
     34        return "%s" % target[0]
     35    env.MessageAction = env.Action(null_action, message)
    4436
    4537def exists(env):
     
    4739        import os
    4840        import glob
    49         import tarfile
    5041    except ImportError:
    5142        return False
Note: See TracChangeset for help on using the changeset viewer.