OXYGENHUB
◆ main openmsx / build / components.py
1.5 KiB · Python · last changed chore(): initial commit 1 month ago source blame history raw
1
# Defines the building blocks of openMSX and their dependencies.
2
3
class Component(object):
4
	niceName = None
5
	makeName = None
6
	dependsOn = None
7
8
	@classmethod
9
	def canBuild(cls, probeVars):
10
		return all(
11
			probeVars.get('HAVE_%s_H' % makeName) and
12
			probeVars.get('HAVE_%s_LIB' % makeName)
13
			for makeName in cls.dependsOn
14
			)
15
16
class EmulationCore(Component):
17
	niceName = 'Emulation core'
18
	makeName = 'CORE'
19
	dependsOn = ('SDL2', 'SDL2_TTF', 'FREETYPE', 'PNG', 'TCL', 'ZLIB')
20
21
class GLRenderer(Component):
22
	niceName = 'GL renderer'
23
	makeName = 'GL'
24
	dependsOn = ('GL', 'GLEW')
25
26
class Laserdisc(Component):
27
	niceName = 'Laserdisc'
28
	makeName = 'LASERDISC'
29
	dependsOn = ('OGG', 'VORBIS', 'THEORA')
30
31
class ALSAMIDI(Component):
32
	niceName = 'ALSA MIDI'
33
	makeName = 'ALSAMIDI'
34
	dependsOn = ('ALSA', )
35
36
def iterComponents():
37
	'''Iterates through all components of openMSX.
38
	'''
39
	yield EmulationCore
40
	yield GLRenderer
41
	yield Laserdisc
42
	yield ALSAMIDI
43
44
def iterBuildableComponents(probeVars):
45
	'''Iterates through those components of openMSX that can be built
46
	on the probed system.
47
	'''
48
	for component in iterComponents():
49
		if component.canBuild(probeVars):
50
			yield component
51
52
def requiredLibrariesFor(components):
53
	'''Compute the library packages required to build the given components.
54
	Only the direct dependencies from openMSX are included, not dependencies
55
	between libraries.
56
	Returns a set of Make names.
57
	'''
58
	return set(
59
		makeName
60
		for comp in components
61
		for makeName in comp.dependsOn
62
		)