@@ -23,6 +23,24 @@ usage()
23
23
exit 1
24
24
}
25
25
26
+ initDistroName ()
27
+ {
28
+ if [ " $__BuildOS " == " Linux" ]; then
29
+ # Detect Distro
30
+ if [ " $( cat /etc/* -release | grep -cim1 ubuntu) " -eq 1 ]; then
31
+ export __DistroName=ubuntu
32
+ elif [ " $( cat /etc/* -release | grep -cim1 centos) " -eq 1 ]; then
33
+ export __DistroName=rhel
34
+ elif [ " $( cat /etc/* -release | grep -cim1 rhel) " -eq 1 ]; then
35
+ export __DistroName=rhel
36
+ elif [ " $( cat /etc/* -release | grep -cim1 debian) " -eq 1 ]; then
37
+ export __DistroName=debian
38
+ else
39
+ export __DistroName=" "
40
+ fi
41
+ fi
42
+ }
43
+
26
44
setup_dirs ()
27
45
{
28
46
echo Setting up directories for build
@@ -162,50 +180,49 @@ build_coreclr()
162
180
fi
163
181
}
164
182
165
- build_mscorlib ()
183
+ restoreBuildTools ()
166
184
{
167
- hash mono 2> /dev/null || { echo >&2 " Skipping mscorlib.dll build since Mono is not installed. " ; return ; }
168
-
169
- if [ $__SkipMSCorLib == 1 ]; then
170
- echo " Skipping mscorlib.dll build ."
171
- return
185
+ echo " Restoring BuildTools... "
186
+ $__ProjectRoot /init-tools.sh
187
+ if [ $? -ne 0 ]; then
188
+ echo " Failed to restore BuildTools ."
189
+ exit 1
172
190
fi
191
+ }
173
192
174
- # Temporary hack to make dnu restore more reliable. This is specifically for dnu beta 5 since this issue should already be addressed in later versions of dnu.
175
- export MONO_THREADS_PER_CPU=2000
193
+ isMSBuildOnNETCoreSupported ()
194
+ {
195
+ __isMSBuildOnNETCoreSupported=0
176
196
177
- echo " Commencing build of mscorlib components for $__BuildOS .$__BuildArch .$__BuildType "
197
+ if [ " $__BuildOS " == " Linux" ]; then
198
+ if [ " $__DistroName " == " ubuntu" ]; then
199
+ __isMSBuildOnNETCoreSupported=1
200
+ fi
201
+ elif [ " $__BuildOS " == " OSX" ]; then
202
+ __isMSBuildOnNETCoreSupported=1
203
+ fi
204
+ }
178
205
179
- # Pull NuGet.exe down if we don't have it already
180
- if [ ! -e " $__NuGetPath " ]; then
181
- hash curl 2> /dev/null || hash wget 2> /dev/null || { echo >&2 echo " cURL or wget is required to build mscorlib." ; exit 1; }
206
+ build_mscorlib ()
207
+ {
182
208
183
- echo " Restoring NuGet.exe..."
209
+ if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
210
+ echo " Mscorlib.dll build unsupported."
211
+ return
212
+ fi
184
213
185
- # curl has HTTPS CA trust-issues less often than wget, so lets try that first.
186
- which curl > /dev/null 2> /dev/null
187
- if [ $? -ne 0 ]; then
188
- mkdir -p $__PackagesDir
189
- wget -q -O $__NuGetPath https://api.nuget.org/downloads/nuget.exe
190
- else
191
- curl -sSL --create-dirs -o $__NuGetPath https://api.nuget.org/downloads/nuget.exe
192
- fi
214
+ # CI_TODO: Until we switch CI to stop building mscorlib for platforms supported by isMSBuildOnNETCoreSupported function,
215
+ # we should ignore skipping building mscorlib.
216
+ # if [ $__SkipMSCorLib == 1 ]; then
217
+ # echo "Skipping building mscorlib."
218
+ # return
219
+ # fi
193
220
194
- if [ $? -ne 0 ]; then
195
- echo " Failed to restore NuGet.exe."
196
- exit 1
197
- fi
198
- fi
221
+ # Restore buildTools
199
222
200
- # Grab the MSBuild package if we don't have it already
201
- if [ ! -e " $__MSBuildPath " ]; then
202
- echo " Restoring MSBuild..."
203
- $__ProjectRoot /init-tools.sh
204
- if [ $? -ne 0 ]; then
205
- echo " Failed to restore MSBuild."
206
- exit 1
207
- fi
208
- fi
223
+ restoreBuildTools
224
+
225
+ echo " Commencing build of mscorlib components for $__BuildOS .$__BuildArch .$__BuildType "
209
226
210
227
# Invoke MSBuild
211
228
$__ProjectRoot /Tools/corerun " $__MSBuildPath " /nologo " $__ProjectRoot /build.proj" /verbosity:minimal " /fileloggerparameters:Verbosity=normal;LogFile=$__LogsDir /MSCorLib_$__BuildOS__$__BuildArch__$__BuildType .log" /t:Build /p:__BuildOS=$__BuildOS /p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__IntermediatesDir=$__IntermediatesDir /p:UseRoslynCompiler=true /p:BuildNugetPackage=false /p:UseSharedCompilation=false
@@ -225,6 +242,38 @@ build_mscorlib()
225
242
fi
226
243
}
227
244
245
+ generate_NugetPackages ()
246
+ {
247
+ # We can only generate nuget package if we also support building mscorlib as part of this build.
248
+ if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
249
+ echo " Microsoft.NETCore.Runtime.CoreCLR nuget package generation unsupported."
250
+ return
251
+ fi
252
+
253
+ # Since we can build mscorlib for this OS, did we build the native components as well?
254
+ if [ $__SkipCoreCLR == 1 ]; then
255
+ echo " Unable to generate Microsoft.NETCore.Runtime.CoreCLR nuget package since native components were not built."
256
+ return
257
+ fi
258
+
259
+ # CI_TODO: Until we switch CI to stop building mscorlib for platforms supported by isMSBuildOnNETCoreSupported function,
260
+ # we should ignore skipping building mscorlib.
261
+ # if [ $__SkipMSCorLib == 1 ]; then
262
+ # echo "Unable to generate Microsoft.NETCore.Runtime.CoreCLR nuget package since mscorlib was not built."
263
+ # return
264
+ # fi
265
+
266
+ echo " Generating nuget packages for " $__BuildOS
267
+
268
+ # Invoke MSBuild
269
+ $__ProjectRoot /Tools/corerun " $__MSBuildPath " /nologo " $__ProjectRoot /src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/Microsoft.NETCore.Runtime.CoreCLR.builds" /verbosity:minimal " /fileloggerparameters:Verbosity=normal;LogFile=$__LogsDir /Nuget_$__BuildOS__$__BuildArch__$__BuildType .log" /t:Build /p:__BuildOS=$__BuildOS /p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__IntermediatesDir=$__IntermediatesDir /p:UseRoslynCompiler=true /p:BuildNugetPackage=false /p:UseSharedCompilation=false
270
+
271
+ if [ $? -ne 0 ]; then
272
+ echo " Failed to generate Nuget packages."
273
+ exit 1
274
+ fi
275
+ }
276
+
228
277
echo " Commencing CoreCLR Repo build"
229
278
230
279
# Argument types supported by this script:
@@ -240,7 +289,7 @@ __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
240
289
# Use uname to determine what the CPU is.
241
290
CPUName=$( uname -p)
242
291
# Some Linux platforms report unknown for platform, but the arch for machine.
243
- if [ $CPUName = " unknown" ]; then
292
+ if [ $CPUName == " unknown" ]; then
244
293
CPUName=$( uname -m)
245
294
fi
246
295
@@ -327,6 +376,7 @@ __ClangMajorVersion=3
327
376
__ClangMinorVersion=5
328
377
__MSBuildPath=$__ProjectRoot /Tools/MSBuild.exe
329
378
__NuGetPath=" $__PackagesDir /NuGet.exe"
379
+ __DistroName=" "
330
380
331
381
for i in " $@ "
332
382
do
@@ -443,13 +493,30 @@ if [[ $__ConfigureOnly == 1 && $__SkipConfigure == 1 ]]; then
443
493
exit 1
444
494
fi
445
495
496
+ # init the distro name
497
+ initDistroName
498
+
446
499
# Set the remaining variables based upon the determined build configuration
447
500
__BinDir=" $__RootBinDir /Product/$__BuildOS .$__BuildArch .$__BuildType "
448
501
__PackagesBinDir=" $__BinDir /.nuget"
449
502
__ToolsDir=" $__RootBinDir /tools"
450
503
__TestWorkingDir=" $__RootBinDir /tests/$__BuildOS .$__BuildArch .$__BuildType "
451
504
export __IntermediatesDir=" $__RootBinDir /obj/$__BuildOS .$__BuildArch .$__BuildType "
452
505
__TestIntermediatesDir=" $__RootBinDir /tests/obj/$__BuildOS .$__BuildArch .$__BuildType "
506
+ __isMSBuildOnNETCoreSupported=0
507
+
508
+ # Init if MSBuild for .NET Core is supported for this platform
509
+ isMSBuildOnNETCoreSupported
510
+
511
+ # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
512
+ # This is needed by CLI to function.
513
+ if [ -z " $HOME " ]; then
514
+ if [ ! -d " $__ProjectDir /temp_home" ]; then
515
+ mkdir temp_home
516
+ fi
517
+ export HOME=$__ProjectDir /temp_home
518
+ echo " HOME not defined; setting it to $HOME "
519
+ fi
453
520
454
521
# Specify path to be set for CMAKE_INSTALL_PREFIX.
455
522
# This is where all built CoreClr libraries will copied to.
@@ -489,6 +556,11 @@ build_coreclr
489
556
490
557
build_mscorlib
491
558
559
+ # Generate nuget packages
560
+
561
+ generate_NugetPackages
562
+
563
+
492
564
# Build complete
493
565
494
566
echo " Repo successfully built."
0 commit comments