public
Last active

A quick-and-dirty python script to find invalid ClInclude nodes in VS 2010 projects

  • Download Gist
check_inc.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#!/c/Python32/python.exe
import sys
import os.path
import xml.etree.ElementTree as ET
 
ns = '{http://schemas.microsoft.com/developer/msbuild/2003}'
 
filterTree = ET.parse(sys.argv[1]+".filters")
filterRoot = filterTree.getroot()
filterDict = dict()
missingDict = dict()
 
for inc in filterRoot.iter(ns+'ClInclude'):
incFileRel = inc.get('Include')
incFilter = inc.find(ns+'Filter')
if incFileRel != None and incFilter != None:
filterDict[incFileRel] = incFilter.text
if incFilter.text not in missingDict:
missingDict[incFilter.text] = []
 
projTree = ET.parse(sys.argv[1])
projRoot = projTree.getroot()
 
for inc in projRoot.iter(ns+'ClInclude'):
incFileRel = inc.get('Include')
if incFileRel != None:
incFile = os.path.abspath( os.path.dirname(sys.argv[1]) +"\\"+ incFileRel )
if not os.path.exists(incFile):
missingDict[filterDict[incFileRel]].append(incFileRel)
 
for (missingGroup, missingList) in missingDict.items():
if len(missingList) > 0:
print("["+missingGroup+"]:")
for missing in missingList:
print(" " + os.path.basename(missing) + " (" + missing + ")")

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.