OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Wrapper around a build action that should only be executed in release mode. | 8 Wrapper around a build action that should only be executed in release mode. |
9 | 9 |
10 The mode is defined via an environment varible DART_BUILD_MODE. | 10 The mode is defined via an environment varible DART_BUILD_MODE. |
(...skipping 10 matching lines...) Expand all Loading... |
21 import os | 21 import os |
22 import subprocess | 22 import subprocess |
23 import sys | 23 import sys |
24 | 24 |
25 | 25 |
26 def Main(): | 26 def Main(): |
27 # Throws an error if '--' is not in the argument list. | 27 # Throws an error if '--' is not in the argument list. |
28 separator_index = sys.argv.index('--') | 28 separator_index = sys.argv.index('--') |
29 outputs = sys.argv[1:separator_index] | 29 outputs = sys.argv[1:separator_index] |
30 arguments = sys.argv[separator_index + 1:] | 30 arguments = sys.argv[separator_index + 1:] |
| 31 arguments[0] = os.path.normpath(arguments[0]) |
31 mode = os.getenv('DART_BUILD_MODE', default='release') | 32 mode = os.getenv('DART_BUILD_MODE', default='release') |
32 if mode != 'release': | 33 if mode != 'release': |
33 print >> sys.stderr, 'Not running %s in mode=%s' % (arguments, mode) | 34 print >> sys.stderr, 'Not running %s in mode=%s' % (arguments, mode) |
34 for output in outputs: | 35 for output in outputs: |
35 with open(output, 'w'): | 36 with open(output, 'w'): |
36 # Create an empty file to ensure that we don't rerun this | 37 # Create an empty file to ensure that we don't rerun this |
37 # command unnecessarily. | 38 # command unnecessarily. |
38 pass | 39 pass |
39 return 0 | 40 return 0 |
40 else: | 41 else: |
41 try: | 42 try: |
42 subprocess.check_call(arguments) | 43 subprocess.check_call(arguments) |
43 except subprocess.CalledProcessError as e: | 44 except subprocess.CalledProcessError as e: |
44 return e.returncode | 45 return e.returncode |
45 return 0 | 46 return 0 |
46 | 47 |
47 | 48 |
48 if __name__ == '__main__': | 49 if __name__ == '__main__': |
49 sys.exit(Main()) | 50 sys.exit(Main()) |
OLD | NEW |