flutter.bat 2.43 KB
Newer Older
1
@ECHO off
Ian Hickson's avatar
Ian Hickson committed
2
REM Copyright 2014 The Flutter Authors. All rights reserved.
3 4 5
REM Use of this source code is governed by a BSD-style license that can be
REM found in the LICENSE file.

6 7 8
REM ---------------------------------- NOTE ----------------------------------
REM
REM Please keep the logic in this file consistent with the logic in the
9
REM `flutter` script in the same directory to ensure that Flutter & Dart continue to
10 11 12
REM work across all platforms!
REM
REM --------------------------------------------------------------------------
13

14
SETLOCAL
15

16 17 18
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%"

19
FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi
20

21 22 23 24
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%

25
REM We test if Git is available on the Host as we run git in shared.bat
26 27 28 29 30 31
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
32
  EXIT 1
33 34
)

35
REM Include shared scripts in shared.bat
36
SET shared_bin=%FLUTTER_ROOT%\bin\internal\shared.bat
37 38
CALL "%shared_bin%"

39
SET flutter_tools_dir=%FLUTTER_ROOT%\packages\flutter_tools
40
SET cache_dir=%FLUTTER_ROOT%\bin\cache
41 42 43 44
SET snapshot_path=%cache_dir%\flutter_tools.snapshot
SET dart_sdk_path=%cache_dir%\dart-sdk
SET dart=%dart_sdk_path%\bin\dart.exe

45 46
SET exit_with_errorlevel=%FLUTTER_ROOT%/bin/internal/exit_with_errorlevel.bat

47 48
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
49
REM avoids nasty errors that may otherwise occur when the dart command (e.g. as
50 51 52 53 54
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.
55
"%dart%" --disable-dart-dev --packages="%flutter_tools_dir%\.dart_tool\package_config.json" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %* & "%exit_with_errorlevel%"