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

Side by Side Diff: mandoline/tools/android/run_mandoline.py

Issue 1677293002: Bye bye Mandoline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 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 | « mandoline/tools/android/install_mandoline.py ('k') | mandoline/tools/data/FILES.cfg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import argparse
7 import atexit
8 import logging
9 import os
10 import shutil
11 import sys
12 import tempfile
13
14 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
15 os.pardir, 'build', 'android'))
16 from pylib import constants
17
18 sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)),
19 os.pardir, os.pardir, os.pardir, 'mojo',
20 'tools'))
21
22 from mopy.android import AndroidShell
23 from mopy.config import Config
24
25 USAGE = ('run_mandoline.py [<shell-and-app-args>] [<start-page-url>]')
26
27 def _CreateSOLinks(dest_dir):
28 '''Creates links from files (eg. *.mojo) to the real .so for gdb to find.'''
29 # The files to create links for. The key is the name as seen on the device,
30 # and the target an array of path elements as to where the .so lives (relative
31 # to the output directory).
32 # TODO(sky): come up with some way to automate this.
33 files_to_link = {
34 'html_viewer.mojo': ['libhtml_viewer_library.so'],
35 'libmandoline_runner.so': ['mandoline_runner'],
36 }
37 build_dir = constants.GetOutDirectory()
38 print build_dir
39 for android_name, so_path in files_to_link.iteritems():
40 src = os.path.join(build_dir, *so_path)
41 if not os.path.isfile(src):
42 print '*** Expected file not found', src
43 print '*** Aborting launch.'
44 sys.exit(-1)
45 os.symlink(src, os.path.join(dest_dir, android_name))
46
47
48 def main():
49 logging.basicConfig()
50
51 parser = argparse.ArgumentParser(usage=USAGE)
52
53 debug_group = parser.add_mutually_exclusive_group()
54 debug_group.add_argument('--debug', help='Debug build (default)',
55 default=True, action='store_true')
56 debug_group.add_argument('--release', help='Release build', default=False,
57 dest='debug', action='store_false')
58 parser.add_argument('--build-dir', help='Build directory')
59 parser.add_argument('--target-cpu', help='CPU architecture to run for.',
60 choices=['x64', 'x86', 'arm'], default='arm')
61 parser.add_argument('--device', help='Serial number of the target device.')
62 parser.add_argument('--gdb', help='Run gdb',
63 default=False, action='store_true')
64 runner_args, args = parser.parse_known_args()
65
66 config = Config(build_dir=runner_args.build_dir,
67 target_os=Config.OS_ANDROID,
68 target_cpu=runner_args.target_cpu,
69 is_debug=runner_args.debug,
70 apk_name='Mandoline.apk')
71 shell = AndroidShell(config)
72 shell.InitShell(runner_args.device)
73 p = shell.ShowLogs()
74
75 temp_gdb_dir = None
76 if runner_args.gdb:
77 temp_gdb_dir = tempfile.mkdtemp()
78 atexit.register(shutil.rmtree, temp_gdb_dir, True)
79 _CreateSOLinks(temp_gdb_dir)
80
81 shell.StartActivity('MandolineActivity',
82 args,
83 sys.stdout,
84 p.terminate,
85 temp_gdb_dir)
86 return 0
87
88
89 if __name__ == '__main__':
90 sys.exit(main())
OLDNEW
« no previous file with comments | « mandoline/tools/android/install_mandoline.py ('k') | mandoline/tools/data/FILES.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698