Renamed libapr* dlls
[TortoiseGit.git] / ext / OGDF / makeVCProj.py
blobb85fa00c7c4e416bb04904bdea78a063632df409
1 #!/usr/bin/env python
2 # Make VCProj
4 # March 2006
5 # Markus Chimani, markus.chimani@cs.uni-dortmund.de
6 #########################################################
8 #########################################################
9 # edit July 2009:
11 # argument config= sets template file
12 # Sebastian Stein, sebastian.stein@tu-dortmund.de
13 #########################################################
15 import os, sys, fnmatch, ConfigParser
17 class stuff:
18 def __init__(self, ttag, tpath, tpats):
19 self.tag, self.path, self.pats = ttag, tpath, tpats
21 def bailout(msg):
22 print msg
23 print 'Please use the original makeVCProj.config as a template'
24 sys.exit()
26 def loadConfig(sect, key, noError = False ):
27 if config.has_option(sect, key):
28 v = config.get(sect, key)
29 print ' [', sect, ']', key, '=', v
30 return v
31 else:
32 if noError:
33 return None
34 else:
35 bailout('Option "' + key + '" in section "' + sect + '" is missing')
37 #########################################################
38 # LOAD CONFIGURATION
40 config = ConfigParser.ConfigParser()
42 makecfg = 'makeVCProj.config'
43 for x in sys.argv[1:]:
44 if x[:7] == "config=":
45 makecfg = x[7:]
47 print 'Loading ' + makecfg + '...'
49 try:
50 config.readfp( open(makecfg))
51 except IOError:
52 bailout(makecfg + ' not found')
54 if not config.has_section('GENERAL'):
55 bailout('Section "GENERAL" is missing')
56 if not config.has_section('COIN'):
57 bailout('Section "COIN" is missing')
59 #########################################################
60 # CONFIGS
62 # Filenames
63 filename_vcproj = loadConfig('GENERAL', 'projectFile')
64 filename_template = loadConfig('GENERAL', 'templateFile')
65 addIncludes = ''
66 addDefines = ''
67 addLibs = ''
68 addLibPathsDebugWin32 = ''
69 addLibPathsReleaseWin32 = ''
70 addLibPathsDebugX64 = ''
71 addLibPathsReleaseX64 = ''
73 useOwnLpSolver = loadConfig('GENERAL', 'useOwnLpSolver', 'false').startswith('t')
74 if useOwnLpSolver:
75 addDefines += 'OGDF_OWN_LPSOLVER;'
77 useCoin = loadConfig('COIN', 'useCoin').startswith('t')
78 if useCoin:
79 coinIncl = loadConfig('COIN', 'coinIncl')
80 coinLib = loadConfig('COIN', 'coinLib')
81 solver_name = loadConfig('COIN', 'solver_name')
82 solver_incl = loadConfig('COIN', 'solver_incl')
84 addDefines += 'USE_COIN;'+solver_name+';'
85 addIncludes += coinIncl+';'
86 if solver_incl.strip() != '':
87 addIncludes += solver_incl+';'
88 addLibs += 'libCoinUtils.lib libOsi.lib '
89 addLibs += 'libClp.lib libOsiClp.lib '
90 addLibPathsDebugWin32 += coinLib+'/win32/Debug;'
91 addLibPathsReleaseWin32 += coinLib+'/win32/Release;'
92 addLibPathsDebugX64 += coinLib+'/x64/Debug;'
93 addLibPathsReleaseX64 += coinLib+'/x64/Release;'
95 addDefines = addDefines[:-1]
96 addIncludes = addIncludes[:-1]
97 addLibs = addLibs[:-1]
98 addLibPathsDebugWin32 = addLibPathsDebugWin32[:-1]
99 addLibPathsReleaseWin32 = addLibPathsReleaseWin32[:-1]
100 addLibPathsDebugX64 = addLibPathsDebugX64[:-1]
101 addLibPathsReleaseX64 = addLibPathsReleaseX64[:-1]
102 defineTag = '<<DEFINETAG>>'
103 includeTag = '<<INCLUDETAG>>'
104 libTag = '<<LIBTAG>>'
105 libPathsTagDebugWin32 = '<<LIBPATHSDEBUGWIN32TAG>>'
106 libPathsTagReleaseWin32 = '<<LIBPATHSRELEASEWIN32TAG>>'
107 libPathsTagDebugX64 = '<<LIBPATHSDEBUGX64TAG>>'
108 libPathsTagReleaseX64 = '<<LIBPATHSRELEASEX64TAG>>'
110 # Params are:
111 # - Tag in template-File
112 # - Directory to start search & subfilters from
113 # - File Patterns
114 cppStuff = stuff( '<<CPPTAG>>', '.\\src', [ '*.c', '*.cpp' ] )
115 hStuff = stuff( '<<HTAG>>', '.\\ogdf', [ '*.h' ] )
116 hLegacyStuff = stuff( '<<HLEGACYTAG>>', '.\\ogdf_legacy', [ '*.h' ] )
117 otherStuff = stuff( '<<OTHERTAG>>', '.', [ ] )
119 includeStuff = stuff
121 stuff = [ cppStuff, hStuff, hLegacyStuff, otherStuff ]
124 #########################################################
125 #########################################################
126 ## only code below...
128 # just the def. nothing happens yet
129 def Walk( curdir, pats, intro ):
130 names = os.listdir( curdir)
131 names.sort()
133 for name in names:
134 if name.startswith('.') or name.startswith('_') or (name=='legacy' and not includeLegacyCode):
135 continue
137 outpath = curdir + '\\' + name
138 fullname = os.path.normpath(outpath)
140 if os.path.isdir(fullname) and not os.path.islink(fullname):
141 if Walk( outpath, pats, intro + '<Filter Name="' + name + '">\n'):
142 intro = ''
143 vcproj.write('</Filter>\n')
144 else:
145 for pat in pats:
146 if fnmatch.fnmatch(name, pat):
147 if len(intro)>0:
148 vcproj.write(intro)
149 intro = ''
150 vcproj.write('<File RelativePath="' + outpath + '"> </File>\n')
151 return len(intro) == 0
153 ##########################################
154 ## Main below...
156 print 'Generating VCProj...'
158 includeLegacyCode = 0;
159 if len(sys.argv)>1 and sys.argv[1]=='legacy':
160 includeLegacyCode = 1
161 print '(including legacy code)'
163 vcproj = open(filename_vcproj,'w')
164 template = open(filename_template)
166 check = 0
167 for line in template:
168 if check < len(stuff) and line.find(stuff[check].tag) > -1:
169 if (stuff[check].tag!='<<HLEGACYTAG>>' or includeLegacyCode):
170 Walk(stuff[check].path, stuff[check].pats, '')
171 check = check + 1
172 elif line.find(defineTag) > -1:
173 vcproj.write(line.replace(defineTag,addDefines,1))
174 elif line.find(includeTag) > -1:
175 vcproj.write(line.replace(includeTag,addIncludes,1))
176 elif line.find(libTag) > -1:
177 vcproj.write(line.replace(libTag,addLibs,1))
178 elif line.find(libPathsTagDebugWin32) > -1:
179 vcproj.write(line.replace(libPathsTagDebugWin32,addLibPathsDebugWin32,1))
180 elif line.find(libPathsTagReleaseWin32) > -1:
181 vcproj.write(line.replace(libPathsTagReleaseWin32,addLibPathsReleaseWin32,1))
182 elif line.find(libPathsTagDebugX64) > -1:
183 vcproj.write(line.replace(libPathsTagDebugX64,addLibPathsDebugX64,1))
184 elif line.find(libPathsTagReleaseX64) > -1:
185 vcproj.write(line.replace(libPathsTagReleaseX64,addLibPathsReleaseX64,1))
186 else:
187 vcproj.write(line)
189 template.close()
190 vcproj.close()
192 print 'VCProj generated'