1#!/usr/bin/env python3 2# Times script using Visual Studio compiler in Windows 3# 4# This script assumes that you have: 5# Python 3 6# Visual Studio (script assumes VS2013, manipulate the sed command otherwise) 7# Cygwin64 for the sed command 8# Command line svn. TortoiseSVN with that feature selected works. 9# 10# Usage: 11# Open VS command prompt. 12# cd c:\users\... 13# svn checkout https://github.com/danmar/cppcheck/trunk cppcheck-svn 14# cd cppcheck-svn 15# c:\python34\python.exe times-vs.py rev1:rev2 16 17 18import subprocess 19import glob 20import re 21import sys 22 23if len(sys.argv) != 2: 24 print('revisions not specified') 25 sys.exit(1) 26 27res = re.match(r'([0-9]+):([0-9]+)', sys.argv[1]) 28if res is None: 29 print('invalid format, 11111:22222') 30 sys.exit(1) 31 32rev1 = int(res.group(1)) 33rev2 = int(res.group(2)) 34 35if rev1 > rev2 or rev1 < 10000 or rev2 > 20000 or rev2 - rev1 > 500: 36 print('range, aborting') 37 sys.exit(1) 38 39print('Revisions: ' + str(rev1) + ':' + str(rev2)) 40 41f = open('results.txt', 'wt') 42f.write('\n') 43f.close() 44 45for rev in range(rev1, rev2): 46 subprocess.call(['svn', 'revert', '-R', '.']) 47 subprocess.call(['svn', 'up', '-r' + str(rev)]) 48 for vcxproj in glob.glob('*/*.vcxproj'): 49 subprocess.call([r'c:\cygwin64\bin\sed.exe', '-i', 's/140/120/', vcxproj]) 50 subprocess.call('msbuild cppcheck.sln /t:build /p:configuration=Release,platform=x64'.split()) 51 print('Revision:' + str(rev)) 52 p = subprocess.Popen(r'bin\cppcheck.exe src -q --showtime=summary'.split(), 53 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 54 comm = p.communicate() 55 f = open('results.txt', 'at') 56 f.write('\nREV ' + str(rev) + '\n') 57 f.write(comm[0].decode('utf-8')) 58 f.close() 59