Merge pull request #5028 from ramarag/R2Rtests
[platform/upstream/coreclr.git] / sync.cmd
1 @if "%_echo%" neq "on" echo off
2 setlocal EnableDelayedExpansion
3
4 set synclog=sync.log
5 echo Running Sync.cmd %* > %synclog%
6
7 set options=/nologo /v:minimal /clp:Summary /flp:v=detailed;Append;LogFile=%synclog%
8 set unprocessedBuildArgs=
9 set allargs=%*
10 set thisArgs=
11
12 set src=false
13 set packages=false
14
15 if [%1]==[] (
16   set src=true
17   set packages=true
18   goto Begin
19 )
20
21 :Loop
22 if [%1]==[] goto Begin
23
24 if /I [%1] == [/?] goto Usage
25 if /I [%1] == [/help] goto Usage
26
27 if /I [%1] == [/p] (
28     set packages=true
29     set thisArgs=!thisArgs!%1
30     goto Next
31 )
32
33 if /I [%1] == [/s] (
34     set src=true
35     set thisArgs=!thisArgs!%1
36     goto Next
37 )
38
39 set unprocessedBuildArgs=!unprocessedBuildArgs! %1
40
41 :Next
42 shift /1
43 goto Loop
44
45 :Begin
46 echo Running init-tools.cmd
47 call %~dp0init-tools.cmd
48
49 if [%src%] == [true] (
50   echo Fetching git database from remote repos ...
51   call git fetch --all -p -v >> %synclog% 2>&1
52   if NOT [!ERRORLEVEL!]==[0] (
53     echo ERROR: An error occurred while fetching remote source code, see %synclog% for more details.
54     exit /b 1
55   )
56 )
57
58 set targets=RestoreNETCorePlatforms
59
60 if [%packages%] == [true] (
61   set options=!options! /t:!targets! /p:RestoreDuringBuild=true
62   echo msbuild.exe %~dp0build.proj !options! !unprocessedBuildArgs! >> %synclog%
63   call msbuild.exe %~dp0build.proj !options! !unprocessedBuildArgs!
64   if NOT [!ERRORLEVEL!]==[0] (
65     echo ERROR: An error occurred while syncing packages, see %synclog% for more details. There may have been networking problems so please try again in a few minutes.
66     exit /b 1
67   )
68 )
69
70 echo Done Syncing.
71 exit /b 0
72
73 goto :EOF
74
75 :Usage
76 echo.
77 echo Repository syncing script.
78 echo.
79 echo Options:
80 echo     /s     - Fetches source history from all configured remotes
81 echo              (git fetch --all -p -v)
82 echo     /p     - Restores all nuget packages for repository
83 echo.
84 echo If no option is specified then sync.cmd /s /p is implied.