| Index: mojo/tools/upload_binaries.py
|
| diff --git a/mojo/tools/upload_binaries.py b/mojo/tools/upload_binaries.py
|
| index 69be3cc10b55f6cde6e1c63e45c05e15e237ab23..2c7537eca1ce5c4352618cdad042e06c5151ca32 100755
|
| --- a/mojo/tools/upload_binaries.py
|
| +++ b/mojo/tools/upload_binaries.py
|
| @@ -9,6 +9,7 @@ https://github.com/domokit/mojo/wiki/Rolling-code-between-chromium-and-mojo#chro
|
|
|
| import argparse
|
| import glob
|
| +import itertools
|
| import os
|
| import subprocess
|
| import sys
|
| @@ -21,6 +22,11 @@ from mopy.config import Config
|
| from mopy.paths import Paths
|
| from mopy.version import Version
|
|
|
| +sys.path.append(os.path.join(os.path.dirname(__file__),
|
| + os.pardir, os.pardir, "third_party", "pyelftools"))
|
| +import elftools
|
| +import elftools.elf.elffile as elffile
|
| +
|
| BLACKLISTED_APPS = [
|
| # The network service apps are not produced out of the Mojo repo, but may
|
| # be present in the build dir.
|
| @@ -79,6 +85,42 @@ def upload(config, source, dest, dry_run):
|
| subprocess.check_call([gsutil_exe, "cp", source, dest])
|
|
|
|
|
| +def _get_signature(file_object):
|
| + """Compute a unique signature of a library file.
|
| +
|
| + TODO(qsr): Move this function to devtools and import it from there to ensure
|
| + signature computation is always coherent.
|
| + """
|
| + try:
|
| + elf = elffile.ELFFile(file_object)
|
| + text_section = elf.get_section_by_name(".text")
|
| + file_object.seek(text_section["sh_offset"])
|
| + data = file_object.read(min(4096, text_section["sh_size"]))
|
| + def combine((i, c)):
|
| + return i ^ ord(c)
|
| + result = 16 * [0]
|
| + for i in xrange(0, len(data), len(result)):
|
| + result = map(combine,
|
| + itertools.izip_longest(result,
|
| + data[i:i + len(result)],
|
| + fillvalue="\0"))
|
| + return "".join(["%02x" % x for x in result])
|
| + except elftools.common.exceptions.ELFError:
|
| + return None
|
| +
|
| +
|
| +def upload_symbols(config, build_dir, dry_run):
|
| + dest_dir = "gs://mojo/symbols/"
|
| + symbols_dir = os.path.join(build_dir, "symbols")
|
| + for name in os.listdir(symbols_dir):
|
| + path = os.path.join(symbols_dir, name)
|
| + with open(path) as f:
|
| + signature = _get_signature(f)
|
| + if signature is not None:
|
| + dest = dest_dir + _get_signature(f)
|
| + upload(config, path, dest, dry_run)
|
| +
|
| +
|
| def upload_shell(config, dry_run, verbose):
|
| paths = Paths(config)
|
| zipfile_name = target(config)
|
| @@ -224,6 +266,8 @@ def main():
|
| for file_to_upload in files_to_upload:
|
| upload_file(file_to_upload, config, args.dry_run)
|
|
|
| + upload_symbols(config, build_directory, args.dry_run)
|
| +
|
| return 0
|
|
|
| if __name__ == "__main__":
|
|
|