mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[Windows] Add a flutter-dev
script to run the flutter CLI from source (#153892)
Follow-up to https://github.com/flutter/flutter/pull/153599, adds support for the objectively better OS ð¼
This commit is contained in:
parent
5fad2bea2a
commit
56fcc724e0
@ -6,8 +6,8 @@
|
||||
# ---------------------------------- NOTE ---------------------------------- #
|
||||
#
|
||||
# Please keep the logic in this file consistent with the logic in the
|
||||
# `flutter.bat` script in the same directory to ensure that Flutter continues
|
||||
# to work across all platforms!
|
||||
# `flutter.bat` script in the same directory to ensure that Flutter
|
||||
# continues to work across all platforms!
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
|
@ -3,6 +3,14 @@
|
||||
# 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-dev.bat` script in the same directory to ensure that Flutter
|
||||
# continues to work across all platforms!
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
set -e
|
||||
|
||||
# This is a helper script for development purposes. It runs the Flutter tool
|
||||
@ -50,6 +58,12 @@ PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
|
||||
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
||||
SHARED_NAME="$BIN_DIR/internal/shared.sh"
|
||||
FLUTTER_ROOT="$(cd "$BIN_DIR/.." ; pwd -P)"
|
||||
OS="$(uname -s)"
|
||||
|
||||
# If we're on Windows, invoke the batch script instead to get proper locking.
|
||||
if [[ $OS =~ MINGW.* || $OS =~ CYGWIN.* || $OS =~ MSYS.* ]]; then
|
||||
exec "${BIN_DIR}/flutter-dev.bat" "$@"
|
||||
fi
|
||||
|
||||
# To define `shared::execute()` function
|
||||
source "$SHARED_NAME"
|
||||
|
60
bin/flutter-dev.bat
Normal file
60
bin/flutter-dev.bat
Normal file
@ -0,0 +1,60 @@
|
||||
@ECHO off
|
||||
REM Copyright 2014 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 `flutter-dev` script in the same directory to ensure that Flutter & Dart
|
||||
REM continue to work across all platforms!
|
||||
REM
|
||||
REM --------------------------------------------------------------------------
|
||||
|
||||
SETLOCAL
|
||||
|
||||
REM This is a helper script for development purposes. It runs the Flutter tool
|
||||
REM from source code directly, without using the prebuilt snapshot. This is
|
||||
REM useful for development, as it allows you to make changes to the tool and see
|
||||
REM the effects immediately, but is much slower than using the prebuilt snapshot.
|
||||
|
||||
REM To debug the tool, you can uncomment the following line to enable debug mode:
|
||||
REM SET FLUTTER_TOOL_ARGS="--enable-asserts %FLUTTER_TOOL_ARGS%"
|
||||
|
||||
FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi
|
||||
|
||||
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 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.
|
||||
ECHO The flutter tool requires Git in order to operate properly;
|
||||
ECHO to set up Flutter, run the following command:
|
||||
ECHO git clone -b stable https://github.com/flutter/flutter.git
|
||||
EXIT 1
|
||||
)
|
||||
|
||||
REM Include shared scripts in shared.bat
|
||||
SET shared_bin=%FLUTTER_ROOT%\bin\internal\shared.bat
|
||||
CALL "%shared_bin%"
|
||||
|
||||
SET flutter_tools_dir=%FLUTTER_ROOT%\packages\flutter_tools
|
||||
SET cache_dir=%FLUTTER_ROOT%\bin\cache
|
||||
SET script_path=%flutter_tools_dir%\bin\flutter_tools.dart
|
||||
SET dart_sdk_path=%cache_dir%\dart-sdk
|
||||
SET dart=%dart_sdk_path%\bin\dart.exe
|
||||
|
||||
SET exit_with_errorlevel=%FLUTTER_ROOT%/bin/internal/exit_with_errorlevel.bat
|
||||
|
||||
REM Chaining the call to 'dart' and 'exit' with an ampersand ensures that
|
||||
REM Windows reads both commands into memory once before executing them. This
|
||||
REM avoids nasty errors that may otherwise occur when the dart command (e.g. as
|
||||
REM part of 'flutter upgrade') modifies this batch script while it is executing.
|
||||
REM
|
||||
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%" run --resident --packages="%flutter_tools_dir%\.dart_tool\package_config.json" %FLUTTER_TOOL_ARGS% "%script_path%" %* & "%exit_with_errorlevel%"
|
@ -6,8 +6,8 @@ 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 & Dart continue to
|
||||
REM work across all platforms!
|
||||
REM `flutter` script in the same directory to ensure that Flutter & Dart
|
||||
REM continue to work across all platforms!
|
||||
REM
|
||||
REM --------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user