qtchainer.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Federico Pellegrin, 2016 (fedepell)
  4. #
  5. # Example extra that chains to either qt5 or pyqt5 for QRC/UI files as
  6. # just one handler for an extension can be natively defined. The extra
  7. # has to be loaded after qt5 and pyqt5 and files need to have explicitly
  8. # set the feature they want to use.
  9. #
  10. import os
  11. from waflib.Tools import python
  12. from waflib.Tools import cxx
  13. from waflib.extras import pyqt5
  14. from waflib.Tools import qt5
  15. from waflib import Task
  16. from waflib.TaskGen import extension
  17. from waflib import Logs
  18. EXT_RCC = ['.qrc']
  19. """
  20. File extension for the resource (.qrc) files
  21. """
  22. EXT_UI = ['.ui']
  23. """
  24. File extension for the user interface (.ui) files
  25. """
  26. @extension(*EXT_RCC)
  27. def create_chain_task(self, node):
  28. "Creates rcc and py task for ``.qrc`` files"
  29. if 'qt5' in self.features:
  30. qt5.create_rcc_task(self, node)
  31. elif 'pyqt5' in self.features:
  32. pyqt5.create_pyrcc_task(self, node)
  33. else:
  34. Logs.warn("No feature explicitly defined for '%s'",node)
  35. @extension(*EXT_UI)
  36. def create_chain_task(self, node):
  37. "Create uic tasks and py for user interface ``.ui`` definition files"
  38. if 'qt5' in self.features:
  39. qt5.create_uic_task(self, node)
  40. elif 'pyqt5' in self.features:
  41. pyqt5.create_pyuic_task(self, node)
  42. else:
  43. Logs.warn("No feature explicitly defined for '%s'",node)