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 Main(): args = sys.argv[1:] tools_dir = os.path.dirname(os.path.realpath(__file__)) dart_script_name = os.path.join(tools_dir, 'testing', 'dart', 'reset_safari.dart') command = [utils.CheckedInSdkExecutable(), '--checked', dart_script_name ] + args exit_code = subprocess.call(command) utils.DiagnoseExitCode(exit_code, command) return exit_code
def Main(): args = sys.argv[1:] tools_dir = os.path.dirname(os.path.realpath(__file__)) dart_script_name = 'test.dart' dart_test_script = string.join([tools_dir, dart_script_name], os.sep) command = [utils.CheckedInSdkExecutable(), '--checked', dart_test_script ] + args exit_code = subprocess.call(command) utils.DiagnoseExitCode(exit_code, command) return exit_code
def start_test_server(port, build_directory): print('Browse tests at ' '\033[94mhttp://localhost:%d/root_build/generated_tests/\033[0m' % port) return call([ utils.CheckedInSdkExecutable(), os.path.join('tools', 'testing', 'dart', 'http_server.dart'), '--port=%d' % port, '--crossOriginPort=%d' % (port + 1), '--network=0.0.0.0', '--build-directory=%s' % build_directory ])
def Main(): args = sys.argv[1:] yaml2json_dart = os.path.relpath( os.path.join(os.path.dirname(__file__), "yaml2json.dart")) command = [utils.CheckedInSdkExecutable(), yaml2json_dart] + args with utils.CoreDumpArchiver(args): exit_code = subprocess.call(command) utils.DiagnoseExitCode(exit_code, command) return exit_code
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 PubCommand(dart_executable, pub_executable, pub_snapshot, pkg_root, 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, '--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 PubCommand(dart_executable, pub_executable, pub_snapshot, command, silent): if pub_executable is not None: executable = [pub_executable] elif pub_snapshot is not None: executable = [utils.CheckedInSdkExecutable(), pub_snapshot] else: if not silent: 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 PubCommand(dart_executable, pub_executable, pub_snapshot, pkg_root, 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, '--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, stdout=silent_sink if silent else None, stderr=silent_sink if silent else None)
def Main(): args = sys.argv[1:] tools_dir = os.path.dirname(os.path.realpath(__file__)) dart_script_name = 'test.dart' dart_test_script = string.join([tools_dir, dart_script_name], os.sep) command = [utils.CheckedInSdkExecutable(), '--checked', dart_test_script ] + args # The testing script potentially needs the android platform tools in PATH so # we do that in ./tools/test.py (a similar logic exists in ./tools/build.py). android_platform_tools = os.path.normpath( os.path.join(tools_dir, '../third_party/android_tools/sdk/platform-tools')) if os.path.isdir(android_platform_tools): os.environ['PATH'] = '%s%s%s' % (os.environ['PATH'], os.pathsep, android_platform_tools) exit_code = subprocess.call(command) utils.DiagnoseExitCode(exit_code, command) return exit_code
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)
def Main(): args = sys.argv[1:] cleanup_dart = False if '--cleanup-dart-processes' in args: args.remove('--cleanup-dart-processes') cleanup_dart = True tools_dir = os.path.dirname(os.path.realpath(__file__)) repo_dir = os.path.dirname(tools_dir) dart_test_script = os.path.join(repo_dir, 'pkg', 'test_runner', 'bin', 'test_runner.dart') command = [utils.CheckedInSdkExecutable(), dart_test_script] + args # The testing script potentially needs the android platform tools in PATH so # we do that in ./tools/test.py (a similar logic exists in ./tools/build.py). android_platform_tools = os.path.normpath( os.path.join(tools_dir, '../third_party/android_tools/sdk/platform-tools')) if os.path.isdir(android_platform_tools): os.environ['PATH'] = '%s%s%s' % (os.environ['PATH'], os.pathsep, android_platform_tools) with utils.FileDescriptorLimitIncreaser(): with ExitStack() as stack: for ctx in utils.CoreDumpArchiver(args): stack.enter_context(ctx) exit_code = subprocess.call(command) if cleanup_dart: cleanup_command = [ sys.executable, os.path.join(tools_dir, 'task_kill.py'), '--kill_dart=True', '--kill_vc=False' ] subprocess.call(cleanup_command) utils.DiagnoseExitCode(exit_code, command) return exit_code
def Main(): args = sys.argv[1:] tools_dir = os.path.dirname(os.path.realpath(__file__)) repo_dir = os.path.dirname(tools_dir) dart_test_script = os.path.join(repo_dir, 'pkg', 'test_runner', 'bin', 'test_runner.dart') command = [utils.CheckedInSdkExecutable(), dart_test_script] + args # The testing script potentially needs the android platform tools in PATH so # we do that in ./tools/test.py (a similar logic exists in ./tools/build.py). android_platform_tools = os.path.normpath( os.path.join(tools_dir, '../third_party/android_tools/sdk/platform-tools')) if os.path.isdir(android_platform_tools): os.environ['PATH'] = '%s%s%s' % (os.environ['PATH'], os.pathsep, android_platform_tools) with utils.FileDescriptorLimitIncreaser(): with utils.CoreDumpArchiver(args): exit_code = subprocess.call(command) utils.DiagnoseExitCode(exit_code, command) return exit_code