You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.2 KiB

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