Copy cdb.exe into telemetry_chrome_test's isolate.

This binary needs to be available on the Swarming bots, but only
Google employees and the bots have access to the hermetic Windows
toolchain. Since the isolates are only built by these entities, only
copy and bundle them in this situation.

BUG=561763
R=scottmg@chromium.org, nednguyen@chromium.org
TBR=maruel@chromium.org

Review URL: https://codereview.chromium.org/1859013002

Cr-Original-Commit-Position: refs/heads/master@{#385880}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 52685e82ecadd2824732bd6990b8c377142b8b81
This commit is contained in:
kbr 2016-04-07 14:37:19 -07:00 коммит произвёл Commit bot
Родитель bc05023426
Коммит 4e0c864169
1 изменённых файлов: 83 добавлений и 0 удалений

83
win/copy_cdb_to_output.py Executable file
Просмотреть файл

@ -0,0 +1,83 @@
#!/usr/bin/env python
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import hashlib
import os
import shutil
import sys
script_dir = os.path.dirname(os.path.realpath(__file__))
src_build_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
sys.path.insert(0, src_build_dir)
import vs_toolchain
def _HexDigest(file_name):
hasher = hashlib.sha256()
afile = open(file_name, 'rb')
blocksize = 65536
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
return hasher.hexdigest()
def _CopyImpl(file_name, target_dir, source_dir, verbose=True):
"""Copy |source| to |target| if it doesn't already exist or if it
needs to be updated.
"""
target = os.path.join(target_dir, file_name)
source = os.path.join(source_dir, file_name)
if (os.path.isdir(os.path.dirname(target)) and
((not os.path.isfile(target)) or
_HexDigest(source) != _HexDigest(target))):
if verbose:
print 'Copying %s to %s...' % (source, target)
if os.path.exists(target):
os.unlink(target)
shutil.copy(source, target)
def _CopyCDBToOutput(output_dir, target_arch):
"""Copies the Windows debugging executable cdb.exe to the output
directory, which is created if it does not exist. The output
directory, and target architecture that should be copied, are
passed. Supported values for the target architecture are the GYP
values "ia32" and "x64".
"""
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
win_sdk_dir = os.path.normpath(os.environ['WINDOWSSDKDIR'])
if target_arch == 'ia32':
src_arch = 'x86'
elif target_arch == 'x64':
src_arch = 'x64'
else:
print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch
sys.exit(1)
# We need to copy multiple files, so cache the computed source directory.
src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch)
# Note that the outputs from the "copy_cdb_to_output" target need to
# be kept in sync with this list.
_CopyImpl('cdb.exe', output_dir, src_dir)
_CopyImpl('dbgeng.dll', output_dir, src_dir)
_CopyImpl('dbghelp.dll', output_dir, src_dir)
_CopyImpl('dbgmodel.dll', output_dir, src_dir)
return 0
def main():
if len(sys.argv) < 2:
print >>sys.stderr, 'Usage: copy_cdb_to_output.py <output_dir> ' + \
'<target_arch>'
return 1
return _CopyCDBToOutput(sys.argv[1], sys.argv[2])
if __name__ == '__main__':
sys.exit(main())