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 "-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 if [[ $ID == "alpine" ]]; then
66 # remove the last version digit
67 VERSION_ID=${VERSION_ID%.*}
69 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
70 elif [ -e /etc/redhat-release ]; then
71 local redhatRelease=$(</etc/redhat-release)
72 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
73 __HostDistroRid="rhel.6-$__HostArch"
77 if [ "$__HostOS" == "FreeBSD" ]; then
78 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
79 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
82 if [ "$__HostDistroRid" == "" ]; then
83 echo "WARNING: Can not determine runtime id for current distro."
89 if [ $__CrossBuild == 1 ]; then
90 if [ "$__BuildOS" == "Linux" ]; then
91 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
92 if [ -e $ROOTFS_DIR/android_platform ]; then
93 source $ROOTFS_DIR/android_platform
94 export __DistroRid="$RID"
96 echo "WARNING: Can not determine runtime id for current distro."
100 source $ROOTFS_DIR/etc/os-release
101 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
105 export __DistroRid="$__HostDistroRid"
108 # Portable builds target the base RID
109 if [ $__PortableBuild == 1 ]; then
110 if [ "$__BuildOS" == "Linux" ]; then
111 export __DistroRid="linux-$__BuildArch"
112 elif [ "$__BuildOS" == "OSX" ]; then
113 export __DistroRid="osx-$__BuildArch"
114 elif [ "$__BuildOS" == "FreeBSD" ]; then
115 export __DistroRid="freebsd-$__BuildArch"
122 echo Setting up directories for build
124 mkdir -p "$__RootBinDir"
126 mkdir -p "$__LogsDir"
127 mkdir -p "$__IntermediatesDir"
129 if [ $__CrossBuild == 1 ]; then
130 mkdir -p "$__CrossComponentBinDir"
131 mkdir -p "$__CrossCompIntermediatesDir"
135 # Check the system to ensure the right prereqs are in place
139 echo "Checking prerequisites..."
141 # Check presence of CMake on the path
142 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
145 # Minimum required version of clang is version 3.9 for arm/armel cross build
146 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
147 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
148 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
153 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; }
159 # we only need optdata on a Release build
160 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
162 if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
163 echo "Restoring the OptimizationData package"
164 "$__ProjectRoot/run.sh" sync -optdata
166 echo "Failed to restore the optimization data package."
171 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
172 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
173 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
174 if [ ! -f $DotNetCli ]; then
175 "$__ProjectRoot/init-tools.sh"
177 echo "Failed to restore buildtools."
181 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
182 __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
183 __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
187 generate_event_logging_sources()
189 if [ $__SkipCoreCLR == 1 ]; then
193 # Event Logging Infrastructure
194 __GeneratedIntermediate="$__IntermediatesDir/Generated"
195 __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
196 __GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe_new"
198 if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
199 rm -rf "$__GeneratedIntermediateEventProvider"
202 if [[ -d "$__GeneratedIntermediateEventPipe" ]]; then
203 rm -rf "$__GeneratedIntermediateEventPipe"
206 if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
207 mkdir -p "$__GeneratedIntermediate/eventprovider"
210 if [[ ! -d "$__GeneratedIntermediate/eventpipe" ]]; then
211 mkdir -p "$__GeneratedIntermediate/eventpipe"
214 mkdir -p "$__GeneratedIntermediateEventProvider"
215 mkdir -p "$__GeneratedIntermediateEventPipe"
217 __PythonWarningFlags="-Wall"
218 if [[ $__IgnoreWarnings == 0 ]]; then
219 __PythonWarningFlags="$__PythonWarningFlags -Werror"
223 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
224 echo "Laying out dynamically generated files consumed by the build system "
225 echo "Laying out dynamically generated Event Logging Test files"
226 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
228 if [[ $? != 0 ]]; then
234 echo "Laying out dynamically generated EventPipe Implementation"
235 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst"
236 if [[ $? != 0 ]]; then
244 #determine the logging system
247 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
248 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
249 if [[ $? != 0 ]]; then
258 echo "Cleaning the temp folder of dynamically generated Event Logging files"
259 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
260 if [[ $? != 0 ]]; then
264 rm -rf "$__GeneratedIntermediateEventProvider"
266 echo "Cleaning the temp folder of dynamically generated EventPipe files"
267 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventpipe\",\"$__GeneratedIntermediateEventPipe\")"
268 if [[ $? != 0 ]]; then
272 rm -rf "$__GeneratedIntermediateEventPipe"
279 intermediatesForBuild="$3"
280 extraCmakeArguments="$4"
283 if [ $skipCondition == 1 ]; then
284 echo "Skipping $message build."
288 # All set to commence the build
289 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
294 if [ $__UseNinja == 1 ]; then
296 buildFile="build.ninja"
297 if ! buildTool=$(command -v ninja || command -v ninja-build); then
298 echo "Unable to locate ninja!" 1>&2
303 if [ $__SkipConfigure == 0 ]; then
304 # if msbuild is not supported, then set __SkipGenerateVersion to 1
305 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
306 # Drop version.cpp file
307 __versionSourceFile="$intermediatesForBuild/version.cpp"
308 if [ $__SkipGenerateVersion == 0 ]; then
310 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile $__RunArgs $__UnprocessedBuildArgs
312 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
313 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
314 if [ -e $__versionSourceFile ]; then
315 read existingVersionSourceLine < $__versionSourceFile
317 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
318 echo $__versionSourceLine > $__versionSourceFile
323 pushd "$intermediatesForBuild"
324 # Regenerate the CMake solution
325 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
326 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
330 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
331 echo "Failed to generate $message build project!"
336 if [ $__ConfigureOnly == 1 ]; then
337 echo "Finish configuration & skipping $message build."
341 # Check that the makefiles were created.
342 pushd "$intermediatesForBuild"
344 echo "Executing $buildTool install -j $__NumProc"
346 $buildTool install -j $__NumProc
348 echo "Failed to build $message."
355 build_cross_arch_component()
357 __SkipCrossArchBuild=1
359 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
360 if [[ ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") && "$__CrossArch" == "x86" ]]; then
361 export CROSSCOMPILE=0
362 __SkipCrossArchBuild=0
364 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
365 if [ "$__HostArch" == "x64" ]; then
366 export CROSSCOMPILE=1
373 export __CMakeBinDir="$__CrossComponentBinDir"
374 export CROSSCOMPONENT=1
377 if [ $CROSSCOMPILE == 1 ]; then
378 TARGET_ROOTFS="$ROOTFS_DIR"
379 if [ -n "$CAC_ROOTFS_DIR" ]; then
380 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
382 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
386 __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"
387 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
389 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
390 if [ -n "$TARGET_ROOTFS" ]; then
391 export ROOTFS_DIR="$TARGET_ROOTFS"
393 export CROSSCOMPONENT=
394 export CROSSCOMPILE=1
397 isMSBuildOnNETCoreSupported()
399 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
401 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
405 if [ "$__HostArch" == "x64" ]; then
406 if [ "$__HostOS" == "Linux" ]; then
407 __isMSBuildOnNETCoreSupported=1
408 # note: the RIDs below can use globbing patterns
409 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
410 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
412 if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
413 __isMSBuildOnNETCoreSupported=0
417 elif [ "$__HostOS" == "OSX" ]; then
418 __isMSBuildOnNETCoreSupported=1
426 if [ $__SkipCrossgen == 1 ]; then
427 echo "Skipping generating native image"
431 if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
432 echo "Generating native image for System.Private.CoreLib."
433 echo "$__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll"
434 $__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
435 if [ $? -ne 0 ]; then
436 echo "Failed to generate native image for System.Private.CoreLib."
440 if [ "$__BuildOS" == "Linux" ]; then
441 echo "Generating symbol file for System.Private.CoreLib."
442 $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
443 if [ $? -ne 0 ]; then
444 echo "Failed to generate symbol file for System.Private.CoreLib."
454 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
455 echo "System.Private.CoreLib.dll build unsupported."
459 if [ $__SkipMSCorLib == 1 ]; then
460 echo "Skipping building System.Private.CoreLib."
464 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
468 if [[ "$__IbcTuning" -eq "" ]]; then
469 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
470 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
472 $__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
474 if [ $? -ne 0 ]; then
475 echo "Failed to build managed components."
479 # The cross build generates a crossgen with the target architecture.
480 if [ $__CrossBuild != 1 ]; then
481 # The architecture of host pc must be same architecture with target.
482 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
484 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
486 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
494 generate_NugetPackages()
496 # We can only generate nuget package if we also support building mscorlib as part of this build.
497 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
498 echo "Nuget package generation unsupported."
502 # Since we can build mscorlib for this OS, did we build the native components as well?
503 if [ $__SkipCoreCLR == 1 ]; then
504 echo "Unable to generate nuget packages since native components were not built."
508 echo "Generating nuget packages for "$__BuildOS
509 echo "DistroRid is "$__DistroRid
510 echo "ROOTFS_DIR is "$ROOTFS_DIR
512 $__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
514 if [ $? -ne 0 ]; then
515 echo "Failed to generate Nuget packages."
520 echo "Commencing CoreCLR Repo build"
522 # Argument types supported by this script:
524 # Build architecture - valid values are: x64, ARM.
525 # Build Type - valid values are: Debug, Checked, Release
527 # Set the default arguments for build
529 # Obtain the location of the bash script to figure out where the root of the repo is.
530 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
532 # Use uname to determine what the CPU is.
534 # Some Linux platforms report unknown for platform, but the arch for machine.
535 if [ "$CPUName" == "unknown" ]; then
541 echo "Unsupported CPU $CPUName detected, build might not succeed!"
552 echo "Unsupported CPU $CPUName detected, build might not succeed!"
567 echo "Unknown CPU $CPUName detected, configuring as if for x64"
573 # Use uname to determine what the OS is.
607 echo "Unsupported OS $OSName detected, configuring as if for Linux"
615 __IncludeTests=Include_Tests
618 # Set the various build properties here so that CMake and MSBuild can pick them up
619 __ProjectDir="$__ProjectRoot"
620 __SourceDir="$__ProjectDir/src"
621 __PackagesDir="$__ProjectDir/packages"
622 __RootBinDir="$__ProjectDir/bin"
623 __UnprocessedBuildArgs=
637 __SkipRestoreOptData=0
640 __ClangMajorVersion=0
641 __ClangMinorVersion=0
642 __NuGetPath="$__PackagesDir/NuGet.exe"
646 __SkipGenerateVersion=0
649 __msbuildonunsupportedplatform=0
650 __PgoOptDataVersion=""
651 __IbcOptDataVersion=""
653 # Get the number of processors available to the scheduler
654 # Other techniques such as `nproc` only get the number of
655 # processors available to a single process.
656 if [ `uname` = "FreeBSD" ]; then
657 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
658 elif [ `uname` = "NetBSD" ]; then
659 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
660 elif [ `uname` = "Darwin" ]; then
661 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
663 __NumProc=$(nproc --all)
667 if [ $# -le 0 ]; then
671 lowerI="$(echo $1 | awk '{print tolower($0)}')"
711 __CodeCoverage=Coverage
718 -portablebuild=false)
726 stripsymbols|-stripsymbols)
727 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
731 __ClangMajorVersion=3
732 __ClangMinorVersion=5
736 __ClangMajorVersion=3
737 __ClangMinorVersion=6
741 __ClangMajorVersion=3
742 __ClangMinorVersion=7
746 __ClangMajorVersion=3
747 __ClangMinorVersion=8
751 __ClangMajorVersion=3
752 __ClangMinorVersion=9
756 __ClangMajorVersion=4
757 __ClangMinorVersion=0
764 pgoinstrument|-pgoinstrument)
768 nopgooptimize|-nopgooptimize)
770 __SkipRestoreOptData=1
773 ibcinstrument|-ibcinstrument)
774 __IbcTuning="/Tuning"
777 configureonly|-configureonly)
783 skipconfigure|-skipconfigure)
787 skipnative|-skipnative)
788 # Use "skipnative" to use the same option name as build.cmd.
792 skipcoreclr|-skipcoreclr)
793 # Accept "skipcoreclr" for backwards-compatibility.
797 crosscomponent|-crosscomponent)
801 skipmscorlib|-skipmscorlib)
805 skipgenerateversion|-skipgenerateversion)
806 __SkipGenerateVersion=1
809 skiprestoreoptdata|-skiprestoreoptdata)
810 __SkipRestoreOptData=1
813 skipcrossgen|-skipcrossgen)
817 includetests|-includetests)
820 skiptests|-skiptests)
824 skipnuget|-skipnuget)
828 ignorewarnings|-ignorewarnings)
830 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
833 cmakeargs|-cmakeargs)
835 __cmakeargs="$__cmakeargs $2"
838 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
846 if [ ! -d $__RootBinDir ]; then
849 __RootBinParent=$(dirname $__RootBinDir)
850 __RootBinName=${__RootBinDir##*/}
851 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
854 echo "ERROR: 'bindir' requires a non-empty option argument"
858 buildstandalonegc|-buildstandalonegc)
859 __cmakeargs="$__cmakeargs -DFEATURE_STANDALONE_GC=1 -DFEATURE_STANDALONE_GC_ONLY=1"
861 msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
862 __msbuildonunsupportedplatform=1
869 echo "ERROR: 'numproc' requires a non-empty option argument"
878 echo "ERROR: 'osgroup' requires a non-empty option argument"
884 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
891 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
893 # Configure environment if we are doing a verbose build
894 if [ $__VerboseBuild == 1 ]; then
896 __RunArgs="$__RunArgs -verbose"
899 # Set default clang version
900 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
901 __ClangMajorVersion=3
902 __ClangMinorVersion=9
905 if [[ "$__BuildArch" == "armel" ]]; then
906 # Armel cross build is Tizen specific and does not support Portable RID build
910 if [ $__PortableBuild == 0 ]; then
911 __RunArgs="$__RunArgs -PortableBuild=false"
914 # Set dependent variables
915 __LogsDir="$__RootBinDir/Logs"
917 # init the host distro name
920 # Set the remaining variables based upon the determined build configuration
921 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
922 __PackagesBinDir="$__BinDir/.nuget"
923 __ToolsDir="$__RootBinDir/tools"
924 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
925 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
926 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
927 __isMSBuildOnNETCoreSupported=0
928 __CrossComponentBinDir="$__BinDir"
929 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
931 __CrossArch="$__HostArch"
932 if [[ "$__HostArch" == "x64" && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
935 if [ $__CrossBuild == 1 ]; then
936 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
938 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
939 __CrossgenExe="$__CrossComponentBinDir/crossgen"
941 # Init if MSBuild for .NET Core is supported for this platform
942 isMSBuildOnNETCoreSupported
944 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
945 # This is needed by CLI to function.
946 if [ -z "$HOME" ]; then
947 if [ ! -d "$__ProjectDir/temp_home" ]; then
950 export HOME=$__ProjectDir/temp_home
951 echo "HOME not defined; setting it to $HOME"
954 # Specify path to be set for CMAKE_INSTALL_PREFIX.
955 # This is where all built CoreClr libraries will copied to.
956 export __CMakeBinDir="$__BinDir"
958 # Configure environment if we are doing a cross compile.
959 if [ $__CrossBuild == 1 ]; then
960 export CROSSCOMPILE=1
961 if ! [[ -n "$ROOTFS_DIR" ]]; then
962 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
966 # init the target distro name
969 # Make the directories necessary for build if they don't exist
975 # Restore the package containing profile counts for profile-guided optimizations
978 # Generate event logging infrastructure sources
979 generate_event_logging_sources
981 # Build the coreclr (native) components.
982 __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"
983 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
985 # Build cross-architecture components
986 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
987 build_cross_arch_component
990 # Build System.Private.CoreLib.
994 # Generate nuget packages
995 if [ $__SkipNuget != 1 ]; then
996 generate_NugetPackages
1002 echo "Repo successfully built."
1003 echo "Product binaries are available at $__BinDir"