def main(): verbose = False arguments = [None] # Leave room for the Dart VM executable. arguments.append("--packages=" + path(".packages")) arguments.append(path("pkg/front_end/tool/_fasta/compile_platform.dart")) i = 1 # Skip argument #0 which is the script name. dart_executable = None while i < len(sys.argv): argument = sys.argv[i] if argument == "--dart-executable": dart_executable = sys.argv[i + 1] i += 1 elif argument.startswith("--dart-executable="): dart_executable = argument[len("--dart-executable="):] else: if argument == "-v" or argument == "--verbose": verbose = True arguments.append(argument) i += 1 if dart_executable: dart_executable = os.path.abspath(dart_executable) else: if utils.CheckedInSdkCheckExecutable(): dart_executable = utils.CheckedInSdkExecutable() else: DisplayBootstrapWarning() print >> sys.stderr, "ERROR: Can't locate Dart VM executable." return -1 arguments[0] = os.path.relpath(dart_executable) if verbose: print "Running:", " ".join(arguments) return subprocess.call(arguments)
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: # 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 # 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 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 # We need a dart executable and a package root. return (options.package_root is not None and options.dart_executable is not None)
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 # Required options. if options.command is None or options.directory is None: return False # If a dart2js execuble was provided, try and use that. # TODO(whesse): Drop the dart2js-executable option if it isn't used. if options.dart2js_executable is not None: try: if 0 == RunCommand([options.dart2js_executable, '--version'], always_silent=True): return True except OSError as e: pass options.dart2js_executable = None # Use the checked in dart2js executable. if options.sdk and utils.CheckedInSdkCheckExecutable(): dart2js_binary = 'dart2js.bat' if utils.IsWindows() else 'dart2js' options.dart2js_executable = os.path.join(utils.CheckedInSdkPath(), 'bin', dart2js_binary) try: if 0 == RunCommand([options.dart2js_executable, '--version'], always_silent=True): return True except OSError as e: pass options.dart2js_executable = None # We need a dart executable and will run from source return (options.dart_executable is not None)
def main(): # Parse the options. parser = BuildArguments() (options, args) = parser.parse_known_args() if utils.CheckedInSdkCheckExecutable(): options.dart_executable = utils.CheckedInSdkExecutable() elif options.dart_executable is not None: DisplayBootstrapWarning() options.dart_executable = os.path.abspath(options.dart_executable) else: print >> sys.stderr, 'ERROR: cannot locate dart executable' return -1 dart_file = os.path.join(os.path.dirname(__file__), 'patch_sdk.dart') subprocess.check_call([options.dart_executable, dart_file] + args) return 0
def main(): # Parse the options. parser = BuildArguments() (options, args) = parser.parse_known_args() if utils.CheckedInSdkCheckExecutable(): options.dart = utils.CheckedInSdkExecutable() elif options.dart is not None: DisplayBootstrapWarning() options.dart = os.path.abspath(options.dart) else: print >> sys.stderr, 'ERROR: cannot locate dart executable' return -1 if options.quiet: # Pipe output to /dev/null. See https://stackoverflow.com/a/14736249/9457. out = open(os.devnull, 'w') else: out = None return subprocess.call([options.dart] + args, stdout=out, stderr=out)
def ProcessOptions(options, args): with open(os.devnull, 'wb') as silent_sink: # 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 # 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 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' ], stdout=silent_sink, stderr=silent_sink): 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)