| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 command_line.extend([source, dest]) | 83 command_line.extend([source, dest]) |
| 84 | 84 |
| 85 check_call(command_line, dry_run) | 85 check_call(command_line, dry_run) |
| 86 | 86 |
| 87 | 87 |
| 88 def upload_symbols(config, build_dir, breakpad_upload_urls, dry_run): | 88 def upload_symbols(config, build_dir, breakpad_upload_urls, dry_run): |
| 89 dump_syms_exe = os.path.join(Paths().src_root, | 89 dump_syms_exe = os.path.join(Paths().src_root, |
| 90 "mojo", "tools", "linux64", "dump_syms") | 90 "mojo", "tools", "linux64", "dump_syms") |
| 91 symupload_exe = os.path.join(Paths().src_root, | 91 symupload_exe = os.path.join(Paths().src_root, |
| 92 "mojo", "tools", "linux64", "symupload") | 92 "mojo", "tools", "linux64", "symupload") |
| 93 dest_dir = "gs://mojo/symbols/" | 93 dest_dir = config.values['upload_location'] + "symbols/" |
| 94 symbols_dir = os.path.join(build_dir, "symbols") | 94 symbols_dir = os.path.join(build_dir, "symbols") |
| 95 with open(os.devnull, "w") as devnull: | 95 with open(os.devnull, "w") as devnull: |
| 96 for name in os.listdir(symbols_dir): | 96 for name in os.listdir(symbols_dir): |
| 97 path = os.path.join(symbols_dir, name) | 97 path = os.path.join(symbols_dir, name) |
| 98 with open(path) as f: | 98 with open(path) as f: |
| 99 signature = signatures.get_signature(f, elffile) | 99 signature = signatures.get_signature(f, elffile) |
| 100 if signature is not None: | 100 if signature is not None: |
| 101 dest = dest_dir + signature | 101 dest = dest_dir + signature |
| 102 upload(config, path, dest, dry_run) | 102 upload(config, path, dest, dry_run) |
| 103 if breakpad_upload_urls: | 103 if breakpad_upload_urls: |
| 104 with tempfile.NamedTemporaryFile() as temp: | 104 with tempfile.NamedTemporaryFile() as temp: |
| 105 check_call([dump_syms_exe, path], dry_run, | 105 check_call([dump_syms_exe, path], dry_run, |
| 106 stdout=temp, stderr=devnull) | 106 stdout=temp, stderr=devnull) |
| 107 temp.flush() | 107 temp.flush() |
| 108 for upload_url in breakpad_upload_urls: | 108 for upload_url in breakpad_upload_urls: |
| 109 check_call([symupload_exe, temp.name, upload_url], dry_run) | 109 check_call([symupload_exe, temp.name, upload_url], dry_run) |
| 110 | 110 |
| 111 def upload_shell(config, dry_run, verbose): | 111 def upload_shell(config, dry_run, verbose): |
| 112 paths = Paths(config) | 112 paths = Paths(config) |
| 113 zipfile_name = target(config) | 113 zipfile_name = target(config) |
| 114 version = Version().version | 114 version = Version().version |
| 115 | 115 |
| 116 # Upload the binary. | 116 # Upload the binary. |
| 117 # TODO(blundell): Change this to be in the same structure as the LATEST files, | 117 # TODO(blundell): Change this to be in the same structure as the LATEST files, |
| 118 # e.g., gs://mojo/shell/linux-x64/<version>/shell.zip. | 118 # e.g., gs://mojo/shell/linux-x64/<version>/shell.zip. |
| 119 dest = "gs://mojo/shell/" + version + "/" + zipfile_name + ".zip" | 119 dest = config.values['upload_location'] + "shell/" + version + "/" + \ |
| 120 zipfile_name + ".zip" |
| 120 with tempfile.NamedTemporaryFile() as zip_file: | 121 with tempfile.NamedTemporaryFile() as zip_file: |
| 121 with zipfile.ZipFile(zip_file, 'w') as z: | 122 with zipfile.ZipFile(zip_file, 'w') as z: |
| 122 shell_path = paths.target_mojo_shell_path | 123 shell_path = paths.target_mojo_shell_path |
| 123 with open(shell_path) as shell_binary: | 124 with open(shell_path) as shell_binary: |
| 124 shell_filename = os.path.basename(shell_path) | 125 shell_filename = os.path.basename(shell_path) |
| 125 zipinfo = zipfile.ZipInfo(shell_filename) | 126 zipinfo = zipfile.ZipInfo(shell_filename) |
| 126 zipinfo.external_attr = 0777 << 16L | 127 zipinfo.external_attr = 0777 << 16L |
| 127 compress_type = zipfile.ZIP_DEFLATED | 128 compress_type = zipfile.ZIP_DEFLATED |
| 128 if config.target_os == Config.OS_ANDROID: | 129 if config.target_os == Config.OS_ANDROID: |
| 129 # The APK is already compressed. | 130 # The APK is already compressed. |
| 130 compress_type = zipfile.ZIP_STORED | 131 compress_type = zipfile.ZIP_STORED |
| 131 zipinfo.compress_type = compress_type | 132 zipinfo.compress_type = compress_type |
| 132 zipinfo.date_time = time.gmtime(os.path.getmtime(shell_path)) | 133 zipinfo.date_time = time.gmtime(os.path.getmtime(shell_path)) |
| 133 if verbose: | 134 if verbose: |
| 134 print "zipping %s" % shell_path | 135 print "zipping %s" % shell_path |
| 135 z.writestr(zipinfo, shell_binary.read()) | 136 z.writestr(zipinfo, shell_binary.read()) |
| 136 upload(config, zip_file.name, dest, dry_run, gzip=False) | 137 upload(config, zip_file.name, dest, dry_run, gzip=False) |
| 137 | 138 |
| 138 # Update the LATEST file to contain the version of the new binary. | 139 # Update the LATEST file to contain the version of the new binary. |
| 139 latest_file = "gs://mojo/shell/%s/LATEST" % target(config) | 140 latest_file = config.values['upload_location'] + \ |
| 141 ("shell/%s/LATEST" % target(config)) |
| 140 write_file_to_gs(version, latest_file, config, dry_run) | 142 write_file_to_gs(version, latest_file, config, dry_run) |
| 141 | 143 |
| 142 | 144 |
| 143 def upload_dart_snapshotter(config, dry_run, verbose): | 145 def upload_dart_snapshotter(config, dry_run, verbose): |
| 144 # Only built for Linux and Mac. | 146 # Only built for Linux and Mac. |
| 145 if not config.target_os in [Config.OS_LINUX, Config.OS_MAC]: | 147 if not config.target_os in [Config.OS_LINUX, Config.OS_MAC]: |
| 146 return | 148 return |
| 147 | 149 |
| 148 paths = Paths(config) | 150 paths = Paths(config) |
| 149 zipfile_name = target(config) | 151 zipfile_name = target(config) |
| 150 version = Version().version | 152 version = Version().version |
| 151 | 153 |
| 152 dest = "gs://mojo/dart_snapshotter/" + version + "/" + zipfile_name + ".zip" | 154 dest = config.values['upload_location'] + "dart_snapshotter/" + version + \ |
| 155 "/" + zipfile_name + ".zip" |
| 153 with tempfile.NamedTemporaryFile() as zip_file: | 156 with tempfile.NamedTemporaryFile() as zip_file: |
| 154 with zipfile.ZipFile(zip_file, 'w') as z: | 157 with zipfile.ZipFile(zip_file, 'w') as z: |
| 155 dart_snapshotter_path = paths.target_dart_snapshotter_path | 158 dart_snapshotter_path = paths.target_dart_snapshotter_path |
| 156 with open(dart_snapshotter_path) as dart_snapshotter_binary: | 159 with open(dart_snapshotter_path) as dart_snapshotter_binary: |
| 157 dart_snapshotter_filename = os.path.basename(dart_snapshotter_path) | 160 dart_snapshotter_filename = os.path.basename(dart_snapshotter_path) |
| 158 zipinfo = zipfile.ZipInfo(dart_snapshotter_filename) | 161 zipinfo = zipfile.ZipInfo(dart_snapshotter_filename) |
| 159 zipinfo.external_attr = 0777 << 16L | 162 zipinfo.external_attr = 0777 << 16L |
| 160 compress_type = zipfile.ZIP_DEFLATED | 163 compress_type = zipfile.ZIP_DEFLATED |
| 161 zipinfo.compress_type = compress_type | 164 zipinfo.compress_type = compress_type |
| 162 zipinfo.date_time = time.gmtime(os.path.getmtime(dart_snapshotter_path)) | 165 zipinfo.date_time = time.gmtime(os.path.getmtime(dart_snapshotter_path)) |
| 163 if verbose: | 166 if verbose: |
| 164 print "zipping %s" % dart_snapshotter_path | 167 print "zipping %s" % dart_snapshotter_path |
| 165 z.writestr(zipinfo, dart_snapshotter_binary.read()) | 168 z.writestr(zipinfo, dart_snapshotter_binary.read()) |
| 166 upload(config, zip_file.name, dest, dry_run, gzip=False) | 169 upload(config, zip_file.name, dest, dry_run, gzip=False) |
| 167 | 170 |
| 168 # Update the LATEST file to contain the version of the new binary. | 171 # Update the LATEST file to contain the version of the new binary. |
| 169 latest_file = "gs://mojo/dart_snapshotter/%s/LATEST" % target(config) | 172 latest_file = config.values['upload_location'] + \ |
| 173 ("dart_snapshotter/%s/LATEST" % target(config)) |
| 170 write_file_to_gs(version, latest_file, config, dry_run) | 174 write_file_to_gs(version, latest_file, config, dry_run) |
| 171 | 175 |
| 172 | 176 |
| 173 def upload_app(app_binary_path, config, dry_run): | 177 def upload_app(app_binary_path, config, dry_run): |
| 174 app_binary_name = os.path.basename(app_binary_path) | 178 app_binary_name = os.path.basename(app_binary_path) |
| 175 version = Version().version | 179 version = Version().version |
| 176 gsutil_app_location = ("gs://mojo/services/%s/%s/%s" % | 180 gsutil_app_location = (config.values['upload_location'] + \ |
| 177 (target(config), version, app_binary_name)) | 181 ("services/%s/%s/%s" % (target(config), version, app_binary_name))) |
| 178 | 182 |
| 179 # Upload the new binary. | 183 # Upload the new binary. |
| 180 upload(config, app_binary_path, gsutil_app_location, dry_run) | 184 upload(config, app_binary_path, gsutil_app_location, dry_run) |
| 181 | 185 |
| 182 | 186 |
| 183 def upload_system_thunks_lib(config, dry_run): | 187 def upload_system_thunks_lib(config, dry_run): |
| 184 paths = Paths(config) | 188 paths = Paths(config) |
| 185 version = Version().version | 189 version = Version().version |
| 186 dest = ("gs://mojo/system_thunks/%s/%s/libsystem_thunks.a" % | 190 dest = config.values['upload_location'] + \ |
| 187 (target(config), version)) | 191 ("system_thunks/%s/%s/libsystem_thunks.a" % (target(config), version)) |
| 188 source_path = paths.build_dir + "/obj/mojo/libsystem_thunks.a" | 192 source_path = paths.build_dir + "/obj/mojo/libsystem_thunks.a" |
| 189 upload(config, source_path, dest, dry_run) | 193 upload(config, source_path, dest, dry_run) |
| 190 | 194 |
| 191 | 195 |
| 192 def write_file_to_gs(file_contents, dest, config, dry_run): | 196 def write_file_to_gs(file_contents, dest, config, dry_run): |
| 193 with tempfile.NamedTemporaryFile() as temp_version_file: | 197 with tempfile.NamedTemporaryFile() as temp_version_file: |
| 194 temp_version_file.write(file_contents) | 198 temp_version_file.write(file_contents) |
| 195 temp_version_file.flush() | 199 temp_version_file.flush() |
| 196 upload(config, temp_version_file.name, dest, dry_run) | 200 upload(config, temp_version_file.name, dest, dry_run) |
| 197 | 201 |
| 198 | 202 |
| 199 def main(): | 203 def main(): |
| 200 parser = argparse.ArgumentParser(description="Upload binaries for apps and " | 204 parser = argparse.ArgumentParser(description="Upload binaries for apps and " |
| 201 "the Mojo shell to google storage (by default on Linux, but this can be " | 205 "the Mojo shell to google storage (by default on Linux, but this can be " |
| 202 "changed via options).") | 206 "changed via options).") |
| 203 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+ | 207 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+ |
| 204 "upload", action="store_true") | 208 "upload", action="store_true") |
| 205 parser.add_argument("-v", "--verbose", help="Verbose mode", | 209 parser.add_argument("-v", "--verbose", help="Verbose mode", |
| 206 action="store_true") | 210 action="store_true") |
| 207 parser.add_argument("--android", | 211 parser.add_argument("--android", |
| 208 action="store_true", | 212 action="store_true", |
| 209 help="Upload the shell and apps for Android") | 213 help="Upload the shell and apps for Android") |
| 210 parser.add_argument("--official", | 214 parser.add_argument("--official", |
| 211 action="store_true", | 215 action="store_true", |
| 212 help="Upload the official build of the Android shell") | 216 help="Upload the official build of the Android shell") |
| 213 parser.add_argument("--symbols-upload-url", | 217 parser.add_argument("--symbols-upload-url", |
| 214 action="append", default=[], | 218 action="append", default=[], |
| 215 help="URL of the server to upload breakpad symbols to") | 219 help="URL of the server to upload breakpad symbols to") |
| 220 parser.add_argument("-u", "--upload-location", |
| 221 default="gs://mojo/", |
| 222 help="root URL of the server to upload binaries to") |
| 216 args = parser.parse_args() | 223 args = parser.parse_args() |
| 217 | 224 |
| 218 is_official_build = args.official | 225 is_official_build = args.official |
| 219 target_os = Config.OS_LINUX | 226 target_os = Config.OS_LINUX |
| 220 if args.android: | 227 if args.android: |
| 221 target_os = Config.OS_ANDROID | 228 target_os = Config.OS_ANDROID |
| 222 elif is_official_build: | 229 elif is_official_build: |
| 223 print "Uploading official builds is only supported for android." | 230 print "Uploading official builds is only supported for android." |
| 224 return 1 | 231 return 1 |
| 225 | 232 |
| 226 config = Config(target_os=target_os, is_debug=False, | 233 config = Config(target_os=target_os, is_debug=False, |
| 227 is_official_build=is_official_build) | 234 is_official_build=is_official_build, |
| 235 upload_location=args.upload_location) |
| 228 | 236 |
| 229 upload_shell(config, args.dry_run, args.verbose) | 237 upload_shell(config, args.dry_run, args.verbose) |
| 230 | 238 |
| 231 if is_official_build: | 239 if is_official_build: |
| 232 print "Skipping uploading apps (official apk build)." | 240 print "Skipping uploading apps (official apk build)." |
| 233 return 0 | 241 return 0 |
| 234 | 242 |
| 235 build_directory = gn.BuildDirectoryForConfig(config, Paths(config).src_root) | 243 build_directory = gn.BuildDirectoryForConfig(config, Paths(config).src_root) |
| 236 apps_to_upload = find_apps_to_upload(build_directory) | 244 apps_to_upload = find_apps_to_upload(build_directory) |
| 237 for app in apps_to_upload: | 245 for app in apps_to_upload: |
| 238 upload_app(app, config, args.dry_run) | 246 upload_app(app, config, args.dry_run) |
| 239 | 247 |
| 240 upload_symbols(config, build_directory, | 248 upload_symbols(config, build_directory, |
| 241 args.symbols_upload_url, args.dry_run) | 249 args.symbols_upload_url, args.dry_run) |
| 242 | 250 |
| 243 upload_dart_snapshotter(config, args.dry_run, args.verbose) | 251 upload_dart_snapshotter(config, args.dry_run, args.verbose) |
| 244 | 252 |
| 245 upload_system_thunks_lib(config, args.dry_run) | 253 upload_system_thunks_lib(config, args.dry_run) |
| 246 | 254 |
| 247 return 0 | 255 return 0 |
| 248 | 256 |
| 249 if __name__ == "__main__": | 257 if __name__ == "__main__": |
| 250 sys.exit(main()) | 258 sys.exit(main()) |
| OLD | NEW |