OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2015, 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 """Helper for building and deploying Observatory""" | 5 """Helper for building and deploying Observatory""" |
6 | 6 |
7 import argparse | 7 import argparse |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import subprocess | 10 import subprocess |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 output_dir]) | 61 output_dir]) |
62 | 62 |
63 def Deploy(input_dir, output_dir): | 63 def Deploy(input_dir, output_dir): |
64 shutil.rmtree(output_dir) | 64 shutil.rmtree(output_dir) |
65 shutil.copytree(input_dir, output_dir, ignore=IGNORE_PATTERNS) | 65 shutil.copytree(input_dir, output_dir, ignore=IGNORE_PATTERNS) |
66 return 0 | 66 return 0 |
67 | 67 |
68 def ExecuteCommand(options, args): | 68 def ExecuteCommand(options, args): |
69 cmd = options.command | 69 cmd = options.command |
70 if (cmd == 'get'): | 70 if (cmd == 'get'): |
71 PubGet(options.dart_executable, options.package_root) | 71 return PubGet(options.dart_executable, options.package_root) |
72 elif (cmd == 'build'): | 72 elif (cmd == 'build'): |
73 PubBuild(options.dart_executable, options.package_root, args[0]) | 73 return PubBuild(options.dart_executable, options.package_root, args[0]) |
74 elif (cmd == 'deploy'): | 74 elif (cmd == 'deploy'): |
75 Deploy('build', 'deployed') | 75 Deploy('build', 'deployed') |
76 else: | 76 else: |
77 print >> sys.stderr, ('ERROR: command "%s" not supported') % (cmd) | 77 print >> sys.stderr, ('ERROR: command "%s" not supported') % (cmd) |
78 return -1; | 78 return -1; |
79 | 79 |
80 def main(): | 80 def main(): |
81 # Parse the options. | 81 # Parse the options. |
82 parser = BuildArguments() | 82 parser = BuildArguments() |
83 (options, args) = parser.parse_known_args() | 83 (options, args) = parser.parse_known_args() |
84 if not ProcessOptions(options, args): | 84 if not ProcessOptions(options, args): |
85 parser.print_help() | 85 parser.print_help() |
86 return 1 | 86 return 1 |
87 if os.getenv('DART_USE_BOOTSTRAP_BIN') != None: | 87 if os.getenv('DART_USE_BOOTSTRAP_BIN') != None: |
88 dart_executable = options.dart_executable | 88 dart_executable = options.dart_executable |
89 # Calculate absolute paths before changing directory. | 89 # Calculate absolute paths before changing directory. |
90 options.package_root = os.path.abspath(options.package_root) | 90 options.package_root = os.path.abspath(options.package_root) |
91 options.dart_executable = os.path.abspath(options.dart_executable) | 91 options.dart_executable = os.path.abspath(options.dart_executable) |
92 if len(args) == 1: | 92 if len(args) == 1: |
93 args[0] = os.path.abspath(args[0]) | 93 args[0] = os.path.abspath(args[0]) |
94 # Pub must be run from the project's root directory. | 94 # Pub must be run from the project's root directory. |
95 ChangeDirectory(options.directory) | 95 ChangeDirectory(options.directory) |
96 return ExecuteCommand(options, args) | 96 return ExecuteCommand(options, args) |
97 | 97 |
98 if __name__ == '__main__': | 98 if __name__ == '__main__': |
99 sys.exit(main()); | 99 sys.exit(main()); |
OLD | NEW |