Remove --arch option from runtest.sh
[platform/upstream/coreclr.git] / tests / setup-stress-dependencies.cmd
1 @if not defined _echo @echo off
2 setlocal
3
4 set __ThisScriptShort=%0
5 set __ThisScriptFull=%~f0
6 set __ThisScriptPath=%~dp0
7
8 REM =========================================================================================
9 REM ===
10 REM === Parse arguments
11 REM ===
12 REM =========================================================================================
13
14 set __OutputDir=
15 set __Arch= 
16
17 :Arg_Loop
18 if "%1" == "" goto ArgsDone
19
20 if /i "%1" == "/?"    goto Usage
21 if /i "%1" == "-?"    goto Usage
22 if /i "%1" == "/h"    goto Usage
23 if /i "%1" == "-h"    goto Usage
24 if /i "%1" == "/help" goto Usage
25 if /i "%1" == "-help" goto Usage
26
27 if /i "%1" == "/arch"             (set __Arch=%2&shift&shift&goto Arg_Loop) 
28 if /i "%1" == "/outputdir"        (set __OutputDir=%2&shift&shift&goto Arg_Loop)
29
30 echo Invalid command-line argument: %1
31 goto Usage
32
33 :ArgsDone
34
35 if not defined __OutputDir goto Usage
36 if not defined __Arch goto Usage 
37
38 REM Check if the platform is supported
39 if /i "%__Arch%" == "arm" (
40     echo No runtime dependencies for Arm32.
41     exit /b 0
42 )
43
44 if /i "%__Arch%" == "arm64" (
45     echo No runtime dependencies for Arm64.
46     exit /b 0
47 )
48
49 REM =========================================================================================
50 REM ===
51 REM === Check if dotnet CLI and necessary directories exist
52 REM ===
53 REM =========================================================================================
54
55 set __DotNetToolDir=%__ThisScriptPath%..\Tools
56 set __DotNetCmd=%__ThisScriptPath%..\dotnet.cmd
57 set __PackageDir=%__ThisScriptPath%..\Packages
58 set __CsprojPath=%__ThisScriptPath%\src\Common\stress_dependencies\stress_dependencies.csproj
59
60 REM Check if dotnet cli exists
61 if not exist "%__DotNetToolDir%" (
62     echo Directory containing dotnet CLI does not exist: %__DotNetToolDir%
63     goto Fail
64 )
65 if not exist "%__DotNetCmd%" (
66     echo dotnet.exe does not exist: %__DotNetCmd%
67     goto Fail
68 )
69
70 REM Create directories needed
71 if not exist "%__PackageDir%" md "%__PackageDir%"
72 if not exist "%__OutputDir%" md "%__OutputDir%"
73
74 REM =========================================================================================
75 REM ===
76 REM === Download packages
77 REM ===
78 REM =========================================================================================
79
80 REM Download the package
81 echo Downloading CoreDisTools package
82 set DOTNETCMD="%__DotNetCmd%" restore "%__CsprojPath%" --source https://dotnet.myget.org/F/dotnet-core/ --packages "%__PackageDir%"
83 echo %DOTNETCMD%
84 call %DOTNETCMD%
85 if errorlevel 1 goto Fail
86
87 REM Get downloaded dll path
88 echo Locating coredistools.dll
89 FOR /F "delims=" %%i IN ('dir %__PackageDir%\coredistools.dll /b/s ^| findstr /R "win-%__Arch%"') DO set __LibPath=%%i
90 echo CoreDisTools library path: %__LibPath%
91 if not exist "%__LibPath%" (
92     echo Failed to locate the downloaded library: %__LibPath%
93     goto Fail
94 )
95
96 REM Copy library to output directory
97 echo Copy library: %__LibPath% to %__OutputDir%
98 copy /y "%__LibPath%" "%__OutputDir%"
99 if errorlevel 1 (
100     echo Failed to copy %__LibPath% to %__OutputDir%
101     goto Fail
102 )
103
104 exit /b 0
105
106 :Fail
107 exit /b 1
108
109 REM =========================================================================================
110 REM ===
111 REM === Helper routines
112 REM ===
113 REM =========================================================================================
114
115 :Usage
116 echo.
117 echo Download coredistools for GC stress testing
118 echo.
119 echo Usage:
120 echo     %__ThisScriptShort% /arch ^<TargetArch^> /outputdir ^<coredistools_lib_install_path^>
121 echo.
122 exit /b 1