Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Tool to roll Chromium into Mojo. See: | 6 """Tool to roll Chromium into Mojo. See: |
| 7 https://github.com/domokit/mojo/wiki/Rolling-code-between-chromium-and-mojo#chro mium---mojo-updates | 7 https://github.com/domokit/mojo/wiki/Rolling-code-between-chromium-and-mojo#chro mium---mojo-updates |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import argparse | 10 import argparse |
| 11 import glob | 11 import glob |
| 12 import itertools | |
| 12 import os | 13 import os |
| 13 import subprocess | 14 import subprocess |
| 14 import sys | 15 import sys |
| 15 import tempfile | 16 import tempfile |
| 16 import time | 17 import time |
| 17 import zipfile | 18 import zipfile |
| 18 | 19 |
| 19 import mopy.gn as gn | 20 import mopy.gn as gn |
| 20 from mopy.config import Config | 21 from mopy.config import Config |
| 21 from mopy.paths import Paths | 22 from mopy.paths import Paths |
| 22 from mopy.version import Version | 23 from mopy.version import Version |
| 23 | 24 |
| 25 sys.path.append(os.path.join(os.path.dirname(__file__), | |
| 26 '../../third_party/pyelftools')) | |
|
viettrungluu
2015/07/10 18:27:01
os.path.join(os.pardir, os.pardir, "third_party",
qsr
2015/07/15 13:49:11
Done.
| |
| 27 import elftools.elf.elffile as elffile | |
| 28 | |
| 24 BLACKLISTED_APPS = [ | 29 BLACKLISTED_APPS = [ |
| 25 # The network service apps are not produced out of the Mojo repo, but may | 30 # The network service apps are not produced out of the Mojo repo, but may |
| 26 # be present in the build dir. | 31 # be present in the build dir. |
| 27 "network_service.mojo", | 32 "network_service.mojo", |
| 28 "network_service_apptests.mojo", | 33 "network_service_apptests.mojo", |
| 29 ] | 34 ] |
| 30 | 35 |
| 31 ARCHITECTURE_INDEPENDENT_FILES = [ | 36 ARCHITECTURE_INDEPENDENT_FILES = [ |
| 32 # These are files other than *.mojo files which are part of our binary | 37 # These are files other than *.mojo files which are part of our binary |
| 33 # artifact scheme. These files must be architecture independent. | 38 # artifact scheme. These files must be architecture independent. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 77 |
| 73 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 78 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| 74 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") | 79 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") |
| 75 | 80 |
| 76 if dry_run: | 81 if dry_run: |
| 77 print str([gsutil_exe, "cp", source, dest]) | 82 print str([gsutil_exe, "cp", source, dest]) |
| 78 else: | 83 else: |
| 79 subprocess.check_call([gsutil_exe, "cp", source, dest]) | 84 subprocess.check_call([gsutil_exe, "cp", source, dest]) |
| 80 | 85 |
| 81 | 86 |
| 87 def _get_signature(file_object): | |
| 88 """Compute a unique signature of a library file. | |
|
viettrungluu
2015/07/10 18:27:01
And what if it's not a library file, or even an EL
qsr
2015/07/10 19:35:27
Was certain it was returning None. Will change.
| |
| 89 | |
| 90 TODO(qsr): Move this function to devtools and import it from there to ensure | |
| 91 signature computation is always coherent. | |
| 92 """ | |
| 93 elf = elffile.ELFFile(file_object) | |
| 94 text_section = elf.get_section_by_name('.text') | |
|
viettrungluu
2015/07/10 18:27:01
Apparently, "s are mostly preferred in this file o
qsr
2015/07/15 13:49:11
Done.
| |
| 95 file_object.seek(text_section['sh_offset']) | |
| 96 data = file_object.read(min(4096, text_section['sh_size'])) | |
|
viettrungluu
2015/07/10 18:27:01
It seems a little weak (in terms of "uniqueness")
qsr
2015/07/10 19:35:27
So this algo is what breakpad use, so I do not see
| |
| 97 def combine((i, c)): | |
| 98 return i ^ ord(c) | |
| 99 result = 16 * [0] | |
| 100 for i in xrange(0, len(data), len(result)): | |
|
viettrungluu
2015/07/10 18:27:01
... and I don't understand why you wouldn't use a
qsr
2015/07/10 19:35:27
Same thing, this is what breakpad is doing and I d
| |
| 101 result = map(combine, | |
| 102 itertools.izip_longest(result, | |
| 103 data[i:i + len(result)], | |
| 104 fillvalue='\0')) | |
| 105 return ''.join(["%02x" % x for x in result]) | |
| 106 | |
| 107 | |
| 108 def upload_symbols(config, build_dir, dry_run): | |
| 109 dest_dir = "gs://mojo/symbols/" | |
| 110 for name in os.listdir(build_dir): | |
| 111 path = os.path.join(build_dir, name) | |
| 112 if (os.path.isfile(path) and | |
| 113 not os.path.islink(path) and | |
| 114 os.access(path, os.X_OK) and | |
|
viettrungluu
2015/07/10 18:27:01
This seems to assume that all files in the build d
qsr
2015/07/10 19:35:27
Getting some more artifact is not really a problem
| |
| 115 not path.endswith('.mojo')): | |
| 116 with open(path) as f: | |
| 117 dest = dest_dir + _get_signature(f) | |
| 118 upload(config, path, dest, dry_run) | |
| 119 | |
| 120 | |
| 82 def upload_shell(config, dry_run, verbose): | 121 def upload_shell(config, dry_run, verbose): |
| 83 paths = Paths(config) | 122 paths = Paths(config) |
| 84 zipfile_name = target(config) | 123 zipfile_name = target(config) |
| 85 version = Version().version | 124 version = Version().version |
| 86 | 125 |
| 87 # Upload the binary. | 126 # Upload the binary. |
| 88 # TODO(blundell): Change this to be in the same structure as the LATEST files, | 127 # TODO(blundell): Change this to be in the same structure as the LATEST files, |
| 89 # e.g., gs://mojo/shell/linux-x64/<version>/shell.zip. | 128 # e.g., gs://mojo/shell/linux-x64/<version>/shell.zip. |
| 90 dest = "gs://mojo/shell/" + version + "/" + zipfile_name + ".zip" | 129 dest = "gs://mojo/shell/" + version + "/" + zipfile_name + ".zip" |
| 91 with tempfile.NamedTemporaryFile() as zip_file: | 130 with tempfile.NamedTemporaryFile() as zip_file: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 211 |
| 173 build_directory = gn.BuildDirectoryForConfig(config, Paths(config).src_root) | 212 build_directory = gn.BuildDirectoryForConfig(config, Paths(config).src_root) |
| 174 apps_to_upload = find_apps_to_upload(build_directory) | 213 apps_to_upload = find_apps_to_upload(build_directory) |
| 175 for app in apps_to_upload: | 214 for app in apps_to_upload: |
| 176 upload_app(app, config, args.dry_run) | 215 upload_app(app, config, args.dry_run) |
| 177 | 216 |
| 178 files_to_upload = find_architecture_independent_files(build_directory) | 217 files_to_upload = find_architecture_independent_files(build_directory) |
| 179 for file_to_upload in files_to_upload: | 218 for file_to_upload in files_to_upload: |
| 180 upload_file(file_to_upload, config, args.dry_run) | 219 upload_file(file_to_upload, config, args.dry_run) |
| 181 | 220 |
| 221 upload_symbols(config, build_directory, args.dry_run) | |
| 222 | |
| 182 return 0 | 223 return 0 |
| 183 | 224 |
| 184 if __name__ == "__main__": | 225 if __name__ == "__main__": |
| 185 sys.exit(main()) | 226 sys.exit(main()) |
| OLD | NEW |