From 91530cf31bd9a4019e436f5f7d20bb8c0cac840d Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 25 Jun 2009 14:15:27 +0200 Subject: [PATCH] make dist generation work again --- wscript | 53 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/wscript b/wscript index 739600784..c3ca1db4d 100644 --- a/wscript +++ b/wscript @@ -60,6 +60,30 @@ REGRESSION_SUFFIX = "-ref-traces" srcdir = '.' blddir = 'build' +def load_env(): + bld_cls = getattr(Utils.g_module, 'build_context', Utils.Context) + bld_ctx = bld_cls() + bld_ctx.load_dirs(os.path.abspath(os.path.join (srcdir,'..')), + os.path.abspath(os.path.join (srcdir,'..', blddir))) + bld_ctx.load_envs() + env = bld_ctx.get_env() + return env + +def get_files(base_dir): + retval = [] + reference=os.path.dirname(base_dir) + for root, dirs, files in os.walk(base_dir): + if root.find('.hg') != -1: + continue + for file in files: + if file.find('.hg') != -1: + continue + fullname = os.path.join(root,file) + # we can't use os.path.relpath because it's new in python 2.6 + relname = fullname.replace(reference + '/','') + retval.append([fullname,relname]) + return retval + def dist_hook(): import tarfile @@ -69,18 +93,19 @@ def dist_hook(): ## build the name of the traces subdirectory. Will be something like ## ns-3-dev-ref-traces - traces_name = APPNAME + '-' + VERSION + regression.REGRESSION_SUFFIX + traces_name = APPNAME + '-' + VERSION + REGRESSION_SUFFIX ## Create a tar.bz2 file with the traces - traces_dir = os.path.join(regression.REGRESSION_DIR, traces_name) - if not os.path.isdir(traces_dir): - Logs.warn("Not creating traces archive: the %s directory does not exist" % traces_dir) + env = load_env() + regression_dir = env['REGRESSION_TRACES'] + if not os.path.isdir(regression_dir): + Logs.warn("Not creating traces archive: the %s directory does not exist" % regression_dir) else: traceball = traces_name + wutils.TRACEBALL_SUFFIX tar = tarfile.open(os.path.join("..", traceball), 'w:bz2') - tar.add(traces_dir) + files = get_files(regression_dir) + for fullfilename,relfilename in files: + tar.add(fullfilename,arcname=relfilename) tar.close() - ## Now remove it; we do not ship the traces with the main tarball... - shutil.rmtree(traces_dir, True) def set_options(opt): # options provided by the modules @@ -209,24 +234,24 @@ def configure(conf): pass conf.check_tool('command') - # create the second environment, set the variant and set its name - variant_env = conf.env.copy() - variant_name = Options.options.build_profile - # Check for the location of regression reference traces if Options.options.regression_traces is not None: if os.path.isdir(Options.options.regression_traces): conf.check_message("regression traces location", '', True, ("%s (given)" % Options.options.regression_traces)) - variant_env['REGRESSION_TRACES'] = os.path.abspath(Options.options.regression_traces) + conf.env['REGRESSION_TRACES'] = os.path.abspath(Options.options.regression_traces) else: traces = os.path.join('..', "%s-%s%s" % (APPNAME, VERSION, REGRESSION_SUFFIX)) if os.path.isdir(traces): conf.check_message("regression reference traces", '', True, ("%s (guessed)" % traces)) - variant_env['REGRESSION_TRACES'] = os.path.abspath(traces) + conf.env['REGRESSION_TRACES'] = os.path.abspath(traces) del traces - if not variant_env['REGRESSION_TRACES']: + if not conf.env['REGRESSION_TRACES']: conf.check_message("regression reference traces", '', False) + # create the second environment, set the variant and set its name + variant_env = conf.env.copy() + variant_name = Options.options.build_profile + if Options.options.enable_gcov: variant_name += '-gcov' variant_env.append_value('CCFLAGS', '-fprofile-arcs')