|
2 | 2 | setlocal EnableDelayedExpansion
|
3 | 3 |
|
4 | 4 | set __ThisScriptShort=%0
|
5 |
| -set __ThisScriptFull="%~f0" |
6 | 5 |
|
7 |
| -:: Set the default arguments for build |
8 |
| -set __BuildArch=x64 |
9 |
| -set __BuildType=Debug |
10 |
| -set __BuildOS=Windows_NT |
| 6 | +if /i "%1" == "/?" goto HelpVarCall |
| 7 | +if /i "%1" == "-?" goto HelpVarCall |
| 8 | +if /i "%1" == "/h" goto HelpVarCall |
| 9 | +if /i "%1" == "-h" goto HelpVarCall |
| 10 | +if /i "%1" == "/help" goto HelpVarCall |
| 11 | +if /i "%1" == "-help" goto HelpVarCall |
11 | 12 |
|
12 |
| -:: Default to highest Visual Studio version available |
13 |
| -set __VSVersion=vs2015 |
| 13 | +goto :NormalVarCall |
14 | 14 |
|
15 |
| -:: Set the various build properties here so that CMake and MSBuild can pick them up |
16 |
| -set "__ProjectDir=%~dp0" |
17 |
| -:: remove trailing slash |
18 |
| -if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%" |
19 |
| -set "__SourceDir=%__ProjectDir%\src" |
20 |
| -set "__PackagesDir=%__ProjectDir%\packages" |
21 |
| -set "__RootBinDir=%__ProjectDir%\bin" |
22 |
| -set "__LogsDir=%__RootBinDir%\Logs" |
23 |
| -set __MSBCleanBuildArgs= |
24 |
| -set __SkipTestBuild= |
25 |
| -set __ToolchainMilestone=testing |
26 |
| -set "__DotNetCliPath=%__ProjectDir%\Tools\dotnetcli" |
27 |
| - |
28 |
| -:Arg_Loop |
29 |
| -if "%1" == "" goto ArgsDone |
30 |
| - |
31 |
| -if /i "%1" == "/?" goto Usage |
32 |
| -if /i "%1" == "-?" goto Usage |
33 |
| -if /i "%1" == "/h" goto Usage |
34 |
| -if /i "%1" == "-h" goto Usage |
35 |
| -if /i "%1" == "/help" goto Usage |
36 |
| -if /i "%1" == "-help" goto Usage |
37 |
| - |
38 |
| -if /i "%1" == "x64" (set __BuildArch=x64&&shift&goto Arg_Loop) |
39 |
| -if /i "%1" == "x86" (set __BuildArch=x86&&shift&goto Arg_Loop) |
40 |
| -if /i "%1" == "arm" (set __BuildArch=arm&&shift&goto Arg_Loop) |
41 |
| - |
42 |
| -if /i "%1" == "debug" (set __BuildType=Debug&shift&goto Arg_Loop) |
43 |
| -if /i "%1" == "release" (set __BuildType=Release&shift&goto Arg_Loop) |
44 |
| - |
45 |
| -if /i "%1" == "clean" (set __CleanBuild=1&shift&goto Arg_Loop) |
46 |
| - |
47 |
| -if /i "%1" == "skiptests" (set __SkipTests=1&shift&goto Arg_Loop) |
48 |
| -if /i "%1" == "skipvsdev" (set __SkipVsDev=1&shift&goto Arg_Loop) |
49 |
| -if /i "%1" == "/milestone" (set __ToolchainMilestone=%2&shift&shift&goto Arg_Loop) |
50 |
| -if /i "%1" == "/dotnetclipath" (set __DotNetCliPath=%2&shift&shift&goto Arg_Loop) |
51 |
| - |
52 |
| -echo Invalid command line argument: %1 |
53 |
| -goto Usage |
54 |
| - |
55 |
| -:ArgsDone |
56 |
| - |
57 |
| -echo Commencing CoreRT Repo build |
58 |
| -echo. |
59 |
| - |
60 |
| -:: Set the remaining variables based upon the determined build configuration |
61 |
| -set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%" |
62 |
| -set "__ObjDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%" |
63 |
| -set "__IntermediatesDir=%__RootBinDir%\obj\Native\%__BuildOS%.%__BuildArch%.%__BuildType%\" |
64 |
| -set "__RelativeProductBinDir=bin\Product\%__BuildOS%.%__BuildArch%.%__BuildType%" |
65 |
| - |
66 |
| -set "__ReproProjectDir=%__ProjectDir%\src\ILCompiler\repro" |
67 |
| -set "__ReproProjectBinDir=%__BinDir%\repro" |
68 |
| -set "__ReproProjectObjDir=%__ObjDir%\repro" |
69 |
| - |
70 |
| -:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash |
71 |
| -set "__CMakeBinDir=%__BinDir%" |
72 |
| -set "__CMakeBinDir=%__CMakeBinDir:\=/%" |
73 |
| - |
74 |
| -:: Configure environment if we are doing a clean build. |
75 |
| -if not defined __CleanBuild goto MakeDirs |
76 |
| -echo Doing a clean build |
77 |
| -echo. |
78 |
| - |
79 |
| -:: MSBuild projects would need a rebuild |
80 |
| -set __MSBCleanBuildArgs=/t:rebuild /p:CleanedTheBuild=1 |
81 |
| - |
82 |
| -:: Cleanup the previous output for the selected configuration |
83 |
| -if exist "%__BinDir%" rd /s /q "%__BinDir%" |
84 |
| -if exist "%__ObjDir%" rd /s /q "%__ObjDir%" |
85 |
| -if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%" |
86 |
| - |
87 |
| -if exist "%__LogsDir%" del /f /q "%__LogsDir%\*_%__BuildOS%__%__BuildArch%__%__BuildType%.*" |
88 |
| - |
89 |
| -:MakeDirs |
90 |
| -if not exist "%__BinDir%" md "%__BinDir%" |
91 |
| -if not exist "%__ObjDir%" md "%__ObjDir%" |
92 |
| -if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%" |
93 |
| -if not exist "%__LogsDir%" md "%__LogsDir%" |
94 |
| - |
95 |
| -:CheckPrereqs |
96 |
| -:: Check prerequisites |
97 |
| -echo Checking pre-requisites... |
98 |
| -echo. |
99 |
| - |
100 |
| -:: Validate that PowerShell is accessibile. |
101 |
| -for %%X in (powershell.exe) do (set __PSDir=%%~$PATH:X) |
102 |
| -if defined __PSDir goto EvaluatePS |
103 |
| -echo PowerShell is a prerequisite to build this repository. |
104 |
| -echo See: https://github.com/dotnet/corert/blob/master/Documentation/prerequisites-for-building.md |
| 15 | +:HelpVarCall |
| 16 | +call %~dp0buildscripts\buildvars-setup.cmd -help |
105 | 17 | exit /b 1
|
106 | 18 |
|
107 |
| -:EvaluatePS |
108 |
| -:: Eval the output from probe-win1.ps1 |
109 |
| -for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& ""%__SourceDir%\Native\probe-win.ps1"""') do %%a |
110 |
| - |
111 |
| -:CheckVS |
| 19 | +:NormalVarCall |
| 20 | +call %~dp0buildscripts\buildvars-setup.cmd %* |
112 | 21 |
|
113 |
| -set __VSProductVersion= |
114 |
| -if /i "%__VSVersion%" == "vs2015" set __VSProductVersion=140 |
| 22 | +IF NOT ERRORLEVEL 1 goto AfterVarSetup |
| 23 | +echo Setting build variables failed. |
| 24 | +exit /b %ERRORLEVEL% |
115 | 25 |
|
116 |
| -:: Check presence of VS |
117 |
| -if defined VS%__VSProductVersion%COMNTOOLS goto CheckVSExistence |
118 |
| -echo Visual Studio 2015 (Community is free) is a pre-requisite to build this repository. |
119 |
| -echo See: https://github.com/dotnet/corert/blob/master/Documentation/prerequisites-for-building.md |
120 |
| -exit /b 1 |
121 |
| - |
122 |
| -:CheckVSExistence |
123 |
| -:: Does VS VS 2015 really exist? |
124 |
| -if exist "!VS%__VSProductVersion%COMNTOOLS!\..\IDE\devenv.exe" goto CheckMSBuild |
125 |
| -echo Visual Studio 2015 (Community is free) is a pre-requisite to build this repository. |
126 |
| -echo See: https://github.com/dotnet/corert/blob/master/Documentation/prerequisites-for-building.md |
127 |
| -exit /b 1 |
| 26 | +:AfterVarSetup |
128 | 27 |
|
129 |
| -:CheckMSBuild |
130 |
| -:: Note: We've disabled node reuse because it causes file locking issues. |
131 |
| -:: The issue is that we extend the build with our own targets which |
132 |
| -:: means that that rebuilding cannot successfully delete the task |
133 |
| -:: assembly. |
134 |
| -set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" |
135 |
| -if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe" |
136 |
| -if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe. Please see https://github.com/dotnet/corert/blob/master/Documentation/prerequisites-for-building.md for build instructions. && exit /b 1 |
137 |
| - |
138 |
| -:: All set to commence the build |
139 |
| - |
140 |
| -setlocal |
141 |
| -echo Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType% |
| 28 | +echo Commencing CoreRT Repo build |
142 | 29 | echo.
|
143 | 30 |
|
144 |
| -:: Set the environment for the native build |
145 |
| -set __VCBuildArch=x86_amd64 |
146 |
| -if /i "%__BuildArch%" == "x86" (set __VCBuildArch=x86) |
147 |
| -call "!VS%__VSProductVersion%COMNTOOLS!\..\..\VC\vcvarsall.bat" %__VCBuildArch% |
148 |
| - |
149 |
| -:: Regenerate the VS solution |
150 |
| -pushd "%__IntermediatesDir%" |
151 |
| -call "%__SourceDir%\Native\gen-buildsys-win.bat" "%__ProjectDir%\src\Native" %__VSVersion% %__BuildArch% |
152 |
| -popd |
| 31 | +call %~dp0buildscripts\build-native.cmd %* |
153 | 32 |
|
154 |
| -:BuildComponents |
155 |
| -if exist "%__IntermediatesDir%\install.vcxproj" goto BuildNative |
156 |
| -echo Failed to generate native component build project! |
157 |
| -exit /b 1 |
158 |
| - |
159 |
| -:BuildNative |
160 |
| -set "__NativeBuildLog=%__LogsDir%\Native_%__BuildOS%__%__BuildArch%__%__BuildType%.log" |
161 |
| -%_msbuildexe% /ConsoleLoggerParameters:ForceNoAlign "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=normal;LogFile="%__NativeBuildLog%" |
162 |
| -IF NOT ERRORLEVEL 1 goto ManagedBuild |
| 33 | +IF NOT ERRORLEVEL 1 goto AfterNativeBuild |
163 | 34 | echo Native component build failed. Refer !__NativeBuildLog! for details.
|
164 |
| -exit /b 1 |
165 |
| - |
166 |
| -:ManagedBuild |
167 |
| -REM endlocal to rid us of environment changes from vcvarsall.bat |
168 |
| -endlocal |
169 |
| - |
170 |
| -REM setlocal to prepare for vsdevcmd.bat |
171 |
| -setlocal |
172 |
| - |
173 |
| -rem Explicitly set Platform causes conflicts in managed project files. Clear it to allow building from VS x64 Native Tools Command Prompt |
174 |
| -set Platform= |
175 |
| - |
176 |
| -:: Restore the Tools directory |
177 |
| -call "%~dp0init-tools.cmd" |
178 |
| - |
179 |
| -rem Tell nuget to always use repo-local nuget package cache. The "dotnet restore" invocations use the --packages |
180 |
| -rem argument, but there are a few commands in publish and tests that do not. |
181 |
| -set "NUGET_PACKAGES=%__PackagesDir%" |
182 |
| - |
183 |
| -echo Using CLI tools version: |
184 |
| -dir /b "%__DotNetCliPath%\sdk" |
| 35 | +exit /b %ERRORLEVEL% |
185 | 36 |
|
186 |
| -:: Set the environment for the managed build |
187 |
| -:SetupManagedBuild |
188 |
| -call "!VS%__VSProductVersion%COMNTOOLS!\VsDevCmd.bat" |
189 |
| -echo Commencing build of managed components for %__BuildOS%.%__BuildArch%.%__BuildType% |
190 |
| -echo. |
191 |
| -set "__BuildLog=%__LogsDir%\msbuild_%__BuildOS%__%__BuildArch%__%__BuildType%.log" |
192 |
| -%_msbuildexe% /ConsoleLoggerParameters:ForceNoAlign "%__ProjectDir%\build.proj" %__MSBCleanBuildArgs% /p:RepoPath="%__ProjectDir%" /p:RepoLocalBuild="true" /p:RelativeProductBinDir="%__RelativeProductBinDir%" /p:NuPkgRid=win7-x64 /p:ToolchainMilestone=%__ToolchainMilestone% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%" |
193 |
| -IF NOT ERRORLEVEL 1 ( |
194 |
| - findstr /ir /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" "%__BuildLog%" |
195 |
| - goto AfterILCompilerBuild |
196 |
| -) |
197 |
| -echo ILCompiler build failed. Refer !__BuildLog! for details. |
198 |
| -exit /b 1 |
199 |
| - |
200 |
| - |
201 |
| -:AfterILCompilerBuild |
202 |
| - |
203 |
| - |
204 |
| -:VsDevGenerateRespFiles |
205 |
| -if defined __SkipVsDev goto :AfterVsDevGenerateRespFiles |
206 |
| -set __GenRespFiles=0 |
207 |
| -if not exist "%__ObjDir%\ryujit.rsp" set __GenRespFiles=1 |
208 |
| -if not exist "%__ObjDir%\cpp.rsp" set __GenRespFiles=1 |
209 |
| -if "%__GenRespFiles%"=="1" ( |
210 |
| - if exist "%__ReproProjectBinDir%" rd /s /q "%__ReproProjectBinDir%" |
211 |
| - if exist "%__ReproProjectObjDir%" rd /s /q "%__ReproProjectObjDir%" |
212 |
| - |
213 |
| - %_msbuildexe% /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%__BinDir%\packaging\publish1" /p:Configuration=%__BuildType% /t:IlcCompile "%__ReproProjectDir%\repro.csproj" |
214 |
| - call :CopyResponseFile "%__ReproProjectObjDir%\native\ilc.rsp" "%__ObjDir%\ryujit.rsp" |
| 37 | +:AfterNativeBuild |
215 | 38 |
|
216 |
| - if exist "%__ReproProjectBinDir%" rd /s /q "%__ReproProjectBinDir%" |
217 |
| - if exist "%__ReproProjectObjDir%" rd /s /q "%__ReproProjectObjDir%" |
| 39 | +call %~dp0buildscripts\build-managed.cmd %* |
218 | 40 |
|
219 |
| - set __ExtraArgs=/p:NativeCodeGen=cpp |
220 |
| - if /i "%__BuildType%"=="debug" ( |
221 |
| - set __ExtraArgs=!__ExtraArgs! "/p:AdditionalCppCompilerFlags=/MTd" |
222 |
| - ) |
223 |
| - %_msbuildexe% /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%__BinDir%\packaging\publish1" /p:Configuration=%__BuildType% /t:IlcCompile "%__ReproProjectDir%\repro.csproj" !__ExtraArgs! |
224 |
| - call :CopyResponseFile "%__ReproProjectObjDir%\native\ilc.rsp" "%__ObjDir%\cpp.rsp" |
225 |
| -) |
226 |
| -:AfterVsDevGenerateRespFiles |
| 41 | +IF NOT ERRORLEVEL 1 goto AfterManagedBuild |
| 42 | +echo Managed component build failed. Refer !__BuildLog! for details. |
| 43 | +exit /b %ERRORLEVEL% |
227 | 44 |
|
228 |
| -:RunTests |
229 |
| -if defined __SkipTests exit /b 0 |
| 45 | +:AfterManagedBuild |
230 | 46 |
|
231 |
| -pushd "%__ProjectDir%\tests" |
232 |
| -call "runtest.cmd" %__BuildType% %__BuildArch% /dotnetclipath %__DotNetCliPath% |
233 |
| -set TEST_EXIT_CODE=%ERRORLEVEL% |
234 |
| -popd |
235 |
| -exit /b %TEST_EXIT_CODE% |
236 |
| - |
237 |
| -:Usage |
238 |
| -echo. |
239 |
| -echo Build the CoreRT repo. |
240 |
| -echo. |
241 |
| -echo Usage: |
242 |
| -echo %__ThisScriptShort% [option1] [option2] ... |
243 |
| -echo. |
244 |
| -echo All arguments are optional. The options are: |
245 |
| -echo. |
246 |
| -echo./? -? /h -h /help -help: view this message. |
247 |
| -echo Build architecture: one of x64, x86, arm ^(default: x64^). |
248 |
| -echo Build type: one of Debug, Checked, Release ^(default: Debug^). |
249 |
| -echo Visual Studio version: ^(default: VS2015^). |
250 |
| -echo clean: force a clean build ^(default is to perform an incremental build^). |
251 |
| -echo skiptests: skip building tests ^(default: tests are built^). |
252 |
| -exit /b 1 |
| 47 | +call %~dp0buildscripts\build-tests.cmd %* |
253 | 48 |
|
254 |
| -rem Copies the dotnet generated response file while patching up references |
255 |
| -rem to System.Private assemblies to the live built ones. |
256 |
| -rem This is to make sure that making changes in a private library doesn't require |
257 |
| -rem a full rebuild. It also helps with locating the symbols. |
258 |
| -:CopyResponseFile |
259 |
| -setlocal |
260 |
| -> %~2 ( |
261 |
| - for /f "tokens=*" %%l in (%~1) do ( |
262 |
| - set line=%%l |
263 |
| - if "!line:publish1\sdk=!"=="!line!" ( |
264 |
| - echo !line! |
265 |
| - ) ELSE ( |
266 |
| - set assemblyPath=!line:~3! |
267 |
| - call :ExtractFileName !assemblyPath! assemblyFileName |
268 |
| - echo -r:%__BinDir%\!assemblyFileName!\!assemblyFileName!.dll |
269 |
| - ) |
270 |
| - ) |
271 |
| -) |
272 |
| -endlocal |
273 |
| -goto:eof |
| 49 | +IF NOT ERRORLEVEL 1 goto AfterTests |
| 50 | +echo Tests failed. |
| 51 | +exit /b %ERRORLEVEL% |
274 | 52 |
|
275 |
| -rem Extracts a file name from a full path |
276 |
| -rem %1 Full path to the file, %2 Variable to receive the file name |
277 |
| -:ExtractFileName |
278 |
| -setlocal |
279 |
| -for %%i in ("%1") DO set fileName=%%~ni |
280 |
| -endlocal & set "%2=%fileName%" |
281 |
| -goto:eof |
| 53 | +:AfterTests |
0 commit comments