version2code.py 681 B

12345678910111213141516171819202122
  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('Usage: python3 version2code.py VERSION_HEADER', file=sys.stderr)
  16. sys.exit(2)