Lee Thomason | 2705731 | 2012-03-02 09:04:53 -0800 | [diff] [blame] | 1 | # Python program to set the version.
|
| 2 | ##############################################
|
| 3 |
|
| 4 | import re
|
| 5 | import sys
|
| 6 |
|
| 7 | def fileProcess( name, lineFunction ):
|
| 8 | filestream = open( name, 'r' )
|
| 9 | if filestream.closed:
|
| 10 | print( "file " + name + " not open." )
|
| 11 | return
|
| 12 |
|
| 13 | output = ""
|
| 14 | print( "--- Processing " + name + " ---------" )
|
| 15 | while 1:
|
| 16 | line = filestream.readline()
|
| 17 | if not line: break
|
| 18 | output += lineFunction( line )
|
| 19 | filestream.close()
|
| 20 |
|
| 21 | if not output: return # basic error checking
|
| 22 |
|
| 23 | print( "Writing file " + name )
|
| 24 | filestream = open( name, "w" );
|
| 25 | filestream.write( output );
|
| 26 | filestream.close()
|
| 27 |
|
| 28 |
|
| 29 | def echoInput( line ):
|
| 30 | return line
|
| 31 |
|
| 32 | major = input( "Major: " )
|
| 33 | minor = input( "Minor: " )
|
| 34 | build = input( "Build: " )
|
| 35 |
|
| 36 | print "Setting dox,tinyxml2.h"
|
| 37 | print "Version: " + `major` + "." + `minor` + "." + `build`
|
| 38 |
|
| 39 | #### Write the tinyxml.h ####
|
| 40 |
|
| 41 | def engineRule( line ):
|
| 42 |
|
| 43 | matchMajor = "static const int TIXML2_MAJOR_VERSION"
|
| 44 | matchMinor = "static const int TIXML2_MINOR_VERSION"
|
| 45 | matchBuild = "static const int TIXML2_PATCH_VERSION"
|
| 46 |
|
| 47 | if line[0:len(matchMajor)] == matchMajor:
|
| 48 | print "1)tinyxml2.h Major found"
|
| 49 | return matchMajor + " = " + `major` + ";\n"
|
| 50 |
|
| 51 | elif line[0:len(matchMinor)] == matchMinor:
|
| 52 | print "2)tinyxml2.h Minor found"
|
| 53 | return matchMinor + " = " + `minor` + ";\n"
|
| 54 |
|
| 55 | elif line[0:len(matchBuild)] == matchBuild:
|
| 56 | print "3)tinyxml2.h Build found"
|
| 57 | return matchBuild + " = " + `build` + ";\n"
|
| 58 |
|
| 59 | else:
|
| 60 | return line;
|
| 61 |
|
| 62 | fileProcess( "tinyxml2.h", engineRule )
|
| 63 |
|
| 64 |
|
| 65 | #### Write the dox ####
|
| 66 |
|
| 67 | def doxRule( line ):
|
| 68 |
|
| 69 | match = "PROJECT_NUMBER"
|
| 70 |
|
| 71 | if line[0:len( match )] == match:
|
| 72 | print "dox project found"
|
| 73 | return "PROJECT_NUMBER = " + `major` + "." + `minor` + "." + `build` + "\n"
|
| 74 |
|
| 75 | else:
|
| 76 | return line;
|
| 77 |
|
| 78 | fileProcess( "dox", doxRule )
|
| 79 |
|