diff options
author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2012-05-19 21:10:14 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2012-05-19 21:10:14 (GMT) |
commit | c45ea9ebc774d46260230a76e5b8c3c1de020250 (patch) | |
tree | d7d15cba51f5f49bb73c99a2822fb8ef8597d7d9 /PCbuild/vs9to10.py | |
parent | 7fc570a51e6d8647d73e152721b2e72add72d134 (diff) | |
download | cpython-c45ea9ebc774d46260230a76e5b8c3c1de020250.zip cpython-c45ea9ebc774d46260230a76e5b8c3c1de020250.tar.gz cpython-c45ea9ebc774d46260230a76e5b8c3c1de020250.tar.bz2 |
Clean up the PCBuild project files, removing redundant settings and
use "references" to link to dependent projects.
Update readme and batch files.
Diffstat (limited to 'PCbuild/vs9to10.py')
-rw-r--r-- | PCbuild/vs9to10.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/PCbuild/vs9to10.py b/PCbuild/vs9to10.py new file mode 100644 index 0000000..8bf832a --- /dev/null +++ b/PCbuild/vs9to10.py @@ -0,0 +1,56 @@ +#Run this file after automatic convertsion of the VisualStudio 2008 solution by VisualStudio 2010. +#This can be done whenever the 2008 solution changes. +#It will make the necessary cleanup and updates to the vcxproj files +#the .props files need to be maintained by hand if the .vsprops files change + +from __future__ import with_statement +import sys +import os +import os.path + +def vs9to10(src, dest): + for name in os.listdir(src): + path, ext = os.path.splitext(name) + if ext.lower() not in ('.vcxproj',): + continue + + filename = os.path.normpath(os.path.join(src, name)) + destname = os.path.normpath(os.path.join(dest, name)) + print("%s -> %s" % (filename, destname)) + + lines = [] + lastline = b"" + importgroup = False + with open(filename, 'rb') as fin: + for line in fin: + #remove redundant linker output info + if b"<OutputLine>" in line: + continue + if b"<ProgramDatabaseFile>" in line: + continue + if b"<ImportLibrary>" in line and b"</ImportLibrary>" in line: + continue + + #add new property sheet to the pythoncore + if importgroup and "pythoncore" in name.lower(): + if b"</ImportGroup>" in line: + if b"debug.props" in lastline: + lines.append(b' <Import Project="pythoncore_d.props" />\r\n') + elif b"pythoncore" not in lastline: + lines.append(b' <Import Project="pythoncore.props" />\r\n') + if b"<ImportGroup Condition" in line: + importgroup = True + elif b"</ImportGroup>" in line: + importgroup = False + lines.append(line) + lastline = line + with open(destname, 'wb') as fout: + for line in lines: + fout.write(line) + +if __name__ == "__main__": + src = "." if len(sys.argv) < 2 else sys.argv[1] + name = os.path.basename(os.path.abspath(src)) + dest = os.path.abspath(os.path.join(src, "..", name + "Upd")) + os.makedirs(dest) + vs9to10(src, dest) |