Revision: 7245
http://winmerge.svn.sourceforge.net/winmerge/?rev=7245&view=rev
Author: kimmov
Date: 2010-09-12 09:32:59 +0000 (Sun, 12 Sep 2010)
Log Message:
-----------
Merge some script updates/fixes from trunk.
Modified Paths:
--------------
branches/R2_12/Tools/Scripts/ReadMe.txt
branches/R2_12/Tools/Scripts/UpgradeProjects.py
branches/R2_12/Tools/Scripts/fix_manifest.py
Added Paths:
-----------
branches/R2_12/Tools/Scripts/ToolSettings.py
branches/R2_12/Tools/Scripts/cleanup_backups.py
Modified: branches/R2_12/Tools/Scripts/ReadMe.txt
===================================================================
--- branches/R2_12/Tools/Scripts/ReadMe.txt 2010-09-11 13:03:38 UTC (rev 7244)
+++ branches/R2_12/Tools/Scripts/ReadMe.txt 2010-09-12 09:32:59 UTC (rev 7245)
@@ -61,7 +61,7 @@
Run from root folder (Src, Filters etc are subfolders).
- Usage: create_release.py [-h] [-f file] [-v n] [-c] [-l]
+ Usage: create_release [-h] [-f file] [-v n] [-c] [-l]
Where:
-h, --help print usage help
-v n, --version=n set release version
@@ -70,7 +70,7 @@
-f file, --file=filename set the version number ini file
For example:
create_release -v 2.7.7.1
- create_release.py -f versions.ini
+ create_release -f versions.ini
fix_manifest.py
Added: branches/R2_12/Tools/Scripts/ToolSettings.py
===================================================================
--- branches/R2_12/Tools/Scripts/ToolSettings.py (rev 0)
+++ branches/R2_12/Tools/Scripts/ToolSettings.py 2010-09-12 09:32:59 UTC (rev 7245)
@@ -0,0 +1,100 @@
+#
+# The MIT License
+# Copyright (c) 2007-2009 Kimmo Varis
+# Copyright (c) 2008 Matthias Mayer
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+# $Id: ToolSettings.py 6827 2009-06-05 21:20:24Z kimmov $
+
+# This is a tools configuration script. It handles compiling, version control
+# etc tool configuration for scripts calling them. It allows e.g switching the
+# compiler by changing value in the ini file.
+
+import os
+import os.path
+import sys
+import ConfigParser
+
+class ToolSettings:
+ def __init__(self):
+ # Set default values
+ self.svn_binary = r'C:\Program Files\Subversion\bin\svn.exe'
+ self.vs_path = ''
+ self.vs_path7 = r'C:\Program Files\Microsoft Visual Studio .NET 2003'
+ self.vs_path8 = r'C:\Program Files\Microsoft Visual Studio 8'
+ self.vs_path9 = r'C:\Program Files\Microsoft Visual Studio 9.0'
+ self.innosetup_path = r'C:\Program Files\Inno Setup 5'
+ # Checkout sources from local workspace or from SVN server (give URL)
+ self.source = 'workspace'
+ self.vs_version = 2005
+
+ def create_ini(self, filename):
+ config = ConfigParser.RawConfigParser()
+ sect = 'RUNTIME'
+ if os.path.exists('Tools.ini'):
+ config.readfp(open(filename))
+ if not config.has_section(sect):
+ config.add_section(sect)
+ if not config.has_option(sect, 'type'):
+ config.set(sect, 'type', 'VSXXXX')
+ if not config.has_option(sect, 'VSStudio'):
+ config.set(sect, 'VSStudio', self.vs_version)
+ if not config.has_option(sect, 'Source'):
+ config.set(sect, 'Source', self.source)
+ if not config.has_option(sect, 'svn_binary'):
+ config.set(sect, 'svn_binary', self.svn_binary)
+ if not config.has_option(sect, 'vs_path7'):
+ config.set(sect, 'vs_path7', self.vs_path7)
+ if not config.has_option(sect, 'vs_path8'):
+ config.set(sect, 'vs_path8', self.vs_path8)
+ if not config.has_option(sect, 'vs_path9'):
+ config.set(sect, 'vs_path9', self.vs_path9)
+ if not config.has_option(sect, 'innosetup_path'):
+ config.set(sect, 'innosetup_path', self.innosetup_path)
+
+ # Writing our configuration file to 'Tools.ini'
+ with open(filename, 'w') as configfile:
+ config.write(configfile)
+
+ def read_ini(self, filename):
+ config = ConfigParser.RawConfigParser()
+ if not os.path.exists(filename):
+ # If the config file didn't exist, we create a new file and ask
+ # user to edit the config and re-run the script. This is because
+ # our defaults probably don't match user's environment.
+ self.create_ini(filename)
+ print 'New configuration file created: ' + filename
+ print 'Please edit the file to match your configuration and re-run the script.'
+ sys.exit()
+
+ config.readfp(open(filename))
+ self.svn_binary = config.get('RUNTIME', 'svn_binary')
+ self.vs_path7 = config.get('RUNTIME', 'vs_path7')
+ self.vs_path8 = config.get('RUNTIME', 'vs_path8')
+ self.vs_path9 = config.get('RUNTIME', 'vs_path9')
+ self.innosetup_path = config.get('RUNTIME', 'innosetup_path')
+ self.source = config.get('RUNTIME', 'Source')
+ self.vs_version = config.getint('RUNTIME', 'VSStudio')
+
+ if self.vs_version == 2003:
+ self.vs_path = self.vs_path7
+ elif self.vs_version == 2005:
+ self.vs_path = self.vs_path8
+ elif self.vs_version == 2008:
+ self.vs_path = self.vs_path9
Modified: branches/R2_12/Tools/Scripts/UpgradeProjects.py
===================================================================
--- branches/R2_12/Tools/Scripts/UpgradeProjects.py 2010-09-11 13:03:38 UTC (rev 7244)
+++ branches/R2_12/Tools/Scripts/UpgradeProjects.py 2010-09-12 09:32:59 UTC (rev 7245)
@@ -15,7 +15,7 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#############################################################################
-# Copyright (c) 2008 Kimmo Varis <ki...@wi...>
+# Copyright (c) 2008-2010 Kimmo Varis <ki...@wi...>
# $Id$
@@ -31,34 +31,51 @@
import subprocess
import sys
+import cleanup_backups
+import fix_manifest
+import ToolSettings
+
# The version of the script
-script_version = 0.1
+script_version = 0.4
+# global settings class instance
+tools = ToolSettings.ToolSettings()
+
solutions = [r'Externals\expat\expat.sln',
- r'Externals\pcre\Win32\PCRE.sln',
r'WinMerge.sln']
-projects = [r'Externals\heksedit\heksedit.vcproj',
- r'Externals\scew\win32\scew.vcproj',
+projects = [r'Externals\scew\win32\scew.vcproj',
+ r'Externals\pcre\Win32\pcre.vcproj',
r'ShellExtension\ShellExtension.vcproj']
-# TODO: read this from Tools.ini
-vs_path = r'C:\Program Files\Microsoft Visual Studio 8'
+# These projects need the manifest file fix
+manifest_projects = [r'Src\Merge.vcproj']
def upgrade_projects(root_path):
- vs_binary = os.path.join(vs_path, 'Common7/IDE')
+ vs_binary = os.path.join(tools.vs_path, 'Common7/IDE')
vs_binary = os.path.join(vs_binary, 'devenv.com')
for solution in solutions:
sol_file = os.path.join(root_path, solution)
print 'Upgrading VS solution file: ' + sol_file
subprocess.call([vs_binary, sol_file, '/Upgrade'], shell = True)
+ cleanup(sol_file)
for project in projects:
proj_file = os.path.join(root_path, project)
print 'Upgrading project file: ' + proj_file
subprocess.call([vs_binary, proj_file, '/Upgrade'], shell = True)
+ cleanup(proj_file)
+def fix_proj_manifests(root_path):
+ for project in manifest_projects:
+ proj_file = os.path.join(root_path, project)
+ fix_manifest.process_project_file(proj_file)
+
+def cleanup(updatefile):
+ folder = os.path.dirname(updatefile)
+ cleanup_backups.cleanupfolder(folder)
+
def usage():
'''Print script usage information.'''
@@ -92,9 +109,12 @@
if not os.path.exists(root_path):
print 'ERROR: Cannot find path: ' + root_path
sys.exit()
-
+
+ tools.read_ini('Tools.ini')
+
print 'Upgrading VS solution- and project-file in folder: ' + root_path
upgrade_projects(root_path)
+ fix_proj_manifests(root_path)
# MAIN #
if __name__ == "__main__":
Added: branches/R2_12/Tools/Scripts/cleanup_backups.py
===================================================================
--- branches/R2_12/Tools/Scripts/cleanup_backups.py (rev 0)
+++ branches/R2_12/Tools/Scripts/cleanup_backups.py 2010-09-12 09:32:59 UTC (rev 7245)
@@ -0,0 +1,91 @@
+#############################################################################
+## License (GPLv2+):
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#############################################################################
+
+# Copyright (c) 2010 Kimmo Varis <ki...@wi...>
+
+# $Id: cleanup_backups.py 7087 2010-01-09 16:13:30Z kimmov $
+
+# A script for cleaning up Visual Studio backup files that get created when
+# solution/project files are updated to new version of VS.
+
+import getopt
+import os
+import shutil
+import sys
+
+# The version of the script
+scriptversion = 0.1
+
+def cleanupfolder(folder):
+ reportfolder = os.path.join(folder, r'_UpgradeReport_Files')
+ if os.path.exists(reportfolder):
+ shutil.rmtree(reportfolder)
+
+ logfile = r'UpgradeLog{0}.XML'
+ logfile = os.path.join(folder, logfile.format(''))
+ if os.path.exists(logfile):
+ os.remove(logfile)
+
+ index = 2;
+ existed = True
+ while existed == True:
+ logfile = os.path.join(folder, logfile.format(index))
+ if os.path.exists(logfile):
+ os.remove(logfile)
+ else:
+ existed = False
+ index += 1
+
+def usage():
+ '''Print script usage information.'''
+
+ print 'cleanup_backups.py - version ' + str(scriptversion)
+ print 'Script to cleanup VS solution/project update backup/log files.'
+ print 'Usage: cleanup_backups.py [-h] [path]'
+ print 'Where:'
+ print ' -h, --help Print this help.'
+ print ' path folder where solution/project file is.'
+ print 'For example: cleanup_backups.py src'
+
+def main(argv):
+ rootfolder = ''
+ if len(argv) > 0:
+ opts, args = getopt.getopt(argv, 'h', ['help'])
+
+ for opt, arg in opts:
+ if opt in ('-h', '--help'):
+ usage()
+ sys.exit()
+
+ if len(args) == 1:
+ rel_path = args[0]
+ rootfolder = os.path.abspath(rel_path)
+
+ # If not root path given, use current folder as root path
+ if rootfolder == '':
+ rootfolder = os.getcwd()
+
+ if not os.path.exists(rootfolder):
+ print 'ERROR: Cannot find path: ' + rootfolder
+ sys.exit()
+
+ print 'Removing backups from folder: ' + rootfolder
+ cleanupfolder(rootfolder)
+
+# MAIN #
+if __name__ == "__main__":
+ main(sys.argv[1:])
Modified: branches/R2_12/Tools/Scripts/fix_manifest.py
===================================================================
--- branches/R2_12/Tools/Scripts/fix_manifest.py 2010-09-11 13:03:38 UTC (rev 7244)
+++ branches/R2_12/Tools/Scripts/fix_manifest.py 2010-09-12 09:32:59 UTC (rev 7245)
@@ -34,8 +34,6 @@
# The version of the script
script_version = 0.1
-manifest_path = r'$(InputDir)\res\$(TargetFileName).manifest'
-
def process_project_file(filename):
'''Process a given project file.
@@ -48,14 +46,14 @@
#print 'Opening file ' + filename + ' for parsing...'
fread = open(filename, 'r')
except IOError, (errno, strerror):
- print 'Cannot open file ' + file + ' for reading'
+ print 'Cannot open file ' + filename + ' for reading'
print 'Error: ' + strerror
return False
try:
fwrite = open(outfile, 'w')
except IOError, (errno, strerror):
- print 'Cannot open file ' + infile + ' for writing'
+ print 'Cannot open file ' + outfile + ' for writing'
print 'Error: ' + strerror
fread.close()
return False
@@ -131,6 +129,7 @@
def handle_tool_element(element):
'''Adds new attributes to the element.'''
+ manifest_path = r'$(InputDir)\res\$(TargetFileName).manifest'
element.setAttribute('AdditionalManifestFiles', manifest_path)
element.setAttribute('EmbedManifest', 'true')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|