Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: build/android/gyp/util/md5_check.py

Issue 1373443004: Improve javac.py --incremental logic by having it recompile more files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« build/android/gyp/javac.py ('K') | « build/android/gyp/javac.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import difflib 5 import difflib
6 import hashlib 6 import hashlib
7 import itertools 7 import itertools
8 import json 8 import json
9 import os 9 import os
10 import sys 10 import sys
11 import zipfile 11 import zipfile
12 12
13 13
14 # When set and a difference is detected, a diff of what changed is printed. 14 # When set and a difference is detected, a diff of what changed is printed.
15 _PRINT_MD5_DIFFS = int(os.environ.get('PRINT_MD5_DIFFS', 0)) 15 PRINT_EXPLANATIONS = int(os.environ.get('PRINT_INCREMENTAL_EXPLANATIONS', 0))
16 16
17 17
18 def CallAndRecordIfStale( 18 def CallAndRecordIfStale(
19 function, record_path=None, input_paths=None, input_strings=None, 19 function, record_path=None, input_paths=None, input_strings=None,
20 output_paths=None, force=False, pass_changes=False): 20 output_paths=None, force=False, pass_changes=False):
21 """Calls function if outputs are stale. 21 """Calls function if outputs are stale.
22 22
23 Outputs are considered stale if: 23 Outputs are considered stale if:
24 - any output_paths are missing, or 24 - any output_paths are missing, or
25 - the contents of any file within input_paths has changed, or 25 - the contents of any file within input_paths has changed, or
26 - the contents of input_strings has changed. 26 - the contents of input_strings has changed.
27 27
28 To debug which files are out-of-date, set the environment variable: 28 To debug which files are out-of-date, set the environment variable:
29 PRINT_MD5_DIFFS=1 29 PRINT_INCREMENTAL_EXPLANATIONS=1
30 30
31 Args: 31 Args:
32 function: The function to call. 32 function: The function to call.
33 record_path: Path to record metadata. 33 record_path: Path to record metadata.
34 Defaults to output_paths[0] + '.md5.stamp' 34 Defaults to output_paths[0] + '.md5.stamp'
35 input_paths: List of paths to calcualte an md5 sum on. 35 input_paths: List of paths to calcualte an md5 sum on.
36 input_strings: List of strings to record verbatim. 36 input_strings: List of strings to record verbatim.
37 output_paths: List of output paths. 37 output_paths: List of output paths.
38 force: Whether to treat outputs as missing regardless of whether they 38 force: Whether to treat outputs as missing regardless of whether they
39 actually are. 39 actually are.
(...skipping 26 matching lines...) Expand all
66 with open(record_path, 'r') as jsonfile: 66 with open(record_path, 'r') as jsonfile:
67 try: 67 try:
68 old_metadata = _Metadata.FromFile(jsonfile) 68 old_metadata = _Metadata.FromFile(jsonfile)
69 except: # pylint: disable=bare-except 69 except: # pylint: disable=bare-except
70 pass # Not yet using new file format. 70 pass # Not yet using new file format.
71 71
72 changes = Changes(old_metadata, new_metadata, force, missing_outputs) 72 changes = Changes(old_metadata, new_metadata, force, missing_outputs)
73 if not changes.HasChanges(): 73 if not changes.HasChanges():
74 return 74 return
75 75
76 if _PRINT_MD5_DIFFS: 76 if PRINT_EXPLANATIONS:
77 print '=' * 80 77 print '=' * 80
78 print 'Target is stale: %s' % record_path 78 print 'Target is stale: %s' % record_path
79 print changes.DescribeDifference() 79 print changes.DescribeDifference()
80 print '=' * 80 80 print '=' * 80
81 81
82 # Delete the old metdata beforehand since failures leave it in an 82 # Delete the old metdata beforehand since failures leave it in an
83 # inderterminate state. 83 # inderterminate state.
84 if old_metadata: 84 if old_metadata:
85 os.unlink(record_path) 85 os.unlink(record_path)
86 86
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 def _ExtractZipEntries(path): 391 def _ExtractZipEntries(path):
392 """Returns a list of (path, CRC32) of all files within |path|.""" 392 """Returns a list of (path, CRC32) of all files within |path|."""
393 entries = [] 393 entries = []
394 with zipfile.ZipFile(path) as zip_file: 394 with zipfile.ZipFile(path) as zip_file:
395 for zip_info in zip_file.infolist(): 395 for zip_info in zip_file.infolist():
396 # Skip directories and empty files. 396 # Skip directories and empty files.
397 if zip_info.CRC: 397 if zip_info.CRC:
398 entries.append((zip_info.filename, zip_info.CRC)) 398 entries.append((zip_info.filename, zip_info.CRC))
399 return entries 399 return entries
OLDNEW
« build/android/gyp/javac.py ('K') | « build/android/gyp/javac.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698