diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-04-04 13:08:05 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-04-06 20:27:25 +1000 |
commit | 553324bc1022635e05a683c4bec5135d845f6fea (patch) | |
tree | 7d8aa296c7e433793e47bf1227310973a4aed7e9 /buildtools/wafsamba/samba_utils.py | |
parent | 8dc8d31f4adf84f35bce34339e13e9d70c4b8a66 (diff) | |
download | samba-553324bc1022635e05a683c4bec5135d845f6fea.tar.gz samba-553324bc1022635e05a683c4bec5135d845f6fea.tar.bz2 samba-553324bc1022635e05a683c4bec5135d845f6fea.zip |
s4-waf: move to a universal method of recursing into subdirs
This works with both standalone lib builds and bundled builds
Diffstat (limited to 'buildtools/wafsamba/samba_utils.py')
-rw-r--r-- | buildtools/wafsamba/samba_utils.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 07a37aa9e7..37b3fc9dbb 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -418,3 +418,35 @@ def TOUCH_FILE(file, install_dir=False): mkdir_p(os.path.dirname(file)) f = open(file, 'w') f.close() + + + +@conf +def RECURSE(ctx, directory): + '''recurse into a directory, relative to the curdir or top level''' + try: + visited_dirs = ctx.visited_dirs + except: + visited_dirs = ctx.visited_dirs = set() + d = os.path.join(ctx.curdir, directory) + if os.path.exists(d): + abspath = os.path.abspath(d) + else: + abspath = os.path.abspath(os.path.join(Utils.g_module.srcdir, directory)) + ctxclass = ctx.__class__.__name__ + key = ctxclass + ':' + abspath + if key in visited_dirs: + # already done it + return + visited_dirs.add(key) + relpath = os_path_relpath(abspath, ctx.curdir) + if ctxclass == 'Handler': + return ctx.sub_options(relpath) + if ctxclass == 'ConfigurationContext': + return ctx.sub_config(relpath) + if ctxclass == 'BuildContext': + return ctx.add_subdirs(relpath) + print 'Unknown RECURSE context class', ctxclass + raise +Options.Handler.RECURSE = RECURSE +Build.BuildContext.RECURSE = RECURSE |