PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Src/Dependencies/Boost/tools/build/v2/engine/bump_version.py

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