[test_runner]: launch dart2js via 'dart compile js'.
We will be deprecating the dart2js script shipped with the sdk under dart-sdk/bin/. This change starts using 'dart compile js' when running dart2js in `useSdk` mode. For host-asserts, we continue to use a helper script that invokes dart2js from sources. We will continue to support this helper script, but it will become an internal only tool. It is a bit confusing that such script lives under sdk/bin/dart2js and sdk/bin/dart2js_developer. We may consider renaming this in a later CL or moving it to a new location (e.g. under tools). Change-Id: I4f426936f5e0e0a1a7854f4f555198d5ae382079 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229060 Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
committed by
Commit Bot
parent
79dbdea71b
commit
d19a405abb
@@ -124,7 +124,9 @@ class ProcessCommand extends Command {
|
||||
(io.Platform.operatingSystem == 'windows')
|
||||
? env.write('set $key=${escapeCommandLineArgument(value)} & ')
|
||||
: env.write('$key=${escapeCommandLineArgument(value)} '));
|
||||
var command = ([executable]..addAll(batchArguments)..addAll(arguments))
|
||||
var command = ([executable]
|
||||
..addAll(nonBatchArguments)
|
||||
..addAll(arguments))
|
||||
.map(escapeCommandLineArgument)
|
||||
.join(' ');
|
||||
if (workingDirectory != null) {
|
||||
@@ -135,10 +137,13 @@ class ProcessCommand extends Command {
|
||||
|
||||
bool get outputIsUpToDate => false;
|
||||
|
||||
/// Arguments that are passed to the process when starting batch mode.
|
||||
///
|
||||
/// In non-batch mode, they should be passed before [arguments].
|
||||
/// Additional arguments to prepend before [arguments] when running the
|
||||
/// process in batch mode.
|
||||
List<String> get batchArguments => const [];
|
||||
|
||||
/// Additional arguments to prepend before [arguments] when running the
|
||||
/// process in non-batch mode.
|
||||
List<String> get nonBatchArguments => const [];
|
||||
}
|
||||
|
||||
class CompilationCommand extends ProcessCommand {
|
||||
@@ -243,6 +248,61 @@ class CompilationCommand extends ProcessCommand {
|
||||
deepJsonCompare(_bootstrapDependencies, other._bootstrapDependencies);
|
||||
}
|
||||
|
||||
class Dart2jsCompilationCommand extends CompilationCommand {
|
||||
final bool useSdk;
|
||||
|
||||
Dart2jsCompilationCommand(
|
||||
String outputFile,
|
||||
List<Uri> bootstrapDependencies,
|
||||
String executable,
|
||||
List<String> arguments,
|
||||
Map<String, String> environmentOverrides,
|
||||
{this.useSdk,
|
||||
bool alwaysCompile,
|
||||
String workingDirectory,
|
||||
int index = 0})
|
||||
: super("dart2js", outputFile, bootstrapDependencies, executable,
|
||||
arguments, environmentOverrides,
|
||||
alwaysCompile: alwaysCompile || true,
|
||||
workingDirectory: workingDirectory,
|
||||
index: index);
|
||||
|
||||
@override
|
||||
CommandOutput createOutput(int exitCode, bool timedOut, List<int> stdout,
|
||||
List<int> stderr, Duration time, bool compilationSkipped,
|
||||
[int pid = 0]) {
|
||||
return Dart2jsCompilerCommandOutput(
|
||||
this, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> get batchArguments {
|
||||
return <String>[
|
||||
if (useSdk) ...['compile', 'js'],
|
||||
...super.batchArguments,
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> get nonBatchArguments {
|
||||
return <String>[
|
||||
if (useSdk) ...['compile', 'js'],
|
||||
...super.nonBatchArguments,
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
void _buildHashCode(HashCodeBuilder builder) {
|
||||
super._buildHashCode(builder);
|
||||
builder.addJson(useSdk);
|
||||
}
|
||||
|
||||
@override
|
||||
bool _equal(Dart2jsCompilationCommand other) {
|
||||
return super._equal(other) && useSdk == other.useSdk;
|
||||
}
|
||||
}
|
||||
|
||||
class FastaCompilationCommand extends CompilationCommand {
|
||||
final Uri _compilerLocation;
|
||||
|
||||
|
||||
@@ -386,27 +386,26 @@ class Dart2jsCompilerConfiguration extends CompilerConfiguration {
|
||||
: super._subclass(configuration);
|
||||
|
||||
String computeCompilerPath() {
|
||||
var prefix = 'sdk/bin';
|
||||
var suffix = shellScriptExtension;
|
||||
|
||||
if (_isHostChecked) {
|
||||
if (_useSdk) {
|
||||
// Note: when [_useSdk] is true, dart2js is run from a snapshot that was
|
||||
// built without checked mode. The VM cannot make such snapshot run in
|
||||
// checked mode later. These two flags could be used together if we also
|
||||
// build an sdk with checked snapshots.
|
||||
throw "--host-checked and --use-sdk cannot be used together";
|
||||
}
|
||||
// The script dart2js_developer is not included in the
|
||||
// shipped SDK, that is the script is not installed in
|
||||
// "$buildDir/dart-sdk/bin/"
|
||||
return '$prefix/dart2js_developer$suffix';
|
||||
if (_isHostChecked && _useSdk) {
|
||||
// When [_useSdk] is true, dart2js is compiled into a snapshot that was
|
||||
// built without checked mode. The VM cannot make such snapshot run in
|
||||
// checked mode later. These two flags could be used together if we also
|
||||
// build an sdk with checked snapshots.
|
||||
throw "--host-checked and --use-sdk cannot be used together";
|
||||
}
|
||||
|
||||
if (_useSdk) {
|
||||
prefix = '${_configuration.buildDirectory}/dart-sdk/bin';
|
||||
var dartSdk = '${_configuration.buildDirectory}/dart-sdk';
|
||||
// When using the shipped sdk, we invoke dart2js via the dart CLI using
|
||||
// `dart compile js`. The additional `compile js` arguments are added
|
||||
// within [Dart2jsCompilationCommand]. This is because the arguments are
|
||||
// added differently depending on whether the command is executed in batch
|
||||
// mode or not.
|
||||
return '$dartSdk/bin/dart$executableExtension';
|
||||
} else {
|
||||
var scriptName = _isHostChecked ? 'dart2js_developer' : 'dart2js';
|
||||
return 'sdk/bin/$scriptName$shellScriptExtension';
|
||||
}
|
||||
return '$prefix/dart2js$suffix';
|
||||
}
|
||||
|
||||
Command computeCompilationCommand(String outputFileName,
|
||||
@@ -414,14 +413,9 @@ class Dart2jsCompilerConfiguration extends CompilerConfiguration {
|
||||
arguments = arguments.toList();
|
||||
arguments.add('--out=$outputFileName');
|
||||
|
||||
return CompilationCommand(
|
||||
'dart2js',
|
||||
outputFileName,
|
||||
bootstrapDependencies(),
|
||||
computeCompilerPath(),
|
||||
arguments,
|
||||
environmentOverrides,
|
||||
alwaysCompile: !_useSdk);
|
||||
return Dart2jsCompilationCommand(outputFileName, bootstrapDependencies(),
|
||||
computeCompilerPath(), arguments, environmentOverrides,
|
||||
useSdk: _useSdk, alwaysCompile: !_useSdk);
|
||||
}
|
||||
|
||||
List<Uri> bootstrapDependencies() {
|
||||
|
||||
@@ -260,7 +260,7 @@ class RunningProcess {
|
||||
_commandComplete(0);
|
||||
} else {
|
||||
var processEnvironment = _createProcessEnvironment();
|
||||
var args = command.arguments;
|
||||
var args = [...command.nonBatchArguments, ...command.arguments];
|
||||
var processFuture = io.Process.start(command.executable, args,
|
||||
environment: processEnvironment,
|
||||
workingDirectory: command.workingDirectory);
|
||||
|
||||
Reference in New Issue
Block a user