File: setversion.py

package info (click to toggle)
encfs 1.9.5-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 13,560 kB
  • sloc: cpp: 77,790; python: 9,665; xml: 3,888; sh: 995; perl: 866; makefile: 513; ansic: 213; exp: 16; sed: 16
file content (123 lines) | stat: -rwxr-xr-x 3,102 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Python program to set the version.
##############################################

import re
import sys
import optparse

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

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

print ("Setting dox,tinyxml2.h")
print ("Version: " + major + "." + minor + "." + build)

#### 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:
		print( "1)tinyxml2.h Major found" )
		return matchMajor + " = " + major + ";\n"

	elif line[0:len(matchMinor)] == matchMinor:
		print( "2)tinyxml2.h Minor found" )
		return matchMinor + " = " + minor + ";\n"

	elif line[0:len(matchBuild)] == matchBuild:
		print( "3)tinyxml2.h Build found" )
		return matchBuild + " = " + build + ";\n"

	else:
		return line;

fileProcess( "tinyxml2.h", engineRule )


#### Write the dox ####

def doxRule( line ):

	match = "PROJECT_NUMBER"

	if line[0:len( match )] == match:
		print( "dox project found" )
		return "PROJECT_NUMBER = " + major + "." + minor + "." + build + "\n"

	else:
		return line;

fileProcess( "dox", doxRule )


#### Write the CMakeLists.txt ####

def cmakeRule1( line ):

	matchVersion = "set(GENERIC_LIB_VERSION"

	if line[0:len(matchVersion)] == matchVersion:
		print( "1)tinyxml2.h Major found" )
		return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"

	else:
		return line;

fileProcess( "CMakeLists.txt", cmakeRule1 )

def cmakeRule2( line ):

	matchSoversion = "set(GENERIC_LIB_SOVERSION"

	if line[0:len(matchSoversion)] == matchSoversion:
		print( "1)tinyxml2.h Major found" )
		return matchSoversion + " \"" + major + "\")" + "\n"

	else:
		return line;

fileProcess( "CMakeLists.txt", cmakeRule2 )

print( "Release note:" )
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 )
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]')