OXYGENHUB
◆ main openmsx / build / components2defs.py
1.0 KiB · Python · last changed chore(): initial commit 1 month ago source blame history raw
1
# Generates the contents of "components_defs.mk".
2
3
from components import (
4
	EmulationCore, iterBuildableComponents, iterComponents,
5
	requiredLibrariesFor
6
	)
7
from makeutils import extractMakeVariables
8
from outpututils import rewriteIfChanged
9
10
import sys
11
12
def iterComponentDefs(probeMakePath):
13
	probeVars = extractMakeVariables(probeMakePath)
14
15
	yield '# Automatically generated by build process.'
16
	yield ''
17
18
	yield 'LIBRARY_COMPILE_FLAGS:='
19
	yield 'LIBRARY_LINK_FLAGS:='
20
	for libName in requiredLibrariesFor(iterBuildableComponents(probeVars)):
21
		yield '# %s' % libName
22
		yield 'LIBRARY_COMPILE_FLAGS+=' + probeVars.get(libName + '_CFLAGS', '')
23
		yield 'LIBRARY_LINK_FLAGS+=' + probeVars.get(libName + '_LDFLAGS', '')
24
	yield ''
25
26
	for component in iterComponents():
27
		yield 'COMPONENT_%s:=%s' % (
28
			component.makeName,
29
			str(component.canBuild(probeVars)).lower()
30
			)
31
32
if len(sys.argv) == 3:
33
	rewriteIfChanged(sys.argv[1], iterComponentDefs(sys.argv[2]))
34
else:
35
	print(
36
		'Usage: python3 components2defs.py COMPONENTS_DEFS PROBE_MAKE',
37
		file=sys.stderr
38
		)
39
	sys.exit(2)