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

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

Issue 884133002: Revert "Support uploading Mojo Shell on Android." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
15 from mopy.config import Config 14 from mopy.config import Config
16 from mopy.paths import Paths 15 from mopy.paths import Paths
17 from mopy.version import Version 16 from mopy.version import Version
18 17
19 def upload(config, dry_run, verbose): 18 paths = Paths(Config(target_os=Config.OS_LINUX, is_debug=False))
20 paths = Paths(config)
21 19
22 sys.path.insert(0, os.path.join(paths.src_root, "tools")) 20 sys.path.insert(0, os.path.join(paths.src_root, "tools"))
23 # pylint: disable=F0401 21 # pylint: disable=F0401
24 import find_depot_tools 22 import find_depot_tools
25 23
26 depot_tools_path = find_depot_tools.add_depot_tools_to_path() 24 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
27 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") 25 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
28 26
29 zipfile_name = "%s-%s" % (config.target_os, config.target_arch) 27 def upload(dry_run, verbose):
30 dest = "gs://mojo/shell/" + Version().version + "/" + zipfile_name + ".zip" 28 dest = "gs://mojo/shell/" + Version().version + "/linux-x64.zip"
31 29
32 with tempfile.NamedTemporaryFile() as zip_file: 30 with tempfile.NamedTemporaryFile() as zip_file:
33 with zipfile.ZipFile(zip_file, 'w') as z: 31 with zipfile.ZipFile(zip_file, 'w') as z:
34 shell_path = paths.target_mojo_shell_path 32 with open(paths.mojo_shell_path) as shell_binary:
35 with open(shell_path) as shell_binary: 33 zipinfo = zipfile.ZipInfo("mojo_shell")
36 shell_filename = os.path.basename(shell_path)
37 zipinfo = zipfile.ZipInfo(shell_filename)
38 zipinfo.external_attr = 0777 << 16L 34 zipinfo.external_attr = 0777 << 16L
39 compress_type = zipfile.ZIP_DEFLATED 35 zipinfo.compress_type = zipfile.ZIP_DEFLATED
40 if config.target_os == Config.OS_ANDROID: 36 zipinfo.date_time = time.gmtime(os.path.getmtime(paths.mojo_shell_path))
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))
45 if verbose: 37 if verbose:
46 print "zipping %s" % shell_path 38 print "zipping %s" % paths.mojo_shell_path
47 z.writestr(zipinfo, shell_binary.read()) 39 z.writestr(zipinfo, shell_binary.read())
48 if dry_run: 40 if dry_run:
49 print str([gsutil_exe, "cp", zip_file.name, dest]) 41 print str([gsutil_exe, "cp", zip_file.name, dest])
50 else: 42 else:
51 subprocess.check_call([gsutil_exe, "cp", zip_file.name, dest]) 43 subprocess.check_call([gsutil_exe, "cp", zip_file.name, dest])
52 44
53 def main(): 45 def main():
54 parser = argparse.ArgumentParser(description="Upload mojo_shell binary to "+ 46 parser = argparse.ArgumentParser(description="Upload mojo_shell binary to "+
55 "google storage") 47 "google storage")
56 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+ 48 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+
57 "upload", action="store_true") 49 "upload", action="store_true")
58 parser.add_argument("-v", "--verbose", help="Verbose mode", 50 parser.add_argument("-v", "--verbose", help="Verbose mode",
59 action="store_true") 51 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")
65 args = parser.parse_args() 52 args = parser.parse_args()
66 53 upload(args.dry_run, args.verbose)
67 config = gn.ConfigForGNArgs(gn.ParseGNConfig(args.build_dir))
68 upload(config, args.dry_run, args.verbose)
69 return 0 54 return 0
70 55
71 if __name__ == "__main__": 56 if __name__ == "__main__":
72 sys.exit(main()) 57 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