Fix a subtle proguard incremental build error
Prevent a confusing incremental build failure where proguard would read and write to the same file accidentally, failing hard. Can happen after switching the build from not using proguard, where the output jar is a gn-copy hardlink to the input jar, to using proguard, where the output is written to by a script reading from the input jar. Fix by checking if the output is not a hardlink to the input in the wrapper script. NB. The build normally uses proguard on an apk, but makes it possible to try and only proguard a single jar, and the bug potentially only happens in this case. Review-Url: https://codereview.chromium.org/2485663003 Cr-Original-Commit-Position: refs/heads/master@{#430890} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 20b2c575c5ca4b674de21261151af412e9959047
This commit is contained in:
Родитель
8b8efd2512
Коммит
e9ad24f40f
|
@ -66,6 +66,18 @@ def main(args):
|
|||
args = build_utils.ExpandFileArgs(args)
|
||||
options = _ParseOptions(args)
|
||||
|
||||
# Work around cases where we switch from a non-proguard setup
|
||||
# to proguard. The output jar might exist and might be a hardlink
|
||||
# to the input jar, so remove the output before doing anything
|
||||
# in that case to avoid an incremental build failure.
|
||||
try:
|
||||
out_inode = os.stat(options.output_path).st_ino
|
||||
except OSError:
|
||||
out_inode = None
|
||||
if (out_inode and
|
||||
out_inode in (os.stat(injar).st_ino for injar in options.input_paths)):
|
||||
os.unlink(options.output_path)
|
||||
|
||||
proguard = proguard_util.ProguardCmdBuilder(options.proguard_path)
|
||||
proguard.injars(options.input_paths)
|
||||
proguard.configs(options.proguard_configs)
|
||||
|
|
Загрузка…
Ссылка в новой задаче