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