From a8896c57a55be54066770c4e5d79e6115cd68b58 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Sun, 24 Jan 2016 11:38:10 +0100 Subject: [PATCH] New option to create a waf file that takes its file list from a model archive --- wscript | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wscript b/wscript index cdb24d66..1c882a85 100644 --- a/wscript +++ b/wscript @@ -118,6 +118,7 @@ def options(opt): opt.add_option('--coretools', action='store', help='Comma-separated core tools to add, eg: "vala,tex" [Default: all of them]', dest='coretools', default='default') opt.add_option('--prelude', action='store', help='Code to execute before calling waf', dest='prelude', default=PRELUDE) + opt.add_option('--namesfrom', action='store', help='Obtain the file names from a model archive', dest='namesfrom', default=None) opt.load('python') def process_tokens(tokens): @@ -266,6 +267,15 @@ def create_waf(self, *k, **kw): if k.endswith('.py'): files.append(os.path.normpath(os.path.join(dd, k))) + if Options.options.namesfrom: + with tarfile.open(Options.options.namesfrom) as tar: + oldfiles = files + files = [x.name for x in tar.getmembers()] + if set(files) ^ set(oldfiles): + Logs.warn('The archive model has differences:') + Logs.warn('- Added %r' % list(set(files) - set(oldfiles))) + Logs.warn('- Removed %r' % list(set(oldfiles) - set(files))) + #open a file as tar.[extension] for writing tar = tarfile.open('%s.tar.%s' % (mw, zipType), "w:%s" % zipType) z = zipfile.ZipFile("zip/waflib.zip", "w", compression=zipfile.ZIP_DEFLATED) @@ -284,7 +294,6 @@ def create_waf(self, *k, **kw): tarinfo.name = 'waflib/extras/' + os.path.split(x)[1] print(" adding %s as %s" % (x, tarinfo.name)) - def dest(x): if os.path.isabs(x): return os.path.join("extras", os.path.basename(x))