blob: b8c4472c26620b473cc76fdaae2cf27e5052e1f1 [file] [log] [blame]
Lee Thomason27057312012-03-02 09:04:53 -08001# Python program to set the version.
2##############################################
3
4import re
5import sys
6
7def 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
29def echoInput( line ):
30 return line
31
32major = input( "Major: " )
33minor = input( "Minor: " )
34build = input( "Build: " )
35
Lee Thomason5f88e722014-02-21 22:57:38 -080036print ("Setting dox,tinyxml2.h")
37print ("Version: " + major + "." + minor + "." + build)
Lee Thomason27057312012-03-02 09:04:53 -080038
39#### Write the tinyxml.h ####
40
41def 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:
Lee Thomason5f88e722014-02-21 22:57:38 -080048 print( "1)tinyxml2.h Major found" )
49 return matchMajor + " = " + major + ";\n"
Lee Thomason27057312012-03-02 09:04:53 -080050
51 elif line[0:len(matchMinor)] == matchMinor:
Lee Thomason5f88e722014-02-21 22:57:38 -080052 print( "2)tinyxml2.h Minor found" )
53 return matchMinor + " = " + minor + ";\n"
Lee Thomason27057312012-03-02 09:04:53 -080054
55 elif line[0:len(matchBuild)] == matchBuild:
Lee Thomason5f88e722014-02-21 22:57:38 -080056 print( "3)tinyxml2.h Build found" )
57 return matchBuild + " = " + build + ";\n"
Lee Thomason27057312012-03-02 09:04:53 -080058
59 else:
60 return line;
61
62fileProcess( "tinyxml2.h", engineRule )
63
64
65#### Write the dox ####
66
67def doxRule( line ):
68
69 match = "PROJECT_NUMBER"
70
71 if line[0:len( match )] == match:
Lee Thomason5f88e722014-02-21 22:57:38 -080072 print( "dox project found" )
73 return "PROJECT_NUMBER = " + major + "." + minor + "." + build + "\n"
Lee Thomason27057312012-03-02 09:04:53 -080074
75 else:
76 return line;
77
78fileProcess( "dox", doxRule )
79
hasufellaba89e32012-05-14 23:59:42 +020080
81#### Write the CMakeLists.txt ####
82
83def cmakeRule1( line ):
84
85 matchVersion = "set(GENERIC_LIB_VERSION"
86
87 if line[0:len(matchVersion)] == matchVersion:
Lee Thomason5f88e722014-02-21 22:57:38 -080088 print( "1)tinyxml2.h Major found" )
89 return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"
hasufellaba89e32012-05-14 23:59:42 +020090
91 else:
92 return line;
93
94fileProcess( "CMakeLists.txt", cmakeRule1 )
95
96def cmakeRule2( line ):
97
98 matchSoversion = "set(GENERIC_LIB_SOVERSION"
99
100 if line[0:len(matchSoversion)] == matchSoversion:
Lee Thomason5f88e722014-02-21 22:57:38 -0800101 print( "1)tinyxml2.h Major found" )
102 return matchSoversion + " \"" + major + "\")" + "\n"
hasufellaba89e32012-05-14 23:59:42 +0200103
104 else:
105 return line;
106
107fileProcess( "CMakeLists.txt", cmakeRule2 )