validate_d3d_compiler.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # This file is part of Desktop App Toolkit,
  2. # a set of libraries for developing nice desktop applications.
  3. #
  4. # For license and copyright information please follow this link:
  5. # https://github.com/desktop-app/legal/blob/master/LEGAL
  6. from __future__ import print_function
  7. import sys, os, re, hashlib
  8. def error(*args, **kwargs):
  9. print(*args, file=sys.stderr, **kwargs)
  10. sys.exit(1)
  11. try:
  12. from win32api import GetFileVersionInfo
  13. except ImportError:
  14. error('Python module "pywin32" is not installed.\n\nTry "' + sys.executable + ' -m pip install pywin32".')
  15. if len(sys.argv) < 2:
  16. error('Expected input path to "d3dcompiler_47.dll".')
  17. inputPath = sys.argv[1]
  18. if not os.path.exists(inputPath):
  19. error('File "' + inputPath + '" doesn\'t exist.')
  20. info = GetFileVersionInfo(inputPath, '\\')
  21. version = [ info['FileVersionMS'] // 65536, info['FileVersionMS'] % 65536, info['FileVersionLS'] // 65536, info['FileVersionLS'] % 65536 ]
  22. if (version != [10, 0, 22621, 3233]):
  23. error('Bad "d3dcompiler_47.dll" version: ' + '.'.join(str(x) for x in version))
  24. bufferSize = 1024 * 1024
  25. sha256 = hashlib.sha256()
  26. with open(inputPath, 'rb') as f:
  27. print(hashlib.sha256(f.read()).hexdigest())