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.
This commit is contained in:
parent
c16dd8d711
commit
1d600b48cb
|
@ -208,7 +208,7 @@ class Conf:
|
||||||
|
|
||||||
def print_default_values_warning():
|
def print_default_values_warning():
|
||||||
mlog.warning('The source directory instead of the build directory was specified.')
|
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:
|
if self.default_values_only:
|
||||||
print_default_values_warning()
|
print_default_values_warning()
|
||||||
|
@ -297,10 +297,13 @@ class Conf:
|
||||||
def run(options):
|
def run(options):
|
||||||
coredata.parse_cmd_line_options(options)
|
coredata.parse_cmd_line_options(options)
|
||||||
builddir = os.path.abspath(os.path.realpath(options.builddir))
|
builddir = os.path.abspath(os.path.realpath(options.builddir))
|
||||||
|
print_only = not options.cmd_line_options and not options.clearcache
|
||||||
c = None
|
c = None
|
||||||
try:
|
try:
|
||||||
c = Conf(builddir)
|
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)
|
c.print_conf(options.pager)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -308,11 +311,9 @@ def run(options):
|
||||||
if options.cmd_line_options:
|
if options.cmd_line_options:
|
||||||
save = c.set_options(options.cmd_line_options)
|
save = c.set_options(options.cmd_line_options)
|
||||||
coredata.update_cmd_line_file(builddir, options)
|
coredata.update_cmd_line_file(builddir, options)
|
||||||
elif options.clearcache:
|
if options.clearcache:
|
||||||
c.clear_cache()
|
c.clear_cache()
|
||||||
save = True
|
save = True
|
||||||
else:
|
|
||||||
c.print_conf(options.pager)
|
|
||||||
if save:
|
if save:
|
||||||
c.save()
|
c.save()
|
||||||
mintro.update_build_options(c.coredata, c.build.environment.info_dir)
|
mintro.update_build_options(c.coredata, c.build.environment.info_dir)
|
||||||
|
|
Loading…
Reference in New Issue