OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Launch a local server on an ephemeral port, then launch a executable that | 6 """Launch a local server on an ephemeral port, then launch a executable that |
7 points to that server. | 7 points to that server. |
8 """ | 8 """ |
9 | 9 |
10 import copy | 10 import copy |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 for e in options.environ: | 60 for e in options.environ: |
61 key, value = map(str.strip, e.split('=')) | 61 key, value = map(str.strip, e.split('=')) |
62 env[key] = value | 62 env[key] = value |
63 | 63 |
64 cmd = args + [server.GetURL(options.path)] | 64 cmd = args + [server.GetURL(options.path)] |
65 print 'Running: %s...' % (' '.join(cmd),) | 65 print 'Running: %s...' % (' '.join(cmd),) |
66 process = subprocess.Popen(cmd, env=env) | 66 process = subprocess.Popen(cmd, env=env) |
67 | 67 |
68 # If any debug args are passed in, assume we want to debug | 68 # If any debug args are passed in, assume we want to debug |
69 if options.debug: | 69 if options.debug: |
70 if getos.GetPlatform() != 'win': | 70 if getos.GetPlatform() == 'linux': |
71 cmd = ['xterm', '-title', 'NaCl Debugger', '-e'] | 71 cmd = ['xterm', '-title', 'NaCl Debugger', '-e'] |
| 72 cmd += options.debug |
| 73 elif getos.GetPlatform() == 'mac': |
| 74 cmd = ['osascript', '-e', |
| 75 'tell application "Terminal" to do script "%s"' % |
| 76 ' '.join(r'\"%s\"' % x for x in options.debug)] |
72 else: | 77 else: |
73 cmd = [] | 78 cmd = [] |
74 cmd += options.debug | |
75 print 'Starting debugger: ' + ' '.join(cmd) | 79 print 'Starting debugger: ' + ' '.join(cmd) |
76 debug_process = subprocess.Popen(cmd, env=env) | 80 debug_process = subprocess.Popen(cmd, env=env) |
77 else: | 81 else: |
78 debug_process = False | 82 debug_process = False |
79 | 83 |
80 try: | 84 try: |
81 return server.ServeUntilSubprocessDies(process) | 85 return server.ServeUntilSubprocessDies(process) |
82 finally: | 86 finally: |
83 if process.returncode is None: | 87 if process.returncode is None: |
84 process.kill() | 88 process.kill() |
85 if debug_process and debug_process.returncode is None: | 89 if debug_process and debug_process.returncode is None: |
86 debug_process.kill() | 90 debug_process.kill() |
87 | 91 |
88 if __name__ == '__main__': | 92 if __name__ == '__main__': |
89 sys.exit(main(sys.argv[1:])) | 93 sys.exit(main(sys.argv[1:])) |
OLD | NEW |