Commit b65ed452 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Improvments to bat file (#8377)

Mainly: Don't call out to PoerShell (expansive!) if Dart SDK is upto date.
parent 064a63e9
...@@ -18,10 +18,12 @@ FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi ...@@ -18,10 +18,12 @@ FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi
SET flutter_tools_dir=%FLUTTER_ROOT%\packages\flutter_tools SET flutter_tools_dir=%FLUTTER_ROOT%\packages\flutter_tools
SET cache_dir=%FLUTTER_ROOT%\bin\cache SET cache_dir=%FLUTTER_ROOT%\bin\cache
SET snapshot_path=%FLUTTER_ROOT%\bin\cache\flutter_tools.snapshot SET snapshot_path=%cache_dir%\flutter_tools.snapshot
SET stamp_path=%FLUTTER_ROOT%\bin\cache\flutter_tools.stamp SET stamp_path=%cache_dir%\flutter_tools.stamp
SET script_path=%flutter_tools_dir%\bin\flutter_tools.dart SET script_path=%flutter_tools_dir%\bin\flutter_tools.dart
SET dart_sdk_path=%FLUTTER_ROOT%\bin\cache\dart-sdk SET dart_sdk_path=%cache_dir%\dart-sdk
SET dart_stamp_path=%cache_dir%\dart-sdk.stamp
SET dart_version_path=%FLUTTER_ROOT%\bin\internal\dart-sdk.version
SET dart=%dart_sdk_path%\bin\dart.exe SET dart=%dart_sdk_path%\bin\dart.exe
SET pub=%dart_sdk_path%\bin\pub.bat SET pub=%dart_sdk_path%\bin\pub.bat
...@@ -54,6 +56,11 @@ GOTO :after_subroutine ...@@ -54,6 +56,11 @@ GOTO :after_subroutine
REM The following IF conditions are all linked with a logical OR. However, REM The following IF conditions are all linked with a logical OR. However,
REM there is no OR operator in batch and a GOTO construct is used as replacement. REM there is no OR operator in batch and a GOTO construct is used as replacement.
IF NOT EXIST "%dart_stamp_path%" GOTO do_sdk_update_and_snapshot
SET /P dart_required_version=<"%dart_version_path%"
SET /P dart_installed_version=<"%dart_stamp_path%"
IF !dart_required_version! NEQ !dart_installed_version! GOTO do_sdk_update_and_snapshot
IF NOT EXIST "%snapshot_path%" GOTO do_snapshot IF NOT EXIST "%snapshot_path%" GOTO do_snapshot
IF NOT EXIST "%stamp_path%" GOTO do_snapshot IF NOT EXIST "%stamp_path%" GOTO do_snapshot
SET /p stamp_value=<"%stamp_path%" SET /p stamp_value=<"%stamp_path%"
...@@ -66,13 +73,12 @@ GOTO :after_subroutine ...@@ -66,13 +73,12 @@ GOTO :after_subroutine
REM Everything is uptodate - exit subroutine REM Everything is uptodate - exit subroutine
EXIT /B EXIT /B
:do_snapshot :do_sdk_update_and_snapshot
MKDIR "%FLUTTER_ROOT%\bin\cache" 2> NUL
ECHO: > "%FLUTTER_ROOT%\bin\cache\.dartignore"
ECHO Checking Dart SDK version... ECHO Checking Dart SDK version...
CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'" CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'"
:do_snapshot
ECHO: > "%cache_dir%\.dartignore"
ECHO Updating flutter tool... ECHO Updating flutter tool...
PUSHD "%flutter_tools_dir%" PUSHD "%flutter_tools_dir%"
CALL "%pub%" upgrade --verbosity=error --no-packages-dir CALL "%pub%" upgrade --verbosity=error --no-packages-dir
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$progName = split-path -parent $MyInvocation.MyCommand.Definition $progName = Split-Path -parent $MyInvocation.MyCommand.Definition
$flutterRoot = (get-item $progName ).parent.parent.FullName $flutterRoot = (Get-Item $progName ).parent.parent.FullName
$dartSdkPath = "$flutterRoot\bin\cache\dart-sdk" $dartSdkPath = "$flutterRoot\bin\cache\dart-sdk"
$dartSdkStampPath = "$flutterRoot\bin\cache\dart-sdk.stamp" $dartSdkStampPath = "$flutterRoot\bin\cache\dart-sdk.stamp"
...@@ -37,4 +37,4 @@ Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip ...@@ -37,4 +37,4 @@ Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip
Add-Type -assembly "system.io.compression.filesystem" Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::ExtractToDirectory($dartSdkZip, "$flutterRoot\bin\cache") [io.compression.zipfile]::ExtractToDirectory($dartSdkZip, "$flutterRoot\bin\cache")
Remove-Item $dartSdkZip Remove-Item $dartSdkZip
$dartSdkVersion | out-file $dartSdkStampPath $dartSdkVersion | Out-File $dartSdkStampPath -Encoding ASCII
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment