b247090604c618f79c739f2cecce1fcc61fe8274
[platform/upstream/coreclr.git] / build-test.cmd
1 @if not defined _echo @echo off
2 setlocal EnableDelayedExpansion
3
4 :: Set the default arguments for build
5 set __BuildArch=x64
6 set __VCBuildArch=x86_amd64
7 set __BuildType=Debug
8 set __BuildOS=Windows_NT
9
10 :: Default to highest Visual Studio version available
11 ::
12 :: For VS2015 (and prior), only a single instance is allowed to be installed on a box
13 :: and VS140COMNTOOLS is set as a global environment variable by the installer. This
14 :: allows users to locate where the instance of VS2015 is installed.
15 ::
16 :: For VS2017, multiple instances can be installed on the same box SxS and VS150COMNTOOLS
17 :: is no longer set as a global environment variable and is instead only set if the user
18 :: has launched the VS2017 Developer Command Prompt.
19 ::
20 :: Following this logic, we will default to the VS2017 toolset if VS150COMNTOOLS tools is
21 :: set, as this indicates the user is running from the VS2017 Developer Command Prompt and
22 :: is already configured to use that toolset. Otherwise, we will fallback to using the VS2015
23 :: toolset if it is installed. Finally, we will fail the script if no supported VS instance
24 :: can be found.
25 if defined VisualStudioVersion goto :Run
26
27 set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
28 if exist %_VSWHERE% (
29   for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools
30 )
31 if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
32 if not exist "%_VSCOMNTOOLS%" (
33   echo Error: Visual Studio 2015 or 2017 required.
34   echo        Please see https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
35   exit /b 1
36 )
37
38 call "%_VSCOMNTOOLS%\VsDevCmd.bat"
39
40 :Run
41
42 if defined VS150COMNTOOLS (
43   set "__VSToolsRoot=%VS150COMNTOOLS%"
44   set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"
45   set __VSVersion=vs2017
46 ) else (
47   set "__VSToolsRoot=%VS140COMNTOOLS%"
48   set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC"
49   set __VSVersion=vs2015
50 )
51
52 :: Define a prefix for most output progress messages that come from this script. That makes
53 :: it easier to see where these are coming from. Note that there is a trailing space here.
54 set __MsgPrefix=BUILDTEST: 
55
56 set "__ProjectDir=%~dp0"
57 :: remove trailing slash
58 if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
59 set "__TestDir=%__ProjectDir%\tests"
60 set "__ProjectFilesDir=%__TestDir%"
61 set "__SourceDir=%__ProjectDir%\src"
62 set "__PackagesDir=%__ProjectDir%\packages"
63 set "__RootBinDir=%__ProjectDir%\bin"
64 set "__LogsDir=%__RootBinDir%\Logs"
65
66 :: Default __Exclude to issues.targets
67 set __Exclude=%__TestDir%\issues.targets
68
69 REM __unprocessedBuildArgs are args that we pass to msbuild (e.g. /p:__BuildArch=x64)
70 set "__args= %*"
71 set processedArgs=
72 set __unprocessedBuildArgs=
73 set __RunArgs=
74 set __BuildAgainstPackagesArg=
75 set __RuntimeId=
76 set __ZipTests=
77 set __TargetsWindows=1
78 set __DoCrossgen=
79
80 :Arg_Loop
81 if "%1" == "" goto ArgsDone
82
83 if /i "%1" == "-?"    goto Usage
84 if /i "%1" == "-h"    goto Usage
85 if /i "%1" == "-help" goto Usage
86
87 if /i "%1" == "x64"                   (set __BuildArch=x64&set __VCBuildArch=x86_amd64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
88 if /i "%1" == "x86"                   (set __BuildArch=x86&set __VCBuildArch=x86&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
89 if /i "%1" == "arm"                   (set __BuildArch=arm&set __VCBuildArch=x86_arm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
90 if /i "%1" == "arm64"                 (set __BuildArch=arm64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
91
92 if /i "%1" == "debug"                 (set __BuildType=Debug&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
93 if /i "%1" == "release"               (set __BuildType=Release&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
94 if /i "%1" == "checked"               (set __BuildType=Checked&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
95
96 if /i "%1" == "skipmanaged"           (set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
97 if /i "%1" == "toolset_dir"           (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
98 if /i "%1" == "buildagainstpackages"  (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
99 if /i "%1" == "ziptests"              (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
100 if /i "%1" == "crossgen"              (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
101 if /i "%1" == "runtimeid"             (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
102 if /i "%1" == "targetsNonWindows"     (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
103 if /i "%1" == "Exclude"               (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
104
105 if [!processedArgs!]==[] (
106   set __UnprocessedBuildArgs=%__args%
107 ) else (
108   set __UnprocessedBuildArgs=%__args%
109   for %%t in (!processedArgs!) do (
110     set __UnprocessedBuildArgs=!__UnprocessedBuildArgs:*%%t=!
111   )
112 )
113
114 :ArgsDone
115
116 if defined __BuildAgainstPackagesArg (
117     if not defined __RuntimeID (
118         echo %__MsgPrefix%Error: When building against packages, you must supply a target Runtime ID.
119         exit /b 1
120     )
121 )
122
123 echo %__MsgPrefix%Using environment: "%__VSToolsRoot%\VsDevCmd.bat"
124 call                                 "%__VSToolsRoot%\VsDevCmd.bat"
125 @if defined _echo @echo on
126
127 set __RunArgs=-BuildOS=%__BuildOS% -BuildType=%__BuildType% -BuildArch=%__BuildArch%
128
129 rem arm64 builds currently use private toolset which has not been released yet
130 REM TODO, remove once the toolset is open.
131 if /i "%__BuildArch%" == "arm64" call :PrivateToolSet
132
133 echo %__MsgPrefix%Commencing CoreCLR repo test build
134
135 set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
136 set "__TestRootDir=%__RootBinDir%\tests"
137 set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
138 :: We have different managed and native intermediate dirs because the managed bits will include
139 :: the configuration information deeper in the intermediates path.
140 :: These variables are used by the msbuild project files.
141
142 if not defined __TestIntermediateDir (
143     set "__TestIntermediateDir=tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
144 )
145 set "__NativeTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Native"
146 set "__ManagedTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Managed"
147
148 :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
149 set "__CMakeBinDir=%__TestBinDir%"
150 set "__CMakeBinDir=%__CMakeBinDir:\=/%"
151
152 if not exist "%__TestBinDir%"                   md "%__TestBinDir%"
153 if not exist "%__NativeTestIntermediatesDir%"   md "%__NativeTestIntermediatesDir%"
154 if not exist "%__ManagedTestIntermediatesDir%"  md "%__ManagedTestIntermediatesDir%"
155 if not exist "%__LogsDir%"                      md "%__LogsDir%"
156
157 echo %__MsgPrefix%Checking prerequisites
158
159 :: Eval the output from probe-win1.ps1
160 for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a
161
162 REM =========================================================================================
163 REM ===
164 REM === Restore Build Tools
165 REM ===
166 REM =========================================================================================
167 call "%__ProjectDir%\init-tools.cmd"
168 @if defined _echo @echo on
169
170 REM =========================================================================================
171 REM ===
172 REM === Resolve runtime dependences
173 REM ===
174 REM =========================================================================================
175
176 call "%__TestDir%\setup-stress-dependencies.cmd" /arch %__BuildArch% /outputdir %__BinDir%
177 @if defined _echo @echo on
178
179 REM =========================================================================================
180 REM ===
181 REM === Native test build section
182 REM ===
183 REM =========================================================================================
184
185 echo %__MsgPrefix%Commencing build of native test components for %__BuildArch%/%__BuildType%
186
187 if defined __ToolsetDir (
188  echo %__MsgPrefix%ToolsetDir is defined to be :%__ToolsetDir%
189  goto GenVSSolution :: Private ToolSet is Defined
190 )
191
192 :: Set the environment for the native build
193 echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch%
194 call                                 "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch%
195 @if defined _echo @echo on
196
197 if not defined VSINSTALLDIR (
198     echo %__MsgPrefix%Error: VSINSTALLDIR variable not defined.
199     exit /b 1
200 )
201 if not exist "%VSINSTALLDIR%DIA SDK" goto NoDIA
202
203 :GenVSSolution
204
205 pushd "%__NativeTestIntermediatesDir%"
206 call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" ""%__ProjectFilesDir%"" %__VSVersion% %__BuildArch%
207 @if defined _echo @echo on
208 popd
209
210 if not exist "%__NativeTestIntermediatesDir%\install.vcxproj" (
211     echo %__MsgPrefix%Failed to generate test native component build project!
212     exit /b 1
213 )
214
215 set __msbuildNativeArgs=-configuration=%__BuildType%
216
217 if defined __ToolsetDir (
218     set __msbuildNativeArgs=%__msbuildNativeArgs% -UseEnv
219 ) else (
220     set __msbuildNativeArgs=%__msbuildNativeArgs% -platform=%__BuildArch%
221 )
222
223 set __BuildLogRootName=Tests_Native
224 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
225 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
226 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
227 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
228 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
229 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
230
231 call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__unprocessedBuildArgs%
232 if errorlevel 1 (
233     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
234     echo     %__BuildLog%
235     echo     %__BuildWrn%
236     echo     %__BuildErr%
237     exit /b 1
238 )
239
240 :skipnative
241
242 set "__TestWorkingDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
243
244 if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct
245 REM =========================================================================================
246 REM ===
247 REM === Restore product binaries from packages
248 REM ===
249 REM =========================================================================================
250
251 if not defined XunitTestBinBase       set  XunitTestBinBase=%__TestWorkingDir%
252 set "CORE_ROOT=%XunitTestBinBase%\Tests\Core_Root"
253
254 set __BuildLogRootName=Restore_Product
255 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
256 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
257 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
258 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
259 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
260 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
261
262 call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
263
264 set __BuildLogRootName=Tests_GenerateRuntimeLayout
265 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
266 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
267 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
268 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
269 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
270 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
271
272 call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
273 if errorlevel 1 (
274     echo BinPlace of mscorlib.dll failed
275     exit /b 1
276 )
277
278 echo %__MsgPrefix% Restored CoreCLR product from packages
279
280 :SkipRestoreProduct
281
282 if defined __SkipManaged exit /b 0
283
284 REM =========================================================================================
285 REM ===
286 REM === Managed test build section
287 REM ===
288 REM =========================================================================================
289
290 echo %__MsgPrefix%Starting the Managed Tests Build
291
292 if not defined VSINSTALLDIR (
293     echo %__MsgPrefix%Error: build-test.cmd should be run from a Visual Studio Command Prompt.  Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
294     exit /b 1
295 )
296
297 set __BuildLogRootName=Tests_Managed
298 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
299 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
300 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
301 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
302 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
303 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
304
305 call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
306 if errorlevel 1 (
307     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
308     echo     %__BuildLog%
309     echo     %__BuildWrn%
310     echo     %__BuildErr%
311     exit /b 1
312 )
313
314 REM Prepare the Test Drop
315 REM Cleans any NI from the last run
316 powershell "Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force"
317 REM Cleans up any lock folder used for synchronization from last run
318 powershell "Get-ChildItem -path %__TestWorkingDir% -Include 'lock' -Recurse -Force |  where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse"
319
320 set CORE_ROOT=%__TestBinDir%\Tests\Core_Root
321 set CORE_ROOT_STAGE=%__TestBinDir%\Tests\Core_Root_Stage
322 if exist "%CORE_ROOT%" rd /s /q "%CORE_ROOT%"
323 if exist "%CORE_ROOT_STAGE%" rd /s /q "%CORE_ROOT_STAGE%"
324 md "%CORE_ROOT%"
325 md "%CORE_ROOT_STAGE%"
326 xcopy "%__BinDir%" "%CORE_ROOT_STAGE%"
327
328
329 if defined __BuildAgainstPackagesArg ( 
330   if "%__TargetsWindows%"=="0" (
331
332     if not exist %__PackagesDir%\TestNativeBins (
333         echo %__MsgPrefix%Error: Ensure you have run sync.cmd -ab before building a non-Windows test overlay against packages
334         exit /b 1
335     )
336
337     for /R %__PackagesDir%\TestNativeBins\%__RuntimeId%\%__BuildType% %%f in (*.so) do copy %%f %CORE_ROOT_STAGE%
338     for /R %__PackagesDir%\TestNativeBins\%__RuntimeId%\%__BuildType% %%f in (*.dylib) do copy %%f %CORE_ROOT_STAGE%
339   )
340 )
341
342 echo %__MsgPrefix%Creating test wrappers...
343
344 set RuntimeIdArg=
345 set TargetsWindowsArg=
346
347 if defined __RuntimeId (
348     set RuntimeIdArg=-RuntimeID="%__RuntimeId%"
349 )
350
351 if "%__TargetsWindows%"=="1" (
352     set TargetsWindowsArg=-TargetsWindows=true
353 ) else if "%__TargetsWindows%"=="0" (
354     set TargetsWindowsArg=-TargetsWindows=false
355 )
356
357 set __BuildLogRootName=Tests_XunitWrapper
358 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
359 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
360 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
361 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
362 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
363 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
364
365 call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs%
366 if errorlevel 1 (
367     echo Xunit Wrapper build failed
368     exit /b 1
369 )
370
371 echo %__MsgPrefix%Creating test overlay...
372
373 set __BuildLogRootName=Tests_Overlay_Managed
374 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
375 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
376 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
377 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
378 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
379 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
380
381 call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs%
382 if errorlevel 1 (
383     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
384     echo     %__BuildLog%
385     echo     %__BuildWrn%
386     echo     %__BuildErr%
387     exit /b 1
388 )
389
390 xcopy /s /y "%CORE_ROOT_STAGE%" "%CORE_ROOT%"
391
392 set __CrossgenArg = ""
393 if defined __DoCrossgen (
394   set __CrossgenArg="-Crossgen"
395   if "%__TargetsWindows%" == "1" (
396     call :PrecompileFX
397   ) else (
398     echo "%__MsgPrefix% Crossgen only supported on Windows, for now"
399   )
400 )
401
402 rd /s /q "%CORE_ROOT_STAGE%"
403
404 if not defined __ZipTests goto SkipPrepForPublish
405
406 set __BuildLogRootName=Helix_Prep
407 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
408 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
409 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
410 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
411 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
412 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
413
414 REM =========================================================================================
415 REM ===
416 REM === Prep test binaries for Helix publishing
417 REM ===
418 REM =========================================================================================
419
420 call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj  -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__unprocessedBuildArgs%
421 if errorlevel 1 (
422     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
423     echo     %__BuildLog%
424     echo     %__BuildWrn%
425     echo     %__BuildErr%
426     exit /b 1
427 )
428
429 echo %__MsgPrefix% Prepped test binaries for publishing
430
431 :SkipPrepForPublish
432
433 REM =========================================================================================
434 REM ===
435 REM === All builds complete!
436 REM ===
437 REM =========================================================================================
438
439 echo %__MsgPrefix%Test build successful.
440 echo %__MsgPrefix%Test binaries are available at !__TestBinDir!
441 exit /b 0
442
443 :Usage
444 echo.
445 echo Usage:
446 echo     %0 [option1] [option2] ...
447 echo All arguments are optional. Options are case-insensitive. The options are:
448 echo.
449 echo. -? -h -help: view this message.
450 echo Build architecture: -buildArch: only x64 is currently allowed ^(default: x64^).
451 echo Build type: -buildType: one of Debug, Checked, Release ^(default: Debug^).
452 echo buildagainstpackages: builds tests against restored packages, instead of against a built product.
453 echo runtimeid ^<ID^>: Builds a test overlay for the specified OS (Only supported when building against packages). Supported IDs are:
454 echo     alpine.3.4.3-x64: Builds overlay for Alpine 3.4.3
455 echo     debian.8-x64: Builds overlay for Debian 8
456 echo     fedora.24-x64: Builds overlay for Fedora 24
457 echo     linux-x64: Builds overlay for portable linux
458 echo     opensuse.42.1-x64: Builds overlay for OpenSUSE 42.1
459 echo     osx.10.12-x64: Builds overlay for OSX 10.12
460 echo     osx-x64: Builds overlay for portable OSX
461 echo     rhel.7-x64: Builds overlay for RHEL 7 or CentOS
462 echo     ubuntu.14.04-x64: Builds overlay for Ubuntu 14.04
463 echo     ubuntu.16.04-x64: Builds overlay for Ubuntu 16.04
464 echo     ubuntu.16.10-x64: Builds overlay for Ubuntu 16.10
465 echo     win-x64: Builds overlay for portable Windows
466 echo     win7-x64: Builds overlay for Windows 7
467 echo ziptests: zips CoreCLR tests & Core_Root for a Helix run
468 echo crossgen: Precompiles the framework managed assemblies
469 echo Exclude- Optional parameter - specify location of default exclusion file (defaults to tests\issues.targets if not specified)
470 echo     Set to "" to disable default exclusion file.
471 echo -- ... : all arguments following this tag will be passed directly to msbuild.
472 echo -priority=^<N^> : specify a set of test that will be built and run, with priority N.
473 echo     0: Build only priority 0 cases as essential testcases (default)
474 echo     1: Build all tests with priority 0 and 1
475 echo     666: Build all tests with priority 0, 1 ... 666
476 echo -verbose: enables detailed file logging for the msbuild tasks into the msbuild log file.
477 exit /b 1
478
479 :NoDIA
480 echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
481 This is due to a bug in the Visual Studio installer. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
482 at the install location of previous Visual Studio version. The workaround is to copy the DIA SDK folder from the Visual Studio install location ^
483 of the previous version to "%VSINSTALLDIR%" and then build.
484 :: DIA SDK not included in Express editions
485 echo Visual Studio Express does not include the DIA SDK. ^
486 You need Visual Studio 2015 or 2017 (Community is free).
487 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
488 exit /b 1
489
490
491 :PrivateToolSet
492
493 echo %__MsgPrefix% Setting Up the usage of __ToolsetDir:%__ToolsetDir%
494
495 if /i "%__ToolsetDir%" == "" (
496     echo %__MsgPrefix%Error: A toolset directory is required for the Arm64 Windows build. Use the toolset_dir argument.
497     exit /b 1
498 )
499
500 if not exist "%__ToolsetDir%"\buildenv_arm64.cmd goto :Not_EWDK
501 call "%__ToolsetDir%"\buildenv_arm64.cmd
502 exit /b 0
503
504 :Not_EWDK
505 set PATH=%__ToolsetDir%\VC_sdk\bin;%PATH%
506 set LIB=%__ToolsetDir%\VC_sdk\lib\arm64;%__ToolsetDir%\sdpublic\sdk\lib\arm64
507 set INCLUDE=^
508 %__ToolsetDir%\VC_sdk\inc;^
509 %__ToolsetDir%\sdpublic\sdk\inc;^
510 %__ToolsetDir%\sdpublic\shared\inc;^
511 %__ToolsetDir%\sdpublic\shared\inc\minwin;^
512 %__ToolsetDir%\sdpublic\sdk\inc\ucrt;^
513 %__ToolsetDir%\sdpublic\sdk\inc\minwin;^
514 %__ToolsetDir%\sdpublic\sdk\inc\mincore;^
515 %__ToolsetDir%\sdpublic\sdk\inc\abi;^
516 %__ToolsetDir%\sdpublic\sdk\inc\clientcore;^
517 %__ToolsetDir%\diasdk\include
518 exit /b 0
519
520 :PrecompileFX
521 for %%F in (%CORE_ROOT%\*.dll) do call :PrecompileAssembly "%%F" %%~nF%%~xF
522 exit /b 0
523
524 REM Compile the managed assemblies in Core_ROOT before running the tests
525 :PrecompileAssembly
526
527 REM Skip mscorlib since it is already precompiled.
528 if /I "%2" == "mscorlib.dll" exit /b 0
529 if /I "%2" == "mscorlib.ni.dll" exit /b 0
530 REM don't precompile anything from CoreCLR
531 if /I exist %CORE_ROOT_STAGE%\%2 exit /b 0
532
533 "%CORE_ROOT_STAGE%\crossgen.exe" /Platform_Assemblies_Paths "%CORE_ROOT%" /in "%1" /out "%CORE_ROOT%/temp.ni.dll" >nul 2>nul
534 set /a __exitCode = %errorlevel%
535 if "%__exitCode%" == "-2146230517" (
536     echo %2 is not a managed assembly.
537     exit /b 0
538 )
539
540 if %__exitCode% neq 0 (
541     echo Unable to precompile %2
542     exit /b 0
543 )
544
545 :: Delete original .dll & replace it with the Crossgened .dll
546 del %1
547 ren "%CORE_ROOT%\temp.ni.dll" %2
548     
549 echo Successfully precompiled %2
550 exit /b 0