From 82f3ca2b1de4320308f412a45d0913844c668824 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Wed, 7 Dec 2016 13:01:59 -0800 Subject: [PATCH] Fuchsia: Re-land build of VM with Observatory with better debug output. Review URL: https://codereview.chromium.org/2555813004 . --- runtime/bin/BUILD.gn | 56 ++++++++++---------- tools/observatory_tool.py | 109 ++++++++++++++++++++------------------ 2 files changed, 85 insertions(+), 80 deletions(-) diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn index 07b9b1707e6..f8428bd4ae6 100644 --- a/runtime/bin/BUILD.gn +++ b/runtime/bin/BUILD.gn @@ -607,37 +607,35 @@ template("dart_executable") { } } -if (!defined(is_fuchsia) || !is_fuchsia) { - dart_executable("dart") { - extra_deps = [ - "..:libdart", - ":dart_snapshot_cc", - "../observatory:standalone_observatory_archive", - ] - extra_sources = [ "builtin_nolib.cc" ] - } +dart_executable("dart") { + extra_deps = [ + "..:libdart", + ":dart_snapshot_cc", + "../observatory:standalone_observatory_archive", + ] + extra_sources = [ "builtin_nolib.cc" ] +} - dart_executable("dart_noopt") { - extra_configs = [ "..:dart_precompiler_config" ] - extra_deps = [ - "..:libdart_noopt", - ":dart_snapshot_cc", - "../observatory:standalone_observatory_archive", - ] - extra_sources = [ "builtin_nolib.cc" ] - } +dart_executable("dart_noopt") { + extra_configs = [ "..:dart_precompiler_config" ] + extra_deps = [ + "..:libdart_noopt", + ":dart_snapshot_cc", + "../observatory:standalone_observatory_archive", + ] + extra_sources = [ "builtin_nolib.cc" ] +} - dart_executable("dart_precompiled_runtime") { - extra_configs = [ "..:dart_precompiled_runtime_config" ] - extra_deps = [ - "..:libdart_precompiled_runtime", - "../observatory:standalone_observatory_archive", - ] - extra_sources = [ - "builtin_nolib.cc", - "snapshot_empty.cc", - ] - } +dart_executable("dart_precompiled_runtime") { + extra_configs = [ "..:dart_precompiled_runtime_config" ] + extra_deps = [ + "..:libdart_precompiled_runtime", + "../observatory:standalone_observatory_archive", + ] + extra_sources = [ + "builtin_nolib.cc", + "snapshot_empty.cc", + ] } dart_executable("dart_bootstrap") { diff --git a/tools/observatory_tool.py b/tools/observatory_tool.py index 08f807328b5..e82c72c0bf3 100755 --- a/tools/observatory_tool.py +++ b/tools/observatory_tool.py @@ -38,6 +38,19 @@ IGNORE_PATTERNS = shutil.ignore_patterns( usage = """observatory_tool.py [options]""" +# Run |command|. If its return code is 0, return 0 and swallow its output. +# If its return code is non-zero, emit its output unless |always_silent| is +# True, and return the return code. +def RunCommand(command, always_silent=False): + try: + subprocess.check_output(command, stderr=subprocess.STDOUT) + return 0 + except subprocess.CalledProcessError as e: + if not always_silent: + print ("Command failed: " + ' '.join(command) + "\n" + + "output: " + e.output) + return e.returncode + def CreateTimestampFile(options): if options.stamp != '': dir_name = os.path.dirname(options.stamp) @@ -75,45 +88,41 @@ def ProcessOptions(options, args): print "--sdk expects 'True' or 'False' argument." return False - with open(os.devnull, 'wb') as silent_sink: - # Required options. - if options.command is None or options.directory is None: - return False + # Required options. + if options.command is None or options.directory is None: + return False - # Set a default value for pub_snapshot. - options.pub_snapshot = None + # Set a default value for pub_snapshot. + options.pub_snapshot = 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'], - stdout=silent_sink, - stderr=silent_sink): - return True - except OSError as e: - pass - options.pub_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 == RunCommand([options.pub_executable, '--version'], + always_silent=True): + return True + except OSError as e: + pass + options.pub_executable = None - if options.sdk 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'], - stdout=silent_sink, - stderr=silent_sink): - return True - except OSError as e: - pass - options.pub_snapshot = None + if options.sdk 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 == RunCommand([utils.CheckedInSdkExecutable(), + options.pub_snapshot, + '--version'], always_silent=True): + return True + except OSError as e: + pass + options.pub_snapshot = None - # We need a dart executable. - return (options.dart_executable is not None) + # We need a dart executable. + return (options.dart_executable is not None) def ChangeDirectory(directory): os.chdir(directory); @@ -138,23 +147,21 @@ def PubCommand(dart_executable, pub_snapshot, command, silent): - with open(os.devnull, 'wb') as silent_sink: - if pub_executable is not None: - executable = [pub_executable] - elif pub_snapshot is not None: - executable = [utils.CheckedInSdkExecutable(), pub_snapshot] - else: - DisplayBootstrapWarning() - executable = [dart_executable, 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 + if pub_executable is not None: + executable = [pub_executable] + elif pub_snapshot is not None: + executable = [utils.CheckedInSdkExecutable(), pub_snapshot] + else: if not silent: - print >> sys.stderr, ('Running command "%s"') % (executable + command) - return subprocess.call(executable + command, - stdout=silent_sink if silent else None, - stderr=silent_sink if silent else None) + DisplayBootstrapWarning() + executable = [dart_executable, 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 + if not silent: + print >> sys.stderr, ('Running command "%s"') % (executable + command) + return RunCommand(executable + command) def Deploy(input_dir, output_dir): shutil.rmtree(output_dir)