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

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: Response to qsr's review 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)
21 for_android = (config.target_os == Config.OS_ANDROID)
19 22
20 sys.path.insert(0, os.path.join(paths.src_root, "tools")) 23 sys.path.insert(0, os.path.join(paths.src_root, "tools"))
21 # pylint: disable=F0401 24 # pylint: disable=F0401
22 import find_depot_tools 25 import find_depot_tools
23 26
24 depot_tools_path = find_depot_tools.add_depot_tools_to_path() 27 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
25 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") 28 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
26 29
27 def upload(dry_run, verbose): 30 zipfile_name = "linux-x64"
28 dest = "gs://mojo/shell/" + Version().version + "/linux-x64.zip" 31 if for_android:
32 zipfile_name = "arm"
qsr 2015/01/26 16:25:43 what about using config.target_os and config.targe
blundell 2015/01/26 16:31:33 Done.
33 dest = "gs://mojo/shell/" + Version().version + "/" + zipfile_name + ".zip"
29 34
30 with tempfile.NamedTemporaryFile() as zip_file: 35 with tempfile.NamedTemporaryFile() as zip_file:
31 with zipfile.ZipFile(zip_file, 'w') as z: 36 with zipfile.ZipFile(zip_file, 'w') as z:
32 with open(paths.mojo_shell_path) as shell_binary: 37 shell_path = paths.target_mojo_shell_path
33 zipinfo = zipfile.ZipInfo("mojo_shell") 38 with open(shell_path) as shell_binary:
39 shell_filename = os.path.basename(shell_path)
40 zipinfo = zipfile.ZipInfo(shell_filename)
34 zipinfo.external_attr = 0777 << 16L 41 zipinfo.external_attr = 0777 << 16L
35 zipinfo.compress_type = zipfile.ZIP_DEFLATED 42 zipinfo.compress_type = zipfile.ZIP_DEFLATED
36 zipinfo.date_time = time.gmtime(os.path.getmtime(paths.mojo_shell_path)) 43 zipinfo.date_time = time.gmtime(os.path.getmtime(shell_path))
37 if verbose: 44 if verbose:
38 print "zipping %s" % paths.mojo_shell_path 45 print "zipping %s" % shell_path
39 z.writestr(zipinfo, shell_binary.read()) 46 z.writestr(zipinfo, shell_binary.read())
40 if dry_run: 47 if dry_run:
41 print str([gsutil_exe, "cp", zip_file.name, dest]) 48 print str([gsutil_exe, "cp", zip_file.name, dest])
42 else: 49 else:
43 subprocess.check_call([gsutil_exe, "cp", zip_file.name, dest]) 50 subprocess.check_call([gsutil_exe, "cp", zip_file.name, dest])
44 51
45 def main(): 52 def main():
46 parser = argparse.ArgumentParser(description="Upload mojo_shell binary to "+ 53 parser = argparse.ArgumentParser(description="Upload mojo_shell binary to "+
47 "google storage") 54 "google storage")
48 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+ 55 parser.add_argument("-n", "--dry_run", help="Dry run, do not actually "+
49 "upload", action="store_true") 56 "upload", action="store_true")
50 parser.add_argument("-v", "--verbose", help="Verbose mode", 57 parser.add_argument("-v", "--verbose", help="Verbose mode",
51 action="store_true") 58 action="store_true")
59 parser.add_argument("--build_dir",
60 type=str,
61 metavar="<build_dir>",
62 help="The build dir containing the shell to be uploaded",
63 default="out/Release")
52 args = parser.parse_args() 64 args = parser.parse_args()
53 upload(args.dry_run, args.verbose) 65
66 config = gn.ConfigForGNArgs(gn.ParseGNConfig(args.build_dir))
67 upload(config, args.dry_run, args.verbose)
54 return 0 68 return 0
55 69
56 if __name__ == "__main__": 70 if __name__ == "__main__":
57 sys.exit(main()) 71 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