Revert "Migration: fix generate_resources.dart to use `dart compile js`."
This reverts commit 6abea1381bdc8d5dd5ea6784b59a5c639fb249de.
Reason for revert: Breaks internal build of migration tool
Original change's description:
> Migration: fix generate_resources.dart to use `dart compile js`.
>
> This is necessary because the command `dart2js` is no longer present
> in the SDK.
>
> Change-Id: Iea3cf3092bcda6c889c55a51d1b5601773404fb9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253862
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>
TBR=paulberry@google.com,srawlins@google.com
Change-Id: I73c3321e6c473f5690eaddd94d13003c978234b6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253900
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/nnbd_migration/tool/codegen/generate_resources.dart b/pkg/nnbd_migration/tool/codegen/generate_resources.dart
index d28c9f3..83cfd8c 100644
--- a/pkg/nnbd_migration/tool/codegen/generate_resources.dart
+++ b/pkg/nnbd_migration/tool/codegen/generate_resources.dart
@@ -18,7 +18,7 @@
var argParser = ArgParser()
..addFlag('verify', negatable: false)
..addFlag('dev', negatable: false)
- ..addOption('dart_path')
+ ..addOption('dart2js_path')
..addFlag('help', negatable: false);
var argResults = argParser.parse(args);
if (argResults['help'] == true) {
@@ -45,7 +45,8 @@
if (verify) {
verifyResourcesGDartGenerated();
} else {
- await compileWebFrontEnd(devMode: dev!, dartPath: dartPath(argResults)!);
+ await compileWebFrontEnd(
+ devMode: dev!, dart2jsPath: dart2jsPath(argResults)!);
print('');
@@ -90,11 +91,9 @@
}
Future<void> compileWebFrontEnd(
- {required bool devMode, required String dartPath}) async {
- // dart compile js -m -o output source
- var process = await Process.start(dartPath, [
- 'compile',
- 'js',
+ {required bool devMode, required String dart2jsPath}) async {
+ // dart2js -m -o output source
+ var process = await Process.start(dart2jsPath, [
devMode ? '-O1' : '-m',
'--no-frequency-based-minification',
'-o',
@@ -121,12 +120,14 @@
resourcesFile.writeAsStringSync(content);
}
-/// Returns the dartPath, either from [argResults] or the Platform.
-String? dartPath(ArgResults argResults) {
- if (argResults.wasParsed('dart_path')) {
- return argResults['dart_path'] as String?;
+/// Returns the dart2jsPath, either from [argResults] or the Platform.
+String? dart2jsPath(ArgResults argResults) {
+ if (argResults.wasParsed('dart2js_path')) {
+ return argResults['dart2js_path'] as String?;
} else {
- return Platform.resolvedExecutable;
+ var sdkBinDir = path.dirname(Platform.resolvedExecutable);
+ var dart2jsBinary = Platform.isWindows ? 'dart2js.bat' : 'dart2js';
+ return path.join(sdkBinDir, dart2jsBinary);
}
}