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

Unified Diff: tools/observatory_tool.py

Issue 1343103002: Observatory build should try backup method if the SDK doesn't work. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/build.py ('k') | tools/run_pub.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/observatory_tool.py
diff --git a/tools/observatory_tool.py b/tools/observatory_tool.py
index adf103fde62b31c32ee4ab930f40256ae9c9de62..90c2aa272f81eae443184164dbfefa871ea37938 100755
--- a/tools/observatory_tool.py
+++ b/tools/observatory_tool.py
@@ -14,7 +14,8 @@ import utils
SCRIPT_DIR = os.path.dirname(sys.argv[0])
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
-RUN_PUB = os.path.join(DART_ROOT, 'tools/run_pub.py')
+PUB_PATH = os.path.join(DART_ROOT, 'third_party', 'pkg',
+ 'pub', 'bin', 'pub.dart')
IGNORE_PATTERNS = shutil.ignore_patterns(
'*.map',
'*.concat.js',
@@ -26,7 +27,7 @@ IGNORE_PATTERNS = shutil.ignore_patterns(
'*.log',
'*~')
-usage = """obs_tool.py [options]"""
+usage = """observatory_tool.py [options]"""
def BuildArguments():
result = argparse.ArgumentParser(usage=usage)
@@ -41,64 +42,69 @@ def BuildArguments():
def ProcessOptions(options, args):
# Required options.
- if (options.command == None) or (options.directory == None):
+ if options.command is None or options.directory is None:
return False
- # If we have a pub executable, we are running from the dart-sdk.
- if (options.pub_executable != None):
- return True
- if (options.sdk != None):
- # Use the checked in pub executable by default.
- options.pub_executable = utils.CheckedInPubPath()
- return True
- # Otherwise, we need a dart executable and a package root.
- return ((options.package_root != None) and
- (options.dart_executable != None))
+ # If we have a working pub executable, try and use that.
+ # TODO(whesse): Drop the pub-executable option if it isn't used.
+ if options.pub_executable is not None:
+ try:
+ if 0 == subprocess.call([options.pub_executable, '--version']):
+ return True
+ except OSError as e:
+ pass
+ options.pub_executable = None
+
+ if options.sdk is not None and utils.CheckedInSdkCheckExecutable():
+ # Use the checked in pub executable.
+ options.pub_snapshot = os.path.join(utils.CheckedInSdkPath(),
+ 'bin',
+ 'snapshots',
+ 'pub.dart.snapshot');
+ try:
+ if 0 == subprocess.call([utils.CheckedInSdkExecutable(),
+ options.pub_snapshot,
+ '--version']):
+ return True
+ except OSError as e:
+ pass
+ options.pub_snapshot = None
+
+ # We need a dart executable and a package root.
+ return (options.package_root is not None and
+ options.dart_executable is not None)
def ChangeDirectory(directory):
os.chdir(directory);
-def PubGet(dart_executable, pub_executable, pkg_root, silent):
- # Always remove pubspec.lock before running 'pub get'.
- try:
- os.remove('pubspec.lock');
- except OSError as e:
- pass
- with open(os.devnull, 'wb') as silent_sink:
- if (pub_executable != None):
- return subprocess.call([pub_executable,
- 'get',
- '--offline'],
- stdout=silent_sink if silent else None,
- stderr=silent_sink if silent else None)
- else:
- return subprocess.call(['python',
- RUN_PUB,
- '--package-root=' + pkg_root,
- '--dart-executable=' + dart_executable,
- 'get',
- '--offline'],
- stdout=silent_sink if silent else None,
- stderr=silent_sink if silent else None,)
-
-def PubBuild(dart_executable, pub_executable, pkg_root, silent, output_dir):
+def DisplayBootstrapWarning():
+ print """\
+
+
+WARNING: Your system cannot run the checked-in Dart SDK. Using the
+bootstrap Dart executable will make debug builds slow.
+Please see the Wiki for instructions on replacing the checked-in Dart SDK.
+
+https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in--tools
+
+"""
+
+def PubCommand(dart_executable,
+ pub_executable,
+ pub_snapshot,
+ pkg_root,
+ command,
+ silent):
with open(os.devnull, 'wb') as silent_sink:
- if (pub_executable != None):
- return subprocess.call([pub_executable,
- 'build',
- '--output',
- output_dir],
- stdout=silent_sink if silent else None,
- stderr=silent_sink if silent else None,)
+ if pub_executable is not None:
+ executable = [pub_executable]
+ elif pub_snapshot is not None:
+ executable = [utils.CheckedInSdkExecutable(), pub_snapshot]
else:
- return subprocess.call(['python',
- RUN_PUB,
- '--package-root=' + pkg_root,
- '--dart-executable=' + dart_executable,
- 'build',
- '--output',
- output_dir],
- stdout=silent_sink if silent else None,
- stderr=silent_sink if silent else None,)
+ DisplayBootstrapWarning()
+ executable = [dart_executable, '--package-root=' + pkg_root, PUB_PATH]
+ return subprocess.call(executable + command,
+ stdout=silent_sink if silent else None,
+ stderr=silent_sink if silent else None)
def Deploy(input_dir, output_dir):
shutil.rmtree(output_dir)
@@ -117,16 +123,24 @@ def RewritePubSpec(input_path, output_path, search, replace):
def ExecuteCommand(options, args):
cmd = options.command
if (cmd == 'get'):
- return PubGet(options.dart_executable,
- options.pub_executable,
- options.package_root,
- options.silent)
+ # Always remove pubspec.lock before running 'pub get'.
+ try:
+ os.remove('pubspec.lock');
+ except OSError as e:
+ pass
+ return PubCommand(options.dart_executable,
+ options.pub_executable,
+ options.pub_snapshot,
+ options.package_root,
+ ['get', '--offline'],
+ options.silent)
elif (cmd == 'build'):
- return PubBuild(options.dart_executable,
- options.pub_executable,
- options.package_root,
- options.silent,
- args[0])
+ return PubCommand(options.dart_executable,
+ options.pub_executable,
+ options.pub_snapshot,
+ options.package_root,
+ ['build', '--output', args[0]],
+ options.silent)
elif (cmd == 'deploy'):
Deploy('build', 'deployed')
elif (cmd == 'rewrite'):
@@ -142,8 +156,6 @@ def main():
if not ProcessOptions(options, args):
parser.print_help()
return 1
- if os.getenv('DART_USE_BOOTSTRAP_BIN') != None:
- dart_executable = options.dart_executable
# Calculate absolute paths before changing directory.
if (options.package_root != None):
options.package_root = os.path.abspath(options.package_root)
@@ -151,6 +163,8 @@ def main():
options.dart_executable = os.path.abspath(options.dart_executable)
if (options.pub_executable != None):
options.pub_executable = os.path.abspath(options.pub_executable)
+ if (options.pub_snapshot != None):
+ options.pub_snapshot = os.path.abspath(options.pub_snapshot)
if len(args) == 1:
args[0] = os.path.abspath(args[0])
# Pub must be run from the project's root directory.
@@ -158,4 +172,4 @@ def main():
return ExecuteCommand(options, args)
if __name__ == '__main__':
- sys.exit(main());
+ sys.exit(main());
« no previous file with comments | « tools/build.py ('k') | tools/run_pub.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698