File: .generate_link_dependencies.py

package info (click to toggle)
shogun 0.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 8,688 kB
  • ctags: 6,563
  • sloc: cpp: 61,677; python: 5,233; sh: 2,767; makefile: 555; objc: 37
file content (69 lines) | stat: -rwxr-xr-x 1,860 bytes parent folder | download
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
import os,re,sys

try:
	prefix=sys.argv[1]
	suffix=sys.argv[2]
except IndexError:
	prefix='_'
	suffix='so'

incexpr=re.compile('^\s*[%#]include "(\S+)"',re.MULTILINE)
deps=dict();
deps['carrays.i']=[]
deps['cpointer.i']=[]
deps['exception.i']=[]
deps['lib/Library_doxygen.i']=[]
deps['features/Features_doxygen.i']=[]
deps['classifier/Classifier_doxygen.i']=[]
deps['structure/Structure_doxygen.i']=[]
deps['regression/Regression_doxygen.i']=[]
deps['kernel/Kernel_doxygen.i']=[]
deps['preproc/PreProc_doxygen.i']=[]
deps['distributions/Distribution_doxygen.i']=[]
deps['classifier/Classifier_doxygen.i']=[]
deps['clustering/Clustering_doxygen.i']=[]
deps['distance/Distance_doxygen.i']=[]
deps['evaluation/Evaluation_doxygen.i']=[]

initial_deps=deps.copy()

def get_deps(f):
	global deps
	global fdep
	try:
		for d in deps[f]:
			if d not in fdep:
				fdep+=[d]
				get_deps(d)
				cppfile=d[:-1]+'cpp'

				if cppfile not in fdep and deps.has_key(cppfile):
					fdep+=[cppfile]
					get_deps(cppfile)
	except KeyError:
		print >>sys.stderr, "generate_link_dependencies: warning: could not find dependencies for '%s'" % f 

#scan each file for potential includes
files=sys.stdin.readlines()
for f in files:
	f=f[:-1]
	deps[f]=re.findall(incexpr, file(f).read())

#generate linker dependencies
for f in deps.iterkeys():
	if f[-1] == 'i' and not initial_deps.has_key(f):
		if file(f).read().find('%module')>-1:
			str1=os.path.join(os.path.dirname(f), prefix + os.path.basename(f)[:-2]) + '.' + suffix + ': ' + f[:-2]+'_wrap.cxx.o'
			str2=os.path.join(os.path.dirname(f), os.path.basename(f)[:-2]) + '_wrap.cxx: ' + f

			fdep=list();
			get_deps(f)
			for d in fdep:
				if not initial_deps.has_key(d):
					if d[-4:]=='.cpp' or d[-2:]=='.c':
						str1+=' ' + d + '.o'
					if d[-2:]=='.h' or d[-2:]=='.i':
						str2+=' ' + d 

			print str1
			print str2