blob: eb7dab50b882a4b88daddd510ebc9eeb94c9227d [file] [log] [blame]
Ezio Melotti7c4a7e62013-08-26 01:32:56 +03001#Run this file after automatic conversion of the VisualStudio 2008 solution by VisualStudio 2010.
Kristján Valur Jónssonc45ea9e2012-05-19 21:10:14 +00002#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
6from __future__ import with_statement
7import sys
8import os
9import os.path
10
11def 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
51if __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)