3 # Work around Jenkins CI + msbuild problem: Jenkins sometimes creates very large environment
4 # variables, and msbuild can't handle environment blocks with such large variables. So clear
5 # out the variables that might be too large.
6 export ghprbCommentBody=
8 # resolve python-version to use
9 if [ "$PYTHON" == "" ] ; then
10 if ! PYTHON=$(command -v python2.7 || command -v python2 || command -v python)
12 echo "Unable to locate build-dependency python2.x!" 1>&2
17 # validate python-dependency
18 # useful in case of explicitly set option.
19 if ! command -v $PYTHON > /dev/null
21 echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2
27 echo "Usage: $0 [BuildArch] [BuildType] [-verbose] [-coverage] [-cross] [-clangx.y] [-ninja] [-configureonly] [-skipconfigure] [-skipnative] [-skipmscorlib] [-skiptests] [-stripsymbols] [-ignorewarnings] [-cmakeargs] [-bindir]"
28 echo "BuildArch can be: -x64, -x86, -arm, -armel, -arm64"
29 echo "BuildType can be: -debug, -checked, -release"
30 echo "-coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
31 echo "-ninja - target ninja instead of GNU make"
32 echo "-clangx.y - optional argument to build using clang version x.y."
33 echo "-cross - optional argument to signify cross compilation,"
34 echo " - will use ROOTFS_DIR environment variable if set."
35 echo "-crosscomponent - optional argument to build cross-architecture component,"
36 echo " - will use CAC_ROOTFS_DIR environment variable if set."
37 echo "-nopgooptimize - do not use profile guided optimizations."
38 echo "-pgoinstrument - generate instrumented code for profile guided optimization enabled binaries."
39 echo "-ibcinstrument - generate IBC-tuning-enabled native images when invoking crossgen."
40 echo "-configureonly - do not perform any builds; just configure the build."
41 echo "-skipconfigure - skip build configuration."
42 echo "-skipnative - do not build native components."
43 echo "-skipmscorlib - do not build mscorlib.dll."
44 echo "-skiptests - skip the tests in the 'tests' subdirectory."
45 echo "-skipnuget - skip building nuget packages."
46 echo "-skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations."
47 echo "-skipcrossgen - skip native image generation"
48 echo "-verbose - optional argument to enable verbose build output."
49 echo "-skiprestore: skip restoring packages ^(default: packages are restored during build^)."
50 echo "-disableoss: Disable Open Source Signing for System.Private.CoreLib."
51 echo "-officialbuildid=^<ID^>: specify the official build ID to be used by this build."
52 echo "-Rebuild: passes /t:rebuild to the build projects."
53 echo "-stripSymbols - Optional argument to strip native symbols during the build."
54 echo "-skipgenerateversion - disable version generation even if MSBuild is supported."
55 echo "-ignorewarnings - do not treat warnings as errors"
56 echo "-cmakeargs - user-settable additional arguments passed to CMake."
57 echo "-bindir - output directory (defaults to $__ProjectRoot/bin)"
58 echo "-msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
59 echo "-numproc - set the number of build processes."
66 if [ "$__HostOS" == "Linux" ]; then
67 if [ -e /etc/os-release ]; then
68 source /etc/os-release
69 if [[ $ID == "rhel" ]]; then
70 # remove the last version digit
71 VERSION_ID=${VERSION_ID%.*}
73 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
74 if [[ $ID == "alpine" ]]; then
75 __HostDistroRid="linux-musl-$__HostArch"
77 if [[ $ID == "tizen" ]]; then
79 export __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
81 elif [ -e /etc/redhat-release ]; then
82 local redhatRelease=$(</etc/redhat-release)
83 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
84 __HostDistroRid="rhel.6-$__HostArch"
88 if [ "$__HostOS" == "FreeBSD" ]; then
89 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
90 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
93 if [ "$__HostDistroRid" == "" ]; then
94 echo "WARNING: Can not determine runtime id for current distro."
100 if [ $__CrossBuild == 1 ]; then
101 if [ "$__BuildOS" == "Linux" ]; then
102 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
103 if [ -e $ROOTFS_DIR/android_platform ]; then
104 source $ROOTFS_DIR/android_platform
105 export __DistroRid="$RID"
107 echo "WARNING: Can not determine runtime id for current distro."
108 export __DistroRid=""
111 source $ROOTFS_DIR/etc/os-release
112 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
116 export __DistroRid="$__HostDistroRid"
119 if [ "$__BuildOS" == "OSX" ]; then
123 # Portable builds target the base RID
124 if [ $__PortableBuild == 1 ]; then
125 if [ "$__BuildOS" == "Linux" ]; then
126 export __DistroRid="linux-$__BuildArch"
127 elif [ "$__BuildOS" == "OSX" ]; then
128 export __DistroRid="osx-$__BuildArch"
129 elif [ "$__BuildOS" == "FreeBSD" ]; then
130 export __DistroRid="freebsd-$__BuildArch"
137 echo Setting up directories for build
139 mkdir -p "$__RootBinDir"
141 mkdir -p "$__LogsDir"
142 mkdir -p "$__IntermediatesDir"
144 if [ $__CrossBuild == 1 ]; then
145 mkdir -p "$__CrossComponentBinDir"
146 mkdir -p "$__CrossCompIntermediatesDir"
150 # Check the system to ensure the right prereqs are in place
154 echo "Checking prerequisites..."
156 # Check presence of CMake on the path
157 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
160 # Minimum required version of clang is version 4.0 for arm/armel cross build
161 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
162 if ! [[ "$__ClangMajorVersion" -ge "4" ]]; then
163 echo "Please install clang4.0 or latest for arm/armel cross build"; exit 1;
168 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; }
174 # we only need optdata on a Release build
175 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
177 if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
178 echo "Restoring the OptimizationData package"
179 "$__ProjectRoot/run.sh" build -optdata $__RunArgs $__UnprocessedBuildArgs
181 echo "Failed to restore the optimization data package."
186 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
187 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
188 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
189 if [ ! -f $DotNetCli ]; then
190 source "$__ProjectRoot/init-tools.sh"
192 echo "Failed to restore buildtools."
196 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
197 __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
198 __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
202 generate_event_logging_sources()
205 __ConsumingBuildSystem=$2
207 __OutputIncDir="$__OutputDir/src/inc"
208 __OutputEventingDir="$__OutputDir/eventing"
209 __OutputEventProviderDir="$__OutputEventingDir/eventprovider"
211 echo "Laying out dynamically generated files consumed by $__ConsumingBuildSystem"
212 echo "Laying out dynamically generated Event test files, etmdummy stub functions, and external linkages"
214 __PythonWarningFlags="-Wall"
215 if [[ $__IgnoreWarnings == 0 ]]; then
216 __PythonWarningFlags="$__PythonWarningFlags -Werror"
219 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventing.py" --inc $__OutputIncDir --dummy $__OutputIncDir/etmdummy.h --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --testdir "$__OutputEventProviderDir/tests"
220 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 "$__OutputEventingDir/eventpipe"
227 # determine the logging system
230 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
231 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genLttngProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventProviderDir"
232 if [[ $? != 0 ]]; then
237 echo "Laying out dummy event logging provider"
238 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genDummyProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventProviderDir"
239 if [[ $? != 0 ]]; then
246 generate_event_logging()
248 # Event Logging Infrastructure
249 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
250 generate_event_logging_sources "$__IntermediatesDir" "the native build system"
253 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
254 generate_event_logging_sources "$__CrossCompIntermediatesDir" "the crossarch build system"
262 intermediatesForBuild="$3"
263 extraCmakeArguments="$4"
266 if [ $skipCondition == 1 ]; then
267 echo "Skipping $message build."
271 # All set to commence the build
272 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
277 if [ $__UseNinja == 1 ]; then
279 buildFile="build.ninja"
280 if ! buildTool=$(command -v ninja || command -v ninja-build); then
281 echo "Unable to locate ninja!" 1>&2
286 if [ $__SkipConfigure == 0 ]; then
287 # if msbuild is not supported, then set __SkipGenerateVersion to 1
288 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
289 # Drop version.cpp file
290 __versionSourceFile="$intermediatesForBuild/version.cpp"
291 if [ $__SkipGenerateVersion == 0 ]; then
293 "$__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
295 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
296 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
297 if [ -e $__versionSourceFile ]; then
298 read existingVersionSourceLine < $__versionSourceFile
300 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
301 echo $__versionSourceLine > $__versionSourceFile
306 pushd "$intermediatesForBuild"
307 # Regenerate the CMake solution
308 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
309 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
313 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
314 echo "Failed to generate $message build project!"
319 if [ $__ConfigureOnly == 1 ]; then
320 echo "Finish configuration & skipping $message build."
324 # Check that the makefiles were created.
325 pushd "$intermediatesForBuild"
327 echo "Executing $buildTool install -j $__NumProc"
329 $buildTool install -j $__NumProc
331 echo "Failed to build $message."
338 build_cross_arch_component()
340 __SkipCrossArchBuild=1
342 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
343 if [[ ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") && "$__CrossArch" == "x86" ]]; then
344 export CROSSCOMPILE=0
345 __SkipCrossArchBuild=0
347 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
348 if [ "$__HostArch" == "x64" ]; then
349 export CROSSCOMPILE=1
351 elif [[ ("$__BuildArch" == "arm64") && "$__CrossArch" == "x64" ]]; then
352 export CROSSCOMPILE=0
353 __SkipCrossArchBuild=0
359 export __CMakeBinDir="$__CrossComponentBinDir"
360 export CROSSCOMPONENT=1
363 if [ $CROSSCOMPILE == 1 ]; then
364 TARGET_ROOTFS="$ROOTFS_DIR"
365 if [ -n "$CAC_ROOTFS_DIR" ]; then
366 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
368 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
372 __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"
373 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
375 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
376 if [ -n "$TARGET_ROOTFS" ]; then
377 export ROOTFS_DIR="$TARGET_ROOTFS"
379 export CROSSCOMPONENT=
380 export CROSSCOMPILE=1
383 isMSBuildOnNETCoreSupported()
385 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
387 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
391 if [ "$__HostArch" == "x64" ]; then
392 if [ "$__HostOS" == "Linux" ]; then
393 __isMSBuildOnNETCoreSupported=1
394 # note: the RIDs below can use globbing patterns
395 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
396 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
398 if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
399 __isMSBuildOnNETCoreSupported=0
403 elif [ "$__HostOS" == "OSX" ]; then
404 __isMSBuildOnNETCoreSupported=1
412 local __CrossGenExec=$1
414 echo "Generating native image for System.Private.CoreLib.dll"
415 echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll"
416 $__CrossGenExec /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
417 if [ $? -ne 0 ]; then
418 echo "Failed to generate native image for System.Private.CoreLib."
422 if [ "$__BuildOS" == "Linux" ]; then
423 echo "Generating symbol file for System.Private.CoreLib.dll"
424 echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll"
425 $__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
426 if [ $? -ne 0 ]; then
427 echo "Failed to generate symbol file for System.Private.CoreLib."
435 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
436 echo "System.Private.CoreLib.dll build unsupported."
440 if [ $__SkipMSCorLib == 1 ]; then
441 echo "Skipping building System.Private.CoreLib."
445 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
449 if [[ "$__IbcTuning" -eq "" ]]; then
450 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
451 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
453 $__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
455 if [ $? -ne 0 ]; then
456 echo "Failed to build managed components."
460 if [ $__SkipCrossgen == 1 ]; then
461 echo "Skipping generating native image"
465 # The cross build generates a crossgen with the target architecture.
466 if [ $__CrossBuild == 0 ]; then
467 if [ $__SkipCoreCLR == 1 ]; then
471 # The architecture of host pc must be same architecture with target.
472 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
473 build_CoreLib_ni "$__BinDir/crossgen"
474 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
475 build_CoreLib_ni "$__BinDir/crossgen"
476 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
477 build_CoreLib_ni "$__BinDir/crossgen"
481 elif [ $__DoCrossArchBuild == 1 ]; then
482 if [[ ( "$__CrossArch" == "x86" ) && ( "$__BuildArch" == "arm" ) ]]; then
483 build_CoreLib_ni "$__CrossComponentBinDir/crossgen"
484 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "arm64" ) ]]; then
485 build_CoreLib_ni "$__CrossComponentBinDir/crossgen"
490 generate_NugetPackages()
492 # We can only generate nuget package if we also support building mscorlib as part of this build.
493 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
494 echo "Nuget package generation unsupported."
498 # Since we can build mscorlib for this OS, did we build the native components as well?
499 if [ $__SkipCoreCLR == 1 ]; then
500 echo "Unable to generate nuget packages since native components were not built."
504 echo "Generating nuget packages for "$__BuildOS
505 echo "DistroRid is "$__DistroRid
506 echo "ROOTFS_DIR is "$ROOTFS_DIR
508 $__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 -__DoCrossArchBuild=$__DoCrossArchBuild $__RunArgs $__UnprocessedBuildArgs
510 if [ $? -ne 0 ]; then
511 echo "Failed to generate Nuget packages."
516 echo "Commencing CoreCLR Repo build"
518 # Argument types supported by this script:
520 # Build architecture - valid values are: x64, ARM.
521 # Build Type - valid values are: Debug, Checked, Release
523 # Set the default arguments for build
525 # Obtain the location of the bash script to figure out where the root of the repo is.
526 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
528 # Use uname to determine what the CPU is.
530 # Some Linux platforms report unknown for platform, but the arch for machine.
531 if [ "$CPUName" == "unknown" ]; then
537 echo "Unsupported CPU $CPUName detected, build might not succeed!"
548 echo "Unsupported CPU $CPUName detected, build might not succeed!"
563 echo "Unknown CPU $CPUName detected, configuring as if for x64"
569 # Use uname to determine what the OS is.
603 echo "Unsupported OS $OSName detected, configuring as if for Linux"
611 __IncludeTests=Include_Tests
614 # Set the various build properties here so that CMake and MSBuild can pick them up
615 __ProjectDir="$__ProjectRoot"
616 __SourceDir="$__ProjectDir/src"
617 __PackagesDir="${DotNetRestorePackagesPath:-${__ProjectDir}/packages}"
618 __RootBinDir="$__ProjectDir/bin"
619 __UnprocessedBuildArgs=
633 __SkipRestoreOptData=0
636 __ClangMajorVersion=0
637 __ClangMinorVersion=0
638 __NuGetPath="$__PackagesDir/NuGet.exe"
642 __SkipGenerateVersion=0
645 __msbuildonunsupportedplatform=0
646 __PgoOptDataVersion=""
647 __IbcOptDataVersion=""
649 # Get the number of processors available to the scheduler
650 # Other techniques such as `nproc` only get the number of
651 # processors available to a single process.
652 if [ `uname` = "FreeBSD" ]; then
653 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
654 elif [ `uname` = "NetBSD" ]; then
655 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
656 elif [ `uname` = "Darwin" ]; then
657 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
659 __NumProc=$(nproc --all)
663 if [ $# -le 0 ]; then
667 lowerI="$(echo $1 | awk '{print tolower($0)}')"
707 __CodeCoverage=Coverage
714 -portablebuild=false)
722 stripsymbols|-stripsymbols)
723 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
727 __ClangMajorVersion=3
728 __ClangMinorVersion=5
732 __ClangMajorVersion=3
733 __ClangMinorVersion=6
737 __ClangMajorVersion=3
738 __ClangMinorVersion=7
742 __ClangMajorVersion=3
743 __ClangMinorVersion=8
747 __ClangMajorVersion=3
748 __ClangMinorVersion=9
752 __ClangMajorVersion=4
753 __ClangMinorVersion=0
757 __ClangMajorVersion=5
758 __ClangMinorVersion=0
762 __ClangMajorVersion=6
763 __ClangMinorVersion=0
770 pgoinstrument|-pgoinstrument)
774 nopgooptimize|-nopgooptimize)
776 __SkipRestoreOptData=1
779 ibcinstrument|-ibcinstrument)
780 __IbcTuning="/Tuning"
783 configureonly|-configureonly)
789 skipconfigure|-skipconfigure)
793 skipnative|-skipnative)
794 # Use "skipnative" to use the same option name as build.cmd.
798 skipcoreclr|-skipcoreclr)
799 # Accept "skipcoreclr" for backwards-compatibility.
803 crosscomponent|-crosscomponent)
807 skipmscorlib|-skipmscorlib)
811 skipgenerateversion|-skipgenerateversion)
812 __SkipGenerateVersion=1
815 skiprestoreoptdata|-skiprestoreoptdata)
816 __SkipRestoreOptData=1
819 skipcrossgen|-skipcrossgen)
823 includetests|-includetests)
826 skiptests|-skiptests)
830 skipnuget|-skipnuget)
834 ignorewarnings|-ignorewarnings)
836 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
839 cmakeargs|-cmakeargs)
841 __cmakeargs="$__cmakeargs $2"
844 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
852 if [ ! -d $__RootBinDir ]; then
855 __RootBinParent=$(dirname $__RootBinDir)
856 __RootBinName=${__RootBinDir##*/}
857 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
860 echo "ERROR: 'bindir' requires a non-empty option argument"
864 msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
865 __msbuildonunsupportedplatform=1
872 echo "ERROR: 'numproc' requires a non-empty option argument"
881 echo "ERROR: 'osgroup' requires a non-empty option argument"
887 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
894 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
896 # Configure environment if we are doing a verbose build
897 if [ $__VerboseBuild == 1 ]; then
899 __RunArgs="$__RunArgs -verbose"
902 # Set default clang version
903 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
904 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
905 __ClangMajorVersion=5
906 __ClangMinorVersion=0
908 __ClangMajorVersion=3
909 __ClangMinorVersion=9
913 if [[ "$__BuildArch" == "armel" ]]; then
914 # Armel cross build is Tizen specific and does not support Portable RID build
918 if [ $__PortableBuild == 0 ]; then
919 __RunArgs="$__RunArgs -PortableBuild=false"
922 # Set dependent variables
923 __LogsDir="$__RootBinDir/Logs"
925 # init the host distro name
928 # Set the remaining variables based upon the determined build configuration
929 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
930 __PackagesBinDir="$__BinDir/.nuget"
931 __ToolsDir="$__RootBinDir/tools"
932 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
933 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
934 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
935 __isMSBuildOnNETCoreSupported=0
936 __CrossComponentBinDir="$__BinDir"
937 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
939 __CrossArch="$__HostArch"
940 if [[ "$__HostArch" == "x64" && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
943 if [ $__CrossBuild == 1 ]; then
944 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
946 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
947 __CrossgenExe="$__CrossComponentBinDir/crossgen"
949 # Init if MSBuild for .NET Core is supported for this platform
950 isMSBuildOnNETCoreSupported
952 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
953 # This is needed by CLI to function.
954 if [ -z "$HOME" ]; then
955 if [ ! -d "$__ProjectDir/temp_home" ]; then
958 export HOME=$__ProjectDir/temp_home
959 echo "HOME not defined; setting it to $HOME"
962 # Specify path to be set for CMAKE_INSTALL_PREFIX.
963 # This is where all built CoreClr libraries will copied to.
964 export __CMakeBinDir="$__BinDir"
966 # Configure environment if we are doing a cross compile.
967 if [ $__CrossBuild == 1 ]; then
968 export CROSSCOMPILE=1
969 if ! [[ -n "$ROOTFS_DIR" ]]; then
970 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
974 # init the target distro name
977 # Make the directories necessary for build if they don't exist
983 # Restore the package containing profile counts for profile-guided optimizations
986 # Generate event logging infrastructure sources
987 generate_event_logging
989 # Build the coreclr (native) components.
990 __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"
991 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
993 # Build cross-architecture components
994 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
995 build_cross_arch_component
998 # Build System.Private.CoreLib.
1002 # Generate nuget packages
1003 if [ $__SkipNuget != 1 ]; then
1004 generate_NugetPackages
1010 echo "Repo successfully built."
1011 echo "Product binaries are available at $__BinDir"