source: trunk/scons/utils.py @ 1184

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

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

File size: 1.4 KB
Line 
1import os
2import glob
3
4def generate(env):
5    def SGlob(pattern):
6        path = env.GetBuildPath('SConscript').replace('SConscript', '')
7        return [ i.replace(path, '') for i in glob.glob(path + pattern) ]
8    env.SGlob = SGlob
9
10    def AddCustomPath(path=""):
11        if not len(path) or not os.path.exists(path):
12            return
13        env.PrependUnique(CPPPATH = [os.path.join(path, "include")])
14        env.PrependUnique(LIBPATH = [os.path.join(path, "lib")])
15    env.AddCustomPath = AddCustomPath
16
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
30
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)
36
37def exists(env):
38    try:
39        import os
40        import glob
41    except ImportError:
42        return False
43    else:
44        return True
Note: See TracBrowser for help on using the repository browser.