Merge pull request #7310 from wateret/for-7002-2
[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                 *)
262             esac
263         elif [ "$__HostOS" == "OSX" ]; then
264             __isMSBuildOnNETCoreSupported=1
265         fi
266     fi
267 }
268
269 build_CoreLib_ni()
270 {
271     if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
272         echo "Generating native image for System.Private.CoreLib."
273         $__BinDir/crossgen $__BinDir/System.Private.CoreLib.dll
274         if [ $? -ne 0 ]; then
275             echo "Failed to generate native image for System.Private.CoreLib."
276             exit 1
277         fi
278
279         echo "Generating native image for MScorlib Facade."
280         $__BinDir/crossgen $__BinDir/mscorlib.dll
281         if [ $? -ne 0 ]; then
282             echo "Failed to generate native image for mscorlib facade."
283             exit 1
284         fi
285
286         if [ "$__BuildOS" == "Linux" ]; then
287             echo "Generating symbol file for System.Private.CoreLib."
288             $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.ni.dll
289             if [ $? -ne 0 ]; then
290                 echo "Failed to generate symbol file for System.Private.CoreLib."
291                 exit 1
292             fi
293         fi
294     fi
295 }
296
297 build_CoreLib()
298 {
299
300     if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
301         echo "System.Private.CoreLib.dll build unsupported."
302         return
303     fi
304
305     if [ $__SkipMSCorLib == 1 ]; then
306        echo "Skipping building System.Private.CoreLib."
307        return
308     fi
309
310     echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
311
312     # Invoke MSBuild
313     $__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
314
315     if [ $? -ne 0 ]; then
316         echo "Failed to build managed components."
317         exit 1
318     fi
319
320     # The cross build generates a crossgen with the target architecture.
321     if [ $__CrossBuild != 1 ]; then
322        # The architecture of host pc must be same architecture with target.
323        if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
324            build_CoreLib_ni
325        elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
326            build_CoreLib_ni
327        elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
328            build_CoreLib_ni
329        else 
330            exit 1
331        fi
332     fi 
333 }
334
335 generate_NugetPackages()
336 {
337     # We can only generate nuget package if we also support building mscorlib as part of this build.
338     if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
339         echo "Nuget package generation unsupported."
340         return
341     fi
342
343     # Since we can build mscorlib for this OS, did we build the native components as well?
344     if [ $__SkipCoreCLR == 1 ]; then
345         echo "Unable to generate nuget packages since native components were not built."
346         return
347     fi
348
349     echo "Generating nuget packages for "$__BuildOS
350
351     # Build the packages
352     $__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
353
354     if [ $? -ne 0 ]; then
355         echo "Failed to generate Nuget packages."
356         exit 1
357     fi
358 }
359
360 echo "Commencing CoreCLR Repo build"
361
362 # Argument types supported by this script:
363 #
364 # Build architecture - valid values are: x64, ARM.
365 # Build Type         - valid values are: Debug, Checked, Release
366 #
367 # Set the default arguments for build
368
369 # Obtain the location of the bash script to figure out where the root of the repo is.
370 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
371
372 # Use uname to determine what the CPU is.
373 CPUName=$(uname -p)
374 # Some Linux platforms report unknown for platform, but the arch for machine.
375 if [ "$CPUName" == "unknown" ]; then
376     CPUName=$(uname -m)
377 fi
378
379 case $CPUName in
380     i686)
381         echo "Unsupported CPU $CPUName detected, build might not succeed!"
382         __BuildArch=x86
383         __HostArch=x86
384         ;;
385
386     x86_64)
387         __BuildArch=x64
388         __HostArch=x64
389         ;;
390
391     armv7l)
392         echo "Unsupported CPU $CPUName detected, build might not succeed!"
393         __BuildArch=arm
394         __HostArch=arm
395         ;;
396
397     aarch64)
398         echo "Unsupported CPU $CPUName detected, build might not succeed!"
399         __BuildArch=arm64
400         __HostArch=arm64
401         ;;
402
403     *)
404         echo "Unknown CPU $CPUName detected, configuring as if for x64"
405         __BuildArch=x64
406         __HostArch=x64
407         ;;
408 esac
409
410 # Use uname to determine what the OS is.
411 OSName=$(uname -s)
412 case $OSName in
413     Linux)
414         __BuildOS=Linux
415         __HostOS=Linux
416         ;;
417
418     Darwin)
419         __BuildOS=OSX
420         __HostOS=OSX
421         ;;
422
423     FreeBSD)
424         __BuildOS=FreeBSD
425         __HostOS=FreeBSD
426         ;;
427
428     OpenBSD)
429         __BuildOS=OpenBSD
430         __HostOS=OpenBSD
431         ;;
432
433     NetBSD)
434         __BuildOS=NetBSD
435         __HostOS=NetBSD
436         ;;
437
438     SunOS)
439         __BuildOS=SunOS
440         __HostOS=SunOS
441         ;;
442
443     *)
444         echo "Unsupported OS $OSName detected, configuring as if for Linux"
445         __BuildOS=Linux
446         __HostOS=Linux
447         ;;
448 esac
449
450 __BuildType=Debug
451 __CodeCoverage=
452 __IncludeTests=Include_Tests
453
454 # Set the various build properties here so that CMake and MSBuild can pick them up
455 __ProjectDir="$__ProjectRoot"
456 __SourceDir="$__ProjectDir/src"
457 __PackagesDir="$__ProjectDir/packages"
458 __RootBinDir="$__ProjectDir/bin"
459 __UnprocessedBuildArgs=
460 __RunArgs=
461 __MSBCleanBuildArgs=
462 __UseNinja=0
463 __VerboseBuild=0
464 __PgoInstrument=0
465 __ConfigureOnly=0
466 __SkipConfigure=0
467 __SkipRestore=""
468 __SkipNuget=0
469 __SkipCoreCLR=0
470 __SkipMSCorLib=0
471 __CrossBuild=0
472 __ClangMajorVersion=0
473 __ClangMinorVersion=0
474 __NuGetPath="$__PackagesDir/NuGet.exe"
475 __DistroRid=""
476 __cmakeargs=""
477 __SkipGenerateVersion=0
478
479 while :; do
480     if [ $# -le 0 ]; then
481         break
482     fi
483
484     lowerI="$(echo $1 | awk '{print tolower($0)}')"
485     case $lowerI in
486         -\?|-h|--help)
487             usage
488             exit 1
489             ;;
490
491         x86)
492             __BuildArch=x86
493             ;;
494
495         x64)
496             __BuildArch=x64
497             ;;
498
499         arm)
500             __BuildArch=arm
501             ;;
502
503         arm-softfp)
504             __BuildArch=arm-softfp
505             ;;
506
507         arm64)
508             __BuildArch=arm64
509             ;;
510
511         debug)
512             __BuildType=Debug
513             ;;
514
515         checked)
516             __BuildType=Checked
517             ;;
518
519         release)
520             __BuildType=Release
521             ;;
522
523         coverage)
524             __CodeCoverage=Coverage
525             ;;
526
527         cross)
528             __CrossBuild=1
529             ;;
530
531                 verbose)
532         __VerboseBuild=1
533         ;;
534
535         clang3.5)
536             __ClangMajorVersion=3
537             __ClangMinorVersion=5
538             ;;
539
540         clang3.6)
541             __ClangMajorVersion=3
542             __ClangMinorVersion=6
543             ;;
544
545         clang3.7)
546             __ClangMajorVersion=3
547             __ClangMinorVersion=7
548             ;;
549
550         clang3.8)
551             __ClangMajorVersion=3
552             __ClangMinorVersion=8
553             ;;
554
555         clang3.9)
556             __ClangMajorVersion=3
557             __ClangMinorVersion=9
558             ;;
559
560         ninja)
561             __UseNinja=1
562             ;;
563
564         pgoinstrument)
565             __PgoInstrument=1
566             ;;
567
568         configureonly)
569             __ConfigureOnly=1
570             __SkipMSCorLib=1
571             __SkipNuget=1
572             __IncludeTests=
573             ;;
574
575         skipconfigure)
576             __SkipConfigure=1
577             ;;
578
579         skipnative)
580             # Use "skipnative" to use the same option name as build.cmd.
581             __SkipCoreCLR=1
582             ;;
583
584         skipcoreclr)
585             # Accept "skipcoreclr" for backwards-compatibility.
586             __SkipCoreCLR=1
587             ;;
588
589         skipmscorlib)
590             __SkipMSCorLib=1
591             ;;
592
593         skipgenerateversion)
594             __SkipGenerateVersion=1
595             ;;
596
597         includetests)
598             ;;
599
600         skiptests)
601             __IncludeTests=
602             ;;
603
604         skipnuget)
605             __SkipNuget=1
606             ;;
607
608         cmakeargs)
609             if [ -n "$2" ]; then
610                 __cmakeargs="$2"
611                 shift
612             else
613                 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
614                 exit 1
615             fi
616             ;;
617
618         bindir)
619             if [ -n "$2" ]; then
620                 __RootBinDir="$2"
621                 if [ ! -d $__RootBinDir ]; then
622                     mkdir $__RootBinDir
623                 fi
624                 __RootBinParent=$(dirname $__RootBinDir)
625                 __RootBinName=${__RootBinDir##*/}
626                 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
627                 shift
628             else
629                 echo "ERROR: 'bindir' requires a non-empty option argument"
630                 exit 1
631             fi
632             ;;
633
634         *)
635             __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
636             ;;
637     esac
638
639     shift
640 done
641
642 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
643
644 # Configure environment if we are doing a verbose build
645 if [ $__VerboseBuild == 1 ]; then
646     export VERBOSE=1
647         __RunArgs="$__RunArgs -verbose"
648 fi
649
650 # Set default clang version
651 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
652     if [ $__CrossBuild == 1 ]; then
653         __ClangMajorVersion=3
654         __ClangMinorVersion=6
655     else
656         __ClangMajorVersion=3
657         __ClangMinorVersion=5
658     fi
659 fi
660
661 # Set dependent variables
662 __LogsDir="$__RootBinDir/Logs"
663
664 # init the distro name
665 initDistroRid
666
667 # Set the remaining variables based upon the determined build configuration
668 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
669 __PackagesBinDir="$__BinDir/.nuget"
670 __ToolsDir="$__RootBinDir/tools"
671 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
672 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
673 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
674 __isMSBuildOnNETCoreSupported=0
675
676 # Init if MSBuild for .NET Core is supported for this platform
677 isMSBuildOnNETCoreSupported
678
679 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
680 # This is needed by CLI to function.
681 if [ -z "$HOME" ]; then
682     if [ ! -d "$__ProjectDir/temp_home" ]; then
683         mkdir temp_home
684     fi
685     export HOME=$__ProjectDir/temp_home
686     echo "HOME not defined; setting it to $HOME"
687 fi
688
689 # Specify path to be set for CMAKE_INSTALL_PREFIX.
690 # This is where all built CoreClr libraries will copied to.
691 export __CMakeBinDir="$__BinDir"
692
693 # Configure environment if we are doing a cross compile.
694 if [ $__CrossBuild == 1 ]; then
695     export CROSSCOMPILE=1
696     if ! [[ -n "$ROOTFS_DIR" ]]; then
697         export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
698     fi
699 fi
700
701 # Make the directories necessary for build if they don't exist
702
703 setup_dirs
704
705 # Check prereqs.
706
707 check_prereqs
708
709 # Build the coreclr (native) components.
710
711 build_coreclr
712
713 # Build System.Private.CoreLib.
714
715 build_CoreLib
716
717 # Generate nuget packages
718 if [ $__SkipNuget != 1 ]; then
719     generate_NugetPackages
720 fi
721
722
723 # Build complete
724
725 echo "Repo successfully built."
726 echo "Product binaries are available at $__BinDir"
727 exit 0