configurations.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from components import (
  2. EmulationCore, GLRenderer, Laserdisc, iterComponents
  3. )
  4. class Configuration(object):
  5. def __init__(self, requiredComponents, optionalComponents, linkStatic):
  6. self.__requiredComponents = requiredComponents
  7. self.__optionalComponents = optionalComponents
  8. self.__linkStatic = linkStatic
  9. def iterRequiredComponents(self):
  10. return iter(self.__requiredComponents)
  11. def iterOptionalComponents(self):
  12. return iter(self.__optionalComponents)
  13. def iterDesiredComponents(self):
  14. return iter(self.__requiredComponents | self.__optionalComponents)
  15. def iterBuildableComponents(self, probeVars):
  16. for component in self.iterDesiredComponents():
  17. if component.canBuild(probeVars):
  18. yield component
  19. def linkStatic(self):
  20. '''Returns True iff static linking should be used for non-system libs.
  21. '''
  22. return self.__linkStatic
  23. def getConfiguration(name):
  24. if name == 'SYS_DYN':
  25. requiredComponents = set((EmulationCore, ))
  26. optionalComponents = set(iterComponents()) - requiredComponents
  27. linkStatic = False
  28. elif name == '3RD_STA':
  29. requiredComponents = set((EmulationCore, GLRenderer))
  30. optionalComponents = set(iterComponents()) - requiredComponents
  31. linkStatic = True
  32. elif name == '3RD_STA_GLES':
  33. # TODO: We don't have an OpenGL ES component yet.
  34. requiredComponents = set((EmulationCore, ))
  35. optionalComponents = \
  36. set(iterComponents()) - requiredComponents - set((GLRenderer, ))
  37. linkStatic = True
  38. elif name == '3RD_STA_MIN':
  39. requiredComponents = set((EmulationCore, ))
  40. optionalComponents = set()
  41. linkStatic = True
  42. else:
  43. raise ValueError('No configuration named "%s"' % name)
  44. return Configuration(requiredComponents, optionalComponents, linkStatic)