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