Chromium Code Reviews| Index: mojo/tools/upload_shell_binary.py |
| diff --git a/mojo/tools/upload_shell_binary.py b/mojo/tools/upload_shell_binary.py |
| index 83c8847db457ac8f7932b77425541f21d69fbbc3..fdb3c46264adccee1625c182ff929deac891e2ff 100755 |
| --- a/mojo/tools/upload_shell_binary.py |
| +++ b/mojo/tools/upload_shell_binary.py |
| @@ -11,31 +11,35 @@ import tempfile |
| import time |
| import zipfile |
| +import mopy.gn as gn |
| from mopy.config import Config |
| from mopy.paths import Paths |
| from mopy.version import Version |
| -paths = Paths(Config(target_os=Config.OS_LINUX, is_debug=False)) |
| +def upload(config, dry_run, verbose): |
| + paths = Paths(config) |
| -sys.path.insert(0, os.path.join(paths.src_root, "tools")) |
| -# pylint: disable=F0401 |
| -import find_depot_tools |
| + sys.path.insert(0, os.path.join(paths.src_root, "tools")) |
| + # pylint: disable=F0401 |
| + import find_depot_tools |
| -depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| -gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") |
| + depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| + gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") |
| -def upload(dry_run, verbose): |
| - dest = "gs://mojo/shell/" + Version().version + "/linux-x64.zip" |
| + zipfile_name = "%s-%s" % (config.target_os, config.target_arch) |
| + dest = "gs://mojo/shell/" + Version().version + "/" + zipfile_name + ".zip" |
| with tempfile.NamedTemporaryFile() as zip_file: |
| with zipfile.ZipFile(zip_file, 'w') as z: |
| - with open(paths.mojo_shell_path) as shell_binary: |
| - zipinfo = zipfile.ZipInfo("mojo_shell") |
| + shell_path = paths.target_mojo_shell_path |
| + with open(shell_path) as shell_binary: |
| + shell_filename = os.path.basename(shell_path) |
| + zipinfo = zipfile.ZipInfo(shell_filename) |
|
qsr
2015/01/26 16:41:43
Zipping the apk is not really useful... But I don'
blundell
2015/01/27 09:20:50
I prefer to keep it as-is, as making platform-spec
|
| zipinfo.external_attr = 0777 << 16L |
| zipinfo.compress_type = zipfile.ZIP_DEFLATED |
|
jamesr
2015/01/27 20:29:31
if you're worried about burning CPU zipping useles
blundell
2015/01/28 14:57:08
Done.
|
| - zipinfo.date_time = time.gmtime(os.path.getmtime(paths.mojo_shell_path)) |
| + zipinfo.date_time = time.gmtime(os.path.getmtime(shell_path)) |
| if verbose: |
| - print "zipping %s" % paths.mojo_shell_path |
| + print "zipping %s" % shell_path |
| z.writestr(zipinfo, shell_binary.read()) |
| if dry_run: |
| print str([gsutil_exe, "cp", zip_file.name, dest]) |
| @@ -49,8 +53,15 @@ def main(): |
| "upload", action="store_true") |
| parser.add_argument("-v", "--verbose", help="Verbose mode", |
| action="store_true") |
| + parser.add_argument("--build_dir", |
| + type=str, |
| + metavar="<build_dir>", |
| + help="The build dir containing the shell to be uploaded", |
| + default="out/Release") |
| args = parser.parse_args() |
| - upload(args.dry_run, args.verbose) |
| + |
| + config = gn.ConfigForGNArgs(gn.ParseGNConfig(args.build_dir)) |
| + upload(config, args.dry_run, args.verbose) |
| return 0 |
| if __name__ == "__main__": |