mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
[cfe] Run commands of tool/fasta.dart in the same VM
This changes tool/fasta.dart to run the subcommand in the same VM when no VM arguments are specified. This speeds up the tool and as a consequence speeds up the tool/update_all.dart and tool/update_expectation.dart tools. Change-Id: I80b61a692a3ac2e15a7d1d097e65e1efbf9e4aee Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236560 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
e48e85c87f
commit
d380ae8d48
|
@ -4,7 +4,19 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import "package:testing/src/run_tests.dart" as run_tests;
|
||||
import 'package:kernel/src/tool/dump.dart' as dump;
|
||||
import '../test/utils/io_utils.dart' show computeRepoDir;
|
||||
import '_fasta/abcompile.dart' as abcompile;
|
||||
import '_fasta/compile.dart' as compile;
|
||||
import '_fasta/compile_platform.dart' as compile_platform;
|
||||
import '_fasta/generate_experimental_flags.dart' as generate_experimental_flags;
|
||||
import '_fasta/generate_messages.dart' as generate_messages;
|
||||
import '_fasta/log_analyzer.dart' as log_analyzer;
|
||||
import '_fasta/log_collector.dart' as log_collector;
|
||||
import '_fasta/outline.dart' as outline;
|
||||
import '_fasta/parser.dart' as parser;
|
||||
import '_fasta/scanner.dart' as scanner;
|
||||
|
||||
final String repoDir = computeRepoDir();
|
||||
|
||||
|
@ -35,62 +47,86 @@ Future<void> main(List<String> args) async {
|
|||
String command = args[index++];
|
||||
List<String> remainingArguments = args.skip(index).toList();
|
||||
|
||||
dynamic Function(List<String>) mainFunction;
|
||||
|
||||
switch (command) {
|
||||
case 'abcompile':
|
||||
mainFunction = abcompile.main;
|
||||
script = '${toolDir}/abcompile.dart';
|
||||
break;
|
||||
case 'compile':
|
||||
mainFunction = compile.main;
|
||||
script = '${toolDir}/compile.dart';
|
||||
break;
|
||||
case 'compile-platform':
|
||||
mainFunction = compile_platform.main;
|
||||
script = '${toolDir}/compile_platform.dart';
|
||||
break;
|
||||
case 'log':
|
||||
mainFunction = log_analyzer.main;
|
||||
script = '${toolDir}/log_analyzer.dart';
|
||||
break;
|
||||
case 'logd':
|
||||
mainFunction = log_collector.main;
|
||||
script = '${toolDir}/log_collector.dart';
|
||||
break;
|
||||
case 'outline':
|
||||
mainFunction = outline.main;
|
||||
script = '${toolDir}/outline.dart';
|
||||
break;
|
||||
case 'parser':
|
||||
mainFunction = parser.main;
|
||||
script = '${toolDir}/parser.dart';
|
||||
break;
|
||||
case 'scanner':
|
||||
mainFunction = scanner.main;
|
||||
script = '${toolDir}/scanner.dart';
|
||||
break;
|
||||
case 'dump-ir':
|
||||
mainFunction = dump.main;
|
||||
script = '${kernelBin}/dump.dart';
|
||||
if (remainingArguments.isEmpty || remainingArguments.length > 2) {
|
||||
stop("Usage: $command dillFile [output]");
|
||||
}
|
||||
break;
|
||||
case 'testing':
|
||||
mainFunction = run_tests.main;
|
||||
script = '${repoDir}/pkg/testing/bin/testing.dart';
|
||||
scriptArguments.add('--config=${repoDir}/pkg/front_end/testing.json');
|
||||
break;
|
||||
case 'generate-messages':
|
||||
mainFunction = generate_messages.main;
|
||||
script = '${toolDir}/generate_messages.dart';
|
||||
break;
|
||||
case 'generate-experimental-flags':
|
||||
mainFunction = generate_experimental_flags.main;
|
||||
script = '${toolDir}/generate_experimental_flags.dart';
|
||||
break;
|
||||
default:
|
||||
stop("'$command' isn't a valid subcommand.");
|
||||
}
|
||||
|
||||
List<String> arguments = [];
|
||||
arguments.addAll(extraVmArguments);
|
||||
arguments.add('--enable-asserts');
|
||||
arguments.add(script);
|
||||
arguments.addAll(remainingArguments);
|
||||
arguments.addAll(scriptArguments);
|
||||
if (extraVmArguments.isNotEmpty) {
|
||||
List<String> arguments = [];
|
||||
arguments.addAll(extraVmArguments);
|
||||
arguments.add('--enable-asserts');
|
||||
arguments.add(script);
|
||||
arguments.addAll(remainingArguments);
|
||||
arguments.addAll(scriptArguments);
|
||||
|
||||
print('Running: ${dartVm} ${arguments.join(' ')}');
|
||||
Process process = await Process.start(dartVm, arguments,
|
||||
mode: ProcessStartMode.inheritStdio);
|
||||
exitCode = await process.exitCode;
|
||||
print('Running: ${dartVm} ${arguments.join(' ')}');
|
||||
Process process = await Process.start(dartVm, arguments,
|
||||
mode: ProcessStartMode.inheritStdio);
|
||||
exitCode = await process.exitCode;
|
||||
} else {
|
||||
// Run within the same VM if no VM arguments are provided.
|
||||
List<String> arguments = [];
|
||||
arguments.addAll(remainingArguments);
|
||||
arguments.addAll(scriptArguments);
|
||||
|
||||
print('Running: ${script} ${arguments.join(' ')}');
|
||||
await mainFunction(arguments);
|
||||
}
|
||||
}
|
||||
|
||||
Never stop(String message) {
|
||||
|
|
|
@ -3,30 +3,4 @@
|
|||
// 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.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'package:kernel/src/tool/command_line_util.dart';
|
||||
|
||||
void usage() {
|
||||
print("Prints a dill file as a textual format.");
|
||||
print("");
|
||||
print("Usage: dart <script> dillFile.dill [output]");
|
||||
print("");
|
||||
print("The first given argument should be an existing file");
|
||||
print("that is valid to load as a dill file.");
|
||||
print("");
|
||||
print("The second argument is optional.");
|
||||
print("If given, output will be written to this file.");
|
||||
print("If not given, output will be written to standard out.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void main(List<String> args) {
|
||||
CommandLineHelper.requireVariableArgumentCount([1, 2], args, usage);
|
||||
CommandLineHelper.requireFileExists(args[0]);
|
||||
var binary = CommandLineHelper.tryLoadDill(args[0]);
|
||||
writeComponentToText(binary,
|
||||
path: args.length > 1 ? args[1] : null,
|
||||
showOffsets: const bool.fromEnvironment("showOffsets"));
|
||||
}
|
||||
export 'package:kernel/src/tool/dump.dart';
|
||||
|
|
31
pkg/kernel/lib/src/tool/dump.dart
Normal file
31
pkg/kernel/lib/src/tool/dump.dart
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
|
||||
// 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.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import '../../kernel.dart';
|
||||
import 'command_line_util.dart';
|
||||
|
||||
void usage() {
|
||||
print("Prints a dill file as a textual format.");
|
||||
print("");
|
||||
print("Usage: dart <script> dillFile.dill [output]");
|
||||
print("");
|
||||
print("The first given argument should be an existing file");
|
||||
print("that is valid to load as a dill file.");
|
||||
print("");
|
||||
print("The second argument is optional.");
|
||||
print("If given, output will be written to this file.");
|
||||
print("If not given, output will be written to standard out.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void main(List<String> args) {
|
||||
CommandLineHelper.requireVariableArgumentCount([1, 2], args, usage);
|
||||
CommandLineHelper.requireFileExists(args[0]);
|
||||
Component binary = CommandLineHelper.tryLoadDill(args[0]);
|
||||
writeComponentToText(binary,
|
||||
path: args.length > 1 ? args[1] : null,
|
||||
showOffsets: const bool.fromEnvironment("showOffsets"));
|
||||
}
|
Loading…
Reference in a new issue