diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2024-03-08 10:40:42 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-03-18 16:06:37 -0700 |
| commit | c6875305f327a6be506d6544516f35e792f6d625 (patch) | |
| tree | c54b1534f5e8c914678525721e8448903faf92bd | |
| parent | 8a10c8a5399077cb3cd8436914ad1d8a71d1a3e7 (diff) | |
| download | meson-c6875305f327a6be506d6544516f35e792f6d625.tar.gz | |
coredata: add tracking of the options files
When we load the option file in the interpreter record which file it
was, and what the hash of that file was. This will let `meson configure`
know that the options have changed since the last re-configure.
| -rw-r--r-- | mesonbuild/coredata.py | 5 | ||||
| -rw-r--r-- | mesonbuild/interpreter/interpreter.py | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 0c2f5010c..b12ec8203 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -575,6 +575,11 @@ class CoreData: self.cross_files = self.__load_config_files(options, scratch_dir, 'cross') self.compilers: PerMachine[T.Dict[str, Compiler]] = PerMachine(OrderedDict(), OrderedDict()) + # Stores the (name, hash) of the options file, The name will be either + # "meson_options.txt" or "meson.options". + # This is used by mconf to reload the option file if it's changed. + self.options_files: T.Dict[SubProject, T.Optional[T.Tuple[str, str]]] = {} + # Set of subprojects that have already been initialized once, this is # required to be stored and reloaded with the coredata, as we don't # want to overwrite options for such subprojects. diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index d870de191..2c1ac89f6 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -4,6 +4,8 @@ from __future__ import annotations +import hashlib + from .. import mparser from .. import environment from .. import coredata @@ -1187,10 +1189,16 @@ class Interpreter(InterpreterBase, HoldableObject): else: option_file = old_option_file if os.path.exists(option_file): + with open(option_file, 'rb') as f: + # We want fast, not cryptographically secure, this is just to see of + # the option file has changed + self.coredata.options_files[self.subproject] = (option_file, hashlib.sha1(f.read()).hexdigest()) oi = optinterpreter.OptionInterpreter(self.subproject) oi.process(option_file) self.coredata.update_project_options(oi.options, self.subproject) self.add_build_def_file(option_file) + else: + self.coredata.options_files[self.subproject] = None if self.subproject: self.project_default_options = {k.evolve(subproject=self.subproject): v |
