aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-05-29 12:52:30 -0400
committerEli Schwartz <eschwartz93@gmail.com>2023-06-23 13:53:35 -0400
commit1d600b48cb223e2fca326ff76a6c73166b34f9d1 (patch)
treea25cdf1ef93de9bad3a96518975b0719d7c999e5 /mesonbuild
parentc16dd8d71197641ee4bbbebe8e10401201666cc8 (diff)
downloadmeson-1d600b48cb223e2fca326ff76a6c73166b34f9d1.zip
meson-1d600b48cb223e2fca326ff76a6c73166b34f9d1.tar.gz
meson-1d600b48cb223e2fca326ff76a6c73166b34f9d1.tar.bz2
mconf: Allow changing options and clearing cache at the same time
Setting options or clearing cache is also an error without a valid build directory.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mconf.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index bdc1d57..dd74d89 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -208,7 +208,7 @@ class Conf:
def print_default_values_warning():
mlog.warning('The source directory instead of the build directory was specified.')
- mlog.warning('Only the default values for the project are printed, and all command line parameters are ignored.')
+ mlog.warning('Only the default values for the project are printed.')
if self.default_values_only:
print_default_values_warning()
@@ -297,10 +297,13 @@ class Conf:
def run(options):
coredata.parse_cmd_line_options(options)
builddir = os.path.abspath(os.path.realpath(options.builddir))
+ print_only = not options.cmd_line_options and not options.clearcache
c = None
try:
c = Conf(builddir)
- if c.default_values_only:
+ if c.default_values_only and not print_only:
+ raise mesonlib.MesonException('No valid build directory found, cannot modify options.')
+ if c.default_values_only or print_only:
c.print_conf(options.pager)
return 0
@@ -308,11 +311,9 @@ def run(options):
if options.cmd_line_options:
save = c.set_options(options.cmd_line_options)
coredata.update_cmd_line_file(builddir, options)
- elif options.clearcache:
+ if options.clearcache:
c.clear_cache()
save = True
- else:
- c.print_conf(options.pager)
if save:
c.save()
mintro.update_build_options(c.coredata, c.build.environment.info_dir)