| 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 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 import android_gdb.signatures as signatures | 31 import android_gdb.signatures as signatures |
| 32 | 32 |
| 33 | 33 |
| 34 BLACKLISTED_APPS = [ | 34 BLACKLISTED_APPS = [ |
| 35 # The network service apps are not produced out of the Mojo repo, but may | 35 # The network service apps are not produced out of the Mojo repo, but may |
| 36 # be present in the build dir. | 36 # be present in the build dir. |
| 37 "network_service.mojo", | 37 "network_service.mojo", |
| 38 "network_service_apptests.mojo", | 38 "network_service_apptests.mojo", |
| 39 ] | 39 ] |
| 40 | 40 |
| 41 ARCHITECTURE_INDEPENDENT_FILES = [ | |
| 42 # These are files other than *.mojo files which are part of our binary | |
| 43 # artifact scheme. These files must be architecture independent. | |
| 44 "obj/mojo/dart/apptest/apptest.dartzip", | |
| 45 ] | |
| 46 | |
| 47 | 41 |
| 48 def target(config): | 42 def target(config): |
| 49 target_name = config.target_os + "-" + config.target_cpu | 43 target_name = config.target_os + "-" + config.target_cpu |
| 50 if config.is_official_build: | 44 if config.is_official_build: |
| 51 target_name += "-official" | 45 target_name += "-official" |
| 52 return target_name | 46 return target_name |
| 53 | 47 |
| 48 |
| 54 def find_apps_to_upload(build_dir): | 49 def find_apps_to_upload(build_dir): |
| 55 apps = [] | 50 apps = [] |
| 56 for path in glob.glob(build_dir + "/*"): | 51 for path in glob.glob(build_dir + "/*"): |
| 57 if not os.path.isfile(path): | 52 if not os.path.isfile(path): |
| 58 continue | 53 continue |
| 59 _, ext = os.path.splitext(path) | 54 _, ext = os.path.splitext(path) |
| 60 if ext != '.mojo': | 55 if ext != '.mojo': |
| 61 continue | 56 continue |
| 62 if os.path.basename(path) in BLACKLISTED_APPS: | 57 if os.path.basename(path) in BLACKLISTED_APPS: |
| 63 continue | 58 continue |
| 64 apps.append(path) | 59 apps.append(path) |
| 65 return apps | 60 return apps |
| 66 | 61 |
| 67 | 62 |
| 68 def find_architecture_independent_files(build_dir): | |
| 69 existing_files = [] | |
| 70 for path in ARCHITECTURE_INDEPENDENT_FILES: | |
| 71 joined_path = os.path.join(build_dir, path) | |
| 72 if os.path.isfile(joined_path): | |
| 73 existing_files.append(joined_path) | |
| 74 return existing_files | |
| 75 | |
| 76 | |
| 77 def check_call(command_line, dry_run, **kwargs): | 63 def check_call(command_line, dry_run, **kwargs): |
| 78 if dry_run: | 64 if dry_run: |
| 79 print command_line | 65 print command_line |
| 80 else: | 66 else: |
| 81 subprocess.check_call(command_line, **kwargs) | 67 subprocess.check_call(command_line, **kwargs) |
| 82 | 68 |
| 83 | 69 |
| 84 def upload(config, source, dest, dry_run, gzip=False): | 70 def upload(config, source, dest, dry_run, gzip=False): |
| 85 paths = Paths(config) | 71 paths = Paths(config) |
| 86 sys.path.insert(0, os.path.join(paths.src_root, "tools")) | 72 sys.path.insert(0, os.path.join(paths.src_root, "tools")) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 def upload_app(app_binary_path, config, dry_run): | 173 def upload_app(app_binary_path, config, dry_run): |
| 188 app_binary_name = os.path.basename(app_binary_path) | 174 app_binary_name = os.path.basename(app_binary_path) |
| 189 version = Version().version | 175 version = Version().version |
| 190 gsutil_app_location = ("gs://mojo/services/%s/%s/%s" % | 176 gsutil_app_location = ("gs://mojo/services/%s/%s/%s" % |
| 191 (target(config), version, app_binary_name)) | 177 (target(config), version, app_binary_name)) |
| 192 | 178 |
| 193 # Upload the new binary. | 179 # Upload the new binary. |
| 194 upload(config, app_binary_path, gsutil_app_location, dry_run) | 180 upload(config, app_binary_path, gsutil_app_location, dry_run) |
| 195 | 181 |
| 196 | 182 |
| 197 def upload_file(file_path, config, dry_run): | |
| 198 file_binary_name = os.path.basename(file_path) | |
| 199 version = Version().version | |
| 200 gsutil_file_location = "gs://mojo/file/%s/%s" % (version, file_binary_name) | |
| 201 | |
| 202 # Upload the new binary. | |
| 203 upload(config, file_path, gsutil_file_location, dry_run) | |
| 204 | |
| 205 | |
| 206 def write_file_to_gs(file_contents, dest, config, dry_run): | 183 def write_file_to_gs(file_contents, dest, config, dry_run): |
| 207 with tempfile.NamedTemporaryFile() as temp_version_file: | 184 with tempfile.NamedTemporaryFile() as temp_version_file: |
| 208 temp_version_file.write(file_contents) | 185 temp_version_file.write(file_contents) |
| 209 temp_version_file.flush() | 186 temp_version_file.flush() |
| 210 upload(config, temp_version_file.name, dest, dry_run) | 187 upload(config, temp_version_file.name, dest, dry_run) |
| 211 | 188 |
| 212 | 189 |
| 213 def main(): | 190 def main(): |
| 214 parser = argparse.ArgumentParser(description="Upload binaries for apps and " | 191 parser = argparse.ArgumentParser(description="Upload binaries for apps and " |
| 215 "the Mojo shell to google storage (by default on Linux, but this can be " | 192 "the Mojo shell to google storage (by default on Linux, but this can be " |
| (...skipping 28 matching lines...) Expand all Loading... |
| 244 | 221 |
| 245 if is_official_build: | 222 if is_official_build: |
| 246 print "Skipping uploading apps (official apk build)." | 223 print "Skipping uploading apps (official apk build)." |
| 247 return 0 | 224 return 0 |
| 248 | 225 |
| 249 build_directory = gn.BuildDirectoryForConfig(config, Paths(config).src_root) | 226 build_directory = gn.BuildDirectoryForConfig(config, Paths(config).src_root) |
| 250 apps_to_upload = find_apps_to_upload(build_directory) | 227 apps_to_upload = find_apps_to_upload(build_directory) |
| 251 for app in apps_to_upload: | 228 for app in apps_to_upload: |
| 252 upload_app(app, config, args.dry_run) | 229 upload_app(app, config, args.dry_run) |
| 253 | 230 |
| 254 files_to_upload = find_architecture_independent_files(build_directory) | |
| 255 for file_to_upload in files_to_upload: | |
| 256 upload_file(file_to_upload, config, args.dry_run) | |
| 257 | |
| 258 upload_symbols(config, build_directory, | 231 upload_symbols(config, build_directory, |
| 259 args.symbols_upload_url, args.dry_run) | 232 args.symbols_upload_url, args.dry_run) |
| 260 | 233 |
| 261 upload_dart_snapshotter(config, args.dry_run, args.verbose) | 234 upload_dart_snapshotter(config, args.dry_run, args.verbose) |
| 262 | 235 |
| 263 return 0 | 236 return 0 |
| 264 | 237 |
| 265 if __name__ == "__main__": | 238 if __name__ == "__main__": |
| 266 sys.exit(main()) | 239 sys.exit(main()) |
| OLD | NEW |