5 # Markus Chimani, markus.chimani@cs.uni-dortmund.de
6 #########################################################
8 #########################################################
11 # argument config= sets template file
12 # Sebastian Stein, sebastian.stein@tu-dortmund.de
13 #########################################################
15 import os
, sys
, fnmatch
, ConfigParser
18 def __init__(self
, ttag
, tpath
, tpats
):
19 self
.tag
, self
.path
, self
.pats
= ttag
, tpath
, tpats
23 print 'Please use the original makeVCProj.config as a template'
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
35 bailout('Option "' + key
+ '" in section "' + sect
+ '" is missing')
37 #########################################################
40 config
= ConfigParser
.ConfigParser()
42 makecfg
= 'makeVCProj.config'
43 for x
in sys
.argv
[1:]:
44 if x
[:7] == "config=":
47 print 'Loading ' + makecfg
+ '...'
50 config
.readfp( open(makecfg
))
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 #########################################################
63 filename_vcproj
= loadConfig('GENERAL', 'projectFile')
64 filename_template
= loadConfig('GENERAL', 'templateFile')
68 addLibPathsDebugWin32
= ''
69 addLibPathsReleaseWin32
= ''
70 addLibPathsDebugX64
= ''
71 addLibPathsReleaseX64
= ''
73 useOwnLpSolver
= loadConfig('GENERAL', 'useOwnLpSolver', 'false').startswith('t')
75 addDefines
+= 'OGDF_OWN_LPSOLVER;'
77 useCoin
= loadConfig('COIN', 'useCoin').startswith('t')
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>>'
111 # - Tag in template-File
112 # - Directory to start search & subfilters from
114 cppStuff
= stuff( '<<CPPTAG>>', '.\\src', [ '*.c', '*.cpp' ] )
115 hStuff
= stuff( '<<HTAG>>', '.\\ogdf', [ '*.h' ] )
116 hLegacyStuff
= stuff( '<<HLEGACYTAG>>', '.\\ogdf_legacy', [ '*.h' ] )
117 otherStuff
= stuff( '<<OTHERTAG>>', '.', [ ] )
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
)
134 if name
.startswith('.') or name
.startswith('_') or (name
=='legacy' and not includeLegacyCode
):
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'):
143 vcproj
.write('</Filter>\n')
146 if fnmatch
.fnmatch(name
, pat
):
150 vcproj
.write('<File RelativePath="' + outpath
+ '"> </File>\n')
151 return len(intro
) == 0
153 ##########################################
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
)
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
, '')
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))
192 print 'VCProj generated'