Have build/landmines.py delete contents of build directory.

Some checkouts have the build directory mounted, which causes the script
to throw an exception when it attempts to remove the directory itself.

Review URL: https://codereview.chromium.org/532323002

Cr-Original-Commit-Position: refs/heads/master@{#293199}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: bb04e1054366543cb554531c728b33525a5dae8c
This commit is contained in:
scherkus 2014-09-03 14:28:23 -07:00 коммит произвёл Commit bot
Родитель 86d4db9d3d
Коммит d0249ef6cb
1 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -5,7 +5,8 @@
"""
This script runs every build as the first hook (See DEPS). If it detects that
the build should be clobbered, it will remove the build directory.
the build should be clobbered, it will delete the contents of the build
directory.
A landmine is tripped when a builder checks out a different revision, and the
diff between the new landmines and the old ones is non-null. At this point, the
@ -70,8 +71,14 @@ def clobber_if_necessary(new_landmines):
sys.stdout.write('Clobbering due to:\n')
sys.stdout.writelines(diff)
# Clobber.
shutil.rmtree(out_dir)
# Clobber contents of build directory but not directory itself: some
# checkouts have the build directory mounted.
for f in os.listdir(out_dir):
path = os.path.join(out_dir, f)
if os.path.isfile(path):
os.unlink(path)
elif os.path.isdir(path):
shutil.rmtree(path)
# Save current set of landmines for next time.
with open(landmines_path, 'w') as f: