OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be 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 utils | 10 import utils |
11 | 11 |
12 usage = """patch_sdk.py [options]""" | 12 usage = """patch_sdk.py [options]""" |
13 | 13 |
14 def DisplayBootstrapWarning(): | 14 def DisplayBootstrapWarning(): |
15 print """\ | 15 print """\ |
16 | 16 |
17 | 17 |
18 WARNING: Your system cannot run the checked-in Dart SDK. Using the | 18 WARNING: Your system cannot run the checked-in Dart SDK. Using the |
19 bootstrap Dart executable will make debug builds slow. | 19 bootstrap Dart executable will make debug builds slow. |
20 Please see the Wiki for instructions on replacing the checked-in Dart SDK. | 20 Please see the Wiki for instructions on replacing the checked-in Dart SDK. |
21 | 21 |
22 https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in-tools | 22 https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in-tools |
23 | 23 |
24 """ | 24 """ |
25 | 25 |
26 def BuildArguments(): | 26 def BuildArguments(): |
27 result = argparse.ArgumentParser(usage=usage) | 27 result = argparse.ArgumentParser(usage=usage) |
28 result.add_argument("--dart-executable", help="dart executable", default=None) | 28 result.add_argument("-q", "--quiet", |
| 29 help="emit no output", |
| 30 default=False, |
| 31 action="store_true") |
| 32 result.add_argument("--dart-executable", |
| 33 help="dart executable", |
| 34 default=None) |
29 return result | 35 return result |
30 | 36 |
31 def main(): | 37 def main(): |
32 # Parse the options. | 38 # Parse the options. |
33 parser = BuildArguments() | 39 parser = BuildArguments() |
34 (options, args) = parser.parse_known_args() | 40 (options, args) = parser.parse_known_args() |
35 if utils.CheckedInSdkCheckExecutable(): | 41 if utils.CheckedInSdkCheckExecutable(): |
36 options.dart_executable = utils.CheckedInSdkExecutable() | 42 options.dart_executable = utils.CheckedInSdkExecutable() |
37 elif options.dart_executable is not None: | 43 elif options.dart_executable is not None: |
38 DisplayBootstrapWarning() | 44 if not options.quiet: |
| 45 DisplayBootstrapWarning() |
39 options.dart_executable = os.path.abspath(options.dart_executable) | 46 options.dart_executable = os.path.abspath(options.dart_executable) |
40 else: | 47 else: |
41 print >> sys.stderr, 'ERROR: cannot locate dart executable' | 48 print >> sys.stderr, 'ERROR: cannot locate dart executable' |
42 return -1 | 49 return -1 |
43 dart_file = os.path.join(os.path.dirname(__file__), 'patch_sdk.dart') | 50 dart_file = os.path.join(os.path.dirname(__file__), 'patch_sdk.dart') |
44 subprocess.check_call([options.dart_executable, dart_file] + args) | 51 subprocess.check_call([options.dart_executable, dart_file] + args) |
45 return 0 | 52 return 0 |
46 | 53 |
47 if __name__ == '__main__': | 54 if __name__ == '__main__': |
48 sys.exit(main()) | 55 sys.exit(main()) |
OLD | NEW |