Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: mojo/tools/upload_shell_binary.py

Issue 874243002: Support uploading Mojo Shell on Android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Use ZIP_STORED on Android Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/tools/mopy/paths.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 import argparse 6 import argparse
7 import os 7 import os
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 import tempfile 10 import tempfile
11 import time 11 import time
12 import zipfile 12 import zipfile
13 13
14 import mopy.gn as gn
14 from mopy.config import Config 15 from mopy.config import Config
15 from mopy.paths import Paths 16 from mopy.paths import Paths
16 from mopy.version import Version 17 from mopy.version import Version
17 18
18 paths = Paths(Config(target_os=Config.OS_LINUX, is_debug=False)) 19 def upload(config, dry_run, verbose):
20 paths = Paths(config)
19 21
20 sys.path.insert(0, os.path.join(paths.src_root, "tools")) 22 sys.path.insert(0, os.path.join(paths.src_root, "tools"))
21 # pylint: disable=F0401 23 # pylint: disable=F0401
22 import find_depot_tools 24 import find_depot_tools
23 25
24 depot_tools_path = find_depot_tools.add_depot_tools_to_path() 26 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
25 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") 27 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
26 28
27 def upload(dry_run, verbose): 29 zipfile_name = "%s-%s" % (config.target_os, config.target_arch)
28 dest = "gs://mojo/shell/" + Version().version + "/linux-x64.zip" 30 dest = "gs://mojo/shell/" + Version().version + "/" + zipfile_name + ".zip"
29 31
30 with tempfile.NamedTemporaryFile() as zip_file: 32 with tempfile.NamedTemporaryFile() as zip_file:
31 with zipfile.ZipFile(zip_file, 'w') as z: 33 with zipfile.ZipFile(zip_file, 'w') as z:
32 with open(paths.mojo_shell_path) as shell_binary: 34 shell_path = paths.target_mojo_shell_path
33 zipinfo = zipfile.ZipInfo("mojo_shell") 35 with open(shell_path) as shell_binary:
36 shell_filename = os.path.basename(shell_path)
37 zipinfo = zipfile.ZipInfo(shell_filename)
34 zipinfo.external_attr = 0777 << 16L 38 zipinfo.external_attr = 0777 << 16L
35 zipinfo.compress_type = zipfile.ZIP_DEFLATED 39 compress_type = zipfile.ZIP_DEFLATED
36 zipinfo.date_time = time.gmtime(os.path.getmtime(paths.mojo_shell_path)) 40 if config.target_os == Config.OS_ANDROID:
41 # The APK is already compressed.
42 compress_type = zipfile.ZIP_STORED
43 zipinfo.compress_type = compress_type
44 zipinfo.date_time = time.gmtime(os.path.getmtime(shell_path))
37 if verbose: 45 if verbose:
38 print "zipping %s" % paths.mojo_shell_path 46 print "zipping %s" % shell_path
39 z.writestr(zipinfo, shell_binary.read()) 47 z.writestr(zipinfo, shell_binary.read())
40 if dry_run: 48 if dry_run:
41 print str([gsutil_exe, "cp", zip_file.name, dest]) 49 print str([gsutil_exe, "cp", zip_file.name, dest])
42 else: 50 else:
43 subprocess.check_call([gsutil_exe, "cp", zip_file.name, dest]) 51 subprocess.check_call([gsutil_exe, "cp", zip_file.name, dest])
44 52
45 def main(): 53 def main():
46 parser = argparse.ArgumentParser(description="Upload mojo_shell binary to "+ 54 parser = argparse.ArgumentParser(description="Upload mojo_shell binary to "+
47 "google storage") 55 "google storage")
48 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+ 56 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+
49 "upload", action="store_true") 57 "upload", action="store_true")
50 parser.add_argument("-v", "--verbose", help="Verbose mode", 58 parser.add_argument("-v", "--verbose", help="Verbose mode",
51 action="store_true") 59 action="store_true")
60 parser.add_argument("--build_dir",
61 type=str,
62 metavar="<build_dir>",
63 help="The build dir containing the shell to be uploaded",
64 default="out/Release")
52 args = parser.parse_args() 65 args = parser.parse_args()
53 upload(args.dry_run, args.verbose) 66
67 config = gn.ConfigForGNArgs(gn.ParseGNConfig(args.build_dir))
68 upload(config, args.dry_run, args.verbose)
54 return 0 69 return 0
55 70
56 if __name__ == "__main__": 71 if __name__ == "__main__":
57 sys.exit(main()) 72 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/tools/mopy/paths.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698