diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-09-13 14:17:17 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-09-19 15:19:00 -0400 |
commit | 9ed5cfda155c585f7aea896fe2f40d3a92eac43a (patch) | |
tree | 1dc44da1f3f1831192589e5f7abe138c9a1d2b55 /mesonbuild/mesonmain.py | |
parent | d3dac3cfb255e1f6f018c4cd3fcbd04706b3c16e (diff) | |
download | meson-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/mesonmain.py')
-rw-r--r-- | mesonbuild/mesonmain.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 84555fc..d024deb 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -27,15 +27,17 @@ import shutil from . import mesonlib from . import mlog -from . import mconf, mdist, minit, minstall, mintro, msetup, mtest, rewriter, msubprojects, munstable_coredata, mcompile, mdevenv from .mesonlib import MesonException, MesonBugException -from .wrap import wraptool -from .scripts import env2mfile # Note: when adding arguments, please also add them to the completion # scripts in $MESONSRC/data/shell-completions/ class CommandLineParser: def __init__(self): + # only import these once we do full argparse processing + from . import mconf, mdist, minit, minstall, mintro, msetup, mtest, rewriter, msubprojects, munstable_coredata, mcompile, mdevenv + from .scripts import env2mfile + from .wrap import wraptool + self.term_width = shutil.get_terminal_size().columns self.formatter = lambda prog: argparse.HelpFormatter(prog, max_help_position=int(self.term_width / 2), width=self.term_width) @@ -253,9 +255,8 @@ def run(original_args, mainfile): # need to go through argparse. if len(args) >= 2 and args[0] == '--internal': if args[1] == 'regenerate': - # Rewrite "meson --internal regenerate" command line to - # "meson --reconfigure" - args = ['setup', '--reconfigure'] + args[2:] + from . import msetup + return msetup.run(['--reconfigure'] + args[2:]) else: return run_script_command(args[1], args[2:]) |