3 # resolve python-version to use
4 if [ "$PYTHON" == "" ] ; then
5 if ! PYTHON=$(command -v python2.7 || command -v python2 || command -v python)
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 "-officialbuildid=^<ID^>: specify the official build ID to be used by this build."
47 echo "-Rebuild: passes /t:rebuild to the build projects."
48 echo "-stripSymbols - Optional argument to strip native symbols during the build."
49 echo "-skipgenerateversion - disable version generation even if MSBuild is supported."
50 echo "-ignorewarnings - do not treat warnings as errors"
51 echo "-cmakeargs - user-settable additional arguments passed to CMake."
52 echo "-bindir - output directory (defaults to $__ProjectRoot/bin)"
53 echo "-msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
54 echo "-numproc - set the number of build processes."
61 if [ "$__HostOS" == "Linux" ]; then
62 if [ -e /etc/os-release ]; then
63 source /etc/os-release
64 if [[ $ID == "alpine" || $ID == "rhel" ]]; then
65 # remove the last version digit
66 VERSION_ID=${VERSION_ID%.*}
68 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
69 elif [ -e /etc/redhat-release ]; then
70 local redhatRelease=$(</etc/redhat-release)
71 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
72 __HostDistroRid="rhel.6-$__HostArch"
76 if [ "$__HostOS" == "FreeBSD" ]; then
77 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
78 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
81 if [ "$__HostDistroRid" == "" ]; then
82 echo "WARNING: Can not determine runtime id for current distro."
88 if [ $__CrossBuild == 1 ]; then
89 if [ "$__BuildOS" == "Linux" ]; then
90 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
91 if [ -e $ROOTFS_DIR/android_platform ]; then
92 source $ROOTFS_DIR/android_platform
93 export __DistroRid="$RID"
95 echo "WARNING: Can not determine runtime id for current distro."
99 source $ROOTFS_DIR/etc/os-release
100 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
104 export __DistroRid="$__HostDistroRid"
107 if [ "$__BuildOS" == "OSX" ]; then
111 # Portable builds target the base RID
112 if [ $__PortableBuild == 1 ]; then
113 if [ "$__BuildOS" == "Linux" ]; then
114 export __DistroRid="linux-$__BuildArch"
115 elif [ "$__BuildOS" == "OSX" ]; then
116 export __DistroRid="osx-$__BuildArch"
117 elif [ "$__BuildOS" == "FreeBSD" ]; then
118 export __DistroRid="freebsd-$__BuildArch"
125 echo Setting up directories for build
127 mkdir -p "$__RootBinDir"
129 mkdir -p "$__LogsDir"
130 mkdir -p "$__IntermediatesDir"
132 if [ $__CrossBuild == 1 ]; then
133 mkdir -p "$__CrossComponentBinDir"
134 mkdir -p "$__CrossCompIntermediatesDir"
138 # Check the system to ensure the right prereqs are in place
142 echo "Checking prerequisites..."
144 # Check presence of CMake on the path
145 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
148 # Minimum required version of clang is version 3.9 for arm/armel cross build
149 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
150 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
151 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
156 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; }
162 # we only need optdata on a Release build
163 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
165 if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
166 echo "Restoring the OptimizationData package"
167 "$__ProjectRoot/run.sh" sync -optdata
169 echo "Failed to restore the optimization data package."
174 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
175 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
176 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
177 if [ ! -f $DotNetCli ]; then
178 source "$__ProjectRoot/init-tools.sh"
180 echo "Failed to restore buildtools."
184 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
185 __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
186 __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
190 generate_event_logging_sources()
192 if [ $__SkipCoreCLR == 1 ]; then
196 # Event Logging Infrastructure
197 __GeneratedIntermediate="$__IntermediatesDir/eventing"
198 __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider"
199 __GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe"
201 __PythonWarningFlags="-Wall"
202 if [[ $__IgnoreWarnings == 0 ]]; then
203 __PythonWarningFlags="$__PythonWarningFlags -Werror"
207 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
208 echo "Laying out dynamically generated files consumed by the build system "
209 echo "Laying out dynamically generated Event test files, etmdummy stub functions, and external linkages"
210 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventing.py" --inc $__IntermediatesDir/src/inc --dummy $__IntermediatesDir/src/inc/etmdummy.h --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --testdir "$__GeneratedIntermediateEventProvider/tests"
212 if [[ $? != 0 ]]; then
216 echo "Laying out dynamically generated EventPipe Implementation"
217 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe"
219 #determine the logging system
222 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
223 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genLttngProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
224 if [[ $? != 0 ]]; then
229 echo "Laying out dummy event logging provider"
230 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genDummyProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
231 if [[ $? != 0 ]]; then
237 if [[ $__CrossBuild == 1 ]]; then
238 cp -r $__GeneratedIntermediate $__CrossCompIntermediatesDir
247 intermediatesForBuild="$3"
248 extraCmakeArguments="$4"
251 if [ $skipCondition == 1 ]; then
252 echo "Skipping $message build."
256 # All set to commence the build
257 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
262 if [ $__UseNinja == 1 ]; then
264 buildFile="build.ninja"
265 if ! buildTool=$(command -v ninja || command -v ninja-build); then
266 echo "Unable to locate ninja!" 1>&2
271 if [ $__SkipConfigure == 0 ]; then
272 # if msbuild is not supported, then set __SkipGenerateVersion to 1
273 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
274 # Drop version.cpp file
275 __versionSourceFile="$intermediatesForBuild/version.cpp"
276 if [ $__SkipGenerateVersion == 0 ]; then
278 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile -MsBuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log" $__RunArgs $__UnprocessedBuildArgs
280 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
281 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
282 if [ -e $__versionSourceFile ]; then
283 read existingVersionSourceLine < $__versionSourceFile
285 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
286 echo $__versionSourceLine > $__versionSourceFile
291 pushd "$intermediatesForBuild"
292 # Regenerate the CMake solution
293 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
294 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
298 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
299 echo "Failed to generate $message build project!"
304 if [ $__ConfigureOnly == 1 ]; then
305 echo "Finish configuration & skipping $message build."
309 # Check that the makefiles were created.
310 pushd "$intermediatesForBuild"
312 echo "Executing $buildTool install -j $__NumProc"
314 $buildTool install -j $__NumProc
316 echo "Failed to build $message."
323 build_cross_arch_component()
325 __SkipCrossArchBuild=1
327 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
328 if [[ ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") && "$__CrossArch" == "x86" ]]; then
329 export CROSSCOMPILE=0
330 __SkipCrossArchBuild=0
332 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
333 if [ "$__HostArch" == "x64" ]; then
334 export CROSSCOMPILE=1
341 export __CMakeBinDir="$__CrossComponentBinDir"
342 export CROSSCOMPONENT=1
345 if [ $CROSSCOMPILE == 1 ]; then
346 TARGET_ROOTFS="$ROOTFS_DIR"
347 if [ -n "$CAC_ROOTFS_DIR" ]; then
348 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
350 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
354 __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"
355 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
357 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
358 if [ -n "$TARGET_ROOTFS" ]; then
359 export ROOTFS_DIR="$TARGET_ROOTFS"
361 export CROSSCOMPONENT=
362 export CROSSCOMPILE=1
365 isMSBuildOnNETCoreSupported()
367 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
369 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
373 if [ "$__HostArch" == "x64" ]; then
374 if [ "$__HostOS" == "Linux" ]; then
375 __isMSBuildOnNETCoreSupported=1
376 # note: the RIDs below can use globbing patterns
377 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
378 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
380 if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
381 __isMSBuildOnNETCoreSupported=0
385 elif [ "$__HostOS" == "OSX" ]; then
386 __isMSBuildOnNETCoreSupported=1
394 if [ $__SkipCrossgen == 1 ]; then
395 echo "Skipping generating native image"
399 if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
400 echo "Generating native image for System.Private.CoreLib."
401 echo "$__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll"
402 $__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
403 if [ $? -ne 0 ]; then
404 echo "Failed to generate native image for System.Private.CoreLib."
408 if [ "$__BuildOS" == "Linux" ]; then
409 echo "Generating symbol file for System.Private.CoreLib."
410 $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
411 if [ $? -ne 0 ]; then
412 echo "Failed to generate symbol file for System.Private.CoreLib."
422 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
423 echo "System.Private.CoreLib.dll build unsupported."
427 if [ $__SkipMSCorLib == 1 ]; then
428 echo "Skipping building System.Private.CoreLib."
432 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
436 if [[ "$__IbcTuning" -eq "" ]]; then
437 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
438 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
440 $__ProjectRoot/run.sh build -Project=$__ProjectDir/build.proj -MsBuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log" -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
442 if [ $? -ne 0 ]; then
443 echo "Failed to build managed components."
447 # The cross build generates a crossgen with the target architecture.
448 if [ $__CrossBuild != 1 ]; then
449 # The architecture of host pc must be same architecture with target.
450 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
452 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
454 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
462 generate_NugetPackages()
464 # We can only generate nuget package if we also support building mscorlib as part of this build.
465 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
466 echo "Nuget package generation unsupported."
470 # Since we can build mscorlib for this OS, did we build the native components as well?
471 if [ $__SkipCoreCLR == 1 ]; then
472 echo "Unable to generate nuget packages since native components were not built."
476 echo "Generating nuget packages for "$__BuildOS
477 echo "DistroRid is "$__DistroRid
478 echo "ROOTFS_DIR is "$ROOTFS_DIR
480 $__ProjectRoot/run.sh build -Project=$__SourceDir/.nuget/packages.builds -MsBuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log" -MsBuildLog="/flp:Verbosity=normal;LogFile=$__LogsDir/Nuget_$__BuildOS__$__BuildArch__$__BuildType.log" -BuildTarget -__IntermediatesDir=$__IntermediatesDir -__RootBinDir=$__RootBinDir -BuildNugetPackage=false -UseSharedCompilation=false $__RunArgs $__UnprocessedBuildArgs
482 if [ $? -ne 0 ]; then
483 echo "Failed to generate Nuget packages."
488 echo "Commencing CoreCLR Repo build"
490 # Argument types supported by this script:
492 # Build architecture - valid values are: x64, ARM.
493 # Build Type - valid values are: Debug, Checked, Release
495 # Set the default arguments for build
497 # Obtain the location of the bash script to figure out where the root of the repo is.
498 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
500 # Use uname to determine what the CPU is.
502 # Some Linux platforms report unknown for platform, but the arch for machine.
503 if [ "$CPUName" == "unknown" ]; then
509 echo "Unsupported CPU $CPUName detected, build might not succeed!"
520 echo "Unsupported CPU $CPUName detected, build might not succeed!"
535 echo "Unknown CPU $CPUName detected, configuring as if for x64"
541 # Use uname to determine what the OS is.
575 echo "Unsupported OS $OSName detected, configuring as if for Linux"
583 __IncludeTests=Include_Tests
586 # Set the various build properties here so that CMake and MSBuild can pick them up
587 __ProjectDir="$__ProjectRoot"
588 __SourceDir="$__ProjectDir/src"
589 __PackagesDir="${DotNetRestorePackagesPath:-${__ProjectDir}/packages}"
590 __RootBinDir="$__ProjectDir/bin"
591 __UnprocessedBuildArgs=
605 __SkipRestoreOptData=0
608 __ClangMajorVersion=0
609 __ClangMinorVersion=0
610 __NuGetPath="$__PackagesDir/NuGet.exe"
614 __SkipGenerateVersion=0
617 __msbuildonunsupportedplatform=0
618 __PgoOptDataVersion=""
619 __IbcOptDataVersion=""
621 # Get the number of processors available to the scheduler
622 # Other techniques such as `nproc` only get the number of
623 # processors available to a single process.
624 if [ `uname` = "FreeBSD" ]; then
625 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
626 elif [ `uname` = "NetBSD" ]; then
627 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
628 elif [ `uname` = "Darwin" ]; then
629 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
631 __NumProc=$(nproc --all)
635 if [ $# -le 0 ]; then
639 lowerI="$(echo $1 | awk '{print tolower($0)}')"
679 __CodeCoverage=Coverage
686 -portablebuild=false)
694 stripsymbols|-stripsymbols)
695 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
699 __ClangMajorVersion=3
700 __ClangMinorVersion=5
704 __ClangMajorVersion=3
705 __ClangMinorVersion=6
709 __ClangMajorVersion=3
710 __ClangMinorVersion=7
714 __ClangMajorVersion=3
715 __ClangMinorVersion=8
719 __ClangMajorVersion=3
720 __ClangMinorVersion=9
724 __ClangMajorVersion=4
725 __ClangMinorVersion=0
732 pgoinstrument|-pgoinstrument)
736 nopgooptimize|-nopgooptimize)
738 __SkipRestoreOptData=1
741 ibcinstrument|-ibcinstrument)
742 __IbcTuning="/Tuning"
745 configureonly|-configureonly)
751 skipconfigure|-skipconfigure)
755 skipnative|-skipnative)
756 # Use "skipnative" to use the same option name as build.cmd.
760 skipcoreclr|-skipcoreclr)
761 # Accept "skipcoreclr" for backwards-compatibility.
765 crosscomponent|-crosscomponent)
769 skipmscorlib|-skipmscorlib)
773 skipgenerateversion|-skipgenerateversion)
774 __SkipGenerateVersion=1
777 skiprestoreoptdata|-skiprestoreoptdata)
778 __SkipRestoreOptData=1
781 skipcrossgen|-skipcrossgen)
785 includetests|-includetests)
788 skiptests|-skiptests)
792 skipnuget|-skipnuget)
796 ignorewarnings|-ignorewarnings)
798 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
801 cmakeargs|-cmakeargs)
803 __cmakeargs="$__cmakeargs $2"
806 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
814 if [ ! -d $__RootBinDir ]; then
817 __RootBinParent=$(dirname $__RootBinDir)
818 __RootBinName=${__RootBinDir##*/}
819 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
822 echo "ERROR: 'bindir' requires a non-empty option argument"
826 msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
827 __msbuildonunsupportedplatform=1
834 echo "ERROR: 'numproc' requires a non-empty option argument"
843 echo "ERROR: 'osgroup' requires a non-empty option argument"
849 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
856 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
858 # Configure environment if we are doing a verbose build
859 if [ $__VerboseBuild == 1 ]; then
861 __RunArgs="$__RunArgs -verbose"
864 # Set default clang version
865 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
866 __ClangMajorVersion=3
867 __ClangMinorVersion=9
870 if [[ "$__BuildArch" == "armel" ]]; then
871 # Armel cross build is Tizen specific and does not support Portable RID build
875 if [ $__PortableBuild == 0 ]; then
876 __RunArgs="$__RunArgs -PortableBuild=false"
879 # Set dependent variables
880 __LogsDir="$__RootBinDir/Logs"
882 # init the host distro name
885 # Set the remaining variables based upon the determined build configuration
886 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
887 __PackagesBinDir="$__BinDir/.nuget"
888 __ToolsDir="$__RootBinDir/tools"
889 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
890 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
891 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
892 __isMSBuildOnNETCoreSupported=0
893 __CrossComponentBinDir="$__BinDir"
894 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
896 __CrossArch="$__HostArch"
897 if [[ "$__HostArch" == "x64" && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
900 if [ $__CrossBuild == 1 ]; then
901 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
903 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
904 __CrossgenExe="$__CrossComponentBinDir/crossgen"
906 # Init if MSBuild for .NET Core is supported for this platform
907 isMSBuildOnNETCoreSupported
909 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
910 # This is needed by CLI to function.
911 if [ -z "$HOME" ]; then
912 if [ ! -d "$__ProjectDir/temp_home" ]; then
915 export HOME=$__ProjectDir/temp_home
916 echo "HOME not defined; setting it to $HOME"
919 # Specify path to be set for CMAKE_INSTALL_PREFIX.
920 # This is where all built CoreClr libraries will copied to.
921 export __CMakeBinDir="$__BinDir"
923 # Configure environment if we are doing a cross compile.
924 if [ $__CrossBuild == 1 ]; then
925 export CROSSCOMPILE=1
926 if ! [[ -n "$ROOTFS_DIR" ]]; then
927 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
931 # init the target distro name
934 # Make the directories necessary for build if they don't exist
940 # Restore the package containing profile counts for profile-guided optimizations
943 # Generate event logging infrastructure sources
944 generate_event_logging_sources
946 # Build the coreclr (native) components.
947 __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"
948 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
950 # Build cross-architecture components
951 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
952 build_cross_arch_component
955 # Build System.Private.CoreLib.
959 # Generate nuget packages
960 if [ $__SkipNuget != 1 ]; then
961 generate_NugetPackages
967 echo "Repo successfully built."
968 echo "Product binaries are available at $__BinDir"