From 553324bc1022635e05a683c4bec5135d845f6fea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 4 Apr 2010 13:08:05 +1000 Subject: s4-waf: move to a universal method of recursing into subdirs This works with both standalone lib builds and bundled builds --- buildtools/wafsamba/samba_utils.py | 32 ++++++++++++++++++++++++++++++++ buildtools/wafsamba/wafsamba.py | 12 ------------ 2 files changed, 32 insertions(+), 12 deletions(-) (limited to 'buildtools') 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 diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index f9cb1a882f..55dfe26b0a 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -442,18 +442,6 @@ Build.BuildContext.SAMBA_GENERATOR = SAMBA_GENERATOR -def BUILD_SUBDIR(bld, dir): - '''add a new set of build rules from a subdirectory''' - path = os.path.normpath(bld.curdir + '/' + dir) - cache = LOCAL_CACHE(bld, 'SUBDIR_LIST') - if path in cache: return - cache[path] = True - debug("build: Processing subdirectory %s" % dir) - bld.add_subdirs(dir) -Build.BuildContext.BUILD_SUBDIR = BUILD_SUBDIR - - - @runonce def SETUP_BUILD_GROUPS(bld): '''setup build groups used to ensure that the different build -- cgit