[et] Adds a .bat entrypoint for Windows (#50784)
For https://github.com/flutter/flutter/issues/132807
diff --git a/bin/et.bat b/bin/et.bat
new file mode 100644
index 0000000..b1236e2
--- /dev/null
+++ b/bin/et.bat
@@ -0,0 +1,40 @@
+@ECHO off
+REM Copyright 2013 The Flutter Authors. All rights reserved.
+REM Use of this source code is governed by a BSD-style license that can be
+REM found in the LICENSE file.
+
+REM ---------------------------------- NOTE ----------------------------------
+REM
+REM Please keep the logic in this file consistent with the logic in the
+REM `et` script in the same directory to ensure that it continues to
+REM work across all platforms!
+REM
+REM --------------------------------------------------------------------------
+
+SETLOCAL ENABLEDELAYEDEXPANSION
+
+FOR %%i IN ("%~dp0..\..") DO SET SRC_DIR=%%~fi
+
+REM Test if Git is available on the Host
+where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1
+
+SET repo_dir=%SRC_DIR%\flutter
+SET engine_tool_dir=%repo_dir%\tools\engine_tool
+
+REM Determine which platform we are on and use the right prebuilt Dart SDK
+IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
+ SET dart_sdk_path=%SRC_DIR%\flutter\prebuilts\windows-x64\dart-sdk
+) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
+ SET dart_sdk_path=%SRC_DIR%\flutter\prebuilts\windows-arm64\dart-sdk
+) ELSE (
+ ECHO "Windows x86 (32-bit) is not supported" && EXIT /B 1
+)
+
+SET dart=%dart_sdk_path%\bin\dart.exe
+
+cd "%engine_tool_dir%"
+
+REM Do not use the CALL command in the next line to execute Dart. CALL causes
+REM Windows to re-read the line from disk after the CALL command has finished
+REM regardless of the ampersand chain.
+"%dart%" --disable-dart-dev bin\et.dart %* & exit /B !ERRORLEVEL!
diff --git a/tools/engine_tool/README.md b/tools/engine_tool/README.md
index 496824a..2a36eb9 100644
--- a/tools/engine_tool/README.md
+++ b/tools/engine_tool/README.md
@@ -23,7 +23,6 @@
GitHub issue [here](https://github.com/flutter/flutter/issues/132807). Some
desirable new features would do the following:
-* Support Windows hosts.
* Add a `doctor` command.
* Update the engine checkout so that engine developers no longer have to remeber
to run `gclient sync -D`.
diff --git a/tools/engine_tool/lib/src/commands/command_runner.dart b/tools/engine_tool/lib/src/commands/command_runner.dart
index 360e649..48e306d 100644
--- a/tools/engine_tool/lib/src/commands/command_runner.dart
+++ b/tools/engine_tool/lib/src/commands/command_runner.dart
@@ -41,7 +41,7 @@
@override
Future<int> run(Iterable<String> args) async {
try{
- return await runCommand(parse(args)) ?? 1;
+ return await runCommand(parse(args)) ?? 0;
} on FormatException catch (e) {
environment.logger.error(e);
return 1;
diff --git a/tools/engine_tool/test/entry_point_test.dart b/tools/engine_tool/test/entry_point_test.dart
new file mode 100644
index 0000000..052b361
--- /dev/null
+++ b/tools/engine_tool/test/entry_point_test.dart
@@ -0,0 +1,40 @@
+// Copyright 2013 The Flutter Authors. 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' as io;
+
+import 'package:engine_repo_tools/engine_repo_tools.dart';
+import 'package:litetest/litetest.dart';
+import 'package:path/path.dart' as path;
+import 'package:platform/platform.dart';
+import 'package:process_runner/process_runner.dart';
+
+void main() {
+ final Engine engine;
+ try {
+ engine = Engine.findWithin();
+ } catch (e) {
+ io.stderr.writeln(e);
+ io.exitCode = 1;
+ return;
+ }
+
+ test('The entry points under bin/ work', () async {
+ const Platform platform = LocalPlatform();
+ final ProcessRunner runner = ProcessRunner();
+ final String exe = platform.isWindows ? '.bat' : '';
+ final String entrypointPath = path.join(
+ engine.flutterDir.path, 'bin', 'et$exe',
+ );
+ final ProcessRunnerResult processResult = await runner.runProcess(
+ <String>[entrypointPath, 'help'],
+ failOk: true,
+ );
+ if (processResult.exitCode != 0) {
+ io.stdout.writeln(processResult.stdout);
+ io.stderr.writeln(processResult.stderr);
+ }
+ expect(processResult.exitCode, equals(0));
+ });
+}