OXYGENHUB
◆ main openmsx / build / msvc / genconfig.py
2.1 KiB · Python · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
# Generates configuration headers for VC++ builds
2
3
import sys
4
import os.path
5
import outpututils
6
import buildinfo2code
7
import components2code
8
import systemfuncs2code
9
import win_resource
10
import version2code
11
12
#
13
# platform: one of { Win32, x64 }
14
# configuration: one of { Debug, Developer, Release }
15
# outputPath: the location in which to generate config files
16
#
17
def genConfig(platform, configuration, outputPath):
18
19
	buildPath = 'build'
20
	msvcPath = os.path.join(buildPath, 'msvc')
21
	probeMakePath = os.path.join(msvcPath, 'probed_defs.mk')
22
23
	#
24
	# build-info.hh
25
	#
26
	buildInfoHeader = os.path.join(outputPath, 'build-info.hh')
27
	targetPlatform = 'mingw32'
28
	if platform == 'Win32':
29
		targetCPU = 'x86'
30
	elif platform == 'x64':
31
		targetCPU = 'x86_64'
32
	else:
33
		raise ValueError('Invalid platform: ' + platform)
34
	flavour = configuration
35
	installShareDir = '/opt/openMSX/share' #not used on Windows, so whatever
36
	installDocDir = 'doc' #not used on Windows, so whatever
37
	generator = buildinfo2code.iterBuildInfoHeader(targetPlatform, targetCPU, flavour, installShareDir, installDocDir)
38
	outpututils.rewriteIfChanged(buildInfoHeader, generator)
39
40
	#
41
	# components.hh
42
	#
43
	componentsHeader = os.path.join(outputPath, 'components.hh')
44
	generator = components2code.iterComponentsHeader(probeMakePath)
45
	outpututils.rewriteIfChanged(componentsHeader, generator)
46
47
	#
48
	# systemfuncs.hh
49
	#
50
51
	systemFuncsHeader = os.path.join(outputPath, 'systemfuncs.hh')
52
	generator = systemfuncs2code.iterSystemFuncsHeader(systemfuncs2code.getSystemFuncsInfo())
53
	outpututils.rewriteIfChanged(systemFuncsHeader, generator)
54
55
	#
56
	# resource-info.hh
57
	#
58
	resourceInfoHeader = os.path.join(outputPath, 'resource-info.h')
59
	generator = win_resource.iterResourceHeader()
60
	outpututils.rewriteIfChanged(resourceInfoHeader, generator)
61
62
	#
63
	# version.ii
64
	#
65
	versionHeader = os.path.join(outputPath, 'version.ii')
66
	generator = version2code.iterVersionInclude()
67
	outpututils.rewriteIfChanged(versionHeader, generator)
68
69
if len(sys.argv) == 4:
70
	genConfig(sys.argv[1], sys.argv[2], sys.argv[3])
71
else:
72
	print('Usage: py genconfig.py platform configuration outputPath', file=sys.stderr)
73
	sys.exit(2)