Skip to content

Commit

Permalink
Faster wrapper script on Windows (flutter#111465)
Browse files Browse the repository at this point in the history
  • Loading branch information
jensjoha authored Sep 19, 2022
1 parent 085a187 commit b84bfa3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
3 changes: 1 addition & 2 deletions bin/flutter.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ REM If available, add location of bundled mingit to PATH
SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd
IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path%

REM Test if Git is available on the Host
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1
REM We test if Git is available on the Host as we run git in shared.bat
REM Test if the flutter directory is a git clone, otherwise git rev-parse HEAD would fail
IF NOT EXIST "%flutter_root%\.git" (
ECHO Error: The Flutter directory is not a clone of the GitHub project.
Expand Down
40 changes: 24 additions & 16 deletions bin/internal/shared.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ SET pub_cache_path=%FLUTTER_ROOT%\.pub-cache

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

REM Detect which PowerShell executable is available on the Host
REM PowerShell version <= 5: PowerShell.exe
REM PowerShell version >= 6: pwsh.exe
WHERE /Q pwsh.exe && (
SET powershell_executable=pwsh.exe
) || WHERE /Q PowerShell.exe && (
SET powershell_executable=PowerShell.exe
) || (
ECHO Error: PowerShell executable not found. 1>&2
ECHO Either pwsh.exe or PowerShell.exe must be in your PATH. 1>&2
EXIT 1
)

REM Ensure that bin/cache exists.
IF NOT EXIST "%cache_dir%" MKDIR "%cache_dir%"

Expand Down Expand Up @@ -66,9 +53,18 @@ GOTO :after_subroutine
CALL "%bootstrap_path%"
)

PUSHD "%flutter_root%"
FOR /f %%r IN ('git rev-parse HEAD') DO SET revision=%%r
POPD
REM Check that git exists and get the revision
SET git_exists=false
2>NUL (
PUSHD "%flutter_root%"
FOR /f %%r IN ('git rev-parse HEAD') DO (
SET git_exists=true
SET revision=%%r
)
POPD
)
REM If git didn't execute we don't have git. Exit without /B to avoid retrying.
if %git_exists% == false echo Error: Unable to find git in your PATH. && EXIT 1
SET compilekey="%revision%:%FLUTTER_TOOL_ARGS%"

REM Invalidate cache if:
Expand Down Expand Up @@ -101,6 +97,18 @@ GOTO :after_subroutine
EXIT /B

:do_sdk_update_and_snapshot
REM Detect which PowerShell executable is available on the Host
REM PowerShell version <= 5: PowerShell.exe
REM PowerShell version >= 6: pwsh.exe
WHERE /Q pwsh.exe && (
SET powershell_executable=pwsh.exe
) || WHERE /Q PowerShell.exe && (
SET powershell_executable=PowerShell.exe
) || (
ECHO Error: PowerShell executable not found. 1>&2
ECHO Either pwsh.exe or PowerShell.exe must be in your PATH. 1>&2
EXIT 1
)
ECHO Checking Dart SDK version... 1>&2
SET update_dart_bin=%FLUTTER_ROOT%\bin\internal\update_dart_sdk.ps1
REM Escape apostrophes from the executable path
Expand Down

0 comments on commit b84bfa3

Please sign in to comment.