add_post_fun
このようなツールは、ビルド ステップで次のように簡単に追加できます。
from waflib.Errors import WafError
from waflib import Utils
def filter_uses(ctx, uses):
filtered = []
for use in uses:
try:
ctx.get_tgen_by_name(use)
filtered.append(use)
except WafError:
pass
return filtered
@Utils.run_once # print only once, even if used in multiple script
def make_dot_file(ctx):
for group in ctx.groups:
for taskgen in group:
uses = Utils.to_list(getattr(taskgen, 'use', []))
uses = filter_uses(ctx, uses) # Optional, only print TaskGens
try:
name = taskgen.name # Sometimes this fails, don't know why
print "{} -> {}".format(name, ", ".join(uses))
except AttributeError:
pass
def build(bld):
# Build stuff ...
bld.add_post_fun(make_dot_file)
注: 本当に良い出力を得るには、さらにフィルタリングを行うと便利な場合があります