1 #############################################################################
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful, but
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; if not, write to the Free Software
15 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 #############################################################################
18 # Copyright (c) 2008-2009 Kimmo Varis <kimmov@winmerge.org>
22 # A script for upgrading VS solution- and project-files from VS2003 to newer
23 # VS versions. This script calls VS binary to upgrade every file listed. If the
24 # file is solution file, then all projects in the solution are also upgraded.
26 # For more info about using VS command line, see:
27 # http://www.devsource.com/c/a/Using-VS/Working-at-the-Visual-Studio-Command-Line/1/
34 # The version of the script
37 solutions = [r'Externals\expat\expat.sln',
38 r'Externals\pcre\Win32\PCRE.sln',
41 projects = [r'Externals\scew\win32\scew.vcproj',
42 r'ShellExtension\ShellExtension.vcproj']
44 # TODO: read this from Tools.ini
45 vs_path = r'C:\Program Files\Microsoft Visual Studio 9.0'
47 def upgrade_projects(root_path):
48 vs_binary = os.path.join(vs_path, 'Common7/IDE')
49 vs_binary = os.path.join(vs_binary, 'devenv.com')
51 for solution in solutions:
52 sol_file = os.path.join(root_path, solution)
53 print 'Upgrading VS solution file: ' + sol_file
54 subprocess.call([vs_binary, sol_file, '/Upgrade'], shell = True)
56 for project in projects:
57 proj_file = os.path.join(root_path, project)
58 print 'Upgrading project file: ' + proj_file
59 subprocess.call([vs_binary, proj_file, '/Upgrade'], shell = True)
62 '''Print script usage information.'''
64 print 'UpgradeProjects.py - version ' + str(script_version)
65 print 'Script to upgrade VS solution/project files.'
66 print 'Usage: UpgradeProjects.py [-h] [path]'
68 print ' -h, --help Print this help.'
69 print ' path Root path for WinMerge.'
70 print 'For example: UpgradeProjects.py ../..'
71 print ' which upgrades current project when run from Scripts folder.'
76 opts, args = getopt.getopt(argv, 'h', ['help'])
79 if opt in ('-h', '--help'):
85 root_path = os.path.abspath(rel_path)
87 # If not root path given, use current folder as root path
89 root_path = os.getcwd()
91 if not os.path.exists(root_path):
92 print 'ERROR: Cannot find path: ' + root_path
95 print 'Upgrading VS solution- and project-file in folder: ' + root_path
96 upgrade_projects(root_path)
99 if __name__ == "__main__":