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