Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: tools/observatory_tool.py

Issue 839543002: Revert "Build Observatory with runtime" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/canary.dart ('k') | tools/run_pub.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # BSD-style license that can be found in the LICENSE file.
5 """Helper for building and deploying Observatory"""
6
7 import argparse
8 import os
9 import shutil
10 import subprocess
11 import sys
12
13 SCRIPT_DIR = os.path.dirname(sys.argv[0])
14 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
15 RUN_PUB = os.path.join(DART_ROOT, 'tools/run_pub.py')
16 IGNORE_PATTERNS = shutil.ignore_patterns(
17 '*.map',
18 '*.concat.js',
19 '*.scriptUrls',
20 '*.precompiled.js',
21 'main.*',
22 'unittest*',
23 '*_buildLogs*',
24 '*.log',
25 '*~')
26
27 usage = """obs_tool.py [options]"""
28
29 def BuildArguments():
30 result = argparse.ArgumentParser(usage=usage)
31 result.add_argument("--package-root", help="package root", default=None)
32 result.add_argument("--dart-executable", help="dart executable", default=None)
33 result.add_argument("--directory", help="observatory root", default=None)
34 result.add_argument("--command", help="[get, build, deploy]", default=None)
35 return result
36
37 def ProcessOptions(options, args):
38 return ((options.package_root != None) and
39 (options.directory != None) and
40 (options.command != None) and
41 (options.dart_executable != None))
42
43 def ChangeDirectory(directory):
44 os.chdir(directory);
45
46 def PubGet(dart_executable, pkg_root):
47 return subprocess.call(['python',
48 RUN_PUB,
49 '--package-root=' + pkg_root,
50 '--dart-executable=' + dart_executable,
51 'get',
52 '--offline'])
53
54 def PubBuild(dart_executable, pkg_root, output_dir):
55 return subprocess.call(['python',
56 RUN_PUB,
57 '--package-root=' + pkg_root,
58 '--dart-executable=' + dart_executable,
59 'build',
60 '--output',
61 output_dir])
62
63 def Deploy(input_dir, output_dir):
64 shutil.rmtree(output_dir)
65 shutil.copytree(input_dir, output_dir, ignore=IGNORE_PATTERNS)
66 return 0
67
68 def ExecuteCommand(options, args):
69 cmd = options.command
70 if (cmd == 'get'):
71 PubGet(options.dart_executable, options.package_root)
72 elif (cmd == 'build'):
73 PubBuild(options.dart_executable, options.package_root, args[0])
74 elif (cmd == 'deploy'):
75 Deploy('build', 'deployed')
76 else:
77 print >> sys.stderr, ('ERROR: command "%s" not supported') % (cmd)
78 return -1;
79
80 def main():
81 # Parse the options.
82 parser = BuildArguments()
83 (options, args) = parser.parse_known_args()
84 if not ProcessOptions(options, args):
85 parser.print_help()
86 return 1
87 ChangeDirectory(options.directory)
88 return ExecuteCommand(options, args)
89
90 if __name__ == '__main__':
91 sys.exit(main());
OLDNEW
« no previous file with comments | « tools/canary.dart ('k') | tools/run_pub.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698