5 # Markus Chimani, markus.chimani@cs.tu-dortmund.de
6 # Carsten Gutwenger, carsten.gutwenger@cs.tu-dortmund.de
7 #########################################################
10 import os
, sys
, fnmatch
, ConfigParser
13 def __init__(self
, ttag
, tpath
, tpats
, tcommand
, tfilter
):
14 self
.tag
, self
.path
, self
.pats
, self
.command
, self
.filter = ttag
, tpath
, tpats
, tcommand
, tfilter
18 print 'Please use the original makeVCXProj.config as a template'
21 def loadConfig(sect
, key
, noError
= False ):
22 if config
.has_option(sect
, key
):
23 v
= config
.get(sect
, key
)
24 print ' [', sect
, ']', key
, '=', v
30 bailout('Option "' + key
+ '" in section "' + sect
+ '" is missing')
32 #########################################################
35 config
= ConfigParser
.ConfigParser()
37 makecfg
= 'makeVCXProj.config'
38 for x
in sys
.argv
[1:]:
39 if x
[:7] == "config=":
42 print 'Loading ' + makecfg
+ '...'
45 config
.readfp( open(makecfg
))
47 bailout(makecfg
+ ' not found')
49 if not config
.has_section('GENERAL'):
50 bailout('Section "GENERAL" is missing')
51 if not config
.has_section('COIN'):
52 bailout('Section "COIN" is missing')
54 #########################################################
58 filename_vcxproj
= loadConfig('GENERAL', 'projectFile')
59 filename_template
= loadConfig('GENERAL', 'templateFile')
60 filename_vcxfilters
= loadConfig('GENERAL', 'projectFiltersFile')
61 filename_template_filters
= loadConfig('GENERAL', 'templateFiltersFile')
65 addLibPathsDebugWin32
= ''
66 addLibPathsReleaseWin32
= ''
67 addLibPathsDebugX64
= ''
68 addLibPathsReleaseX64
= ''
70 useOwnLpSolver
= loadConfig('GENERAL', 'useOwnLpSolver', 'false').startswith('t')
72 addDefines
+= 'OGDF_OWN_LPSOLVER;'
74 useCoin
= loadConfig('COIN', 'useCoin').startswith('t')
76 coinIncl
= loadConfig('COIN', 'coinIncl')
77 coinLib
= loadConfig('COIN', 'coinLib')
78 solver_name
= loadConfig('COIN', 'solver_name')
79 solver_incl
= loadConfig('COIN', 'solver_incl')
81 addDefines
+= 'USE_COIN;'+solver_name
+';'
82 addIncludes
+= coinIncl
+';'
83 if solver_incl
.strip() != '':
84 addIncludes
+= solver_incl
+';'
85 addLibs
+= 'libCoinUtils.lib libOsi.lib '
86 addLibs
+= 'libClp.lib libOsiClp.lib '
87 addLibPathsDebugWin32
+= coinLib
+'/win32/Debug;'
88 addLibPathsReleaseWin32
+= coinLib
+'/win32/Release;'
89 addLibPathsDebugX64
+= coinLib
+'/x64/Debug;'
90 addLibPathsReleaseX64
+= coinLib
+'/x64/Release;'
92 addDefines
= addDefines
[:-1]
93 addIncludes
= addIncludes
[:-1]
94 addLibs
= addLibs
[:-1]
95 addLibPathsDebugWin32
= addLibPathsDebugWin32
[:-1]
96 addLibPathsReleaseWin32
= addLibPathsReleaseWin32
[:-1]
97 addLibPathsDebugX64
= addLibPathsDebugX64
[:-1]
98 addLibPathsReleaseX64
= addLibPathsReleaseX64
[:-1]
99 defineTag
= '<<DEFINETAG>>'
100 includeTag
= '<<INCLUDETAG>>'
101 libTag
= '<<LIBTAG>>'
102 libPathsTagDebugWin32
= '<<LIBPATHSDEBUGWIN32TAG>>'
103 libPathsTagReleaseWin32
= '<<LIBPATHSRELEASEWIN32TAG>>'
104 libPathsTagDebugX64
= '<<LIBPATHSDEBUGX64TAG>>'
105 libPathsTagReleaseX64
= '<<LIBPATHSRELEASEX64TAG>>'
106 filtersTag
= '<<FTAG>>'
109 # - Tag in template-File
110 # - Directory to start search & subfilters from
112 cppStuff
= stuff( '<<CPPTAG>>', 'src', [ '*.c', '*.cpp' ], 'ClCompile', 'Source Files' )
113 hStuff
= stuff( '<<HTAG>>', 'ogdf', [ '*.h' ], 'ClInclude', 'Header Files' )
114 hLegacyStuff
= stuff( '<<HLEGACYTAG>>', 'ogdf_legacy', [ '*.h' ], 'ClInclude', 'Header Files Legacy' )
118 stuff
= [ cppStuff
, hStuff
, hLegacyStuff
]
121 #########################################################
122 #########################################################
123 ## only code below...
125 # just the def. nothing happens yet
126 def Walk( curdir
, pats
, command
):
127 names
= os
.listdir( curdir
)
131 if name
.startswith('.') or name
.startswith('_') or (name
=='legacy' and not includeLegacyCode
):
134 outpath
= curdir
+ '\\' + name
135 fullname
= os
.path
.normpath(outpath
)
137 if os
.path
.isdir(fullname
) and not os
.path
.islink(fullname
):
138 Walk( outpath
, pats
, command
)
141 if fnmatch
.fnmatch(name
, pat
):
142 vcxproj
.write(' <' + command
+ ' Include="' + outpath
+ '" />\n')
144 def WalkFilterFiles( curdir
, pats
, command
, filter ):
145 names
= os
.listdir( curdir
)
149 if name
.startswith('.') or name
.startswith('_') or (name
=='legacy' and not includeLegacyCode
):
152 outpath
= curdir
+ '\\' + name
153 fullname
= os
.path
.normpath(outpath
)
155 if os
.path
.isdir(fullname
) and not os
.path
.islink(fullname
):
156 WalkFilterFiles( outpath
, pats
, command
, filter + '\\' + name
)
159 if fnmatch
.fnmatch(name
, pat
):
160 vcxfilters
.write(' <' + command
+ ' Include="' + outpath
+ '">\n')
161 vcxfilters
.write(' <Filter>' + filter + '</Filter>\n')
162 vcxfilters
.write(' </' + command
+ '>\n')
164 def WalkFilters( curdir
, filter ):
165 names
= os
.listdir( curdir
)
169 if name
.startswith('.') or name
.startswith('_') or (name
=='legacy' and not includeLegacyCode
):
172 outpath
= curdir
+ '\\' + name
173 fullname
= os
.path
.normpath(outpath
)
175 if os
.path
.isdir(fullname
) and not os
.path
.islink(fullname
):
176 filtername
= filter + '\\' + name
177 vcxfilters
.write(' <Filter Include="' + filtername
+ '">\n')
178 vcxfilters
.write(' </Filter>\n')
179 WalkFilters( outpath
, filtername
)
182 ##########################################
185 print 'Generating VCXProj...'
187 includeLegacyCode
= 0;
188 if len(sys
.argv
)>1 and sys
.argv
[1]=='legacy':
189 includeLegacyCode
= 1
190 print '(including legacy code)'
192 vcxproj
= open(filename_vcxproj
,'w')
193 template
= open(filename_template
)
196 for line
in template
:
197 if check
< len(stuff
) and line
.find(stuff
[check
].tag
) > -1:
198 if (stuff
[check
].tag
!='<<HLEGACYTAG>>' or includeLegacyCode
):
199 Walk(stuff
[check
].path
, stuff
[check
].pats
, stuff
[check
].command
)
201 elif line
.find(defineTag
) > -1:
202 vcxproj
.write(line
.replace(defineTag
,addDefines
,1))
203 elif line
.find(includeTag
) > -1:
204 vcxproj
.write(line
.replace(includeTag
,addIncludes
,1))
205 elif line
.find(libTag
) > -1:
206 vcxproj
.write(line
.replace(libTag
,addLibs
,1))
207 elif line
.find(libPathsTagDebugWin32
) > -1:
208 vcxproj
.write(line
.replace(libPathsTagDebugWin32
,addLibPathsDebugWin32
,1))
209 elif line
.find(libPathsTagReleaseWin32
) > -1:
210 vcxproj
.write(line
.replace(libPathsTagReleaseWin32
,addLibPathsReleaseWin32
,1))
211 elif line
.find(libPathsTagDebugX64
) > -1:
212 vcxproj
.write(line
.replace(libPathsTagDebugX64
,addLibPathsDebugX64
,1))
213 elif line
.find(libPathsTagReleaseX64
) > -1:
214 vcxproj
.write(line
.replace(libPathsTagReleaseX64
,addLibPathsReleaseX64
,1))
221 # Creation of filters file...
223 vcxfilters
= open(filename_vcxfilters
,'w')
224 template_filters
= open(filename_template_filters
)
227 for line
in template_filters
:
228 if check
< len(stuff
) and line
.find(stuff
[check
].tag
) > -1:
229 if (stuff
[check
].tag
!='<<HLEGACYTAG>>' or includeLegacyCode
):
230 WalkFilterFiles(stuff
[check
].path
, stuff
[check
].pats
, stuff
[check
].command
, stuff
[check
].filter)
232 elif line
.find(filtersTag
) > -1:
234 if (s
.tag
!='<<HLEGACYTAG>>' or includeLegacyCode
):
235 WalkFilters(s
.path
, s
.filter)
237 vcxfilters
.write(line
)
240 template_filters
.close()
244 print 'VCXProj generated'