Replace bin/flutter.ps1 with bin/flutter.bat (#7713)
fixes https://github.com/flutter/flutter/issues/7654
This commit is contained in:
committed by
GitHub
parent
078f6854cd
commit
c234d405af
@@ -7,7 +7,7 @@
|
||||
# ---------------------------------- NOTE ---------------------------------- #
|
||||
#
|
||||
# Please keep the logic in this file consistent with the logic in the
|
||||
# `flutter.ps1` script in the same directory to ensure that Flutter continues
|
||||
# `flutter.bat` script in the same directory to ensure that Flutter continues
|
||||
# to work across all platforms!
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
@@ -1 +1,76 @@
|
||||
@PowerShell.exe -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1' %*"
|
||||
@ECHO off
|
||||
REM Copyright 2017 The Chromium 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 `flutter` script in the same directory to ensure that Flutter continues to
|
||||
REM work across all platforms!
|
||||
REM
|
||||
REM --------------------------------------------------------------------------
|
||||
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi
|
||||
|
||||
SET flutter_tools_dir=%FLUTTER_ROOT%\packages\flutter_tools
|
||||
SET snapshot_path=%FLUTTER_ROOT%\bin\cache\flutter_tools.snapshot
|
||||
SET stamp_path=%FLUTTER_ROOT%\bin\cache\flutter_tools.stamp
|
||||
SET script_path=%flutter_tools_dir%\bin\flutter_tools.dart
|
||||
SET dart_sdk_path=%FLUTTER_ROOT%\bin\cache\dart-sdk
|
||||
|
||||
SET dart=%dart_sdk_path%\bin\dart.exe
|
||||
SET pub=%dart_sdk_path%\bin\pub.bat
|
||||
|
||||
REM Test if Git is available on the Host
|
||||
where /q git.exe || ECHO Error: Unable to find git.exe in your PATH. && EXIT /B
|
||||
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.
|
||||
EXIT /B
|
||||
)
|
||||
|
||||
PUSHD "%flutter_root%"
|
||||
FOR /f %%r IN ('git rev-parse HEAD') DO SET revision=%%r
|
||||
POPD
|
||||
|
||||
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.
|
||||
IF NOT EXIST "%snapshot_path%" GOTO do_snapshot
|
||||
IF NOT EXIST "%stamp_path%" GOTO do_snapshot
|
||||
SET /p stamp_value=<"%stamp_path%"
|
||||
IF !stamp_value! NEQ !revision! GOTO do_snapshot
|
||||
REM Get modified timestamps
|
||||
FOR %%f IN ("%flutter_tools_dir%\pubspec.yaml") DO SET yamlt=%%~tf
|
||||
FOR %%a IN ("%flutter_tools_dir%\pubspec.lock") DO SET lockt=%%~ta
|
||||
IF !lockt! LSS !yamlt! GOTO do_snapshot
|
||||
|
||||
GOTO after_snapshot
|
||||
|
||||
:do_snapshot
|
||||
MKDIR "%FLUTTER_ROOT%\bin\cache" 2> NUL
|
||||
ECHO: > "%FLUTTER_ROOT%\bin\cache\.dartignore"
|
||||
|
||||
ECHO Checking Dart SDK version...
|
||||
CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'"
|
||||
|
||||
ECHO Updating flutter tool...
|
||||
del "%flutter_tools_dir%\pubspec.lock"
|
||||
PUSHD "%flutter_tools_dir%"
|
||||
CALL "%pub%" get --verbosity=error --no-packages-dir
|
||||
POPD
|
||||
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
|
||||
>"%stamp_path%" ECHO %revision%
|
||||
|
||||
:after_snapshot
|
||||
|
||||
CALL "%dart%" "%snapshot_path%" %*
|
||||
|
||||
REM The VM exits with code 253 if the snapshot version is out-of-date.
|
||||
IF /I "%ERRORLEVEL%" EQU "253" (
|
||||
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
|
||||
CALL "%dart%" "%snapshot_path%" %*
|
||||
)
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
# Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
|
||||
# ---------------------------------- NOTE ---------------------------------- #
|
||||
#
|
||||
# Please keep the logic in this file consistent with the logic in the
|
||||
# `flutter` script in the same directory to ensure that Flutter continues to
|
||||
# work across all platforms!
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$progName = split-path -parent $MyInvocation.MyCommand.Definition
|
||||
$flutterRoot = (get-item $progName ).parent.FullName
|
||||
$env:FLUTTER_ROOT = $flutterRoot
|
||||
|
||||
$flutterToolsDir = "$flutterRoot\packages\flutter_tools"
|
||||
$snapshotPath = "$flutterRoot\bin\cache\flutter_tools.snapshot"
|
||||
$stampPath = "$flutterRoot\bin\cache\flutter_tools.stamp"
|
||||
$scriptPath = "$flutterToolsDir\bin\flutter_tools.dart"
|
||||
$dartSdkPath = "$flutterRoot\bin\cache\dart-sdk"
|
||||
|
||||
$dart = "$dartSdkPath\bin\dart.exe"
|
||||
$pub = "$dartSdkPath\bin\pub.bat"
|
||||
|
||||
# Test if Git is available on the Host
|
||||
if ((Get-Command "git.exe" -ErrorAction SilentlyContinue) -eq $null) {
|
||||
Write-Host "Error: Unable to find git.exe in your PATH."
|
||||
exit
|
||||
}
|
||||
# Test if the flutter directory is a git clone (otherwise git rev-parse HEAD would fail)
|
||||
if (-not (Test-Path "$flutterRoot\.git")) {
|
||||
Write-Host "Error: The Flutter directory is not a clone of the GitHub project."
|
||||
exit
|
||||
}
|
||||
|
||||
Push-Location
|
||||
Set-Location $flutterRoot
|
||||
$revision = Invoke-Expression "git rev-parse HEAD"
|
||||
Pop-Location
|
||||
|
||||
if (!(Test-Path $snapshotPath) `
|
||||
-or !(Test-Path $stampPath) `
|
||||
-or ((Get-Content $stampPath) -ne $revision) `
|
||||
-or !(Test-Path "$flutterToolsDir\pubspec.lock") `
|
||||
-or ((ls "$flutterToolsDir\pubspec.lock").LastWriteTime -lt (ls "$flutterToolsDir\pubspec.yaml").LastWriteTime)) {
|
||||
New-Item "$flutterRoot\bin\cache" -force -type directory | Out-Null
|
||||
New-Item "$flutterRoot\bin\cache\.dartignore" -force -type file | Out-Null
|
||||
Invoke-Expression "$flutterRoot\bin\internal\update_dart_sdk.ps1"
|
||||
|
||||
Write-Host "Building flutter tool..."
|
||||
if (Test-Path "$flutterToolsDir\pubspec.lock") { Remove-Item "$flutterToolsDir\pubspec.lock" }
|
||||
|
||||
Push-Location
|
||||
Set-Location $flutterToolsDir
|
||||
Invoke-Expression "$pub get --verbosity=error --no-packages-dir"
|
||||
Pop-Location
|
||||
|
||||
Invoke-Expression "$dart --snapshot=`"$snapshotPath`" `"$scriptPath`" --packages=`"$flutterToolsDir\.packages`""
|
||||
$revision | Out-File $stampPath
|
||||
}
|
||||
|
||||
# Switch PowerShell to UTF8 encoding for Dart.
|
||||
$encoding = [Console]::OutputEncoding
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
Invoke-Expression "$dart `"$snapshotPath`" $args"
|
||||
|
||||
# The VM exits with code 253 if the snapshot version is out-of-date.
|
||||
if ($LASTEXITCODE -eq 253) {
|
||||
Invoke-Expression "$dart --snapshot=`"$snapshotPath`" `"$scriptPath`" --packages=`"$flutterToolsDir\.packages`""
|
||||
Invoke-Expression "$dart `"$snapshotPath`" $args"
|
||||
}
|
||||
|
||||
# Reset PowerShell to whatever the user's encoding was.
|
||||
[Console]::OutputEncoding = $encoding
|
||||
@@ -124,14 +124,12 @@ class Doctor {
|
||||
else
|
||||
printStatus('${result.leadingBox} ${validator.title}');
|
||||
|
||||
final String separator = '•';
|
||||
|
||||
for (ValidationMessage message in result.messages) {
|
||||
String text = message.message.replaceAll('\n', '\n ');
|
||||
if (message.isError) {
|
||||
printStatus(' x $text', emphasis: true);
|
||||
} else {
|
||||
printStatus(' $separator $text');
|
||||
printStatus(' • $text');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,9 +178,9 @@ class ValidationResult {
|
||||
|
||||
String get leadingBox {
|
||||
if (type == ValidationType.missing)
|
||||
return '[x]';
|
||||
return '[✗]';
|
||||
else if (type == ValidationType.installed)
|
||||
return platform.isWindows ? '[√]' : '[✓]';
|
||||
return '[✓]';
|
||||
else
|
||||
return '[-]';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user