[build] Make generating the VM's version strings work with Ninja's restat feature.
If the version is unchanged, don't write to the file. Ninja will notice the modification time is unchanged and avoid rebuilding the target's dependents. In particular, this means merely adding or amending a commit will no longer make the VM and all SDK snapshots dirty. Change-Id: I25617c6c584d1d1094a339fe14716d18b28c688f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506101 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
e04d2179a1
commit
cf5494aa89
@@ -130,8 +130,13 @@ def main():
|
||||
args.no_sdk_hash, args.version_file)
|
||||
|
||||
if args.output:
|
||||
with open(args.output, 'w') as fh:
|
||||
fh.write(version)
|
||||
# If the output already exists and there is no change, don't even
|
||||
# write to the file. Ninja will notice the output's modified time
|
||||
# is unchanged and avoid rebuilding dependents.
|
||||
if not os.path.exists(args.output) or open(
|
||||
args.output).read() != version:
|
||||
with open(args.output, 'w') as fh:
|
||||
fh.write(version)
|
||||
else:
|
||||
sys.stdout.write(version)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user