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.
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 0c2f501..b12ec82 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -575,6 +575,11 @@
         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 d870de1..2c1ac89 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 @@
         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