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

Unified Diff: tools/determinism/compare_build_artifacts.py

Issue 2303063003: Skip COFF timestamp difference. (Closed)
Patch Set: merge may_skip_conff_header function. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/determinism/compare_build_artifacts.py
diff --git a/tools/determinism/compare_build_artifacts.py b/tools/determinism/compare_build_artifacts.py
index d486cb99db63af1ac1eaa66dcce8164b7e3b6d87..564cf62a360ecc9aec224c69b26692f6acdd4bb7 100755
--- a/tools/determinism/compare_build_artifacts.py
+++ b/tools/determinism/compare_build_artifacts.py
@@ -445,6 +445,24 @@ def diff_binary(first_filepath, second_filepath, file_len):
offset = 0
with open(first_filepath, 'rb') as lhs:
with open(second_filepath, 'rb') as rhs:
+ # Skip part of Win32 COFF header if timestamps are different.
+ #
+ # COFF header:
+ # 0 - 1: magic.
+ # 2 - 3: # sections.
+ # 4 - 7: timestamp.
+ # ....
+ COFF_HEADER_TO_COMPARE_SIZE = 8
+ if (sys.platform == 'win32' and first_filepath.endswith('.obj')
+ and file_len > COFF_HEADER_TO_COMPARE_SIZE):
+ rhs_data = rhs.read(COFF_HEADER_TO_COMPARE_SIZE)
+ lhs_data = lhs.read(COFF_HEADER_TO_COMPARE_SIZE)
+ if lhs_data[0:4] == rhs_data[0:4] and lhs_data[4:8] != rhs_data[4:8]:
+ offset += COFF_HEADER_TO_COMPARE_SIZE
+ else:
+ lhs.seek(0)
+ rhs.seek(0)
+
while True:
lhs_data = lhs.read(CHUNK_SIZE)
rhs_data = rhs.read(CHUNK_SIZE)
@@ -559,7 +577,7 @@ def compare_deps(first_dir, second_dir, targets):
second_file = os.path.join(second_dir, d)
result = compare_files(first_file, second_file)
if result:
- print('%-*s: %s' % (max_filepath_len, d, result))
+ print(' %-*s: %s' % (max_filepath_len, d, result))
def compare_build_artifacts(first_dir, second_dir, target_platform,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698