Skip to content

Commit b84bfa3

Browse files
authored
Faster wrapper script on Windows (#111465)
1 parent 085a187 commit b84bfa3

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

bin/flutter.bat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ REM If available, add location of bundled mingit to PATH
2222
SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd
2323
IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path%
2424

25-
REM Test if Git is available on the Host
26-
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1
25+
REM We test if Git is available on the Host as we run git in shared.bat
2726
REM Test if the flutter directory is a git clone, otherwise git rev-parse HEAD would fail
2827
IF NOT EXIST "%flutter_root%\.git" (
2928
ECHO Error: The Flutter directory is not a clone of the GitHub project.

bin/internal/shared.bat

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@ SET pub_cache_path=%FLUTTER_ROOT%\.pub-cache
2525

2626
SET dart=%dart_sdk_path%\bin\dart.exe
2727

28-
REM Detect which PowerShell executable is available on the Host
29-
REM PowerShell version <= 5: PowerShell.exe
30-
REM PowerShell version >= 6: pwsh.exe
31-
WHERE /Q pwsh.exe && (
32-
SET powershell_executable=pwsh.exe
33-
) || WHERE /Q PowerShell.exe && (
34-
SET powershell_executable=PowerShell.exe
35-
) || (
36-
ECHO Error: PowerShell executable not found. 1>&2
37-
ECHO Either pwsh.exe or PowerShell.exe must be in your PATH. 1>&2
38-
EXIT 1
39-
)
40-
4128
REM Ensure that bin/cache exists.
4229
IF NOT EXIST "%cache_dir%" MKDIR "%cache_dir%"
4330

@@ -66,9 +53,18 @@ GOTO :after_subroutine
6653
CALL "%bootstrap_path%"
6754
)
6855

69-
PUSHD "%flutter_root%"
70-
FOR /f %%r IN ('git rev-parse HEAD') DO SET revision=%%r
71-
POPD
56+
REM Check that git exists and get the revision
57+
SET git_exists=false
58+
2>NUL (
59+
PUSHD "%flutter_root%"
60+
FOR /f %%r IN ('git rev-parse HEAD') DO (
61+
SET git_exists=true
62+
SET revision=%%r
63+
)
64+
POPD
65+
)
66+
REM If git didn't execute we don't have git. Exit without /B to avoid retrying.
67+
if %git_exists% == false echo Error: Unable to find git in your PATH. && EXIT 1
7268
SET compilekey="%revision%:%FLUTTER_TOOL_ARGS%"
7369

7470
REM Invalidate cache if:
@@ -101,6 +97,18 @@ GOTO :after_subroutine
10197
EXIT /B
10298

10399
:do_sdk_update_and_snapshot
100+
REM Detect which PowerShell executable is available on the Host
101+
REM PowerShell version <= 5: PowerShell.exe
102+
REM PowerShell version >= 6: pwsh.exe
103+
WHERE /Q pwsh.exe && (
104+
SET powershell_executable=pwsh.exe
105+
) || WHERE /Q PowerShell.exe && (
106+
SET powershell_executable=PowerShell.exe
107+
) || (
108+
ECHO Error: PowerShell executable not found. 1>&2
109+
ECHO Either pwsh.exe or PowerShell.exe must be in your PATH. 1>&2
110+
EXIT 1
111+
)
104112
ECHO Checking Dart SDK version... 1>&2
105113
SET update_dart_bin=%FLUTTER_ROOT%\bin\internal\update_dart_sdk.ps1
106114
REM Escape apostrophes from the executable path

0 commit comments

Comments
 (0)