genio.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import os
  2. from enum import Enum, auto
  3. from .gn import GnBuilder
  4. class GenioApp(Enum):
  5. LIGHT = auto()
  6. SHELL = auto()
  7. def ExampleName(self):
  8. if self == GenioApp.LIGHT:
  9. return 'lighting-app'
  10. elif self == GenioApp.SHELL:
  11. return 'shell'
  12. else:
  13. raise Exception('Unknown app type: %r' % self)
  14. def AppNamePrefix(self):
  15. if self == GenioApp.LIGHT:
  16. return 'chip-mt793x-lighting-app-example'
  17. elif self == GenioApp.SHELL:
  18. return 'chip-mt793x-shell-example'
  19. else:
  20. raise Exception('Unknown app type: %r' % self)
  21. def FlashBundleName(self):
  22. if self == GenioApp.LIGHT:
  23. return 'lighting_app.flashbundle.txt'
  24. elif self == GenioApp.SHELL:
  25. return 'shell.flashbundle.txt'
  26. else:
  27. raise Exception('Unknown app type: %r' % self)
  28. def BuildRoot(self, root):
  29. return os.path.join(root, 'examples', self.ExampleName(), 'genio')
  30. class GenioBuilder(GnBuilder):
  31. def __init__(self,
  32. root,
  33. runner,
  34. app: GenioApp = GenioApp.LIGHT):
  35. super(GenioBuilder, self).__init__(
  36. root=app.BuildRoot(root),
  37. runner=runner)
  38. self.app = app
  39. def build_outputs(self):
  40. items = {}
  41. for extension in ['out', 'out.map', 'bin']:
  42. name = '%s.%s' % (self.app.AppNamePrefix(), extension)
  43. items[name] = os.path.join(self.output_dir, name)
  44. return items