version2code.py 682 B

1234567891011121314151617181920212223
  1. # Generates version include file.
  2. from outpututils import rewriteIfChanged
  3. from version import extractRevisionString, packageVersion, releaseFlag
  4. import sys
  5. def iterVersionInclude():
  6. revision = extractRevisionString()
  7. yield '// Automatically generated by build process.'
  8. yield 'const bool Version::RELEASE = %s;' % str(releaseFlag).lower()
  9. yield 'const char* const Version::VERSION = "%s";' % packageVersion
  10. yield 'const char* const Version::REVISION = "%s";' % revision
  11. if __name__ == '__main__':
  12. if len(sys.argv) == 2:
  13. rewriteIfChanged(sys.argv[1], iterVersionInclude())
  14. else:
  15. print >> sys.stderr, \
  16. 'Usage: python version2code.py VERSION_HEADER'
  17. sys.exit(2)