packagewindows.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. from install import installAll
  2. from version import (
  3. extractRevisionNumber, getVersionedPackageName, packageVersionNumber,
  4. releaseFlag
  5. )
  6. from os import makedirs, remove, rmdir, sep, walk
  7. from os.path import exists, join as joinpath
  8. import sys
  9. def emptyOrCreateDirectory(top):
  10. if exists(top):
  11. _emptyDirectory(top)
  12. else:
  13. makedirs(top)
  14. def _emptyDirectory(top):
  15. for root, dirs, files in walk(top, topdown = False):
  16. for name in files:
  17. remove(joinpath(root, name))
  18. for name in dirs:
  19. rmdir(joinpath(root, name))
  20. def generateInstallFiles(info):
  21. emptyOrCreateDirectory(info.makeInstallPath)
  22. installAll(
  23. info.makeInstallPath + sep, 'bin', 'share', 'doc',
  24. info.openmsxExePath, 'mingw32', True, True
  25. )
  26. class PackageInfo(object):
  27. def __init__(self, platform, configuration, catapultPath):
  28. self.platform = platform.lower()
  29. if self.platform == 'win32':
  30. self.cpu = 'x86'
  31. self.platform = 'Win32'
  32. self.win64 = False
  33. elif self.platform == 'x64':
  34. self.cpu = 'x64'
  35. self.platform = 'x64'
  36. self.win64 = True
  37. else:
  38. raise ValueError('Wrong platform: ' + platform)
  39. self.configuration = configuration.lower()
  40. if self.configuration == 'release':
  41. self.configuration = 'Release'
  42. self.catapultConfiguration = 'Unicode Release'
  43. elif self.configuration == 'developer':
  44. self.configuration = 'Developer'
  45. self.catapultConfiguration = 'Unicode Debug'
  46. elif self.configuration == 'debug':
  47. self.configuration = 'Debug'
  48. self.catapultConfiguration = 'Unicode Debug'
  49. else:
  50. raise ValueError('Wrong configuration: ' + configuration)
  51. self.catapultPath = catapultPath
  52. # Useful variables
  53. self.buildFlavor = self.platform + '-VC-' + self.configuration
  54. self.buildPath = joinpath('derived', self.buildFlavor)
  55. self.sourcePath = 'src'
  56. self.codecPath = 'Contrib\\codec\\Win32'
  57. self.packageWindowsPath = 'build\\package-windows'
  58. self.catapultSourcePath = joinpath(self.catapultPath, 'src')
  59. self.catapultBuildFlavor = '%s-VC-%s' % (
  60. self.platform, self.catapultConfiguration
  61. )
  62. self.catapultBuildPath = joinpath(
  63. self.catapultPath, joinpath('derived', self.catapultBuildFlavor)
  64. )
  65. self.catapultExePath = joinpath(
  66. self.catapultBuildPath, 'install\\catapult.exe'
  67. )
  68. self.catapultPdbPath = joinpath(
  69. self.catapultBuildPath, 'install\\catapult.pdb'
  70. )
  71. self.openmsxExePath = joinpath(self.buildPath, 'install\\openmsx.exe')
  72. self.openmsxPdbPath = joinpath(self.buildPath, 'install\\openmsx.pdb')
  73. self.packagePath = joinpath(self.buildPath, 'package-windows')
  74. self.makeInstallPath = joinpath(self.packagePath, 'install')
  75. self.version = packageVersionNumber
  76. if releaseFlag:
  77. self.version += '.0'
  78. else:
  79. self.version += '.%d' % extractRevisionNumber()
  80. # <product>-<version>-<os>-<compiler>-<cpu>-<filetype>.ext
  81. self.os = 'windows'
  82. self.compiler = 'vc'
  83. self.packageFileName = '-'.join((
  84. getVersionedPackageName(),
  85. self.os,
  86. self.compiler,
  87. self.cpu
  88. ))
  89. if __name__ == '__main__':
  90. if len(sys.argv) == 4:
  91. PackageInfo(*sys.argv[1 : ])
  92. else:
  93. print(
  94. 'Usage: python3 packagewindows.py '
  95. 'platform configuration catapultPath',
  96. file=sys.stderr
  97. )
  98. sys.exit(2)