aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mesonlib.py16
-rw-r--r--mesonbuild/msetup.py10
2 files changed, 25 insertions, 1 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 59d4f81..98c2366 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -1116,6 +1116,22 @@ def windows_proof_rmtree(f):
shutil.rmtree(f)
+def windows_proof_rm(fpath):
+ """Like windows_proof_rmtree, but for a single file."""
+ if os.path.isfile(fpath):
+ os.chmod(fpath, os.stat(fpath).st_mode | stat.S_IWRITE | stat.S_IREAD)
+ delays = [0.1, 0.1, 0.2, 0.2, 0.2, 0.5, 0.5, 1, 1, 1, 1, 2]
+ for d in delays:
+ try:
+ os.unlink(fpath)
+ return
+ except FileNotFoundError:
+ return
+ except (OSError, PermissionError):
+ time.sleep(d)
+ os.unlink(fpath)
+
+
def detect_subprojects(spdir_name, current_dir='', result=None):
if result is None:
result = {}
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
index 63014f1..56a0e9a 100644
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -73,7 +73,15 @@ class MesonApp:
coredata.read_cmd_line_file(self.build_dir, options)
try:
- mesonlib.windows_proof_rmtree(self.build_dir)
+ # Don't delete the whole tree, just all of the files and
+ # folders in the tree. Otherwise calling wipe form the builddir
+ # will cause a crash
+ for l in os.listdir(self.build_dir):
+ l = os.path.join(self.build_dir, l)
+ if os.path.isdir(l):
+ mesonlib.windows_proof_rmtree(l)
+ else:
+ mesonlib.windows_proof_rm(l)
finally:
# Restore the file
path = os.path.dirname(filename)