Commit 3f562c04 authored by Nico Weber's avatar Nico Weber Committed by LUCI CQ

win_toolchain: Write json files only if different from what is on disk

Bug: chromium:1188672
Change-Id: I10aed281afd636acc0c680a7da486ae74aa637df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2807968
Auto-Submit: Nico Weber <thakis@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: 's avatarBruce Dawson <brucedawson@chromium.org>
parent 51eac66a
...@@ -22,6 +22,7 @@ from __future__ import print_function ...@@ -22,6 +22,7 @@ from __future__ import print_function
import argparse import argparse
import hashlib import hashlib
import filecmp
import json import json
import os import os
import platform import platform
...@@ -575,8 +576,11 @@ def main(): ...@@ -575,8 +576,11 @@ def main():
os.path.join(abs_toolchain_target_dir, 'sysarm64'), os.path.join(abs_toolchain_target_dir, 'sysarm64'),
], ],
} }
with open(os.path.join(target_dir, '..', 'data.json'), 'w') as f: data_json = json.dumps(data)
json.dump(data, f) data_path = os.path.join(target_dir, '..', 'data.json')
if not os.path.exists(data_path) or open(data_path).read() != data_json:
with open(data_path, 'w') as f:
f.write(data_json)
if got_new_toolchain: if got_new_toolchain:
current_hashes = CalculateToolchainHashes(target_dir, False) current_hashes = CalculateToolchainHashes(target_dir, False)
...@@ -589,8 +593,9 @@ def main(): ...@@ -589,8 +593,9 @@ def main():
SaveTimestampsAndHash(target_dir, args.desired_hash) SaveTimestampsAndHash(target_dir, args.desired_hash)
if args.output_json: if args.output_json:
shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), if (not os.path.exists(args.output_json) or
args.output_json) not filecmp.cmp(data_path, args.output_json)):
shutil.copyfile(data_path, args.output_json)
EnableCrashDumpCollection() EnableCrashDumpCollection()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment