aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/msetup.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-09-13 14:17:17 -0400
committerEli Schwartz <eschwartz@archlinux.org>2022-09-19 15:19:00 -0400
commit9ed5cfda155c585f7aea896fe2f40d3a92eac43a (patch)
tree1dc44da1f3f1831192589e5f7abe138c9a1d2b55 /mesonbuild/msetup.py
parentd3dac3cfb255e1f6f018c4cd3fcbd04706b3c16e (diff)
downloadmeson-9ed5cfda155c585f7aea896fe2f40d3a92eac43a.zip
meson-9ed5cfda155c585f7aea896fe2f40d3a92eac43a.tar.gz
meson-9ed5cfda155c585f7aea896fe2f40d3a92eac43a.tar.bz2
avoid importing the entire codebase at first startup
We want to optimize out some internal codepaths used at build time by avoiding work such as argparse. This doesn't work particularly well when the argparse arguments are imported before then. Between them, they indirectly import pretty much all code anywhere, and msetup alone imports most of it. Also make sure the regenerate internal script goes directly to msetup.
Diffstat (limited to 'mesonbuild/msetup.py')
-rw-r--r--mesonbuild/msetup.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
index 7fa18af..7c452d4 100644
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -297,7 +297,11 @@ class MesonApp:
if devenv:
b.devenv.append(devenv)
-def run(options: argparse.Namespace) -> int:
+def run(options: T.Union[argparse.Namespace, T.List[str]]) -> int:
+ if not isinstance(options, argparse.Namespace):
+ parser = argparse.ArgumentParser()
+ add_arguments(parser)
+ options = parser.parse_args(options)
coredata.parse_cmd_line_options(options)
app = MesonApp(options)
app.generate()