Ezio Melotti | 7c4a7e6 | 2013-08-26 01:32:56 +0300 | [diff] [blame] | 1 | #Run this file after automatic conversion of the VisualStudio 2008 solution by VisualStudio 2010. |
Kristján Valur Jónsson | c45ea9e | 2012-05-19 21:10:14 +0000 | [diff] [blame] | 2 | #This can be done whenever the 2008 solution changes. |
| 3 | #It will make the necessary cleanup and updates to the vcxproj files |
| 4 | #the .props files need to be maintained by hand if the .vsprops files change |
| 5 | |
| 6 | from __future__ import with_statement |
| 7 | import sys |
| 8 | import os |
| 9 | import os.path |
| 10 | |
| 11 | def vs9to10(src, dest): |
| 12 | for name in os.listdir(src): |
| 13 | path, ext = os.path.splitext(name) |
| 14 | if ext.lower() not in ('.vcxproj',): |
| 15 | continue |
| 16 | |
| 17 | filename = os.path.normpath(os.path.join(src, name)) |
| 18 | destname = os.path.normpath(os.path.join(dest, name)) |
| 19 | print("%s -> %s" % (filename, destname)) |
| 20 | |
| 21 | lines = [] |
| 22 | lastline = b"" |
| 23 | importgroup = False |
| 24 | with open(filename, 'rb') as fin: |
| 25 | for line in fin: |
| 26 | #remove redundant linker output info |
| 27 | if b"<OutputLine>" in line: |
| 28 | continue |
| 29 | if b"<ProgramDatabaseFile>" in line: |
| 30 | continue |
| 31 | if b"<ImportLibrary>" in line and b"</ImportLibrary>" in line: |
| 32 | continue |
| 33 | |
| 34 | #add new property sheet to the pythoncore |
| 35 | if importgroup and "pythoncore" in name.lower(): |
| 36 | if b"</ImportGroup>" in line: |
| 37 | if b"debug.props" in lastline: |
| 38 | lines.append(b' <Import Project="pythoncore_d.props" />\r\n') |
| 39 | elif b"pythoncore" not in lastline: |
| 40 | lines.append(b' <Import Project="pythoncore.props" />\r\n') |
| 41 | if b"<ImportGroup Condition" in line: |
| 42 | importgroup = True |
| 43 | elif b"</ImportGroup>" in line: |
| 44 | importgroup = False |
| 45 | lines.append(line) |
| 46 | lastline = line |
| 47 | with open(destname, 'wb') as fout: |
| 48 | for line in lines: |
| 49 | fout.write(line) |
| 50 | |
| 51 | if __name__ == "__main__": |
| 52 | src = "." if len(sys.argv) < 2 else sys.argv[1] |
| 53 | name = os.path.basename(os.path.abspath(src)) |
| 54 | dest = os.path.abspath(os.path.join(src, "..", name + "Upd")) |
| 55 | os.makedirs(dest) |
| 56 | vs9to10(src, dest) |