Created
April 13, 2013 10:34
-
-
Save vitallium/5377893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import os | |
| from xml.etree import ElementTree | |
| def updateProject(filename): | |
| def getXmlns(tag): | |
| return tag[1:].split('}')[0] | |
| tree = ElementTree.parse(filename) | |
| root = tree.getroot() | |
| xmlns = getXmlns(root.tag) | |
| for cb in root.iter('{' + xmlns + '}CustomBuild'): | |
| if(not 'Include' in cb.attrib): | |
| continue | |
| if(not cb.attrib['Include'].endswith('.res')): | |
| continue | |
| for excl in cb.iter('{' + xmlns + '}ExcludedFromBuild'): | |
| if('Condition' in excl.attrib): | |
| del excl.attrib['Condition'] # delete ExcludedFromBuild condition | |
| ElementTree.register_namespace('', xmlns) | |
| tree.write(filename) | |
| if(len(sys.argv)>=2): # use project files specified in command line: | |
| for i in range(1, len(sys.argv)): | |
| updateProject(sys.argv[i]) | |
| else: # update all project files in current directory: | |
| for filename in os.listdir(os.getcwd()): | |
| if(filename.endswith('.vcxproj')): | |
| updateProject(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment