Fix clobber.py to restore args.gn on failure
If delete_dir or os.mkdir throw an exception then the code to restore args.gn, build.ninja, and build.ninja.d will not run. This breaks a design goal of gn which is that the args.gn files should not be deleted. The fix is to catch the exception and raise it after the files have been restored. To test the code leave chrome.exe or base_unittests.exe running in one window and run this in another: python build\clobber.py d:\src\chromium\src\out Note that if you do this without the patch applied then all args.gn files may be deleted, so consider backing them up. Also note that args.gn files won't be restored unless build.ninja and build.ninja.d files are also present, so back them up. Just apply the patch first - it's easier. BUG=612940 Review-Url: https://codereview.chromium.org/1996833002 Cr-Original-Commit-Position: refs/heads/master@{#395177} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 562df4f33e0a29669b83d451d33c81648a9e023e
This commit is contained in:
Родитель
4b8ac34d91
Коммит
0f49abeb34
14
clobber.py
14
clobber.py
|
@ -66,10 +66,17 @@ def delete_build_dir(build_dir):
|
|||
except IOError:
|
||||
args_contents = ''
|
||||
|
||||
delete_dir(build_dir)
|
||||
e = None
|
||||
try:
|
||||
# delete_dir and os.mkdir() may fail, such as when chrome.exe is running,
|
||||
# and we still want to restore args.gn/build.ninja/build.ninja.d, so catch
|
||||
# the exception and rethrow it later.
|
||||
delete_dir(build_dir)
|
||||
os.mkdir(build_dir)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
# Put back the args file (if any).
|
||||
os.mkdir(build_dir)
|
||||
if args_contents != '':
|
||||
with open(gn_args_file, 'w') as f:
|
||||
f.write(args_contents)
|
||||
|
@ -94,6 +101,9 @@ depfile = build.ninja.d
|
|||
with open(build_ninja_d_file, 'w') as f:
|
||||
f.write('build.ninja: nonexistant_file.gn\n')
|
||||
|
||||
if e:
|
||||
# Rethrow the exception we caught earlier.
|
||||
raise e
|
||||
|
||||
def clobber(out_dir):
|
||||
"""Clobber contents of build directory.
|
||||
|
|
Загрузка…
Ссылка в новой задаче