OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright 2016 The Dart project 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 # Usage: dart_for_gn.py path_to_dart_binary [arguments] | |
7 # | |
8 # We have gn set up so that actions can only run python scripts. | |
9 # We use this wrapper script when we need an action to run the Dart VM | |
10 # The first command line argument is mandatory and should be the absolute path | |
11 # to the Dart VM binary. | |
12 | |
13 import subprocess | |
14 import sys | |
15 | |
16 def run_command(command): | |
17 try: | |
18 subprocess.check_output(command, stderr=subprocess.STDOUT) | |
19 return 0 | |
20 except subprocess.CalledProcessError as e: | |
21 return ("Command failed: " + ' '.join(command) + "\n" + | |
22 "output: " + e.output) | |
23 | |
24 def main(argv): | |
25 if len(argv) < 2: | |
26 print "Requires path to Dart VM binary as first argument" | |
27 return -1 | |
28 result = run_command(argv[1:]) | |
29 if result != 0: | |
30 print result | |
31 return -1 | |
32 return 0 | |
33 | |
34 if __name__ == '__main__': | |
35 sys.exit(main(sys.argv)) | |
OLD | NEW |