20faaa5d94
Change-Id: Ib18f554c1076f27a3f7c0df5a36410da41a1f467 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148784 Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
// @dart = 2.7
|
|
|
|
import 'dart:async';
|
|
import 'dart:io';
|
|
import 'package:path/path.dart' as path;
|
|
|
|
List<String> dart2JsCommand(List<String> args) {
|
|
String basePath = path.fromUri(Platform.script);
|
|
while (path.basename(basePath) != 'sdk') {
|
|
basePath = path.dirname(basePath);
|
|
}
|
|
String dart2jsPath =
|
|
path.normalize(path.join(basePath, 'pkg/compiler/lib/src/dart2js.dart'));
|
|
List command = <String>[];
|
|
if (Platform.packageRoot != null) {
|
|
command.add('--package-root=${Platform.packageRoot}');
|
|
} else if (Platform.packageConfig != null) {
|
|
command.add('--packages=${Platform.packageConfig}');
|
|
}
|
|
command.add(dart2jsPath);
|
|
command.addAll(args);
|
|
return command;
|
|
}
|
|
|
|
Future<ProcessResult> launchDart2Js(args, {bool noStdoutEncoding: false}) {
|
|
if (noStdoutEncoding) {
|
|
return Process.run(Platform.executable, dart2JsCommand(args),
|
|
stdoutEncoding: null);
|
|
} else {
|
|
return Process.run(Platform.executable, dart2JsCommand(args));
|
|
}
|
|
}
|