Trees | Indices | Help |
|
---|
|
1 # This file is part of Buildbot. Buildbot is free software: you can 2 # redistribute it and/or modify it under the terms of the GNU General Public 3 # License as published by the Free Software Foundation, version 2. 4 # 5 # This program is distributed in the hope that it will be useful, but WITHOUT 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 8 # details. 9 # 10 # You should have received a copy of the GNU General Public License along with 11 # this program; if not, write to the Free Software Foundation, Inc., 51 12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 13 # 14 # Copyright Buildbot Team Members 15 16 # Visual studio steps 17 18 from buildbot.steps.shell import ShellCommand 19 from buildbot.process.buildstep import LogLineObserver 20 from buildbot.status.results import SUCCESS, WARNINGS, FAILURE 21 22 import re 23 2426 """ concat a path for this name """ 27 try: 28 oldval = env[name] 29 if not oldval.endswith(';'): 30 oldval = oldval + ';' 31 except KeyError: 32 oldval = "" 33 if not value.endswith(';'): 34 value = value + ';' 35 env[name] = oldval + value3638 39 _re_delimiter = re.compile(r'^(\d+>)?-{5}.+-{5}$') 40 _re_file = re.compile(r'^(\d+>)?[^ ]+\.(cpp|c)$') 41 _re_warning = re.compile(r' ?: warning [A-Z]+[0-9]+:') 42 _re_error = re.compile(r' ?error ([A-Z]+[0-9]+)?\s?: ') 43 44 nbFiles = 0 45 nbProjects = 0 46 nbWarnings = 0 47 nbErrors = 0 48 49 logwarnings = None 50 logerrors = None 5176 7753 LogLineObserver.__init__(self, **kwargs) 54 self.logwarnings = logwarnings 55 self.logerrors = logerrors 56 self.stdoutParser.delimiter = "\r\n" 57 self.stderrParser.delimiter = "\r\n"5860 if self._re_delimiter.search(line): 61 self.nbProjects += 1 62 self.logwarnings.addStdout("%s\n" % line) 63 self.logerrors.addStdout("%s\n" % line) 64 self.step.setProgress('projects', self.nbProjects) 65 elif self._re_file.search(line): 66 self.nbFiles += 1 67 self.step.setProgress('files', self.nbFiles) 68 elif self._re_warning.search(line): 69 self.nbWarnings += 1 70 self.logwarnings.addStdout("%s\n" % line) 71 self.step.setProgress('warnings', self.nbWarnings) 72 elif self._re_error.search("%s\n" % line): 73 # error has no progress indication 74 self.nbErrors += 1 75 self.logerrors.addStderr("%s\n" % line)79 # an *abstract* base class, which will not itself work as a buildstep 80 81 name = "compile" 82 description = "compiling" 83 descriptionDone = "compile" 84 85 logobserver = None 86 87 installdir = None 88 default_installdir = None 89 90 # One of build, or rebuild 91 mode = "rebuild" 92 93 projectfile = None 94 config = None 95 useenv = False 96 project = None 97 PATH = [] 98 INCLUDE = [] 99 LIB = [] 100 101 renderables = [ 'projectfile', 'config', 'project' ] 102205103 - def __init__(self, 104 installdir = None, 105 mode = "rebuild", 106 projectfile = None, 107 config = None, 108 useenv = False, 109 project = None, 110 INCLUDE = [], 111 LIB = [], 112 PATH = [], 113 **kwargs):114 self.installdir = installdir 115 self.mode = mode 116 self.projectfile = projectfile 117 self.config = config 118 self.useenv = useenv 119 self.project = project 120 if len(INCLUDE) > 0: 121 self.INCLUDE = INCLUDE 122 self.useenv = True 123 if len(LIB) > 0: 124 self.LIB = LIB 125 self.useenv = True 126 if len(PATH) > 0: 127 self.PATH = PATH 128 # always upcall ! 129 ShellCommand.__init__(self, **kwargs) 130 self.addFactoryArguments( 131 installdir = installdir, 132 mode = mode, 133 projectfile = projectfile, 134 config = config, 135 useenv = useenv, 136 project = project, 137 INCLUDE = INCLUDE, 138 LIB = LIB, 139 PATH = PATH 140 )141143 self.progressMetrics += ('projects', 'files', 'warnings',) 144 return ShellCommand.setupProgress(self)145147 logwarnings = self.addLog("warnings") 148 logerrors = self.addLog("errors") 149 self.logobserver = MSLogLineObserver(logwarnings, logerrors) 150 self.addLogObserver('stdio', self.logobserver) 151 ShellCommand.setupLogfiles(self, cmd, logfiles)152 156158 ShellCommand.setupEnvironment(self, cmd) 159 if cmd.args['env'] is None: 160 cmd.args['env'] = {} 161 162 # setup the custom one, those one goes first 163 for path in self.PATH: 164 addEnvPath(cmd.args['env'], "PATH", path) 165 for path in self.INCLUDE: 166 addEnvPath(cmd.args['env'], "INCLUDE", path) 167 for path in self.LIB: 168 addEnvPath(cmd.args['env'], "LIB", path) 169 170 self.setupInstalldir()171173 description = ShellCommand.describe(self, done) 174 if done: 175 description.append('%d projects' % self.step_status.getStatistic('projects', 0)) 176 description.append('%d files' % self.step_status.getStatistic('files', 0)) 177 warnings = self.step_status.getStatistic('warnings', 0) 178 if warnings > 0: 179 description.append('%d warnings' % warnings) 180 errors = self.step_status.getStatistic('errors', 0) 181 if errors > 0: 182 description.append('%d errors' % errors) 183 return description184186 self.step_status.setStatistic('projects', self.logobserver.nbProjects) 187 self.step_status.setStatistic('files', self.logobserver.nbFiles) 188 self.step_status.setStatistic('warnings', self.logobserver.nbWarnings) 189 self.step_status.setStatistic('errors', self.logobserver.nbErrors)190192 if cmd.rc != 0: 193 return FAILURE 194 if self.logobserver.nbErrors > 0: 195 return FAILURE 196 if self.logobserver.nbWarnings > 0: 197 return WARNINGS 198 else: 199 return SUCCESS200207 208 default_installdir = 'C:\\Program Files\\Microsoft Visual Studio' 209246211 VisualStudio.setupEnvironment(self, cmd) 212 213 # Root of Visual Developer Studio Common files. 214 VSCommonDir = self.installdir + '\\Common' 215 MSVCDir = self.installdir + '\\VC98' 216 MSDevDir = VSCommonDir + '\\msdev98' 217 218 addEnvPath(cmd.args['env'], "PATH", MSDevDir + '\\BIN') 219 addEnvPath(cmd.args['env'], "PATH", MSVCDir + '\\BIN') 220 addEnvPath(cmd.args['env'], "PATH", VSCommonDir + '\\TOOLS\\WINNT') 221 addEnvPath(cmd.args['env'], "PATH", VSCommonDir + '\\TOOLS') 222 223 addEnvPath(cmd.args['env'], "INCLUDE", MSVCDir + '\\INCLUDE') 224 addEnvPath(cmd.args['env'], "INCLUDE", MSVCDir + '\\ATL\\INCLUDE') 225 addEnvPath(cmd.args['env'], "INCLUDE", MSVCDir + '\\MFC\\INCLUDE') 226 227 addEnvPath(cmd.args['env'], "LIB", MSVCDir + '\\LIB') 228 addEnvPath(cmd.args['env'], "LIB", MSVCDir + '\\MFC\\LIB')229231 command = ["msdev"] 232 command.append(self.projectfile) 233 command.append("/MAKE") 234 if self.project is not None: 235 command.append(self.project + " - " + self.config) 236 else: 237 command.append("ALL - " + self.config) 238 if self.mode == "rebuild": 239 command.append("/REBUILD") 240 else: 241 command.append("/BUILD") 242 if self.useenv: 243 command.append("/USEENV") 244 self.setCommand(command) 245 return VisualStudio.start(self)248 default_installdir = 'C:\\Program Files\\Microsoft Visual Studio .NET 2003' 249287 288 #alias VC7 as VS2003 289 VS2003 = VC7 290251 VisualStudio.setupEnvironment(self, cmd) 252 253 VSInstallDir = self.installdir + '\\Common7\\IDE' 254 VCInstallDir = self.installdir 255 MSVCDir = self.installdir + '\\VC7' 256 257 addEnvPath(cmd.args['env'], "PATH", VSInstallDir) 258 addEnvPath(cmd.args['env'], "PATH", MSVCDir + '\\BIN') 259 addEnvPath(cmd.args['env'], "PATH", VCInstallDir + '\\Common7\\Tools') 260 addEnvPath(cmd.args['env'], "PATH", VCInstallDir + '\\Common7\\Tools\\bin') 261 262 addEnvPath(cmd.args['env'], "INCLUDE", MSVCDir + '\\INCLUDE') 263 addEnvPath(cmd.args['env'], "INCLUDE", MSVCDir + '\\ATLMFC\\INCLUDE') 264 addEnvPath(cmd.args['env'], "INCLUDE", MSVCDir + '\\PlatformSDK\\include') 265 addEnvPath(cmd.args['env'], "INCLUDE", VCInstallDir + '\\SDK\\v1.1\\include') 266 267 addEnvPath(cmd.args['env'], "LIB", MSVCDir + '\\LIB') 268 addEnvPath(cmd.args['env'], "LIB", MSVCDir + '\\ATLMFC\\LIB') 269 addEnvPath(cmd.args['env'], "LIB", MSVCDir + '\\PlatformSDK\\lib') 270 addEnvPath(cmd.args['env'], "LIB", VCInstallDir + '\\SDK\\v1.1\\lib')271273 command = ["devenv.com"] 274 command.append(self.projectfile) 275 if self.mode == "rebuild": 276 command.append("/Rebuild") 277 else: 278 command.append("/Build") 279 command.append(self.config) 280 if self.useenv: 281 command.append("/UseEnv") 282 if self.project is not None: 283 command.append("/Project") 284 command.append(self.project) 285 self.setCommand(command) 286 return VisualStudio.start(self)292 293 # Our ones 294 arch = None 295 default_installdir = 'C:\\Program Files\\Microsoft Visual Studio 8' 296 297 renderables = ['arch'] 298334 335 #alias VC8 as VS2005 336 VS2005 = VC8 337300 self.arch = arch 301 302 # always upcall ! 303 VisualStudio.__init__(self, **kwargs) 304 self.addFactoryArguments(arch = arch)305307 VisualStudio.setupEnvironment(self, cmd) 308 309 VSInstallDir = self.installdir 310 VCInstallDir = self.installdir + '\\VC' 311 312 addEnvPath(cmd.args['env'], "PATH", VSInstallDir + '\\Common7\\IDE') 313 if self.arch == "x64": 314 addEnvPath(cmd.args['env'], "PATH", VCInstallDir + '\\BIN\\x86_amd64') 315 addEnvPath(cmd.args['env'], "PATH", VCInstallDir + '\\BIN') 316 addEnvPath(cmd.args['env'], "PATH", VSInstallDir + '\\Common7\\Tools') 317 addEnvPath(cmd.args['env'], "PATH", VSInstallDir + '\\Common7\\Tools\\bin') 318 addEnvPath(cmd.args['env'], "PATH", VCInstallDir + '\\PlatformSDK\\bin') 319 addEnvPath(cmd.args['env'], "PATH", VSInstallDir + '\\SDK\\v2.0\\bin') 320 addEnvPath(cmd.args['env'], "PATH", VCInstallDir + '\\VCPackages') 321 addEnvPath(cmd.args['env'], "PATH", r'${PATH}') 322 323 addEnvPath(cmd.args['env'], "INCLUDE", VCInstallDir + '\\INCLUDE') 324 addEnvPath(cmd.args['env'], "INCLUDE", VCInstallDir + '\\ATLMFC\\include') 325 addEnvPath(cmd.args['env'], "INCLUDE", VCInstallDir + '\\PlatformSDK\\include') 326 327 archsuffix = '' 328 if self.arch == "x64": 329 archsuffix = '\\amd64' 330 addEnvPath(cmd.args['env'], "LIB", VCInstallDir + '\\LIB' + archsuffix) 331 addEnvPath(cmd.args['env'], "LIB", VCInstallDir + '\\ATLMFC\\LIB' + archsuffix) 332 addEnvPath(cmd.args['env'], "LIB", VCInstallDir + '\\PlatformSDK\\lib' + archsuffix) 333 addEnvPath(cmd.args['env'], "LIB", VSInstallDir + '\\SDK\\v2.0\\lib' + archsuffix)354 355 # Add first support for VC9 (Same as VC8, with a different installdir)340 command = ["vcexpress"] 341 command.append(self.projectfile) 342 if self.mode == "rebuild": 343 command.append("/Rebuild") 344 else: 345 command.append("/Build") 346 command.append(self.config) 347 if self.useenv: 348 command.append("/UseEnv") 349 if self.project is not None: 350 command.append("/Project") 351 command.append(self.project) 352 self.setCommand(command) 353 return VisualStudio.start(self)357 default_installdir = 'C:\\Program Files\\Microsoft Visual Studio 9.0'358 359 VS2008 = VC9 360 361 # VC10 doesn't looks like it needs extra stuff.363 default_installdir = 'C:\\Program Files\\Microsoft Visual Studio 10.0'364 365 VS2010 = VC10 366
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 25 19:40:41 2012 | http://epydoc.sourceforge.net |