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 "-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 "-buildstandalonegc - builds the GC in a standalone mode. Can't be used with \"cmakeargs\"."
54 echo "-msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
55 echo "-numproc - set the number of build processes."
62 if [ "$__HostOS" == "Linux" ]; then
63 if [ -e /etc/os-release ]; then
64 source /etc/os-release
65 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
66 elif [ -e /etc/redhat-release ]; then
67 local redhatRelease=$(</etc/redhat-release)
68 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
69 __HostDistroRid="rhel.6-$__HostArch"
74 if [ "$__HostDistroRid" == "" ]; then
75 echo "WARNING: Can not determine runtime id for current distro."
81 if [ $__CrossBuild == 1 ]; then
82 if [ "$__BuildOS" == "Linux" ]; then
83 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
84 if [ -e $ROOTFS_DIR/android_platform ]; then
85 source $ROOTFS_DIR/android_platform
86 export __DistroRid="$RID"
88 echo "WARNING: Can not determine runtime id for current distro."
92 source $ROOTFS_DIR/etc/os-release
93 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
97 export __DistroRid="$__HostDistroRid"
100 # Portable builds target the base RID
101 if [ $__PortableBuild == 1 ]; then
102 if [ "$__BuildOS" == "Linux" ]; then
103 export __DistroRid="linux-$__BuildArch"
104 elif [ "$__BuildOS" == "OSX" ]; then
105 export __DistroRid="osx-$__BuildArch"
112 echo Setting up directories for build
114 mkdir -p "$__RootBinDir"
116 mkdir -p "$__LogsDir"
117 mkdir -p "$__IntermediatesDir"
119 if [ $__CrossBuild == 1 ]; then
120 mkdir -p "$__CrossComponentBinDir"
121 mkdir -p "$__CrossCompIntermediatesDir"
125 # Check the system to ensure the right prereqs are in place
129 echo "Checking prerequisites..."
131 # Check presence of CMake on the path
132 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
135 # Minimum required version of clang is version 3.9 for arm/armel cross build
136 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
137 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
138 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
143 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; }
149 # we only need optdata on a Release build
150 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
152 if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
153 echo "Restoring the OptimizationData package"
154 "$__ProjectRoot/run.sh" sync -optdata
156 echo "Failed to restore the optimization data package."
161 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
162 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
163 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
164 if [ ! -f $DotNetCli ]; then
165 "$__ProjectRoot/init-tools.sh"
167 echo "Failed to restore buildtools."
171 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
172 __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
173 __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
177 generate_event_logging_sources()
179 if [ $__SkipCoreCLR == 1 ]; then
183 # Event Logging Infrastructure
184 __GeneratedIntermediate="$__IntermediatesDir/Generated"
185 __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
186 __GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe_new"
188 if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
189 rm -rf "$__GeneratedIntermediateEventProvider"
192 if [[ -d "$__GeneratedIntermediateEventPipe" ]]; then
193 rm -rf "$__GeneratedIntermediateEventPipe"
196 if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
197 mkdir -p "$__GeneratedIntermediate/eventprovider"
200 if [[ ! -d "$__GeneratedIntermediate/eventpipe" ]]; then
201 mkdir -p "$__GeneratedIntermediate/eventpipe"
204 mkdir -p "$__GeneratedIntermediateEventProvider"
205 mkdir -p "$__GeneratedIntermediateEventPipe"
207 __PythonWarningFlags="-Wall"
208 if [[ $__IgnoreWarnings == 0 ]]; then
209 __PythonWarningFlags="$__PythonWarningFlags -Werror"
213 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
214 echo "Laying out dynamically generated files consumed by the build system "
215 echo "Laying out dynamically generated Event Logging Test files"
216 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
218 if [[ $? != 0 ]]; then
224 echo "Laying out dynamically generated EventPipe Implementation"
225 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst"
226 if [[ $? != 0 ]]; then
234 #determine the logging system
237 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
238 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
239 if [[ $? != 0 ]]; then
248 echo "Cleaning the temp folder of dynamically generated Event Logging files"
249 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
250 if [[ $? != 0 ]]; then
254 rm -rf "$__GeneratedIntermediateEventProvider"
256 echo "Cleaning the temp folder of dynamically generated EventPipe files"
257 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventpipe\",\"$__GeneratedIntermediateEventPipe\")"
258 if [[ $? != 0 ]]; then
262 rm -rf "$__GeneratedIntermediateEventPipe"
269 intermediatesForBuild="$3"
270 extraCmakeArguments="$4"
273 if [ $skipCondition == 1 ]; then
274 echo "Skipping $message build."
278 # All set to commence the build
279 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
284 if [ $__UseNinja == 1 ]; then
286 buildFile="build.ninja"
287 if ! buildTool=$(command -v ninja || command -v ninja-build); then
288 echo "Unable to locate ninja!" 1>&2
293 if [ $__SkipConfigure == 0 ]; then
294 # if msbuild is not supported, then set __SkipGenerateVersion to 1
295 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
296 # Drop version.cpp file
297 __versionSourceFile="$intermediatesForBuild/version.cpp"
298 if [ $__SkipGenerateVersion == 0 ]; then
300 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile $__RunArgs $__UnprocessedBuildArgs
302 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
303 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
304 if [ -e $__versionSourceFile ]; then
305 read existingVersionSourceLine < $__versionSourceFile
307 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
308 echo $__versionSourceLine > $__versionSourceFile
313 pushd "$intermediatesForBuild"
314 # Regenerate the CMake solution
315 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
316 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
320 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
321 echo "Failed to generate $message build project!"
326 if [ $__ConfigureOnly == 1 ]; then
327 echo "Finish configuration & skipping $message build."
331 # Check that the makefiles were created.
332 pushd "$intermediatesForBuild"
334 echo "Executing $buildTool install -j $__NumProc"
336 $buildTool install -j $__NumProc
338 echo "Failed to build $message."
345 build_cross_arch_component()
347 __SkipCrossArchBuild=1
349 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
350 if [[ ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") && "$__CrossArch" == "x86" ]]; then
351 export CROSSCOMPILE=0
352 __SkipCrossArchBuild=0
354 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
355 if [ "$__HostArch" == "x64" ]; then
356 export CROSSCOMPILE=1
363 export __CMakeBinDir="$__CrossComponentBinDir"
364 export CROSSCOMPONENT=1
367 if [ $CROSSCOMPILE == 1 ]; then
368 TARGET_ROOTFS="$ROOTFS_DIR"
369 if [ -n "$CAC_ROOTFS_DIR" ]; then
370 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
372 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
376 __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"
377 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
379 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
380 if [ -n "$TARGET_ROOTFS" ]; then
381 export ROOTFS_DIR="$TARGET_ROOTFS"
383 export CROSSCOMPONENT=
384 export CROSSCOMPILE=1
387 isMSBuildOnNETCoreSupported()
389 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
391 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
395 if [ "$__HostArch" == "x64" ]; then
396 if [ "$__HostOS" == "Linux" ]; then
397 __isMSBuildOnNETCoreSupported=1
398 # note: the RIDs below can use globbing patterns
399 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64" "alpine.3.6.*-x64")
400 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
402 if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
403 __isMSBuildOnNETCoreSupported=0
407 elif [ "$__HostOS" == "OSX" ]; then
408 __isMSBuildOnNETCoreSupported=1
416 if [ $__SkipCrossgen == 1 ]; then
417 echo "Skipping generating native image"
421 if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
422 echo "Generating native image for System.Private.CoreLib."
423 echo "$__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll"
424 $__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
425 if [ $? -ne 0 ]; then
426 echo "Failed to generate native image for System.Private.CoreLib."
430 if [ "$__BuildOS" == "Linux" ]; then
431 echo "Generating symbol file for System.Private.CoreLib."
432 $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
433 if [ $? -ne 0 ]; then
434 echo "Failed to generate symbol file for System.Private.CoreLib."
444 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
445 echo "System.Private.CoreLib.dll build unsupported."
449 if [ $__SkipMSCorLib == 1 ]; then
450 echo "Skipping building System.Private.CoreLib."
454 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
458 if [[ "$__IbcTuning" -eq "" ]]; then
459 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
460 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
462 $__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
464 if [ $? -ne 0 ]; then
465 echo "Failed to build managed components."
469 # The cross build generates a crossgen with the target architecture.
470 if [ $__CrossBuild != 1 ]; then
471 # The architecture of host pc must be same architecture with target.
472 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
474 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
476 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
484 generate_NugetPackages()
486 # We can only generate nuget package if we also support building mscorlib as part of this build.
487 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
488 echo "Nuget package generation unsupported."
492 # Since we can build mscorlib for this OS, did we build the native components as well?
493 if [ $__SkipCoreCLR == 1 ]; then
494 echo "Unable to generate nuget packages since native components were not built."
498 echo "Generating nuget packages for "$__BuildOS
499 echo "DistroRid is "$__DistroRid
500 echo "ROOTFS_DIR is "$ROOTFS_DIR
502 $__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
504 if [ $? -ne 0 ]; then
505 echo "Failed to generate Nuget packages."
510 echo "Commencing CoreCLR Repo build"
512 # Argument types supported by this script:
514 # Build architecture - valid values are: x64, ARM.
515 # Build Type - valid values are: Debug, Checked, Release
517 # Set the default arguments for build
519 # Obtain the location of the bash script to figure out where the root of the repo is.
520 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
522 # Use uname to determine what the CPU is.
524 # Some Linux platforms report unknown for platform, but the arch for machine.
525 if [ "$CPUName" == "unknown" ]; then
531 echo "Unsupported CPU $CPUName detected, build might not succeed!"
542 echo "Unsupported CPU $CPUName detected, build might not succeed!"
553 echo "Unknown CPU $CPUName detected, configuring as if for x64"
559 # Use uname to determine what the OS is.
593 echo "Unsupported OS $OSName detected, configuring as if for Linux"
601 __IncludeTests=Include_Tests
604 # Set the various build properties here so that CMake and MSBuild can pick them up
605 __ProjectDir="$__ProjectRoot"
606 __SourceDir="$__ProjectDir/src"
607 __PackagesDir="$__ProjectDir/packages"
608 __RootBinDir="$__ProjectDir/bin"
609 __UnprocessedBuildArgs=
623 __SkipRestoreOptData=0
626 __ClangMajorVersion=0
627 __ClangMinorVersion=0
628 __NuGetPath="$__PackagesDir/NuGet.exe"
632 __SkipGenerateVersion=0
635 __msbuildonunsupportedplatform=0
636 __PgoOptDataVersion=""
637 __IbcOptDataVersion=""
639 # Get the number of processors available to the scheduler
640 # Other techniques such as `nproc` only get the number of
641 # processors available to a single process.
642 if [ `uname` = "FreeBSD" ]; then
643 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
644 elif [ `uname` = "NetBSD" ]; then
645 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
646 elif [ `uname` = "Darwin" ]; then
647 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
649 __NumProc=$(nproc --all)
653 if [ $# -le 0 ]; then
657 lowerI="$(echo $1 | awk '{print tolower($0)}')"
697 __CodeCoverage=Coverage
704 -portablebuild=false)
712 stripsymbols|-stripsymbols)
713 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
717 __ClangMajorVersion=3
718 __ClangMinorVersion=5
722 __ClangMajorVersion=3
723 __ClangMinorVersion=6
727 __ClangMajorVersion=3
728 __ClangMinorVersion=7
732 __ClangMajorVersion=3
733 __ClangMinorVersion=8
737 __ClangMajorVersion=3
738 __ClangMinorVersion=9
742 __ClangMajorVersion=4
743 __ClangMinorVersion=0
750 pgoinstrument|-pgoinstrument)
754 nopgooptimize|-nopgooptimize)
756 __SkipRestoreOptData=1
759 ibcinstrument|-ibcinstrument)
760 __IbcTuning="/Tuning"
763 configureonly|-configureonly)
769 skipconfigure|-skipconfigure)
773 skipnative|-skipnative)
774 # Use "skipnative" to use the same option name as build.cmd.
778 skipcoreclr|-skipcoreclr)
779 # Accept "skipcoreclr" for backwards-compatibility.
783 crosscomponent|-crosscomponent)
787 skipmscorlib|-skipmscorlib)
791 skipgenerateversion|-skipgenerateversion)
792 __SkipGenerateVersion=1
795 skiprestoreoptdata|-skiprestoreoptdata)
796 __SkipRestoreOptData=1
799 skipcrossgen|-skipcrossgen)
803 includetests|-includetests)
806 skiptests|-skiptests)
810 skipnuget|-skipnuget)
814 ignorewarnings|-ignorewarnings)
816 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
819 cmakeargs|-cmakeargs)
821 __cmakeargs="$__cmakeargs $2"
824 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
832 if [ ! -d $__RootBinDir ]; then
835 __RootBinParent=$(dirname $__RootBinDir)
836 __RootBinName=${__RootBinDir##*/}
837 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
840 echo "ERROR: 'bindir' requires a non-empty option argument"
844 buildstandalonegc|-buildstandalonegc)
845 __cmakeargs="$__cmakeargs -DFEATURE_STANDALONE_GC=1 -DFEATURE_STANDALONE_GC_ONLY=1"
847 msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
848 __msbuildonunsupportedplatform=1
855 echo "ERROR: 'numproc' requires a non-empty option argument"
860 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
867 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
869 # Configure environment if we are doing a verbose build
870 if [ $__VerboseBuild == 1 ]; then
872 __RunArgs="$__RunArgs -verbose"
875 # Set default clang version
876 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
877 if [ $__CrossBuild == 1 ]; then
878 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
879 __ClangMajorVersion=3
880 __ClangMinorVersion=9
882 __ClangMajorVersion=3
883 __ClangMinorVersion=6
887 __ClangMajorVersion=3
888 __ClangMinorVersion=5
892 if [[ "$__BuildArch" == "armel" ]]; then
893 # Armel cross build is Tizen specific and does not support Portable RID build
897 if [ $__PortableBuild == 0 ]; then
898 __RunArgs="$__RunArgs -PortableBuild=false"
901 # Set dependent variables
902 __LogsDir="$__RootBinDir/Logs"
904 # init the host distro name
907 # Set the remaining variables based upon the determined build configuration
908 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
909 __PackagesBinDir="$__BinDir/.nuget"
910 __ToolsDir="$__RootBinDir/tools"
911 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
912 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
913 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
914 __isMSBuildOnNETCoreSupported=0
915 __CrossComponentBinDir="$__BinDir"
916 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
918 __CrossArch="$__HostArch"
919 if [[ "$__HostArch" == "x64" && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
922 if [ $__CrossBuild == 1 ]; then
923 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
925 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
926 __CrossgenExe="$__CrossComponentBinDir/crossgen"
928 # Init if MSBuild for .NET Core is supported for this platform
929 isMSBuildOnNETCoreSupported
931 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
932 # This is needed by CLI to function.
933 if [ -z "$HOME" ]; then
934 if [ ! -d "$__ProjectDir/temp_home" ]; then
937 export HOME=$__ProjectDir/temp_home
938 echo "HOME not defined; setting it to $HOME"
941 # Specify path to be set for CMAKE_INSTALL_PREFIX.
942 # This is where all built CoreClr libraries will copied to.
943 export __CMakeBinDir="$__BinDir"
945 # Configure environment if we are doing a cross compile.
946 if [ $__CrossBuild == 1 ]; then
947 export CROSSCOMPILE=1
948 if ! [[ -n "$ROOTFS_DIR" ]]; then
949 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
953 # init the target distro name
956 # Make the directories necessary for build if they don't exist
962 # Restore the package containing profile counts for profile-guided optimizations
965 # Generate event logging infrastructure sources
966 generate_event_logging_sources
968 # Build the coreclr (native) components.
969 __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"
970 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
972 # Build cross-architecture components
973 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
974 build_cross_arch_component
977 # Build System.Private.CoreLib.
981 # Generate nuget packages
982 if [ $__SkipNuget != 1 ]; then
983 generate_NugetPackages
989 echo "Repo successfully built."
990 echo "Product binaries are available at $__BinDir"