In the build process, bld.cur_script is set as a running script node. We can use bld.cur_script to detect building directory.
bld.cur_script.relpath() # Returns relative path from root waf script
I add handy function to bld object as below.
def build(bld):
def add_prefix(bld, path):
return os.path.join(os.path.dirname(bld.cur_script.relpath()), str(path))
bld.add_prefix = functools.partial(add_prefix, bld)
bld.recurse('dir1 dir2 ... dir3')