2012-03-02 17:04:53 +00:00
|
|
|
# Python program to set the version.
|
|
|
|
##############################################
|
|
|
|
|
|
|
|
import re
|
|
|
|
import sys
|
2014-03-15 22:00:54 +00:00
|
|
|
import optparse
|
2012-03-02 17:04:53 +00:00
|
|
|
|
|
|
|
def fileProcess( name, lineFunction ):
|
|
|
|
filestream = open( name, 'r' )
|
|
|
|
if filestream.closed:
|
|
|
|
print( "file " + name + " not open." )
|
|
|
|
return
|
|
|
|
|
|
|
|
output = ""
|
|
|
|
print( "--- Processing " + name + " ---------" )
|
|
|
|
while 1:
|
|
|
|
line = filestream.readline()
|
|
|
|
if not line: break
|
|
|
|
output += lineFunction( line )
|
|
|
|
filestream.close()
|
|
|
|
|
|
|
|
if not output: return # basic error checking
|
|
|
|
|
|
|
|
print( "Writing file " + name )
|
|
|
|
filestream = open( name, "w" );
|
|
|
|
filestream.write( output );
|
|
|
|
filestream.close()
|
|
|
|
|
|
|
|
def echoInput( line ):
|
|
|
|
return line
|
|
|
|
|
2014-03-15 22:00:54 +00:00
|
|
|
parser = optparse.OptionParser( "usage: %prog major minor build" )
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
if len(args) != 3:
|
|
|
|
parser.error( "incorrect number of arguments" );
|
|
|
|
|
|
|
|
major = args[0]
|
|
|
|
minor = args[1]
|
|
|
|
build = args[2]
|
|
|
|
versionStr = major + "." + minor + "." + build
|
2012-03-02 17:04:53 +00:00
|
|
|
|
2014-02-22 06:57:38 +00:00
|
|
|
print ("Setting dox,tinyxml2.h")
|
|
|
|
print ("Version: " + major + "." + minor + "." + build)
|
2012-03-02 17:04:53 +00:00
|
|
|
|
|
|
|
#### Write the tinyxml.h ####
|
|
|
|
|
|
|
|
def engineRule( line ):
|
|
|
|
|
|
|
|
matchMajor = "static const int TIXML2_MAJOR_VERSION"
|
|
|
|
matchMinor = "static const int TIXML2_MINOR_VERSION"
|
|
|
|
matchBuild = "static const int TIXML2_PATCH_VERSION"
|
|
|
|
|
|
|
|
if line[0:len(matchMajor)] == matchMajor:
|
2014-02-22 06:57:38 +00:00
|
|
|
print( "1)tinyxml2.h Major found" )
|
|
|
|
return matchMajor + " = " + major + ";\n"
|
2012-03-02 17:04:53 +00:00
|
|
|
|
|
|
|
elif line[0:len(matchMinor)] == matchMinor:
|
2014-02-22 06:57:38 +00:00
|
|
|
print( "2)tinyxml2.h Minor found" )
|
|
|
|
return matchMinor + " = " + minor + ";\n"
|
2012-03-02 17:04:53 +00:00
|
|
|
|
|
|
|
elif line[0:len(matchBuild)] == matchBuild:
|
2014-02-22 06:57:38 +00:00
|
|
|
print( "3)tinyxml2.h Build found" )
|
|
|
|
return matchBuild + " = " + build + ";\n"
|
2012-03-02 17:04:53 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
return line;
|
|
|
|
|
|
|
|
fileProcess( "tinyxml2.h", engineRule )
|
|
|
|
|
|
|
|
|
|
|
|
#### Write the dox ####
|
|
|
|
|
|
|
|
def doxRule( line ):
|
|
|
|
|
|
|
|
match = "PROJECT_NUMBER"
|
|
|
|
|
|
|
|
if line[0:len( match )] == match:
|
2014-02-22 06:57:38 +00:00
|
|
|
print( "dox project found" )
|
|
|
|
return "PROJECT_NUMBER = " + major + "." + minor + "." + build + "\n"
|
2012-03-02 17:04:53 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
return line;
|
|
|
|
|
|
|
|
fileProcess( "dox", doxRule )
|
|
|
|
|
2012-05-14 21:59:42 +00:00
|
|
|
|
|
|
|
#### Write the CMakeLists.txt ####
|
|
|
|
|
|
|
|
def cmakeRule1( line ):
|
|
|
|
|
|
|
|
matchVersion = "set(GENERIC_LIB_VERSION"
|
|
|
|
|
|
|
|
if line[0:len(matchVersion)] == matchVersion:
|
2014-02-22 06:57:38 +00:00
|
|
|
print( "1)tinyxml2.h Major found" )
|
|
|
|
return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"
|
2012-05-14 21:59:42 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
return line;
|
|
|
|
|
|
|
|
fileProcess( "CMakeLists.txt", cmakeRule1 )
|
|
|
|
|
|
|
|
def cmakeRule2( line ):
|
|
|
|
|
|
|
|
matchSoversion = "set(GENERIC_LIB_SOVERSION"
|
|
|
|
|
|
|
|
if line[0:len(matchSoversion)] == matchSoversion:
|
2014-02-22 06:57:38 +00:00
|
|
|
print( "1)tinyxml2.h Major found" )
|
|
|
|
return matchSoversion + " \"" + major + "\")" + "\n"
|
2012-05-14 21:59:42 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
return line;
|
|
|
|
|
|
|
|
fileProcess( "CMakeLists.txt", cmakeRule2 )
|
2014-03-15 22:00:54 +00:00
|
|
|
|
|
|
|
print( "Release note:" )
|
2014-03-16 17:16:49 +00:00
|
|
|
print( '1. Build. g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
|
|
|
|
print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' )
|
|
|
|
print( '3. Tag. git tag ' + versionStr )
|
2014-09-14 19:47:24 +00:00
|
|
|
print( ' OR git tag -a ' + versionStr + ' -m [tag message]' )
|
|
|
|
print( 'Remember to "git push" both code and tag. For the tag:' )
|
|
|
|
print( 'git push origin [tagname]')
|
|
|
|
|
2014-04-06 21:41:46 +00:00
|
|
|
|