blob: 85523d75ddf36576ad8346e63b1ddc35f3cbfd26 [file] [log] [blame]
Narayan Kamath74c03bb2017-12-22 10:59:43 +00001# Python program to set the version.
2##############################################
3
4import re
5import sys
6import optparse
7
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
29def echoInput( line ):
30 return line
31
32parser = optparse.OptionParser( "usage: %prog major minor build" )
33(options, args) = parser.parse_args()
34if len(args) != 3:
35 parser.error( "incorrect number of arguments" );
36
37major = args[0]
38minor = args[1]
39build = args[2]
40versionStr = major + "." + minor + "." + build
41
42print ("Setting dox,tinyxml2.h")
43print ("Version: " + major + "." + minor + "." + build)
44
45#### Write the tinyxml.h ####
46
47def engineRule( line ):
48
49 matchMajor = "static const int TIXML2_MAJOR_VERSION"
50 matchMinor = "static const int TIXML2_MINOR_VERSION"
51 matchBuild = "static const int TIXML2_PATCH_VERSION"
52
53 if line[0:len(matchMajor)] == matchMajor:
54 print( "1)tinyxml2.h Major found" )
55 return matchMajor + " = " + major + ";\n"
56
57 elif line[0:len(matchMinor)] == matchMinor:
58 print( "2)tinyxml2.h Minor found" )
59 return matchMinor + " = " + minor + ";\n"
60
61 elif line[0:len(matchBuild)] == matchBuild:
62 print( "3)tinyxml2.h Build found" )
63 return matchBuild + " = " + build + ";\n"
64
65 else:
66 return line;
67
68fileProcess( "tinyxml2.h", engineRule )
69
70
71#### Write the dox ####
72
73def doxRule( line ):
74
75 match = "PROJECT_NUMBER"
76
77 if line[0:len( match )] == match:
78 print( "dox project found" )
79 return "PROJECT_NUMBER = " + major + "." + minor + "." + build + "\n"
80
81 else:
82 return line;
83
84fileProcess( "dox", doxRule )
85
86
87#### Write the CMakeLists.txt ####
88
89def cmakeRule1( line ):
90
91 matchVersion = "set(GENERIC_LIB_VERSION"
92
93 if line[0:len(matchVersion)] == matchVersion:
94 print( "1)tinyxml2.h Major found" )
95 return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"
96
97 else:
98 return line;
99
100fileProcess( "CMakeLists.txt", cmakeRule1 )
101
102def cmakeRule2( line ):
103
104 matchSoversion = "set(GENERIC_LIB_SOVERSION"
105
106 if line[0:len(matchSoversion)] == matchSoversion:
107 print( "1)tinyxml2.h Major found" )
108 return matchSoversion + " \"" + major + "\")" + "\n"
109
110 else:
111 return line;
112
113fileProcess( "CMakeLists.txt", cmakeRule2 )
114
115print( "Release note:" )
116print( '1. Build. g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
117print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' )
118print( '3. Tag. git tag ' + versionStr )
119print( ' OR git tag -a ' + versionStr + ' -m [tag message]' )
120print( 'Remember to "git push" both code and tag. For the tag:' )
121print( 'git push origin [tagname]')
122
123