setversion.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Python program to set the version.
  2. ##############################################
  3. import re
  4. import sys
  5. def fileProcess( name, lineFunction ):
  6. filestream = open( name, 'r' )
  7. if filestream.closed:
  8. print( "file " + name + " not open." )
  9. return
  10. output = ""
  11. print( "--- Processing " + name + " ---------" )
  12. while 1:
  13. line = filestream.readline()
  14. if not line: break
  15. output += lineFunction( line )
  16. filestream.close()
  17. if not output: return # basic error checking
  18. print( "Writing file " + name )
  19. filestream = open( name, "w" );
  20. filestream.write( output );
  21. filestream.close()
  22. def echoInput( line ):
  23. return line
  24. major = input( "Major: " )
  25. minor = input( "Minor: " )
  26. build = input( "Build: " )
  27. print "Setting dox,tinyxml2.h"
  28. print "Version: " + `major` + "." + `minor` + "." + `build`
  29. #### Write the tinyxml.h ####
  30. def engineRule( line ):
  31. matchMajor = "static const int TIXML2_MAJOR_VERSION"
  32. matchMinor = "static const int TIXML2_MINOR_VERSION"
  33. matchBuild = "static const int TIXML2_PATCH_VERSION"
  34. if line[0:len(matchMajor)] == matchMajor:
  35. print "1)tinyxml2.h Major found"
  36. return matchMajor + " = " + `major` + ";\n"
  37. elif line[0:len(matchMinor)] == matchMinor:
  38. print "2)tinyxml2.h Minor found"
  39. return matchMinor + " = " + `minor` + ";\n"
  40. elif line[0:len(matchBuild)] == matchBuild:
  41. print "3)tinyxml2.h Build found"
  42. return matchBuild + " = " + `build` + ";\n"
  43. else:
  44. return line;
  45. fileProcess( "tinyxml2.h", engineRule )
  46. #### Write the dox ####
  47. def doxRule( line ):
  48. match = "PROJECT_NUMBER"
  49. if line[0:len( match )] == match:
  50. print "dox project found"
  51. return "PROJECT_NUMBER = " + `major` + "." + `minor` + "." + `build` + "\n"
  52. else:
  53. return line;
  54. fileProcess( "dox", doxRule )