mw320.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (c) 2021 Project CHIP Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import os
  15. from enum import Enum, auto
  16. from .gn import GnBuilder
  17. class MW320App(Enum):
  18. ALL_CLUSTERS = auto()
  19. def ExampleName(self):
  20. if self == MW320App.ALL_CLUSTERS:
  21. return 'all-clusters-app'
  22. else:
  23. raise Exception('Unknown app type: %r' % self)
  24. def AppNamePrefix(self):
  25. if self == MW320App.ALL_CLUSTERS:
  26. return 'chip-mw320-all-clusters-app'
  27. else:
  28. raise Exception('Unknown app type: %r' % self)
  29. def BuildRoot(self, root):
  30. return os.path.join(root, 'examples', self.ExampleName(), 'nxp', 'mw320')
  31. class MW320Builder(GnBuilder):
  32. def __init__(self,
  33. root,
  34. runner,
  35. app: MW320App = MW320App.ALL_CLUSTERS):
  36. super(MW320Builder, self).__init__(
  37. root=app.BuildRoot(root),
  38. runner=runner)
  39. self.app = app
  40. def build_outputs(self):
  41. items = {}
  42. for extension in [".bin", ".out", ".out.map"]:
  43. name = '%s%s' % (self.app.AppNamePrefix(), extension)
  44. items[name] = os.path.join(self.output_dir, name)
  45. return items