blob: 0bf5ad43db4fc0902b20237395a2a3ee40c0d73e [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
Elliott Hughesd173c992019-01-10 14:51:35 -080070def macroVersionRule( line ):
71
72 matchMajor = "#define TINYXML2_MAJOR_VERSION"
73 matchMinor = "#define TINYXML2_MINOR_VERSION"
74 matchBuild = "#define TINYXML2_PATCH_VERSION"
75
76 if line[0:len(matchMajor)] == matchMajor:
77 print( "1)macro Major found" )
78 return matchMajor + " " + major + "\n"
79
80 elif line[0:len(matchMinor)] == matchMinor:
81 print( "2)macro Minor found" )
82 return matchMinor + " " + minor + "\n"
83
84 elif line[0:len(matchBuild)] == matchBuild:
85 print( "3)macro Build found" )
86 return matchBuild + " " + build + "\n"
87
88 else:
89 return line;
90
91fileProcess("tinyxml2.h", macroVersionRule)
Narayan Kamath74c03bb2017-12-22 10:59:43 +000092
93#### Write the dox ####
94
95def doxRule( line ):
96
97 match = "PROJECT_NUMBER"
98
99 if line[0:len( match )] == match:
100 print( "dox project found" )
101 return "PROJECT_NUMBER = " + major + "." + minor + "." + build + "\n"
102
103 else:
104 return line;
105
106fileProcess( "dox", doxRule )
107
108
109#### Write the CMakeLists.txt ####
110
111def cmakeRule1( line ):
112
113 matchVersion = "set(GENERIC_LIB_VERSION"
114
115 if line[0:len(matchVersion)] == matchVersion:
116 print( "1)tinyxml2.h Major found" )
117 return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"
118
119 else:
120 return line;
121
122fileProcess( "CMakeLists.txt", cmakeRule1 )
123
124def cmakeRule2( line ):
125
126 matchSoversion = "set(GENERIC_LIB_SOVERSION"
127
128 if line[0:len(matchSoversion)] == matchSoversion:
129 print( "1)tinyxml2.h Major found" )
130 return matchSoversion + " \"" + major + "\")" + "\n"
131
132 else:
133 return line;
134
135fileProcess( "CMakeLists.txt", cmakeRule2 )
136
137print( "Release note:" )
Elliott Hughesd173c992019-01-10 14:51:35 -0800138print( '1. Build. g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
Narayan Kamath74c03bb2017-12-22 10:59:43 +0000139print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' )
140print( '3. Tag. git tag ' + versionStr )
141print( ' OR git tag -a ' + versionStr + ' -m [tag message]' )
142print( 'Remember to "git push" both code and tag. For the tag:' )
143print( 'git push origin [tagname]')
144
145