win_resource.py 799 B

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