components.py 1.5 KB

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