Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/jam/src/bump_version.py @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.6 KB
Line 
1#!/usr/bin/python
2
3# This script is used to bump version of bjam. It takes a single argument, e.g
4#
5#    ./bump_version.py 3.1.9
6#
7# and updates all necessary files. For the time being, it's assumes presense
8# of 'perl' executable and Debian-specific 'dch' executable.
9#
10
11
12import os
13import os.path
14import re
15import string
16import sys
17
18srcdir = os.path.abspath(os.path.dirname(__file__ ))
19docdir = os.path.abspath(os.path.join(srcdir,"..","doc"))
20
21def edit(file,replacements):
22    print "  '%s'..." %(file)
23    text = open(file,'r').read()
24    while len(replacements) > 0:
25        #~ print  "  '%s' ==> '%s'" % (replacements[0],replacements[1])
26        text = re.compile(replacements[0],re.M).subn(replacements[1],text)[0]
27        replacements = replacements[2:]
28    #~ print text
29    open(file,'w').write(text)
30
31def make_edits(version):
32    edit(os.path.join(srcdir,"boost-jam.spec"), [
33        '^Version:.*$','Version: %s' % string.join(version, "."),
34        ])
35
36    edit(os.path.join(srcdir,"build.jam"), [
37        '^_VERSION_ = .* ;$','_VERSION_ = %s %s %s ;' % (version[0], version[1], version[2]),
38        ])
39
40    edit(os.path.join(docdir,"bjam.qbk"), [
41        '\[version.*\]','[version: %s]' % string.join(version, '.'),
42        '\[def :version:.*\]','[def :version: %s]' % string.join(version, '.'),
43        ])
44
45    edit(os.path.join(srcdir,"patchlevel.h"), [
46        '^#define VERSION_MAJOR .*$',
47            '#define VERSION_MAJOR %s' % (version[0]),
48        '^#define VERSION_MINOR .*$',
49            '#define VERSION_MINOR %s' % (version[1]),
50        '^#define VERSION_PATCH .*$',
51            '#define VERSION_PATCH %s' % (version[2]),
52        '^#define VERSION_MAJOR_SYM .*$',
53            '#define VERSION_MAJOR_SYM "0%s"' % (version[0]),
54        '^#define VERSION_MINOR_SYM .*$',
55            '#define VERSION_MINOR_SYM "%s"' % (version[1]),
56        '^#define VERSION_PATCH_SYM .*$',
57            '#define VERSION_PATCH_SYM "%s"' % (version[2]),
58        '^#define VERSION .*$',
59            '#define VERSION "%s"' % string.join(version, '.'),
60        '^#define JAMVERSYM .*$',
61            '#define JAMVERSYM "JAMVERSION=%s.%s"' % (version[0],version[1]),
62        ])
63
64def main():
65
66    if len(sys.argv) < 2:
67        print "Expect new version as argument"
68        sys.exit(1)
69
70    version = string.split(sys.argv[1], ".")
71    print "Setting version to", version
72    make_edits(version)
73
74if __name__ == '__main__':
75    main()
76
77#~ Copyright 2006 Rene Rivera.
78#~ Copyright 2005-2006 Vladimir Prus.
79#~ Distributed under the Boost Software License, Version 1.0.
80#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Note: See TracBrowser for help on using the repository browser.