aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/rewriter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-03-25 18:22:52 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-03-27 00:39:45 +0300
commit9b2e533d87ad33c86b23869f2992c5882c8f6f6b (patch)
tree94ff3dfb5659757af6943a045ebdd293747b40ef /mesonbuild/rewriter.py
parent977acc94b84077e84da7ddde4099e96f03530038 (diff)
downloadmeson-9b2e533d87ad33c86b23869f2992c5882c8f6f6b.zip
meson-9b2e533d87ad33c86b23869f2992c5882c8f6f6b.tar.gz
meson-9b2e533d87ad33c86b23869f2992c5882c8f6f6b.tar.bz2
Always build parser objects anew to avoid leaking old data.
Diffstat (limited to 'mesonbuild/rewriter.py')
-rw-r--r--mesonbuild/rewriter.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py
index fad7ba0..1127288 100644
--- a/mesonbuild/rewriter.py
+++ b/mesonbuild/rewriter.py
@@ -29,18 +29,20 @@ from mesonbuild import mlog
import sys, traceback
import argparse
-parser = argparse.ArgumentParser(prog='meson rewrite')
-
-parser.add_argument('--sourcedir', default='.',
- help='Path to source directory.')
-parser.add_argument('--target', default=None,
- help='Name of target to edit.')
-parser.add_argument('--filename', default=None,
- help='Name of source file to add or remove to target.')
-parser.add_argument('commands', nargs='+')
+def buildparser():
+ parser = argparse.ArgumentParser(prog='meson rewrite')
+
+ parser.add_argument('--sourcedir', default='.',
+ help='Path to source directory.')
+ parser.add_argument('--target', default=None,
+ help='Name of target to edit.')
+ parser.add_argument('--filename', default=None,
+ help='Name of source file to add or remove to target.')
+ parser.add_argument('commands', nargs='+')
+ return parser
def run(args):
- options = parser.parse_args(args)
+ options = buildparser().parse_args(args)
if options.target is None or options.filename is None:
sys.exit("Must specify both target and filename.")
print('This tool is highly experimental, use with care.')