-
Notifications
You must be signed in to change notification settings - Fork 84
/
phone-latest-branch.bat
165 lines (139 loc) · 3.11 KB
/
phone-latest-branch.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@echo off
setlocal enabledelayedexpansion
call :USAGE %*
if errorlevel 1 goto END
call :PARSEARGS %*
if errorlevel 1 goto END
if not "%ffu%" == "" (
set ffupath=%ffu%
goto FLASHFFU
)
rem required arguments
set requiredok=yes
if "%image%" == "" (
echo Specify what image you want
set requiredok=no
)
if "%branch%" == "" (
echo Specify what branch you want
set requiredok=no
)
if not "%requiredok%" == "yes" (
goto END
)
rem defaults
if "%buildtype%" == "" set buildtype=fre
if "%flavor%" == "" set flavor=Selfhost
if "%proc%" == "" set proc=arm
if /i "%buildtype%" == "random" (
set /a flip=%random% %% 2
if "!flip!"=="0" (
set buildtype=fre
) else (
set buildtype=chk
)
)
if /i "%flavor%" == "random" (
if /i "%buildtype%" == "chk" (
set flavor=Test
) else (
set /a flip=%random% %% 2
if "!flip!"=="0" (
set flavor=Selfhost
) else (
set flavor=Test
)
)
)
if "%language%" == "" set language=USA
set builds=\\build\release\RS\%branch%
set ffu=MC.%proc%%buildtype%\Binaries\Images\%image%\%flavor%\%language%\Flash.ffu
set latest=
set count=0
for /f "usebackq delims=" %%d in (`dir /a:d /b %builds% ^| shellsort.exe -reverse`) do (
if "!count!" == "5" (
echo No %ffu% found in the last five builds^!
goto END
)
set /a count=!count! + 1
if exist %builds%\%%d\%ffu% (
set latest=%%d
goto FOUNDLATEST
) else (
echo %builds%\%%d\%ffu% does not exist...
)
)
:FOUNDLATEST
if "%latest%" == "" (
echo No ffus found^!
goto END
)
set ffupath=%builds%\%latest%\%ffu%
:FLASHFFU
echo Flashing %ffupath%...
ffutool.exe -flash %ffupath%
goto END
rem '''''''''''''''''''
rem ' Usage statement '
rem '''''''''''''''''''
:USAGE
rem usage
if "%1" == "" (
echo phone-latest-branch.bat
echo ffu:^<ffu^>
echo.
echo phone-latest-branch.bat
echo image:^<image^>
echo [ branch:^<branch^> ]
echo [ buildtype:^<buildtype^> ]
echo [ flavor:^<flavor^> ]
echo [ language:^<language^> ]
echo [ proc:^<proc^> ]
echo.
echo ^<ffu^>: specific .ffu file
echo ^<image^>: model of phone ^| ...
echo ^<branch^>: build branch ^| ...
echo ^<buildtype^>: random ^| fre ^| chk ^| coverage (random chooses fre or chk^)
echo ^<flavor^>: random ^| Selfhost ^| Test ^| ...
echo ^<language^>: random ^| en-us ^| qps-ploc ^| qps-plocm ^| de-de ^| ...
echo ^<proc^>: arm ^| arm64 ^| ...
exit /b 1
)
goto END
rem '''''''''''''''''''
rem ' Parse arguments '
rem '''''''''''''''''''
:PARSEARGS
set ffu=
set image=
set branch=
set buildtype=
set flavor=
set language=
rem inputs
:NEWARG
set arg=%1
if "%arg%" == "" goto DONEINPUTS
if not "%arg:branch:=%" == "%arg%" (
set branch=%arg:branch:=%
) else if not "%arg:buildtype:=%" == "%arg%" (
set buildtype=%arg:buildtype:=%
) else if not "%arg:flavor:=%" == "%arg%" (
set flavor=%arg:flavor:=%
) else if not "%arg:ffu:=%" == "%arg%" (
set ffu=%arg:ffu:=%
) else if not "%arg:image:=%" == "%arg%" (
set image=%arg:image:=%
) else if not "%arg:proc:=%" == "%arg%" (
set proc=%arg:proc:=%
) else if not "%arg:language:=%" == "%arg%" (
set language=%arg:language:=%
) else (
echo Unrecognized argument %arg%
exit /b 1
)
shift
goto NEWARG
:DONEINPUTS
goto END
:END