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 | |
---|
12 | import os |
---|
13 | import os.path |
---|
14 | import re |
---|
15 | import string |
---|
16 | import sys |
---|
17 | |
---|
18 | srcdir = os.path.abspath(os.path.dirname(__file__ )) |
---|
19 | docdir = os.path.abspath(os.path.join(srcdir,"..","doc")) |
---|
20 | |
---|
21 | def 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 | |
---|
31 | def 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 | |
---|
64 | def 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 | |
---|
74 | if __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) |
---|