- Prevent running of the dart_bootstrap script by default.

- Fix argument handling in Python: argparse does not properly handle booleans.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1519063004 .
This commit is contained in:
Ivan Posva 2015-12-11 13:23:12 -08:00
parent fc551b6f33
commit 6d0453594a
4 changed files with 33 additions and 11 deletions

View file

@ -44,6 +44,7 @@
'target_name': 'build_observatory', 'target_name': 'build_observatory',
'type': 'none', 'type': 'none',
'dependencies': [ 'dependencies': [
'dart_bootstrap#host',
'fetch_observatory_deps#host', 'fetch_observatory_deps#host',
], ],
'toolsets': ['host'], 'toolsets': ['host'],

View file

@ -2,10 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a // for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
// Script which exits with code 42.
import 'dart:io';
void main() { void main() {
exitCode = 42; print("Success running the canary.");
} }

View file

@ -36,11 +36,28 @@ def BuildArguments():
result.add_argument("--pub-executable", help="pub executable", default=None) result.add_argument("--pub-executable", help="pub executable", default=None)
result.add_argument("--directory", help="observatory root", default=None) result.add_argument("--directory", help="observatory root", default=None)
result.add_argument("--command", help="[get, build, deploy]", default=None) result.add_argument("--command", help="[get, build, deploy]", default=None)
result.add_argument("--silent", help="silence all output", default=False) result.add_argument("--silent", help="silence all output", default=None)
result.add_argument("--sdk", help="Use prebuilt sdk", default=False) result.add_argument("--sdk", help="Use prebuilt sdk", default=None)
return result return result
def ProcessOptions(options, args): def ProcessOptions(options, args):
# Fix broken boolean parsing in argparse, where False ends up being True.
if (options.silent is not None) and (options.silent == "True"):
options.silent = True
elif (options.silent is None) or (options.silent == "False"):
options.silent = False
else:
print "--silent expects 'True' or 'False' argument."
return False
if (options.sdk is not None) and (options.sdk == "True"):
options.sdk = True
elif (options.sdk is None) or (options.sdk == "False"):
options.sdk = False
else:
print "--sdk expects 'True' or 'False' argument."
return False
with open(os.devnull, 'wb') as silent_sink: with open(os.devnull, 'wb') as silent_sink:
# Required options. # Required options.
if options.command is None or options.directory is None: if options.command is None or options.directory is None:
@ -61,7 +78,7 @@ def ProcessOptions(options, args):
pass pass
options.pub_executable = None options.pub_executable = None
if options.sdk is not None and utils.CheckedInSdkCheckExecutable(): if options.sdk and utils.CheckedInSdkCheckExecutable():
# Use the checked in pub executable. # Use the checked in pub executable.
options.pub_snapshot = os.path.join(utils.CheckedInSdkPath(), options.pub_snapshot = os.path.join(utils.CheckedInSdkPath(),
'bin', 'bin',
@ -93,7 +110,10 @@ WARNING: Your system cannot run the checked-in Dart SDK. Using the
bootstrap Dart executable will make debug builds slow. bootstrap Dart executable will make debug builds slow.
Please see the Wiki for instructions on replacing the checked-in Dart SDK. 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 https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in-tools
To use the dart_bootstrap binary please update the PubCommand function
in the tools/observatory_tool.py script.
""" """
@ -111,6 +131,10 @@ def PubCommand(dart_executable,
else: else:
DisplayBootstrapWarning() DisplayBootstrapWarning()
executable = [dart_executable, '--package-root=' + pkg_root, PUB_PATH] executable = [dart_executable, '--package-root=' + pkg_root, PUB_PATH]
# Prevent the bootstrap Dart executable from running in regular
# development flow.
# REMOVE THE FOLLOWING LINE TO USE the dart_bootstrap binary.
return False
return subprocess.call(executable + command, return subprocess.call(executable + command,
stdout=silent_sink if silent else None, stdout=silent_sink if silent else None,
stderr=silent_sink if silent else None) stderr=silent_sink if silent else None)

View file

@ -634,7 +634,8 @@ def CheckedInSdkCheckExecutable():
canary_script = os.path.join(os.path.dirname(os.path.realpath(__file__)), canary_script = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'canary.dart') 'canary.dart')
try: try:
if 42 == subprocess.call([executable, canary_script]): with open(os.devnull, 'wb') as silent_sink:
if 0 == subprocess.call([executable, canary_script], stdout=silent_sink):
return True return True
except OSError as e: except OSError as e:
pass pass