Merge pull request #6297 from CarolEidt/MorphGenTreeRefactors
[platform/upstream/coreclr.git] / build.sh
1 #!/usr/bin/env bash
2
3 # resolve python-version to use
4 if [ "$PYTHON" == "" ] ; then
5     if which python >/dev/null 2>&1
6     then
7        PYTHON=python
8     elif which python2 >/dev/null 2>&1
9     then
10        PYTHON=python2
11     elif which python2.7 >/dev/null 2>&1
12     then
13        PYTHON=python2.7
14     else
15        echo "Unable to locate build-dependency python2.x!" 1>&2
16        exit 1
17     fi
18 fi
19
20 # validate python-dependency
21 # useful in case of explicitly set option.
22 if ! which $PYTHON > /dev/null 2>&1
23 then
24    echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2
25    exit 1
26 fi
27
28 usage()
29 {
30     echo "Usage: $0 [BuildArch] [BuildType] [clean] [verbose] [coverage] [cross] [clangx.y] [ninja] [configureonly] [skipconfigure] [skipnative] [skipmscorlib] [skiptests] [cmakeargs] [bindir]"
31     echo "BuildArch can be: x64, x86, arm, arm-softfp, arm64"
32     echo "BuildType can be: debug, checked, release"
33     echo "clean - optional argument to force a clean build."
34     echo "verbose - optional argument to enable verbose build output."
35     echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
36     echo "ninja - target ninja instead of GNU make"
37     echo "clangx.y - optional argument to build using clang version x.y."
38     echo "cross - optional argument to signify cross compilation,"
39     echo "      - will use ROOTFS_DIR environment variable if set."
40     echo "configureonly - do not perform any builds; just configure the build."
41     echo "skipconfigure - skip build configuration."
42     echo "skipnative - do not build native components."
43     echo "skipmscorlib - do not build mscorlib.dll."
44     echo "skiptests - skip the tests in the 'tests' subdirectory."
45     echo "skiprestore - skip restoring nuget packages."
46     echo "skipnuget - skip building nuget packages."
47     echo "disableoss - Disable Open Source Signing for mscorlib."
48     echo "skipgenerateversion - disable version generation even if MSBuild is supported."
49     echo "cmakeargs - user-settable additional arguments passed to CMake."
50     echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
51
52     exit 1
53 }
54
55 initDistroRid()
56 {
57     if [ "$__BuildOS" == "Linux" ]; then
58         if [ ! -e /etc/os-release ]; then
59             echo "WARNING: Can not determine runtime id for current distro."
60             export __DistroRid=""
61         else
62             source /etc/os-release
63             export __DistroRid="$ID.$VERSION_ID-$__HostArch"
64         fi
65     fi
66 }
67
68 setup_dirs()
69 {
70     echo Setting up directories for build
71
72     mkdir -p "$__RootBinDir"
73     mkdir -p "$__BinDir"
74     mkdir -p "$__LogsDir"
75     mkdir -p "$__IntermediatesDir"
76 }
77
78 # Performs "clean build" type actions (deleting and remaking directories)
79
80 clean()
81 {
82     echo Cleaning previous output for the selected configuration
83     rm -rf "$__BinDir"
84     rm -rf "$__IntermediatesDir"
85
86     rm -rf "$__TestWorkingDir"
87     rm -rf "$__TestIntermediatesDir"
88
89     rm -rf "$__LogsDir/*_$__BuildOS__$__BuildArch__$__BuildType.*"
90     rm -rf "$__ProjectRoot/Tools"
91 }
92
93 # Check the system to ensure the right prereqs are in place
94
95 check_prereqs()
96 {
97     echo "Checking prerequisites..."
98
99     # Check presence of CMake on the path
100     hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
101
102     # Check for clang
103     hash clang-$__ClangMajorVersion.$__ClangMinorVersion 2>/dev/null ||  hash clang$__ClangMajorVersion$__ClangMinorVersion 2>/dev/null ||  hash clang 2>/dev/null || { echo >&2 "Please install clang-$__ClangMajorVersion.$__ClangMinorVersion before running this script"; exit 1; }
104
105 }
106
107 build_coreclr()
108 {
109
110     if [ $__SkipCoreCLR == 1 ]; then
111         echo "Skipping CoreCLR build."
112         return
113     fi
114
115 # Event Logging Infrastructure
116    __GeneratedIntermediate="$__IntermediatesDir/Generated"
117    __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
118     if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
119         rm -rf  "$__GeneratedIntermediateEventProvider"
120     fi
121
122     if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
123         mkdir -p "$__GeneratedIntermediate/eventprovider"
124     fi
125
126     mkdir -p "$__GeneratedIntermediateEventProvider"
127     if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
128         echo "Laying out dynamically generated files consumed by the build system "
129         echo "Laying out dynamically generated Event Logging Test files"
130         $PYTHON -B -Wall -Werror "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
131
132         if  [[ $? != 0 ]]; then
133             exit
134         fi
135
136         #determine the logging system
137         case $__BuildOS in
138             Linux)
139                 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
140                 $PYTHON -B -Wall -Werror "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
141                 if  [[ $? != 0 ]]; then
142                     exit
143                 fi
144                 ;;
145             *)
146                 ;;
147         esac
148     fi
149
150     echo "Cleaning the temp folder of dynamically generated Event Logging files"
151     $PYTHON -B -Wall -Werror -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
152     if  [[ $? != 0 ]]; then
153         exit
154     fi
155
156     rm -rf "$__GeneratedIntermediateEventProvider"
157
158     # All set to commence the build
159
160     echo "Commencing build of native components for $__BuildOS.$__BuildArch.$__BuildType in $__IntermediatesDir"
161
162     cd "$__IntermediatesDir"
163
164     generator=""
165     buildFile="Makefile"
166     buildTool="make"
167     if [ $__UseNinja == 1 ]; then
168         generator="ninja"
169         buildFile="build.ninja"
170         buildTool="ninja"
171     fi
172
173     if [ $__SkipConfigure == 0 ]; then
174         # if msbuild is not supported, then set __SkipGenerateVersion to 1
175         if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
176         # Drop version.c file
177         __versionSourceFile=$__IntermediatesDir/version.cpp
178         if [ $__SkipGenerateVersion == 0 ]; then
179             "$__ProjectRoot/init-tools.sh" > "$__ProjectRoot/init-tools.log"
180             echo "Running: \"$__ProjectRoot/Tools/dotnetcli/dotnet\" \"$__ProjectRoot/Tools/MSBuild.exe\" \"$__ProjectRoot/build.proj\" /v:minimal /t:GenerateVersionSourceFile /p:NativeVersionSourceFile=$__versionSourceFile /p:GenerateVersionSourceFile=true /v:minimal $__OfficialBuildIdArg"
181             "$__ProjectRoot/Tools/dotnetcli/dotnet" "$__ProjectRoot/Tools/MSBuild.exe" "$__ProjectRoot/build.proj" /v:minimal /t:GenerateVersionSourceFile /p:NativeVersionSourceFile=$__versionSourceFile /p:GenerateVersionSourceFile=true /v:minimal $__OfficialBuildIdArg
182         else
183             __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
184             echo $__versionSourceLine > $__versionSourceFile
185         fi
186         # Regenerate the CMake solution
187         echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType $__CodeCoverage $__IncludeTests $generator $__cmakeargs"
188         "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$__cmakeargs"
189     fi
190
191     # Check that the makefiles were created.
192
193     if [ ! -f "$__IntermediatesDir/$buildFile" ]; then
194         echo "Failed to generate native component build project!"
195         exit 1
196     fi
197
198     # Get the number of processors available to the scheduler
199     # Other techniques such as `nproc` only get the number of
200     # processors available to a single process.
201     if [ `uname` = "FreeBSD" ]; then
202         NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
203     elif [ `uname` = "NetBSD" ]; then
204         NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
205     else
206         NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
207     fi
208
209     # Build CoreCLR
210
211     echo "Executing $buildTool install -j $NumProc $__UnprocessedBuildArgs"
212
213     $buildTool install -j $NumProc $__UnprocessedBuildArgs
214     if [ $? != 0 ]; then
215         echo "Failed to build coreclr components."
216         exit 1
217     fi
218 }
219
220 restoreBuildTools()
221 {
222     echo "Restoring BuildTools..."
223     $__ProjectRoot/init-tools.sh
224     if [ $? -ne 0 ]; then
225         echo "Failed to restore BuildTools."
226         exit 1
227     fi
228 }
229
230 isMSBuildOnNETCoreSupported()
231 {
232     # This needs to be updated alongwith corresponding changes to netci.groovy.
233     __isMSBuildOnNETCoreSupported=0
234
235     if [ "$__HostArch" == "x64" ]; then
236         if [ "$__HostOS" == "Linux" ]; then
237             case "$__DistroRid" in
238                 "centos.7-x64")
239                     __isMSBuildOnNETCoreSupported=1
240                     ;;
241                 "debian.8-x64")
242                     __isMSBuildOnNETCoreSupported=1
243                     ;;
244                 "fedora.23-x64")
245                     __isMSBuildOnNETCoreSupported=1
246                     ;;
247                 "opensuse.13.2-x64")
248                     __isMSBuildOnNETCoreSupported=1
249                     ;;
250                 "rhel.7.2-x64")
251                     __isMSBuildOnNETCoreSupported=1
252                     ;;
253                 "ubuntu.14.04-x64")
254                     __isMSBuildOnNETCoreSupported=1
255                     ;;
256                 "ubuntu.16.04-x64")
257                     __isMSBuildOnNETCoreSupported=1
258                     ;;
259                 *)
260             esac
261         elif [ "$__HostOS" == "OSX" ]; then
262             __isMSBuildOnNETCoreSupported=1
263         fi
264     fi
265 }
266
267 build_CoreLib_ni()
268 {
269     if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
270         echo "Generating native image for System.Private.CoreLib."
271         $__BinDir/crossgen $__BinDir/System.Private.CoreLib.dll
272         if [ $? -ne 0 ]; then
273             echo "Failed to generate native image for System.Private.CoreLib."
274             exit 1
275         fi
276
277         echo "Generating native image for MScorlib Facade."
278         $__BinDir/crossgen $__BinDir/mscorlib.dll
279         if [ $? -ne 0 ]; then
280             echo "Failed to generate native image for mscorlib facade."
281             exit 1
282         fi
283
284         if [ "$__BuildOS" == "Linux" ]; then
285             echo "Generating symbol file for System.Private.CoreLib."
286             $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.ni.dll
287             if [ $? -ne 0 ]; then
288                 echo "Failed to generate symbol file for System.Private.CoreLib."
289                 exit 1
290             fi
291         fi
292     fi
293 }
294
295 build_CoreLib()
296 {
297
298     if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
299         echo "System.Private.CoreLib.dll build unsupported."
300         return
301     fi
302
303     if [ $__SkipMSCorLib == 1 ]; then
304        echo "Skipping building System.Private.CoreLib."
305        return
306     fi
307
308     # Restore buildTools
309
310     restoreBuildTools
311
312     echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
313
314     # Invoke MSBuild
315     $__ProjectRoot/Tools/dotnetcli/dotnet "$__MSBuildPath" /nologo "$__ProjectRoot/build.proj" /verbosity:minimal "/fileloggerparameters:Verbosity=normal;LogFile=$__LogsDir/System.Private.CoreLib_$__BuildOS__$__BuildArch__$__BuildType.log" /t:Build /p:__BuildOS=$__BuildOS /p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__IntermediatesDir=$__IntermediatesDir /p:__RootBinDir=$__RootBinDir /p:BuildNugetPackage=false /p:UseSharedCompilation=false ${__SignTypeReal}
316
317     if [ $? -ne 0 ]; then
318         echo "Failed to build managed components."
319         exit 1
320     fi
321
322     # The cross build generates a crossgen with the target architecture.
323     if [ $__CrossBuild != 1 ]; then
324        # The architecture of host pc must be same architecture with target.
325        if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
326            build_CoreLib_ni
327        elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
328            build_CoreLib_ni
329        elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
330            build_CoreLib_ni
331        else 
332            exit 1
333        fi
334     fi 
335 }
336
337 generate_NugetPackages()
338 {
339     # We can only generate nuget package if we also support building mscorlib as part of this build.
340     if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
341         echo "Nuget package generation unsupported."
342         return
343     fi
344
345     # Since we can build mscorlib for this OS, did we build the native components as well?
346     if [ $__SkipCoreCLR == 1 ]; then
347         echo "Unable to generate nuget packages since native components were not built."
348         return
349     fi
350
351     if [ $__SkipMSCorLib == 1 ]; then
352         # Restore buildTools, since we skipped doing so with the mscorlib build.
353         restoreBuildTools
354
355        echo "Unable to generate Microsoft.NETCore.Runtime.CoreCLR nuget package since mscorlib was not built."
356     fi
357
358     echo "Generating nuget packages for "$__BuildOS
359
360     # Build the packages
361     $__ProjectRoot/Tools/dotnetcli/dotnet "$__MSBuildPath" /nologo "$__ProjectRoot/src/.nuget/packages.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:__RootBinDir=$__RootBinDir /p:BuildNugetPackage=false /p:UseSharedCompilation=false
362
363     if [ $? -ne 0 ]; then
364         echo "Failed to generate Nuget packages."
365         exit 1
366     fi
367 }
368
369 echo "Commencing CoreCLR Repo build"
370
371 # Argument types supported by this script:
372 #
373 # Build architecture - valid values are: x64, ARM.
374 # Build Type         - valid values are: Debug, Checked, Release
375 #
376 # Set the default arguments for build
377
378 # Obtain the location of the bash script to figure out where the root of the repo is.
379 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
380
381 # Use uname to determine what the CPU is.
382 CPUName=$(uname -p)
383 # Some Linux platforms report unknown for platform, but the arch for machine.
384 if [ "$CPUName" == "unknown" ]; then
385     CPUName=$(uname -m)
386 fi
387
388 case $CPUName in
389     i686)
390         echo "Unsupported CPU $CPUName detected, build might not succeed!"
391         __BuildArch=x86
392         __HostArch=x86
393         ;;
394
395     x86_64)
396         __BuildArch=x64
397         __HostArch=x64
398         ;;
399
400     armv7l)
401         echo "Unsupported CPU $CPUName detected, build might not succeed!"
402         __BuildArch=arm
403         __HostArch=arm
404         ;;
405
406     aarch64)
407         echo "Unsupported CPU $CPUName detected, build might not succeed!"
408         __BuildArch=arm64
409         __HostArch=arm64
410         ;;
411
412     *)
413         echo "Unknown CPU $CPUName detected, configuring as if for x64"
414         __BuildArch=x64
415         __HostArch=x64
416         ;;
417 esac
418
419 # Use uname to determine what the OS is.
420 OSName=$(uname -s)
421 case $OSName in
422     Linux)
423         __BuildOS=Linux
424         __HostOS=Linux
425         ;;
426
427     Darwin)
428         __BuildOS=OSX
429         __HostOS=OSX
430         ;;
431
432     FreeBSD)
433         __BuildOS=FreeBSD
434         __HostOS=FreeBSD
435         ;;
436
437     OpenBSD)
438         __BuildOS=OpenBSD
439         __HostOS=OpenBSD
440         ;;
441
442     NetBSD)
443         __BuildOS=NetBSD
444         __HostOS=NetBSD
445         ;;
446
447     SunOS)
448         __BuildOS=SunOS
449         __HostOS=SunOS
450         ;;
451
452     *)
453         echo "Unsupported OS $OSName detected, configuring as if for Linux"
454         __BuildOS=Linux
455         __HostOS=Linux
456         ;;
457 esac
458
459 __BuildType=Debug
460 __CodeCoverage=
461 __IncludeTests=Include_Tests
462
463 # Set the various build properties here so that CMake and MSBuild can pick them up
464 __ProjectDir="$__ProjectRoot"
465 __SourceDir="$__ProjectDir/src"
466 __PackagesDir="$__ProjectDir/packages"
467 __RootBinDir="$__ProjectDir/bin"
468 __UnprocessedBuildArgs=
469 __MSBCleanBuildArgs=
470 __UseNinja=0
471 __ConfigureOnly=0
472 __SkipConfigure=0
473 __SkipRestore=""
474 __SkipNuget=0
475 __SkipCoreCLR=0
476 __SkipMSCorLib=0
477 __CleanBuild=0
478 __VerboseBuild=0
479 __SignTypeReal=""
480 __CrossBuild=0
481 __ClangMajorVersion=0
482 __ClangMinorVersion=0
483 __MSBuildPath=$__ProjectRoot/Tools/MSBuild.exe
484 __NuGetPath="$__PackagesDir/NuGet.exe"
485 __DistroRid=""
486 __cmakeargs=""
487 __OfficialBuildIdArg=
488 __SkipGenerateVersion=0
489
490 while :; do
491     if [ $# -le 0 ]; then
492         break
493     fi
494
495     lowerI="$(echo $1 | awk '{print tolower($0)}')"
496     case $lowerI in
497         -\?|-h|--help)
498             usage
499             exit 1
500             ;;
501
502         x86)
503             __BuildArch=x86
504             ;;
505
506         x64)
507             __BuildArch=x64
508             ;;
509
510         arm)
511             __BuildArch=arm
512             ;;
513
514         arm-softfp)
515             __BuildArch=arm-softfp
516             ;;
517
518         arm64)
519             __BuildArch=arm64
520             ;;
521
522         debug)
523             __BuildType=Debug
524             ;;
525
526         checked)
527             __BuildType=Checked
528             ;;
529
530         release)
531             __BuildType=Release
532             ;;
533
534         coverage)
535             __CodeCoverage=Coverage
536             ;;
537
538         clean)
539             __CleanBuild=1
540             ;;
541
542         verbose)
543             __VerboseBuild=1
544             ;;
545
546         cross)
547             __CrossBuild=1
548             ;;
549
550         clang3.5)
551             __ClangMajorVersion=3
552             __ClangMinorVersion=5
553             ;;
554
555         clang3.6)
556             __ClangMajorVersion=3
557             __ClangMinorVersion=6
558             ;;
559
560         clang3.7)
561             __ClangMajorVersion=3
562             __ClangMinorVersion=7
563             ;;
564
565         clang3.8)
566             __ClangMajorVersion=3
567             __ClangMinorVersion=8
568             ;;
569
570         ninja)
571             __UseNinja=1
572             ;;
573
574         configureonly)
575             __ConfigureOnly=1
576             __SkipCoreCLR=1
577             __SkipMSCorLib=1
578             __IncludeTests=
579             ;;
580
581         skipconfigure)
582             __SkipConfigure=1
583             ;;
584
585         skipnative)
586             # Use "skipnative" to use the same option name as build.cmd.
587             __SkipCoreCLR=1
588             ;;
589
590         skipcoreclr)
591             # Accept "skipcoreclr" for backwards-compatibility.
592             __SkipCoreCLR=1
593             ;;
594
595         skipmscorlib)
596             __SkipMSCorLib=1
597             ;;
598
599         skipgenerateversion)
600             __SkipGenerateVersion=1
601             ;;
602
603         includetests)
604             ;;
605
606         skiptests)
607             __IncludeTests=
608             ;;
609
610         skiprestore)
611             __SkipRestore="/p:RestoreDuringBuild=true"
612             ;;
613
614         skipnuget)
615             __SkipNuget=1
616             ;;
617
618         disableoss)
619             __SignTypeReal="/p:SignType=real"
620             ;;
621
622         cmakeargs)
623             if [ -n "$2" ]; then
624                 __cmakeargs="$2"
625                 shift
626             else
627                 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
628                 exit 1
629             fi
630             ;;
631
632         bindir)
633             if [ -n "$2" ]; then
634                 __RootBinDir="$2"
635                 if [ ! -d $__RootBinDir ]; then
636                     mkdir $__RootBinDir
637                 fi
638                 __RootBinParent=$(dirname $__RootBinDir)
639                 __RootBinName=${__RootBinDir##*/}
640                 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
641                 shift
642             else
643                 echo "ERROR: 'bindir' requires a non-empty option argument"
644                 exit 1
645             fi
646             ;;
647
648         *)
649             if [[ $1 == "/p:OfficialBuildId="* ]]; then
650                 __OfficialBuildIdArg=$1
651             else
652                 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
653             fi
654             ;;
655     esac
656
657     shift
658 done
659
660 # Set default clang version
661 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
662     if [ $__CrossBuild == 1 ]; then
663         __ClangMajorVersion=3
664         __ClangMinorVersion=6
665     else
666         __ClangMajorVersion=3
667         __ClangMinorVersion=5
668     fi
669 fi
670
671 # Set dependent variables
672 __LogsDir="$__RootBinDir/Logs"
673
674 if [[ $__ConfigureOnly == 1 && $__SkipConfigure == 1 ]]; then
675     echo "configureonly and skipconfigure are mutually exclusive!"
676     exit 1
677 fi
678
679 # init the distro name
680 initDistroRid
681
682 # Set the remaining variables based upon the determined build configuration
683 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
684 __PackagesBinDir="$__BinDir/.nuget"
685 __ToolsDir="$__RootBinDir/tools"
686 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
687 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
688 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
689 __isMSBuildOnNETCoreSupported=0
690
691 # Init if MSBuild for .NET Core is supported for this platform
692 isMSBuildOnNETCoreSupported
693
694 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
695 # This is needed by CLI to function.
696 if [ -z "$HOME" ]; then
697     if [ ! -d "$__ProjectDir/temp_home" ]; then
698         mkdir temp_home
699     fi
700     export HOME=$__ProjectDir/temp_home
701     echo "HOME not defined; setting it to $HOME"
702 fi
703
704 # Specify path to be set for CMAKE_INSTALL_PREFIX.
705 # This is where all built CoreClr libraries will copied to.
706 export __CMakeBinDir="$__BinDir"
707
708 # Configure environment if we are doing a clean build.
709 if [ $__CleanBuild == 1 ]; then
710     clean
711 fi
712
713 # Configure environment if we are doing a verbose build
714 if [ $__VerboseBuild == 1 ]; then
715     export VERBOSE=1
716 fi
717
718 # Configure environment if we are doing a cross compile.
719 if [ $__CrossBuild == 1 ]; then
720     export CROSSCOMPILE=1
721     if ! [[ -n "$ROOTFS_DIR" ]]; then
722         export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
723     fi
724 fi
725
726 # Make the directories necessary for build if they don't exist
727
728 setup_dirs
729
730 # Check prereqs.
731
732 check_prereqs
733
734 # Build the coreclr (native) components.
735
736 build_coreclr
737
738 # Build System.Private.CoreLib.
739
740 build_CoreLib
741
742 # Generate nuget packages
743 if [ $__SkipNuget != 1 ]; then
744     generate_NugetPackages
745 fi
746
747
748 # Build complete
749
750 echo "Repo successfully built."
751 echo "Product binaries are available at $__BinDir"
752 exit 0