| 1 |
from components import ( |
| 2 |
EmulationCore, GLRenderer, Laserdisc, iterComponents |
| 3 |
) |
| 4 |
|
| 5 |
class Configuration(object): |
| 6 |
|
| 7 |
def __init__(self, requiredComponents, optionalComponents, linkStatic): |
| 8 |
self.__requiredComponents = requiredComponents |
| 9 |
self.__optionalComponents = optionalComponents |
| 10 |
self.__linkStatic = linkStatic |
| 11 |
|
| 12 |
def iterRequiredComponents(self): |
| 13 |
return iter(self.__requiredComponents) |
| 14 |
|
| 15 |
def iterOptionalComponents(self): |
| 16 |
return iter(self.__optionalComponents) |
| 17 |
|
| 18 |
def iterDesiredComponents(self): |
| 19 |
return iter(self.__requiredComponents | self.__optionalComponents) |
| 20 |
|
| 21 |
def iterBuildableComponents(self, probeVars): |
| 22 |
for component in self.iterDesiredComponents(): |
| 23 |
if component.canBuild(probeVars): |
| 24 |
yield component |
| 25 |
|
| 26 |
def linkStatic(self): |
| 27 |
|
| 28 |
|
| 29 |
return self.__linkStatic |
| 30 |
|
| 31 |
def getConfiguration(name): |
| 32 |
if name == 'SYS_DYN': |
| 33 |
requiredComponents = set((EmulationCore, )) |
| 34 |
optionalComponents = set(iterComponents()) - requiredComponents |
| 35 |
linkStatic = False |
| 36 |
elif name == '3RD_STA': |
| 37 |
requiredComponents = set((EmulationCore, GLRenderer)) |
| 38 |
optionalComponents = set(iterComponents()) - requiredComponents |
| 39 |
linkStatic = True |
| 40 |
elif name == '3RD_STA_GLES': |
| 41 |
|
| 42 |
requiredComponents = set((EmulationCore, )) |
| 43 |
optionalComponents = \ |
| 44 |
set(iterComponents()) - requiredComponents - set((GLRenderer, )) |
| 45 |
linkStatic = True |
| 46 |
elif name == '3RD_STA_MIN': |
| 47 |
requiredComponents = set((EmulationCore, )) |
| 48 |
optionalComponents = set() |
| 49 |
linkStatic = True |
| 50 |
else: |
| 51 |
raise ValueError('No configuration named "%s"' % name) |
| 52 |
return Configuration(requiredComponents, optionalComponents, linkStatic) |