jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.9KB

  1. #! /usr/bin/env python
  2. # encoding: UTF-8
  3. # Nicolas Joseph 2009
  4. """
  5. ported from waf 1.5:
  6. TODO: tabs vs spaces
  7. """
  8. from waflib import Task, Utils, Node, Errors, Logs
  9. from waflib.TaskGen import feature, extension, after_method
  10. VALADOC_STR = '${VALADOC}'
  11. class valadoc(Task.Task):
  12. vars = ['VALADOC', 'VALADOCFLAGS']
  13. color = 'BLUE'
  14. after = ['cprogram', 'cstlib', 'cshlib', 'cxxprogram', 'cxxstlib', 'cxxshlib']
  15. quiet = True # no outputs .. this is weird
  16. def __init__(self, *k, **kw):
  17. Task.Task.__init__(self, *k, **kw)
  18. self.output_dir = ''
  19. self.doclet = ''
  20. self.package_name = ''
  21. self.package_version = ''
  22. self.files = []
  23. self.vapi_dirs = []
  24. self.protected = True
  25. self.private = False
  26. self.inherit = False
  27. self.deps = False
  28. self.enable_non_null_experimental = False
  29. self.force = False
  30. def run(self):
  31. if not self.env['VALADOCFLAGS']:
  32. self.env['VALADOCFLAGS'] = ''
  33. cmd = [Utils.subst_vars(VALADOC_STR, self.env)]
  34. cmd.append ('-o %s' % self.output_dir)
  35. if getattr(self, 'doclet', None):
  36. cmd.append ('--doclet %s' % self.doclet)
  37. cmd.append ('--package-name %s' % self.package_name)
  38. if getattr(self, 'package_version', None):
  39. cmd.append ('--package-version %s' % self.package_version)
  40. if getattr(self, 'packages', None):
  41. for package in self.packages:
  42. cmd.append ('--pkg %s' % package)
  43. if getattr(self, 'vapi_dirs', None):
  44. for vapi_dir in self.vapi_dirs:
  45. cmd.append ('--vapidir %s' % vapi_dir)
  46. if not getattr(self, 'protected', None):
  47. cmd.append ('--no-protected')
  48. if getattr(self, 'private', None):
  49. cmd.append ('--private')
  50. if getattr(self, 'inherit', None):
  51. cmd.append ('--inherit')
  52. if getattr(self, 'deps', None):
  53. cmd.append ('--deps')
  54. if getattr(self, 'enable_non_null_experimental', None):
  55. cmd.append ('--enable-non-null-experimental')
  56. if getattr(self, 'force', None):
  57. cmd.append ('--force')
  58. cmd.append (' '.join ([x.abspath() for x in self.files]))
  59. return self.generator.bld.exec_command(' '.join(cmd))
  60. @feature('valadoc')
  61. def process_valadoc(self):
  62. """
  63. Generate API documentation from Vala source code with valadoc
  64. doc = bld(
  65. features = 'valadoc',
  66. output_dir = '../doc/html',
  67. package_name = 'vala-gtk-example',
  68. package_version = '1.0.0',
  69. packages = 'gtk+-2.0',
  70. vapi_dirs = '../vapi',
  71. force = True
  72. )
  73. path = bld.path.find_dir ('../src')
  74. doc.files = path.ant_glob (incl='**/*.vala')
  75. """
  76. task = self.create_task('valadoc')
  77. if getattr(self, 'output_dir', None):
  78. task.output_dir = self.path.find_or_declare(self.output_dir).abspath()
  79. else:
  80. Errors.WafError('no output directory')
  81. if getattr(self, 'doclet', None):
  82. task.doclet = self.doclet
  83. else:
  84. Errors.WafError('no doclet directory')
  85. if getattr(self, 'package_name', None):
  86. task.package_name = self.package_name
  87. else:
  88. Errors.WafError('no package name')
  89. if getattr(self, 'package_version', None):
  90. task.package_version = self.package_version
  91. if getattr(self, 'packages', None):
  92. task.packages = Utils.to_list(self.packages)
  93. if getattr(self, 'vapi_dirs', None):
  94. vapi_dirs = Utils.to_list(self.vapi_dirs)
  95. for vapi_dir in vapi_dirs:
  96. try:
  97. task.vapi_dirs.append(self.path.find_dir(vapi_dir).abspath())
  98. except AttributeError:
  99. Logs.warn("Unable to locate Vala API directory: '%s'" % vapi_dir)
  100. if getattr(self, 'files', None):
  101. task.files = self.files
  102. else:
  103. Errors.WafError('no input file')
  104. if getattr(self, 'protected', None):
  105. task.protected = self.protected
  106. if getattr(self, 'private', None):
  107. task.private = self.private
  108. if getattr(self, 'inherit', None):
  109. task.inherit = self.inherit
  110. if getattr(self, 'deps', None):
  111. task.deps = self.deps
  112. if getattr(self, 'enable_non_null_experimental', None):
  113. task.enable_non_null_experimental = self.enable_non_null_experimental
  114. if getattr(self, 'force', None):
  115. task.force = self.force
  116. def configure(conf):
  117. conf.find_program('valadoc', errmsg='You must install valadoc <http://live.gnome.org/Valadoc> for generate the API documentation')