summaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-10-07 15:03:49 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-10-29 18:59:30 +0200
commit1f0644f9c60eb8c4db7057db50f3316575d06b76 (patch)
treee88e05557ba603e465c76e8ee76870a14d6abac3 /mesonbuild/environment.py
parenta4444c21f3890b4ae18d128864850062d6472ac6 (diff)
downloadmeson-1f0644f9c60eb8c4db7057db50f3316575d06b76.tar.gz
coredata: move cmd_line.txt and command line handling to a new module
cmd_line.txt is not related to serialized data, in fact it's a fallback for when serialized data cannot be used and is also related to setting up argparse for command line parsing. Since there is no code in common with the rest of coredata, move it to a new module. Fixes: #15081 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index b33d8b854..fe364442e 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -9,13 +9,12 @@ import os, platform, re, sys, shutil
import typing as T
import collections
+from . import cmdline
from . import coredata
from . import mesonlib
from . import machinefile
from . import options
-CmdLineFileParser = machinefile.CmdLineFileParser
-
from .mesonlib import (
MesonException, MachineChoice, Popen_safe, PerMachine,
PerMachineDefaultable, PerThreeMachineDefaultable, split_args, quote_arg,
@@ -580,7 +579,7 @@ class Environment:
log_dir = 'meson-logs'
info_dir = 'meson-info'
- def __init__(self, source_dir: str, build_dir: T.Optional[str], cmd_options: coredata.SharedCMDOptions) -> None:
+ def __init__(self, source_dir: str, build_dir: T.Optional[str], cmd_options: cmdline.SharedCMDOptions) -> None:
self.source_dir = source_dir
# Do not try to create build directories when build_dir is none.
# This reduced mode is used by the --buildoptions introspector
@@ -600,15 +599,15 @@ class Environment:
except coredata.MesonVersionMismatchException as e:
# This is routine, but tell the user the update happened
mlog.log('Regenerating configuration from scratch:', str(e))
- coredata.read_cmd_line_file(self.build_dir, cmd_options)
+ cmdline.read_cmd_line_file(self.build_dir, cmd_options)
self.create_new_coredata(cmd_options)
except MesonException as e:
# If we stored previous command line options, we can recover from
# a broken/outdated coredata.
- if os.path.isfile(coredata.get_cmd_line_file(self.build_dir)):
+ if os.path.isfile(cmdline.get_cmd_line_file(self.build_dir)):
mlog.warning('Regenerating configuration from scratch.', fatal=False)
mlog.log('Reason:', mlog.red(str(e)))
- coredata.read_cmd_line_file(self.build_dir, cmd_options)
+ cmdline.read_cmd_line_file(self.build_dir, cmd_options)
self.create_new_coredata(cmd_options)
else:
raise MesonException(f'{str(e)} Try regenerating using "meson setup --wipe".')
@@ -890,7 +889,7 @@ class Environment:
self.properties[for_machine].properties.setdefault(name, p_env)
break
- def create_new_coredata(self, options: coredata.SharedCMDOptions) -> None:
+ def create_new_coredata(self, options: cmdline.SharedCMDOptions) -> None:
# WARNING: Don't use any values from coredata in __init__. It gets
# re-initialized with project options by the interpreter during
# build file parsing.