1 |
#!/usr/bin/python scons |
2 |
Import('env') |
3 |
|
4 |
# Build directories that contain external libraries |
5 |
env.SConscript(['johnpye/SConscript'],['env']) |
6 |
env.SConscript(['test/SConscript'],['env']) |
7 |
env.SConscript(['sensitivity/SConscript'],['env']) |
8 |
|
9 |
# Hunt for all models in the directory structure |
10 |
import os, os.path, re |
11 |
|
12 |
modelfiles = [] |
13 |
|
14 |
excludedirs = ['.svn','CVS'] |
15 |
excludefiles = ['Makefile.in','SConscript','SConstruct','update-Makefile.pl'] |
16 |
excludepatterns = [re.compile(s) for s in [ |
17 |
r"^.*\.os$" |
18 |
, r"^.*\.o$" |
19 |
,r"^.*\.tm2$" |
20 |
,r"^.*/fprops/[a-z]+$" |
21 |
,r"^.*/fprops/.*\.c$" |
22 |
,r"^.*/fprops/.*\.h$" |
23 |
,r"^.*/fprops/test\.py$" |
24 |
,r"^.*/fprops/.*\.mac$" |
25 |
,r"^.*/fprops/precalc\.py$" |
26 |
,r"^.*/fprops/.*\.ods$" |
27 |
,r"^.*/fprops/python/.*$" |
28 |
]] |
29 |
|
30 |
modeldir = env.Dir(".").abspath |
31 |
#print "MODEL DIR =",modeldir |
32 |
|
33 |
cwd = os.getcwd() |
34 |
os.chdir(modeldir) |
35 |
for root,dirs,files in os.walk("."): |
36 |
for d in dirs: |
37 |
if d in excludedirs: |
38 |
dirs.remove(d) |
39 |
if "PACKAGE" in files: |
40 |
print "FOUND 'PACKAGE' file in %s..." % root |
41 |
p = file(os.path.join(root,"PACKAGE")) |
42 |
f1 = [] |
43 |
for l in p: |
44 |
l1 = l.strip() |
45 |
if not len(l1) or l1[0]=="#": |
46 |
continue |
47 |
f1.append(l1) |
48 |
files = f1 |
49 |
|
50 |
for f in files: |
51 |
if f in excludefiles: |
52 |
continue |
53 |
|
54 |
np = os.path.normpath(os.path.join(root,f)) |
55 |
|
56 |
fail = False |
57 |
for r in excludepatterns: |
58 |
if r.match(np): |
59 |
fail = True |
60 |
break |
61 |
if fail: |
62 |
continue |
63 |
|
64 |
#print "ADDING",os.path.normpath(os.path.join(root,f)) |
65 |
modelfiles.append(np) |
66 |
os.chdir(cwd) |
67 |
|
68 |
#print "CWD =",cwd |
69 |
|
70 |
modelsroot = '$INSTALL_ROOT$INSTALL_MODELS' |
71 |
|
72 |
installeddirs = [] |
73 |
|
74 |
for f in modelfiles: |
75 |
head,tail = os.path.split(f) |
76 |
targetdir = Dir(env.subst(modelsroot)+"/"+head) |
77 |
|
78 |
if not targetdir in installeddirs: |
79 |
installeddirs.append(targetdir) |
80 |
env.InstallShared(targetdir,f) |
81 |
|
82 |
#print "MODEL INSTALLED DIRS =",installeddirs |
83 |
Return('installeddirs') |
84 |
|
85 |
# vim: set syntax=python: |
86 |
|