RandomB
RandomB

Reputation: 3737

Waf: target is directory

My wscript file is simple:

def configure(ctx):
    pass

def build(bld):
    bld(rule='mkdir aaa', target='aaa')
    bld(rule='touch bbb', source='aaa', target='bbb')

And first run of waf configure and waf build passes OK. But the second waf build fails with an error:

source not found: 'aaa' in bld(source='aaa', target=['bbb'], meths=['process_rule', 'process_source'], features=[], path=/home/rnd/prj/prj2/prj-web, idx=2, tg_idx_count=2, rule='touch bbb', posted=True, _name='bbb') in /home/rnd/prj/prj2/prj-web

But if to change the "mkdir" to "touch" - everything works as expected. How to use a directory as a target? (PS. It would be interesting is it possible to use it as a source as well), because it's easy in a plain Makefile, so I had feeling that Waf can handle directories too.

Upvotes: 1

Views: 182

Answers (1)

neuro
neuro

Reputation: 15180

Well, the waf model don't manage directories with the source and target keywords. You can handle directories with specific keyword of your own, like source_dir and target_dir. Like :

def my_rule(task):
    tg = task.generator
    target_dir = tg.path.get_bld().make_node(target_dir)
    target_dir.mkdir()
bld(rule=my_rule, target=dir = "bbb")

Upvotes: 0

Related Questions