3 # resolve python-version to use
4 if [ "$PYTHON" == "" ] ; then
5 if ! PYTHON=$(command -v python || command -v python2 || command -v python 2.7)
7 echo "Unable to locate build-dependency python2.x!" 1>&2
12 # validate python-dependency
13 # useful in case of explicitly set option.
14 if ! command -v $PYTHON > /dev/null
16 echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2
22 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [configureonly] [skipconfigure] [skipnative] [skipmscorlib] [skiptests] [stripsymbols] [ignorewarnings] [cmakeargs] [bindir]"
23 echo "BuildArch can be: x64, x86, arm, armel, arm64"
24 echo "BuildType can be: debug, checked, release"
25 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
26 echo "ninja - target ninja instead of GNU make"
27 echo "clangx.y - optional argument to build using clang version x.y."
28 echo "cross - optional argument to signify cross compilation,"
29 echo " - will use ROOTFS_DIR environment variable if set."
30 echo "crosscomponent - optional argument to build cross-architecture component,"
31 echo " - will use CAC_ROOTFS_DIR environment variable if set."
32 echo "nopgooptimize - do not use profile guided optimizations."
33 echo "pgoinstrument - generate instrumented code for profile guided optimization enabled binaries."
34 echo "ibcinstrument - generate IBC-tuning-enabled native images when invoking crossgen."
35 echo "configureonly - do not perform any builds; just configure the build."
36 echo "skipconfigure - skip build configuration."
37 echo "skipnative - do not build native components."
38 echo "skipmscorlib - do not build mscorlib.dll."
39 echo "skiptests - skip the tests in the 'tests' subdirectory."
40 echo "skipnuget - skip building nuget packages."
41 echo "skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations."
42 echo "skipcrossgen - skip native image generation"
43 echo "verbose - optional argument to enable verbose build output."
44 echo "-skiprestore: skip restoring packages ^(default: packages are restored during build^)."
45 echo "-disableoss: Disable Open Source Signing for System.Private.CoreLib."
46 echo "-sequential: force a non-parallel build ^(default is to build in parallel"
47 echo " using all processors^)."
48 echo "-officialbuildid=^<ID^>: specify the official build ID to be used by this build."
49 echo "-Rebuild: passes /t:rebuild to the build projects."
50 echo "stripSymbols - Optional argument to strip native symbols during the build."
51 echo "skipgenerateversion - disable version generation even if MSBuild is supported."
52 echo "ignorewarnings - do not treat warnings as errors"
53 echo "cmakeargs - user-settable additional arguments passed to CMake."
54 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
55 echo "buildstandalonegc - builds the GC in a standalone mode. Can't be used with \"cmakeargs\"."
56 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
57 echo "numproc - set the number of build processes."
64 if [ "$__HostOS" == "Linux" ]; then
65 if [ -e /etc/os-release ]; then
66 source /etc/os-release
67 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
68 elif [ -e /etc/redhat-release ]; then
69 local redhatRelease=$(</etc/redhat-release)
70 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
71 __HostDistroRid="rhel.6-$__HostArch"
76 if [ "$__HostDistroRid" == "" ]; then
77 echo "WARNING: Can not determine runtime id for current distro."
83 if [ $__CrossBuild == 1 ]; then
84 if [ "$__BuildOS" == "Linux" ]; then
85 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
86 if [ -e $ROOTFS_DIR/android_platform ]; then
87 source $ROOTFS_DIR/android_platform
88 export __DistroRid="$RID"
90 echo "WARNING: Can not determine runtime id for current distro."
94 source $ROOTFS_DIR/etc/os-release
95 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
99 export __DistroRid="$__HostDistroRid"
102 # Portable builds target the base RID
103 if [ $__PortableBuild == 1 ]; then
104 if [ "$__BuildOS" == "Linux" ]; then
105 export __DistroRid="linux-$__BuildArch"
106 elif [ "$__BuildOS" == "OSX" ]; then
107 export __DistroRid="osx-$__BuildArch"
114 echo Setting up directories for build
116 mkdir -p "$__RootBinDir"
118 mkdir -p "$__LogsDir"
119 mkdir -p "$__IntermediatesDir"
121 if [ $__CrossBuild == 1 ]; then
122 mkdir -p "$__CrossComponentBinDir"
123 mkdir -p "$__CrossCompIntermediatesDir"
127 # Check the system to ensure the right prereqs are in place
131 echo "Checking prerequisites..."
133 # Check presence of CMake on the path
134 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
137 # Minimum required version of clang is version 3.9 for arm/armel cross build
138 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
139 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
140 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
145 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; }
151 # we only need optdata on a Release build
152 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
154 if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
155 echo "Restoring the OptimizationData package"
156 "$__ProjectRoot/run.sh" sync -optdata
158 echo "Failed to restore the optimization data package."
163 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
164 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
165 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
166 if [ ! -f $DotNetCli ]; then
167 "$__ProjectRoot/init-tools.sh"
169 echo "Failed to restore buildtools."
173 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
174 __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
175 __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
179 generate_event_logging_sources()
181 if [ $__SkipCoreCLR == 1 ]; then
185 # Event Logging Infrastructure
186 __GeneratedIntermediate="$__IntermediatesDir/Generated"
187 __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
188 __GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe_new"
190 if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
191 rm -rf "$__GeneratedIntermediateEventProvider"
194 if [[ -d "$__GeneratedIntermediateEventPipe" ]]; then
195 rm -rf "$__GeneratedIntermediateEventPipe"
198 if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
199 mkdir -p "$__GeneratedIntermediate/eventprovider"
202 if [[ ! -d "$__GeneratedIntermediate/eventpipe" ]]; then
203 mkdir -p "$__GeneratedIntermediate/eventpipe"
206 mkdir -p "$__GeneratedIntermediateEventProvider"
207 mkdir -p "$__GeneratedIntermediateEventPipe"
209 __PythonWarningFlags="-Wall"
210 if [[ $__IgnoreWarnings == 0 ]]; then
211 __PythonWarningFlags="$__PythonWarningFlags -Werror"
215 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
216 echo "Laying out dynamically generated files consumed by the build system "
217 echo "Laying out dynamically generated Event Logging Test files"
218 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
220 if [[ $? != 0 ]]; then
226 echo "Laying out dynamically generated EventPipe Implementation"
227 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst"
228 if [[ $? != 0 ]]; then
236 #determine the logging system
239 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
240 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
241 if [[ $? != 0 ]]; then
250 echo "Cleaning the temp folder of dynamically generated Event Logging files"
251 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
252 if [[ $? != 0 ]]; then
256 rm -rf "$__GeneratedIntermediateEventProvider"
258 echo "Cleaning the temp folder of dynamically generated EventPipe files"
259 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventpipe\",\"$__GeneratedIntermediateEventPipe\")"
260 if [[ $? != 0 ]]; then
264 rm -rf "$__GeneratedIntermediateEventPipe"
271 intermediatesForBuild="$3"
272 extraCmakeArguments="$4"
275 if [ $skipCondition == 1 ]; then
276 echo "Skipping $message build."
280 # All set to commence the build
281 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
286 if [ $__UseNinja == 1 ]; then
288 buildFile="build.ninja"
289 if ! buildTool=$(command -v ninja || command -v ninja-build); then
290 echo "Unable to locate ninja!" 1>&2
295 if [ $__SkipConfigure == 0 ]; then
296 # if msbuild is not supported, then set __SkipGenerateVersion to 1
297 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
298 # Drop version.cpp file
299 __versionSourceFile="$intermediatesForBuild/version.cpp"
300 if [ $__SkipGenerateVersion == 0 ]; then
302 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile $__RunArgs $__UnprocessedBuildArgs
304 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
305 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
306 if [ -e $__versionSourceFile ]; then
307 read existingVersionSourceLine < $__versionSourceFile
309 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
310 echo $__versionSourceLine > $__versionSourceFile
315 pushd "$intermediatesForBuild"
316 # Regenerate the CMake solution
317 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
318 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
322 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
323 echo "Failed to generate $message build project!"
328 if [ $__ConfigureOnly == 1 ]; then
329 echo "Finish configuration & skipping $message build."
333 # Check that the makefiles were created.
334 pushd "$intermediatesForBuild"
336 echo "Executing $buildTool install -j $__NumProc"
338 $buildTool install -j $__NumProc
340 echo "Failed to build $message."
347 build_cross_arch_component()
349 __SkipCrossArchBuild=1
351 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
352 if [[ "$__BuildArch" == "arm" && "$__CrossArch" == "x86" ]]; then
353 export CROSSCOMPILE=0
354 __SkipCrossArchBuild=0
356 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
357 if [ "$__HostArch" == "x64" ]; then
358 export CROSSCOMPILE=1
365 export __CMakeBinDir="$__CrossComponentBinDir"
366 export CROSSCOMPONENT=1
369 if [ $CROSSCOMPILE == 1 ]; then
370 TARGET_ROOTFS="$ROOTFS_DIR"
371 if [ -n "$CAC_ROOTFS_DIR" ]; then
372 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
374 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
378 __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_VERSION=$__PgoOptDataVersion -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize"
379 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
381 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
382 if [ -n "$TARGET_ROOTFS" ]; then
383 export ROOTFS_DIR="$TARGET_ROOTFS"
385 export CROSSCOMPONENT=
386 export CROSSCOMPILE=1
389 isMSBuildOnNETCoreSupported()
391 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
393 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
397 if [ "$__HostArch" == "x64" ]; then
398 if [ "$__HostOS" == "Linux" ]; then
399 __isMSBuildOnNETCoreSupported=1
400 # note: the RIDs below can use globbing patterns
401 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64" "alpine.3.6.*-x64" "rhel.6-x64" "")
402 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
404 if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
405 __isMSBuildOnNETCoreSupported=0
409 elif [ "$__HostOS" == "OSX" ]; then
410 __isMSBuildOnNETCoreSupported=1
418 if [ $__SkipCrossgen == 1 ]; then
419 echo "Skipping generating native image"
423 if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
424 echo "Generating native image for System.Private.CoreLib."
425 $__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
426 if [ $? -ne 0 ]; then
427 echo "Failed to generate native image for System.Private.CoreLib."
431 if [ "$__BuildOS" == "Linux" ]; then
432 echo "Generating symbol file for System.Private.CoreLib."
433 $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
434 if [ $? -ne 0 ]; then
435 echo "Failed to generate symbol file for System.Private.CoreLib."
445 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
446 echo "System.Private.CoreLib.dll build unsupported."
450 if [ $__SkipMSCorLib == 1 ]; then
451 echo "Skipping building System.Private.CoreLib."
455 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
459 if [[ "$__IbcTuning" -eq "" ]]; then
460 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
461 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
463 $__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 $__ExtraBuildArgs $__UnprocessedBuildArgs
465 if [ $? -ne 0 ]; then
466 echo "Failed to build managed components."
470 # The cross build generates a crossgen with the target architecture.
471 if [ $__CrossBuild != 1 ]; then
472 # The architecture of host pc must be same architecture with target.
473 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
475 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
477 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
485 generate_NugetPackages()
487 # We can only generate nuget package if we also support building mscorlib as part of this build.
488 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
489 echo "Nuget package generation unsupported."
493 # Since we can build mscorlib for this OS, did we build the native components as well?
494 if [ $__SkipCoreCLR == 1 ]; then
495 echo "Unable to generate nuget packages since native components were not built."
499 echo "Generating nuget packages for "$__BuildOS
500 echo "DistroRid is "$__DistroRid
501 echo "ROOTFS_DIR is "$ROOTFS_DIR
503 $__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
505 if [ $? -ne 0 ]; then
506 echo "Failed to generate Nuget packages."
511 echo "Commencing CoreCLR Repo build"
513 # Argument types supported by this script:
515 # Build architecture - valid values are: x64, ARM.
516 # Build Type - valid values are: Debug, Checked, Release
518 # Set the default arguments for build
520 # Obtain the location of the bash script to figure out where the root of the repo is.
521 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
523 # Use uname to determine what the CPU is.
525 # Some Linux platforms report unknown for platform, but the arch for machine.
526 if [ "$CPUName" == "unknown" ]; then
532 echo "Unsupported CPU $CPUName detected, build might not succeed!"
543 echo "Unsupported CPU $CPUName detected, build might not succeed!"
554 echo "Unknown CPU $CPUName detected, configuring as if for x64"
560 # Use uname to determine what the OS is.
594 echo "Unsupported OS $OSName detected, configuring as if for Linux"
602 __IncludeTests=Include_Tests
605 # Set the various build properties here so that CMake and MSBuild can pick them up
606 __ProjectDir="$__ProjectRoot"
607 __SourceDir="$__ProjectDir/src"
608 __PackagesDir="$__ProjectDir/packages"
609 __RootBinDir="$__ProjectDir/bin"
610 __UnprocessedBuildArgs=
624 __SkipRestoreOptData=0
627 __ClangMajorVersion=0
628 __ClangMinorVersion=0
629 __NuGetPath="$__PackagesDir/NuGet.exe"
633 __SkipGenerateVersion=0
636 __msbuildonunsupportedplatform=0
637 __PgoOptDataVersion=""
638 __IbcOptDataVersion=""
640 # Get the number of processors available to the scheduler
641 # Other techniques such as `nproc` only get the number of
642 # processors available to a single process.
643 if [ `uname` = "FreeBSD" ]; then
644 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
645 elif [ `uname` = "NetBSD" ]; then
646 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
648 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
652 if [ $# -le 0 ]; then
656 lowerI="$(echo $1 | awk '{print tolower($0)}')"
696 __CodeCoverage=Coverage
703 -portablebuild=false)
712 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
716 __ClangMajorVersion=3
717 __ClangMinorVersion=5
721 __ClangMajorVersion=3
722 __ClangMinorVersion=6
726 __ClangMajorVersion=3
727 __ClangMinorVersion=7
731 __ClangMajorVersion=3
732 __ClangMinorVersion=8
736 __ClangMajorVersion=3
737 __ClangMinorVersion=9
741 __ClangMajorVersion=4
742 __ClangMinorVersion=0
755 __SkipRestoreOptData=1
759 __IbcTuning="/Tuning"
773 # Use "skipnative" to use the same option name as build.cmd.
778 # Accept "skipcoreclr" for backwards-compatibility.
791 __SkipGenerateVersion=1
795 __SkipRestoreOptData=1
815 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
820 __cmakeargs="$__cmakeargs $2"
823 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
831 if [ ! -d $__RootBinDir ]; then
834 __RootBinParent=$(dirname $__RootBinDir)
835 __RootBinName=${__RootBinDir##*/}
836 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
839 echo "ERROR: 'bindir' requires a non-empty option argument"
844 __cmakeargs="$__cmakeargs -DFEATURE_STANDALONE_GC=1 -DFEATURE_STANDALONE_GC_ONLY=1"
846 msbuildonunsupportedplatform)
847 __msbuildonunsupportedplatform=1
854 echo "ERROR: 'numproc' requires a non-empty option argument"
859 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
866 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
868 # Configure environment if we are doing a verbose build
869 if [ $__VerboseBuild == 1 ]; then
871 __RunArgs="$__RunArgs -verbose"
874 # Set default clang version
875 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
876 if [ $__CrossBuild == 1 ]; then
877 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
878 __ClangMajorVersion=3
879 __ClangMinorVersion=9
881 __ClangMajorVersion=3
882 __ClangMinorVersion=6
886 __ClangMajorVersion=3
887 __ClangMinorVersion=5
891 if [[ "$__BuildArch" == "armel" ]]; then
892 # Armel cross build is Tizen specific and does not support Portable RID build
896 if [ $__PortableBuild == 0 ]; then
897 __RunArgs="$__RunArgs -PortableBuild=false"
900 # Set dependent variables
901 __LogsDir="$__RootBinDir/Logs"
903 # init the host distro name
906 # Set the remaining variables based upon the determined build configuration
907 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
908 __PackagesBinDir="$__BinDir/.nuget"
909 __ToolsDir="$__RootBinDir/tools"
910 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
911 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
912 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
913 __isMSBuildOnNETCoreSupported=0
914 __CrossComponentBinDir="$__BinDir"
915 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
917 __CrossArch="$__HostArch"
918 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
921 if [ $__CrossBuild == 1 ]; then
922 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
924 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
925 __CrossgenExe="$__CrossComponentBinDir/crossgen"
927 # Init if MSBuild for .NET Core is supported for this platform
928 isMSBuildOnNETCoreSupported
930 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
931 # This is needed by CLI to function.
932 if [ -z "$HOME" ]; then
933 if [ ! -d "$__ProjectDir/temp_home" ]; then
936 export HOME=$__ProjectDir/temp_home
937 echo "HOME not defined; setting it to $HOME"
940 # Specify path to be set for CMAKE_INSTALL_PREFIX.
941 # This is where all built CoreClr libraries will copied to.
942 export __CMakeBinDir="$__BinDir"
944 # Configure environment if we are doing a cross compile.
945 if [ $__CrossBuild == 1 ]; then
946 export CROSSCOMPILE=1
947 if ! [[ -n "$ROOTFS_DIR" ]]; then
948 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
952 # init the target distro name
955 # Make the directories necessary for build if they don't exist
961 # Restore the package containing profile counts for profile-guided optimizations
964 # Generate event logging infrastructure sources
965 generate_event_logging_sources
967 # Build the coreclr (native) components.
968 __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_VERSION=$__PgoOptDataVersion -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize"
969 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
971 # Build cross-architecture components
972 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
973 build_cross_arch_component
976 # Build System.Private.CoreLib.
980 # Generate nuget packages
981 if [ $__SkipNuget != 1 ]; then
982 generate_NugetPackages
988 echo "Repo successfully built."
989 echo "Product binaries are available at $__BinDir"