flutter.bat 1.99 KB
Newer Older
1 2 3 4 5 6 7 8
@ECHO off
REM Copyright 2015 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.

SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%i IN ("%~dp0..") DO SET "flutter_root=%%~fi" REM Get the parent directory
SET flutter_tools_dir=%flutter_root%\packages\flutter_tools
9
SET flutter_dir=%flutter_root%\packages\flutter
10 11
SET snapshot_path=%flutter_root%\bin\cache\flutter_tools.snapshot
SET stamp_path=%flutter_root%\bin\cache\flutter_tools.stamp
12
SET script_path=%flutter_tools_dir%\bin\flutter_tools.dart
13 14 15
REM TODO: Don't require dart to be on the user's path
SET dart=dart

16 17
REM Set current working directory to the flutter directory
PUSHD %flutter_root%
18 19 20 21
REM IF doesn't have an "or". Instead, just use GOTO
FOR /f %%r IN ('git rev-parse HEAD') DO SET revision=%%r
IF NOT EXIST %snapshot_path% GOTO do_snapshot
IF NOT EXIST %stamp_path% GOTO do_snapshot
22 23 24 25 26 27 28 29
FOR /f "delims=" %%x in (%stamp_path%) do set stamp_value=%%x
IF "!stamp_value!" NEQ "!revision!" GOTO do_snapshot

REM Getting modified timestamps in a batch file is ... troublesome
REM More info: http://stackoverflow.com/questions/1687014/how-do-i-compare-timestamps-of-files-in-a-dos-batch-script
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
30 31 32 33

GOTO :after_snapshot

:do_snapshot
34
CD "%flutter_tools_dir%"
Hixie's avatar
Hixie committed
35
ECHO Updating flutter tool...
36
CALL pub.bat get
37 38 39
CD "%flutter_dir"
REM Allows us to check if sky_engine's REVISION is correct
CALL pub.bat get
40
CD "%flutter_root%"
41
CALL %dart% --snapshot="%snapshot_path%" --package-root="%flutter_tools_dir%\packages" "%script_path%"
42
<nul SET /p=%revision%> "%stamp_path%"
43 44 45

:after_snapshot

46 47
REM Go back to last working directory
POPD
48 49 50 51 52
CALL %dart% "%snapshot_path%" %*

IF /I "%ERRORLEVEL%" EQU "253" (
   CALL %dart% --snapshot="%snapshot_path%" --package-root="%flutter_tools_dir%\packages" "%script_path%"
   CALL %dart% "%snapshot_path%" %*
Hixie's avatar
Hixie committed
53
)