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