86
|
1 |
import os;
|
|
2 |
|
|
3 |
BUILDNO_FILE = 'buildno.txt'
|
|
4 |
|
|
5 |
PKG_FILE_UDEB_TEMPLATE = 'podcatcher_udeb_template.pkg'
|
|
6 |
PKG_FILE_UDEB = 'podcatcher_udeb.pkg'
|
|
7 |
PKG_FILE_UREL_TEMPLATE = 'podcatcher_urel_template.pkg'
|
|
8 |
PKG_FILE_UREL = 'podcatcher_urel.pkg'
|
|
9 |
HEADER_FILE = '..\\inc\\buildno.h'
|
|
10 |
BUILDNO_TAG = 'BUILDNO'
|
|
11 |
|
|
12 |
def update_buildno(buildno_file):
|
|
13 |
#read previous build number
|
|
14 |
f = open(buildno_file, 'r')
|
|
15 |
buildno = int(f.read())
|
|
16 |
f.close()
|
|
17 |
|
|
18 |
# increment build number and write it back to the file
|
|
19 |
buildno = buildno + 1
|
|
20 |
buildno_str = '%d' % buildno
|
|
21 |
|
|
22 |
print 'New build number is %d' % buildno
|
|
23 |
|
|
24 |
f = open(buildno_file, 'w')
|
|
25 |
f.write(buildno_str)
|
|
26 |
f.close()
|
|
27 |
return buildno
|
|
28 |
|
|
29 |
def update_pkg(pkg_template, pkg_file, buildno):
|
|
30 |
print 'Writing %s' % pkg_file
|
|
31 |
#update 'build' number in PKG file
|
|
32 |
f = open (pkg_template, 'r')
|
|
33 |
g = open (pkg_file, 'w')
|
|
34 |
|
|
35 |
buildno_str = '%d' % buildno
|
|
36 |
|
|
37 |
for line in f:
|
|
38 |
line = line.replace(BUILDNO_TAG, buildno_str)
|
|
39 |
g.write(line)
|
|
40 |
|
|
41 |
def update_header(header_file, buildno):
|
|
42 |
print 'Writing %s' % header_file
|
|
43 |
buildno_str = '// Build number generated by increment_buildno.py, do not edit manually\r\n#define BUILD_NO %d' % buildno
|
|
44 |
|
|
45 |
f = open(header_file, 'w')
|
|
46 |
f.write(buildno_str)
|
|
47 |
f.close()
|
|
48 |
return buildno
|
|
49 |
|
|
50 |
new_buildno = update_buildno(BUILDNO_FILE)
|
|
51 |
update_pkg(PKG_FILE_UDEB_TEMPLATE, PKG_FILE_UDEB, new_buildno)
|
|
52 |
update_pkg(PKG_FILE_UREL_TEMPLATE, PKG_FILE_UREL, new_buildno)
|
|
53 |
update_header(HEADER_FILE, new_buildno)
|
|
54 |
print 'Remember to rebuild to get the build number into the about dialog!' |