diff options
Diffstat (limited to 'mesonbuild/mesonmain.py')
-rw-r--r-- | mesonbuild/mesonmain.py | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 3e381dc..cd925e5 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -43,6 +43,10 @@ def create_parser(): help=argparse.SUPPRESS) p.add_argument('--fatal-meson-warnings', action='store_true', dest='fatal_warnings', help='Make all Meson warnings fatal') + p.add_argument('--reconfigure', action='store_true', + help='Set options and reconfigure the project. Useful when new ' + + 'options have been added to the project and the default value ' + + 'is not working.') p.add_argument('builddir', nargs='?', default=None) p.add_argument('sourcedir', nargs='?', default=None) return p @@ -57,10 +61,10 @@ def wrapmodetype(string): class MesonApp: - def __init__(self, handshake, options): + def __init__(self, options): (self.source_dir, self.build_dir) = self.validate_dirs(options.builddir, options.sourcedir, - handshake) + options.reconfigure) self.options = options def has_build_file(self, dirname): @@ -97,21 +101,23 @@ class MesonApp: return ndir2, ndir1 raise MesonException('Neither directory contains a build file %s.' % environment.build_filename) - def validate_dirs(self, dir1, dir2, handshake): + def validate_dirs(self, dir1, dir2, reconfigure): (src_dir, build_dir) = self.validate_core_dirs(dir1, dir2) priv_dir = os.path.join(build_dir, 'meson-private/coredata.dat') if os.path.exists(priv_dir): - if not handshake: - print('Directory already configured, exiting Meson. Just run your build command\n' - '(e.g. ninja) and Meson will regenerate as necessary. If ninja fails, run ninja\n' - 'reconfigure to force Meson to regenerate.\n' + if not reconfigure: + print('Directory already configured.\n' + '\nJust run your build command (e.g. ninja) and Meson will regenerate as necessary.\n' + 'If ninja fails, run "ninja reconfigure" or "meson --reconfigure"\n' + 'to force Meson to regenerate.\n' '\nIf build failures persist, manually wipe your build directory to clear any\n' 'stored system data.\n' - '\nTo change option values, run meson configure instead.') - sys.exit(0) + '\nTo change option values, run "meson configure" instead.') + sys.exit(1) else: - if handshake: - raise RuntimeError('Something went terribly wrong. Please file a bug.') + if reconfigure: + print('Directory does not contain a valid build tree:\n{}'.format(build_dir)) + sys.exit(1) return src_dir, build_dir def check_pkgconfig_envvar(self, env): @@ -328,7 +334,11 @@ def run(original_args, mainfile): # No special command? Do the basic setup/reconf. if len(args) >= 2 and args[0] == '--internal': - if args[1] != 'regenerate': + if args[1] == 'regenerate': + # Rewrite "meson --internal regenerate" command line to + # "meson --reconfigure" + args = ['--reconfigure'] + args[2:] + else: script = args[1] try: sys.exit(run_script_command(args[1:])) @@ -336,10 +346,6 @@ def run(original_args, mainfile): mlog.error('\nError in {} helper script:'.format(script)) mlog.exception(e) sys.exit(1) - args = args[2:] - handshake = True - else: - handshake = False parser = create_parser() @@ -347,7 +353,7 @@ def run(original_args, mainfile): options = parser.parse_args(args) coredata.parse_cmd_line_options(options) try: - app = MesonApp(handshake, options) + app = MesonApp(options) except Exception as e: # Log directory does not exist, so just print # to stdout. |