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

Side by Side Diff: tools/observatory_tool.py

Issue 1337503003: Use the checked in SDK to build Observatory (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « runtime/observatory/observatory.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 platform
9 import shutil 10 import shutil
10 import subprocess 11 import subprocess
11 import sys 12 import sys
12 13
13 SCRIPT_DIR = os.path.dirname(sys.argv[0]) 14 SCRIPT_DIR = os.path.dirname(sys.argv[0])
14 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) 15 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
15 RUN_PUB = os.path.join(DART_ROOT, 'tools/run_pub.py') 16 RUN_PUB = os.path.join(DART_ROOT, 'tools/run_pub.py')
16 IGNORE_PATTERNS = shutil.ignore_patterns( 17 IGNORE_PATTERNS = shutil.ignore_patterns(
17 '*.map', 18 '*.map',
18 '*.concat.js', 19 '*.concat.js',
19 '*.scriptUrls', 20 '*.scriptUrls',
20 '*.precompiled.js', 21 '*.precompiled.js',
21 'main.*', 22 'main.*',
22 'unittest*', 23 'unittest*',
23 '*_buildLogs*', 24 '*_buildLogs*',
24 '*.log', 25 '*.log',
25 '*~') 26 '*~')
26 27
27 usage = """obs_tool.py [options]""" 28 usage = """obs_tool.py [options]"""
28 29
30 def GetDartSdkPubExecutablePath():
ricow1 2015/09/11 07:28:03 how about moving this to tools/utils.py so that we
31 osdict = {'Darwin':'mac', 'Linux':'linux', 'Windows':'win'}
32 system = platform.system()
33 executable_name = 'pub'
34 if system == 'Windows':
35 executable_name = 'pub.bat'
36 try:
37 osname = osdict[system]
38 except KeyError:
39 print >>sys.stderr, ('WARNING: platform "%s" not supported') % (system)
40 return None;
41 return os.path.join(DART_ROOT,
42 'tools',
43 'sdks',
44 osname,
45 'dart-sdk',
46 'bin',
47 executable_name)
48
29 def BuildArguments(): 49 def BuildArguments():
30 result = argparse.ArgumentParser(usage=usage) 50 result = argparse.ArgumentParser(usage=usage)
31 result.add_argument("--package-root", help="package root", default=None) 51 result.add_argument("--package-root", help="package root", default=None)
32 result.add_argument("--dart-executable", help="dart executable", default=None) 52 result.add_argument("--dart-executable", help="dart executable", default=None)
33 result.add_argument("--pub-executable", help="pub executable", default=None) 53 result.add_argument("--pub-executable", help="pub executable", default=None)
34 result.add_argument("--directory", help="observatory root", default=None) 54 result.add_argument("--directory", help="observatory root", default=None)
35 result.add_argument("--command", help="[get, build, deploy]", default=None) 55 result.add_argument("--command", help="[get, build, deploy]", default=None)
36 result.add_argument("--silent", help="silence all output", default=False) 56 result.add_argument("--silent", help="silence all output", default=False)
57 result.add_argument("--sdk", help="Use prebuilt sdk", default=False)
37 return result 58 return result
38 59
39 def ProcessOptions(options, args): 60 def ProcessOptions(options, args):
40 # Required options. 61 # Required options.
41 if (options.command == None) or (options.directory == None): 62 if (options.command == None) or (options.directory == None):
42 return False 63 return False
43 # If we have a pub executable, we are running from the dart-sdk. 64 # If we have a pub executable, we are running from the dart-sdk.
44 if (options.pub_executable != None): 65 if (options.pub_executable != None):
45 return True 66 return True
67 if (options.sdk != None):
68 # Use the checked in pub executable by default.
69 options.pub_executable = GetDartSdkPubExecutablePath()
70 return True
46 # Otherwise, we need a dart executable and a package root. 71 # Otherwise, we need a dart executable and a package root.
47 return ((options.package_root != None) and 72 return ((options.package_root != None) and
48 (options.dart_executable != None)) 73 (options.dart_executable != None))
49 74
50 def ChangeDirectory(directory): 75 def ChangeDirectory(directory):
51 os.chdir(directory); 76 os.chdir(directory);
52 77
53 def PubGet(dart_executable, pub_executable, pkg_root, silent): 78 def PubGet(dart_executable, pub_executable, pkg_root, silent):
54 # Always remove pubspec.lock before running 'pub get'. 79 # Always remove pubspec.lock before running 'pub get'.
55 try: 80 try:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (options.pub_executable != None): 170 if (options.pub_executable != None):
146 options.pub_executable = os.path.abspath(options.pub_executable) 171 options.pub_executable = os.path.abspath(options.pub_executable)
147 if len(args) == 1: 172 if len(args) == 1:
148 args[0] = os.path.abspath(args[0]) 173 args[0] = os.path.abspath(args[0])
149 # Pub must be run from the project's root directory. 174 # Pub must be run from the project's root directory.
150 ChangeDirectory(options.directory) 175 ChangeDirectory(options.directory)
151 return ExecuteCommand(options, args) 176 return ExecuteCommand(options, args)
152 177
153 if __name__ == '__main__': 178 if __name__ == '__main__':
154 sys.exit(main()); 179 sys.exit(main());
OLDNEW
« no previous file with comments | « runtime/observatory/observatory.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698