Commit e3292294 authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Disable zap_timestamp for the 64-bit builds.

zap_timestamp.exe doesn't support the 64-bit binaries.

the build_bitness function comes from https://cs.chromium.org/chromium/src/chrome/test/chromedriver/util.py?l=45&rcl=ffe66181996a36f5d64e507dbd3dcd78dc1ebecb

Bug: 705133
Change-Id: Ie17e963d62bd3ac508b0de8a853f6d653ef2454b
Reviewed-on: https://chromium-review.googlesource.com/576188
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: default avatarMarc-Antoine Ruel <maruel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487588}
parent 47f939f7
...@@ -8,6 +8,7 @@ import json ...@@ -8,6 +8,7 @@ import json
import multiprocessing import multiprocessing
import optparse import optparse
import os import os
import platform
import Queue import Queue
import shutil import shutil
import subprocess import subprocess
...@@ -25,6 +26,35 @@ _ZAP_TIMESTAMP_BLACKLIST = { ...@@ -25,6 +26,35 @@ _ZAP_TIMESTAMP_BLACKLIST = {
'mini_installer.exe', 'mini_installer.exe',
} }
def build_bitness(build_dir):
# This function checks whether the target (not host) word size is 64-bits.
# Since 64-bit hosts can cross-compile 32-bit binaries, check the GN args to
# see what CPU we're targetting.
try:
args_gn = os.path.join(build_dir, 'args.gn')
with open(args_gn) as f:
for line in f:
decommented = line.split('#', 1)[0]
key_and_value = decommented.split('=', 1)
if len(key_and_value) != 2:
continue
key = key_and_value[0].strip()
value = key_and_value[1].strip()
if key == 'target_cpu':
if value.endswith('64'):
return 64
else:
return 32
except:
pass
# If we don't find anything, or if there is no GN args file, default to the
# host architecture.
if platform.machine().endswith('64'):
return 64
return 32
def get_files_to_clean(build_dir, recursive=False): def get_files_to_clean(build_dir, recursive=False):
"""Get the list of files to clean.""" """Get the list of files to clean."""
allowed = frozenset( allowed = frozenset(
...@@ -67,12 +97,12 @@ def run_zap_timestamp(filepath): ...@@ -67,12 +97,12 @@ def run_zap_timestamp(filepath):
return proc.returncode return proc.returncode
def remove_pe_metadata(filename): def remove_pe_metadata(filename, bitness):
"""Remove the build metadata from a PE file.""" """Remove the build metadata from a PE file."""
# Only run zap_timestamp on the PE files for which we have a PDB. # Only run zap_timestamp on the 32-bit PE files for which we have a PDB.
ret = 0 ret = 0
if ((not os.path.basename(filename) in _ZAP_TIMESTAMP_BLACKLIST) and if ((not os.path.basename(filename) in _ZAP_TIMESTAMP_BLACKLIST) and
os.path.exists(filename + '.pdb')): os.path.exists(filename + '.pdb') and bitness != 64):
ret = run_zap_timestamp(filename) ret = run_zap_timestamp(filename)
return ret return ret
...@@ -99,19 +129,19 @@ def remove_zip_timestamps(filename): ...@@ -99,19 +129,19 @@ def remove_zip_timestamps(filename):
os.remove(out_filename) os.remove(out_filename)
def remove_metadata_worker(file_queue, failed_queue, build_dir): def remove_metadata_worker(file_queue, failed_queue, build_dir, bitness):
"""Worker thread for the remove_metadata function.""" """Worker thread for the remove_metadata function."""
while True: while True:
f = file_queue.get() f = file_queue.get()
if f.endswith(('.dll', '.exe')): if f.endswith(('.dll', '.exe')):
if remove_pe_metadata(os.path.join(build_dir, f)): if remove_pe_metadata(os.path.join(build_dir, f), bitness):
failed_queue.put(f) failed_queue.put(f)
elif f.endswith('.jar'): elif f.endswith('.jar'):
remove_zip_timestamps(os.path.join(build_dir, f)) remove_zip_timestamps(os.path.join(build_dir, f))
file_queue.task_done() file_queue.task_done()
def remove_metadata(build_dir, recursive): def remove_metadata(build_dir, recursive, bitness):
"""Remove the build metadata from the artifacts of a build.""" """Remove the build metadata from the artifacts of a build."""
with open(os.path.join(BASE_DIR, 'deterministic_build_blacklist.json')) as f: with open(os.path.join(BASE_DIR, 'deterministic_build_blacklist.json')) as f:
blacklist = frozenset(json.load(f)) blacklist = frozenset(json.load(f))
...@@ -124,7 +154,8 @@ def remove_metadata(build_dir, recursive): ...@@ -124,7 +154,8 @@ def remove_metadata(build_dir, recursive):
worker = threading.Thread(target=remove_metadata_worker, worker = threading.Thread(target=remove_metadata_worker,
args=(files, args=(files,
failed_files, failed_files,
build_dir)) build_dir,
bitness))
worker.daemon = True worker.daemon = True
worker.start() worker.start()
...@@ -152,7 +183,9 @@ def main(): ...@@ -152,7 +183,9 @@ def main():
if not options.build_dir: if not options.build_dir:
parser.error('--build-dir is required') parser.error('--build-dir is required')
return remove_metadata(options.build_dir, options.recursive) bitness = build_bitness(options.build_dir)
return remove_metadata(options.build_dir, options.recursive, bitness)
if __name__ == '__main__': if __name__ == '__main__':
......
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