source: trunk/scons/installtree.py@ 1172

Last change on this file since 1172 was 1137, checked in by mar637, 18 years ago

added hack to prevent scons from failing when ditr doesn't exists

File size: 1.3 KB
Line 
1import os
2import fnmatch
3#from SCons.Script import *
4
5def generate(env):
6 def InstallTree(dest_dir, src_dir, includes, excludes):
7 destnode = env.Dir(dest_dir)
8 dirs = []
9 dirs.append(src_dir)
10 while len(dirs) > 0:
11 currdir = dirs.pop(0)
12 currdestdir = dest_dir + currdir[len(src_dir):]
13 if not os.path.exists(currdir): return
14 flist = os.listdir(currdir)
15 for currfile in flist:
16 currpath = os.path.join(currdir, currfile)
17 match = 0
18 for pattern in includes:
19 if fnmatch.fnmatchcase(currfile, pattern):
20 match = 1
21 if (match == 1):
22 for pattern in excludes:
23 if fnmatch.fnmatchcase(currfile, pattern):
24 match = 0
25 if (match == 1):
26 if (os.path.isdir(currpath)):
27 #print "d=" + currpath
28 dirs.append(currpath)
29 else:
30 #print "f=" + currpath
31 env.Install(currdestdir, currpath)
32 return destnode
33
34 env.InstallTree = InstallTree
35def exists(env):
36 return true
Note: See TracBrowser for help on using the repository browser.