win_resource.py 772 B

12345678910111213141516171819202122232425
  1. # Generates Windows resource header.
  2. from outpututils import rewriteIfChanged
  3. from version import (
  4. extractRevisionNumber, getDetailedVersion, packageVersionNumber
  5. )
  6. import sys
  7. def iterResourceHeader():
  8. versionComponents = packageVersionNumber.split('.')
  9. versionComponents += ['0'] * (3 - len(versionComponents))
  10. versionComponents.append(str(extractRevisionNumber()))
  11. assert len(versionComponents) == 4, versionComponents
  12. yield '#define OPENMSX_VERSION_INT %s' % ', '.join(versionComponents)
  13. yield '#define OPENMSX_VERSION_STR "%s\\0"' % getDetailedVersion()
  14. if __name__ == '__main__':
  15. if len(sys.argv) == 2:
  16. rewriteIfChanged(sys.argv[1], iterResourceHeader())
  17. else:
  18. print('Usage: python3 win-resource.py RESOURCE_HEADER', file=sys.stderr)
  19. sys.exit(2)