~jdpipe/ascend/trunk-old

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python scons
Import('env')

# Build directories that contain external libraries
env.SConscript(['johnpye/SConscript'],['env'])
env.SConscript(['test/SConscript'],['env'])
env.SConscript(['sensitivity/SConscript'],['env'])

# Hunt for all models in the directory structure
import os, os.path, re

modelfiles = []

excludedirs = ['.svn','CVS']
excludefiles = ['Makefile.in','SConscript','SConstruct','update-Makefile.pl']
excludepatterns = [re.compile(s) for s in [
	r"^.*\.os$"
	, r"^.*\.o$"
	,r"^.*\.tm2$"
	,r"^.*/fprops/[a-z]+$"
	,r"^.*/fprops/.*\.c$"
	,r"^.*/fprops/.*\.h$"
	,r"^.*/fprops/test\.py$"
	,r"^.*/fprops/.*\.mac$"
	,r"^.*/fprops/precalc\.py$"
	,r"^.*/fprops/.*\.ods$"
	,r"^.*/fprops/python/.*$"
]]

modeldir = env.Dir(".").abspath
#print "MODEL DIR =",modeldir

cwd = os.getcwd()
os.chdir(modeldir)
for root,dirs,files in os.walk("."):
	for d in dirs:
		if d in excludedirs:
			dirs.remove(d)
	if "PACKAGE" in files:
		print "FOUND 'PACKAGE' file in %s..." % root
		p = file(os.path.join(root,"PACKAGE"))
		f1 = []
		for l in p:
			l1 = l.strip()
			if not len(l1) or l1[0]=="#":
				continue
			f1.append(l1)
		files = f1

	for f in files:
		if f in excludefiles:
			continue

		np = os.path.normpath(os.path.join(root,f))

		fail = False
		for r in excludepatterns:
			if r.match(np):
				fail = True
				break
		if fail:
			continue

		#print "ADDING",os.path.normpath(os.path.join(root,f))
		modelfiles.append(np)
os.chdir(cwd)

#print "CWD =",cwd

modelsroot = '$INSTALL_ROOT$INSTALL_MODELS'

installeddirs = []

for f in modelfiles:
	head,tail = os.path.split(f)
	targetdir = Dir(env.subst(modelsroot)+"/"+head)
	
	if not targetdir in installeddirs:
		installeddirs.append(targetdir)
	env.InstallShared(targetdir,f)

#print "MODEL INSTALLED DIRS =",installeddirs
Return('installeddirs')

# vim: set syntax=python: