diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2023-06-10 18:59:16 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2023-06-10 18:59:57 +0300 |
commit | 93bc01fae9284d00af30cb27ede275bc71cec6f6 (patch) | |
tree | 112caf7ada51ef14887777b857fbcba3f5e88563 | |
parent | f2f42318ed047ebf25cfb53c24faf6c15539fff6 (diff) | |
download | meson-cleanstray.zip meson-cleanstray.tar.gz meson-cleanstray.tar.bz2 |
Purge persistent Ninja state when doing a full reconfigure.cleanstray
-rw-r--r-- | mesonbuild/msetup.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py index 2a559d8..4c5e925 100644 --- a/mesonbuild/msetup.py +++ b/mesonbuild/msetup.py @@ -185,8 +185,27 @@ class MesonApp: raise MesonException(f'Directory is not empty and does not contain a previous build:\n{build_dir}') return src_dir, build_dir + def purge_stray_files(self, builddir): + # If you are in the build directory and reset your build directory like this: + # + # rm -rf * + # meson <args> + # + # Then dotfiles used by Ninja are not deleted and get used in the new build. + # This can lead to very confusing and unexpected behaviour. + try: + os.unlink(os.path.join(builddir, '.ninja_deps')) + except FileNotFoundError: + pass + try: + os.unlink(os.path.join(builddir, '.ninja_log')) + except FileNotFoundError: + pass + def generate(self) -> None: env = environment.Environment(self.source_dir, self.build_dir, self.options) + if env.first_invocation: + self.purge_stray_files(self.build_dir) mlog.initialize(env.get_log_dir(), self.options.fatal_warnings) if self.options.profile: mlog.set_timestamp_start(time.monotonic()) |