blob: 11b2e75e4a94868ce762ba8df6f9fefaef3863a3 [file] [log] [blame]
Lee Thomason27057312012-03-02 09:04:53 -08001# Python program to set the version.
2##############################################
3
4import re
5import sys
Lee Thomason5938e6f2014-03-15 15:00:54 -07006import optparse
Lee Thomason27057312012-03-02 09:04:53 -08007
8def fileProcess( name, lineFunction ):
9 filestream = open( name, 'r' )
10 if filestream.closed:
11 print( "file " + name + " not open." )
12 return
13
14 output = ""
15 print( "--- Processing " + name + " ---------" )
16 while 1:
17 line = filestream.readline()
18 if not line: break
19 output += lineFunction( line )
20 filestream.close()
21
22 if not output: return # basic error checking
23
24 print( "Writing file " + name )
25 filestream = open( name, "w" );
26 filestream.write( output );
27 filestream.close()
28
29
30def echoInput( line ):
31 return line
32
Lee Thomason5938e6f2014-03-15 15:00:54 -070033parser = optparse.OptionParser( "usage: %prog major minor build" )
34(options, args) = parser.parse_args()
35if len(args) != 3:
36 parser.error( "incorrect number of arguments" );
37
38major = args[0]
39minor = args[1]
40build = args[2]
41versionStr = major + "." + minor + "." + build
Lee Thomason27057312012-03-02 09:04:53 -080042
43print "Setting dox,tinyxml2.h"
44print "Version: " + `major` + "." + `minor` + "." + `build`
45
46#### Write the tinyxml.h ####
47
48def engineRule( line ):
49
50 matchMajor = "static const int TIXML2_MAJOR_VERSION"
51 matchMinor = "static const int TIXML2_MINOR_VERSION"
52 matchBuild = "static const int TIXML2_PATCH_VERSION"
53
54 if line[0:len(matchMajor)] == matchMajor:
55 print "1)tinyxml2.h Major found"
56 return matchMajor + " = " + `major` + ";\n"
57
58 elif line[0:len(matchMinor)] == matchMinor:
59 print "2)tinyxml2.h Minor found"
60 return matchMinor + " = " + `minor` + ";\n"
61
62 elif line[0:len(matchBuild)] == matchBuild:
63 print "3)tinyxml2.h Build found"
64 return matchBuild + " = " + `build` + ";\n"
65
66 else:
67 return line;
68
69fileProcess( "tinyxml2.h", engineRule )
70
71
72#### Write the dox ####
73
74def doxRule( line ):
75
76 match = "PROJECT_NUMBER"
77
78 if line[0:len( match )] == match:
79 print "dox project found"
80 return "PROJECT_NUMBER = " + `major` + "." + `minor` + "." + `build` + "\n"
81
82 else:
83 return line;
84
85fileProcess( "dox", doxRule )
86
hasufellaba89e32012-05-14 23:59:42 +020087
88#### Write the CMakeLists.txt ####
89
90def cmakeRule1( line ):
91
92 matchVersion = "set(GENERIC_LIB_VERSION"
93
94 if line[0:len(matchVersion)] == matchVersion:
95 print "1)tinyxml2.h Major found"
96 return matchVersion + " \"" + `major` + "." + `minor` + "." + `build` + "\")" + "\n"
97
98 else:
99 return line;
100
101fileProcess( "CMakeLists.txt", cmakeRule1 )
102
103def cmakeRule2( line ):
104
105 matchSoversion = "set(GENERIC_LIB_SOVERSION"
106
107 if line[0:len(matchSoversion)] == matchSoversion:
108 print "1)tinyxml2.h Major found"
109 return matchSoversion + " \"" + `major` + "\")" + "\n"
110
111 else:
112 return line;
113
114fileProcess( "CMakeLists.txt", cmakeRule2 )
Lee Thomason5938e6f2014-03-15 15:00:54 -0700115
116print( "Release note:" )
117print( '1. Build. Ex: g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
118print( '2. Commit. git commit -am"setting the version to ` + versionStr + '" )
119print( '3. Tag. git tag ' + versionStr )