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