Merge pull request #3244 from erozenfeld/SIMDInit
[platform/upstream/coreclr.git] / build.cmd
index 8656c58..5ace7f7 100644 (file)
--- a/build.cmd
+++ b/build.cmd
@@ -3,6 +3,7 @@ setlocal EnableDelayedExpansion EnableExtensions
 
 set __ThisScriptShort=%0
 set __ThisScriptFull="%~f0"
+set __ThisScriptPath="%~dp0"
 
 :: Note that the msbuild project files (specifically, dir.proj) will use the following variables, if set:
 ::      __BuildArch         -- default: x64
@@ -29,7 +30,6 @@ set __BuildOS=Windows_NT
 :: Default to highest Visual Studio version available
 set __VSVersion=vs2015
 
-if defined VS120COMNTOOLS set __VSVersion=vs2013
 if defined VS140COMNTOOLS set __VSVersion=vs2015
 
 :: Define a prefix for most output progress messages that come from this script. That makes
@@ -48,6 +48,8 @@ set "__LogsDir=%__RootBinDir%\Logs"
 
 set __CleanBuild=
 set __MscorlibOnly=
+set __ConfigureOnly=
+set __SkipConfigure=
 set __SkipMscorlibBuild=
 set __SkipNativeBuild=
 set __SkipTestBuild=
@@ -103,8 +105,9 @@ if /i "%1" == "linuxmscorlib"       (set __MscorlibOnly=1&set __BuildOS=Linux&sh
 if /i "%1" == "osxmscorlib"         (set __MscorlibOnly=1&set __BuildOS=OSX&shift&goto Arg_Loop)
 if /i "%1" == "windowsmscorlib"     (set __MscorlibOnly=1&set __BuildOS=Windows_NT&shift&goto Arg_Loop)
 
-if /i "%1" == "vs2013"              (set __VSVersion=%1&shift&goto Arg_Loop)
 if /i "%1" == "vs2015"              (set __VSVersion=%1&shift&goto Arg_Loop)
+if /i "%1" == "configureonly"       (set __ConfigureOnly=1&set __SkipMscorlibBuild=1&set __SkipTestBuild=1&shift&goto Arg_Loop)
+if /i "%1" == "skipconfigure"       (set __SkipConfigure=1&shift&goto Arg_Loop)
 if /i "%1" == "skipmscorlib"        (set __SkipMscorlibBuild=1&shift&goto Arg_Loop)
 if /i "%1" == "skipnative"          (set __SkipNativeBuild=1&shift&goto Arg_Loop)
 if /i "%1" == "skiptests"           (set __SkipTestBuild=1&shift&goto Arg_Loop)
@@ -134,6 +137,11 @@ goto Usage
 
 :ArgsDone
 
+if defined __ConfigureOnly if defined __SkipConfigure (
+    echo "Error: option 'configureonly' is incompatible with 'skipconfigure'
+    goto Usage
+)
+
 if defined __SkipMscorlibBuild if defined __MscorlibOnly (
     echo Error: option 'skipmscorlib' is incompatible with 'freebsdmscorlib', 'linuxmscorlib', 'osxmscorlib', and 'windowsmscorlib'.
     goto Usage
@@ -168,7 +176,8 @@ echo %__MsgPrefix%Commencing CoreCLR Repo build
 set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
 set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
 set "__PackagesBinDir=%__BinDir%\.nuget"
-set "__TestBinDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
+set "__TestRootDir=%__RootBinDir%\tests"
+set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
 set "__TestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
 
 :: Use this variable to locate dynamically generated files; the actual location though will be different.
@@ -209,7 +218,6 @@ for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "&
 :CheckVS
 
 set __VSProductVersion=
-if /i "%__VSVersion%" == "vs2013" set __VSProductVersion=120
 if /i "%__VSVersion%" == "vs2015" set __VSProductVersion=140
 
 :: Check presence of VS
@@ -223,11 +231,6 @@ if not exist "%__VSToolsRoot%\..\IDE\devenv.exe"      goto NoVS
 if not exist "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" goto NoVS
 if not exist "%__VSToolsRoot%\VsDevCmd.bat"           goto NoVS
 
-if /i "%__VSVersion%" =="vs2015" goto MSBuild14
-set _msbuildexe="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
-if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
-if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
-goto :CheckMSBuild14
 :MSBuild14
 set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
 set UseRoslynCompiler=true
@@ -247,6 +250,13 @@ if not defined __BuildSequential (
 
 REM =========================================================================================
 REM ===
+REM === Restore Build Tools
+REM ===
+REM =========================================================================================
+call %__ThisScriptPath%init-tools.cmd  
+
+REM =========================================================================================
+REM ===
 REM === Start the build steps
 REM ===
 REM =========================================================================================
@@ -301,6 +311,8 @@ if not exist "%VSINSTALLDIR%DIA SDK" goto NoDIA
 
 :GenVSSolution
 
+if defined __SkipConfigure goto SkipConfigure
+
 echo %__MsgPrefix%Regenerating the Visual Studio solution
 
 pushd "%__IntermediatesDir%"
@@ -308,6 +320,8 @@ call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersio
 @if defined __echo @echo on
 popd
 
+:SkipConfigure
+
 if not exist "%__IntermediatesDir%\install.vcxproj" (
     echo %__MsgPrefix%Error: failed to generate native component build project!
     exit /b 1
@@ -315,49 +329,12 @@ if not exist "%__IntermediatesDir%\install.vcxproj" (
 
 REM =========================================================================================
 REM ===
-REM === Build ETW infrastructure
-REM ===
-REM =========================================================================================
-
-echo %__MsgPrefix%Generating ETW files
-
-if not defined PythonPath (
-    echo %__MsgPrefix%Error: Couldn't find Python.
-    exit /b 1
-)
-
-:: Ensure there are no stale files in the Generated Directory
-if exist "%__GeneratedIntermediatesDir%" rd /s /q "%__GeneratedIntermediatesDir%"
-md "%__GeneratedIntermediatesDir%"
-md "%__GeneratedIntermediatesDir%\inc"
-set "genetw=%__SourceDir%\scripts\genWinEtw.py"
-
-mc -h "%__GeneratedIntermediatesDir%\inc" -r "%__GeneratedIntermediatesDir%" -b -co -um -p FireEtw "%__SourceDir%\VM\ClrEtwAll.man"
-IF ERRORLEVEL 1 goto FailedToGenEtwMetadata
-
-"%PythonPath%"  "%genetw%" --man "%__SourceDir%\VM\ClrEtwAll.man" --exc "%__SourceDir%\VM\ClrEtwAllMeta.lst" --eventheader "%__GeneratedIntermediatesDir%\inc\ClrEtwAll.h" --macroheader "%__GeneratedIntermediatesDir%\inc\clretwallmain.h" --dummy "%__GeneratedIntermediatesDir%\inc\etmdummy.h"
-IF  ERRORLEVEL 1 goto FailedToGenEtwMetadata
-
-:: Do not use this variable; it is used below to support incremental build.
-set "__GeneratedIntermediatesDirPresent=%__IntermediatesDir%\Generated"
-"%PythonPath%" -c "import sys;sys.path.insert(0,r\"%__SourceDir%\scripts\"); from Utilities import *;UpdateDirectory(r\"%__GeneratedIntermediatesDirPresent%\",r\"%__GeneratedIntermediatesDir%\")"
-IF  ERRORLEVEL 1 goto FailedToGenEtwMetadata
-
-set __GeneratedIntermediatesDir="%__GeneratedIntermediatesDirPresent%"
-goto DoneGenEtwMetadata
-
-:FailedToGenEtwMetadata
-echo %__MsgPrefix%Error: failed to generate ETW files.
-exit /b %ERRORLEVEL%
-
-:DoneGenEtwMetadata
-
-REM =========================================================================================
-REM ===
 REM === Build the CLR VM
 REM ===
 REM =========================================================================================
 
+if defined __ConfigureOnly goto SkipNativeBuild
+
 echo %__MsgPrefix%Invoking msbuild
 
 set "__BuildLog=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
@@ -448,15 +425,7 @@ if defined __MscorlibOnly (
     exit /b 0
 )
 
-REM Consider doing crossgen build of mscorlib.
-
-if /i "%__BuildArch%" == "x86" (
-    if not defined __DoCrossgen (
-        echo %__MsgPrefix%Skipping Crossgen
-        goto SkipCrossGenBuild
-    )
-)
-
+REM Consider doing crossgen build of mscorlib unless we are skipping it intentionally
 if /i "%__BuildArch%" == "arm64" (
     if not defined __DoCrossgen (
         echo %__MsgPrefix%Skipping Crossgen
@@ -474,6 +443,31 @@ if errorlevel 1 (
     exit /b 1
 )
 
+:GenerateNuget
+if /i "%__BuildArch%" =="arm64" goto :SkipNuget
+
+set "__BuildLog=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
+set "__BuildWrn=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
+set "__BuildErr=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
+set __msbuildLogArgs=^
+/fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%" ^
+/fileloggerparameters1:WarningsOnly;LogFile="%__BuildWrn%" ^
+/fileloggerparameters2:ErrorsOnly;LogFile="%__BuildErr%" ^
+/consoleloggerparameters:Summary ^
+/verbosity:minimal
+
+set __msbuildArgs="%__ProjectFilesDir%\src\.nuget\Microsoft.NETCore.Runtime.CoreClr\Microsoft.NETCore.Runtime.CoreCLR.builds" /p:Platform=%__BuildArch%
+%_msbuildexe% %__msbuildArgs% %__msbuildLogArgs%
+if errorlevel 1 (
+    echo %__MsgPrefix%Error: Nuget package generation failed build failed. Refer to the build log files for details:
+    echo     %__BuildLog%
+    echo     %__BuildWrn%
+    echo     %__BuildErr%
+    exit /b 1
+)
+
+:SkipNuget
+
 :SkipCrossGenBuild
 
 REM endlocal to rid us of environment changes from vsdevenv.bat
@@ -625,8 +619,7 @@ echo.
 echo./? -? /h -h /help -help: view this message.
 echo Build architecture: one of x64, x86, arm, arm64 ^(default: x64^).
 echo Build type: one of Debug, Checked, Release ^(default: Debug^).
-echo Visual Studio version: one of VS2013 or VS2015 to force using a particular
-echo     Visual Studio version ^(default: VS2015^).
+echo Visual Studio version: ^(default: VS2015^).
 echo clean: force a clean build ^(default is to perform an incremental build^).
 echo docrossgen: do a crossgen build of mscorlib.
 echo msbuildargs ... : all arguments following this tag will be passed directly to msbuild.
@@ -637,6 +630,8 @@ echo     respectively^).
 echo priority ^<N^> : specify a set of test that will be built and run, with priority N.
 echo sequential: force a non-parallel build ^(default is to build in parallel
 echo     using all processors^).
+echo configureonly: skip all builds; only run CMake ^(default: CMake and builds are run^)
+echo skipconfigure: skip CMake ^(default: CMake is run^)
 echo skipmscorlib: skip building mscorlib ^(default: mscorlib is built^).
 echo skipnative: skip building native components ^(default: native components are built^).
 echo skiptests: skip building tests ^(default: tests are built^).
@@ -656,7 +651,7 @@ echo        -- builds x64 and x86 architectures, Checked and Release build types
 exit /b 1
 
 :NoVS
-echo Visual Studio 2013+ ^(Community is free^) is a prerequisite to build this repository.
+echo Visual Studio 2015+ ^(Community is free^) is a prerequisite to build this repository.
 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
 exit /b 1
 
@@ -666,7 +661,7 @@ This is due to a bug in the Visual Studio installer. It does not install DIA SDK
 at the install location of previous Visual Studio version. The workaround is to copy the DIA SDK folder from the Visual Studio install location ^
 of the previous version to "%VSINSTALLDIR%" and then build.
 :: DIA SDK not included in Express editions
-echo Visual Studio 2013 Express does not include the DIA SDK. ^
-You need Visual Studio 2013+ (Community is free).
+echo Visual Studio Express does not include the DIA SDK. ^
+You need Visual Studio 2015+ (Community is free).
 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
 exit /b 1