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 == "alpine" || $ID == "rhel" ]]; then
70 # remove the last version digit
71 VERSION_ID=${VERSION_ID%.*}
73 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
74 elif [ -e /etc/redhat-release ]; then
75 local redhatRelease=$(</etc/redhat-release)
76 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
77 __HostDistroRid="rhel.6-$__HostArch"
81 if [ "$__HostOS" == "FreeBSD" ]; then
82 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
83 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
86 if [ "$__HostDistroRid" == "" ]; then
87 echo "WARNING: Can not determine runtime id for current distro."
93 if [ $__CrossBuild == 1 ]; then
94 if [ "$__BuildOS" == "Linux" ]; then
95 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
96 if [ -e $ROOTFS_DIR/android_platform ]; then
97 source $ROOTFS_DIR/android_platform
98 export __DistroRid="$RID"
100 echo "WARNING: Can not determine runtime id for current distro."
101 export __DistroRid=""
104 source $ROOTFS_DIR/etc/os-release
105 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
109 export __DistroRid="$__HostDistroRid"
112 if [ "$__BuildOS" == "OSX" ]; then
116 # Portable builds target the base RID
117 if [ $__PortableBuild == 1 ]; then
118 if [ "$__BuildOS" == "Linux" ]; then
119 export __DistroRid="linux-$__BuildArch"
120 elif [ "$__BuildOS" == "OSX" ]; then
121 export __DistroRid="osx-$__BuildArch"
122 elif [ "$__BuildOS" == "FreeBSD" ]; then
123 export __DistroRid="freebsd-$__BuildArch"
130 echo Setting up directories for build
132 mkdir -p "$__RootBinDir"
134 mkdir -p "$__LogsDir"
135 mkdir -p "$__IntermediatesDir"
137 if [ $__CrossBuild == 1 ]; then
138 mkdir -p "$__CrossComponentBinDir"
139 mkdir -p "$__CrossCompIntermediatesDir"
143 # Check the system to ensure the right prereqs are in place
147 echo "Checking prerequisites..."
149 # Check presence of CMake on the path
150 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
153 # Minimum required version of clang is version 4.0 for arm/armel cross build
154 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
155 if ! [[ "$__ClangMajorVersion" -ge "4" ]]; then
156 echo "Please install clang4.0 or latest for arm/armel cross build"; exit 1;
161 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; }
167 # we only need optdata on a Release build
168 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
170 if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
171 echo "Restoring the OptimizationData package"
172 "$__ProjectRoot/run.sh" build -optdata $__RunArgs $__UnprocessedBuildArgs
174 echo "Failed to restore the optimization data package."
179 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
180 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
181 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
182 if [ ! -f $DotNetCli ]; then
183 source "$__ProjectRoot/init-tools.sh"
185 echo "Failed to restore buildtools."
189 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
190 __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
191 __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
195 generate_event_logging_sources()
198 __ConsumingBuildSystem=$2
200 __OutputIncDir="$__OutputDir/src/inc"
201 __OutputEventingDir="$__OutputDir/eventing"
202 __OutputEventProviderDir="$__OutputEventingDir/eventprovider"
204 echo "Laying out dynamically generated files consumed by $__ConsumingBuildSystem"
205 echo "Laying out dynamically generated Event test files, etmdummy stub functions, and external linkages"
207 __PythonWarningFlags="-Wall"
208 if [[ $__IgnoreWarnings == 0 ]]; then
209 __PythonWarningFlags="$__PythonWarningFlags -Werror"
212 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventing.py" --inc $__OutputIncDir --dummy $__OutputIncDir/etmdummy.h --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --testdir "$__OutputEventProviderDir/tests"
213 if [[ $? != 0 ]]; then
217 echo "Laying out dynamically generated EventPipe Implementation"
218 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventingDir/eventpipe"
220 # determine the logging system
223 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
224 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genLttngProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventProviderDir"
225 if [[ $? != 0 ]]; then
230 echo "Laying out dummy event logging provider"
231 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genDummyProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventProviderDir"
232 if [[ $? != 0 ]]; then
239 generate_event_logging()
241 # Event Logging Infrastructure
242 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
243 generate_event_logging_sources "$__IntermediatesDir" "the native build system"
246 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
247 generate_event_logging_sources "$__CrossCompIntermediatesDir" "the crossarch build system"
255 intermediatesForBuild="$3"
256 extraCmakeArguments="$4"
259 if [ $skipCondition == 1 ]; then
260 echo "Skipping $message build."
264 # All set to commence the build
265 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
270 if [ $__UseNinja == 1 ]; then
272 buildFile="build.ninja"
273 if ! buildTool=$(command -v ninja || command -v ninja-build); then
274 echo "Unable to locate ninja!" 1>&2
279 if [ $__SkipConfigure == 0 ]; then
280 # if msbuild is not supported, then set __SkipGenerateVersion to 1
281 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
282 # Drop version.cpp file
283 __versionSourceFile="$intermediatesForBuild/version.cpp"
284 if [ $__SkipGenerateVersion == 0 ]; then
286 "$__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
288 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
289 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
290 if [ -e $__versionSourceFile ]; then
291 read existingVersionSourceLine < $__versionSourceFile
293 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
294 echo $__versionSourceLine > $__versionSourceFile
299 pushd "$intermediatesForBuild"
300 # Regenerate the CMake solution
301 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
302 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
306 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
307 echo "Failed to generate $message build project!"
312 if [ $__ConfigureOnly == 1 ]; then
313 echo "Finish configuration & skipping $message build."
317 # Check that the makefiles were created.
318 pushd "$intermediatesForBuild"
320 echo "Executing $buildTool install -j $__NumProc"
322 $buildTool install -j $__NumProc
324 echo "Failed to build $message."
331 build_cross_arch_component()
333 __SkipCrossArchBuild=1
335 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
336 if [[ ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") && "$__CrossArch" == "x86" ]]; then
337 export CROSSCOMPILE=0
338 __SkipCrossArchBuild=0
340 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
341 if [ "$__HostArch" == "x64" ]; then
342 export CROSSCOMPILE=1
344 elif [[ ("$__BuildArch" == "arm64") && "$__CrossArch" == "x64" ]]; then
345 export CROSSCOMPILE=0
346 __SkipCrossArchBuild=0
352 export __CMakeBinDir="$__CrossComponentBinDir"
353 export CROSSCOMPONENT=1
356 if [ $CROSSCOMPILE == 1 ]; then
357 TARGET_ROOTFS="$ROOTFS_DIR"
358 if [ -n "$CAC_ROOTFS_DIR" ]; then
359 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
361 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
365 __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"
366 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
368 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
369 if [ -n "$TARGET_ROOTFS" ]; then
370 export ROOTFS_DIR="$TARGET_ROOTFS"
372 export CROSSCOMPONENT=
373 export CROSSCOMPILE=1
376 isMSBuildOnNETCoreSupported()
378 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
380 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
384 if [ "$__HostArch" == "x64" ]; then
385 if [ "$__HostOS" == "Linux" ]; then
386 __isMSBuildOnNETCoreSupported=1
387 # note: the RIDs below can use globbing patterns
388 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
389 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
391 if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
392 __isMSBuildOnNETCoreSupported=0
396 elif [ "$__HostOS" == "OSX" ]; then
397 __isMSBuildOnNETCoreSupported=1
405 local __CrossGenExec=$1
407 echo "Generating native image for System.Private.CoreLib.dll"
408 echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll"
409 $__CrossGenExec /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
410 if [ $? -ne 0 ]; then
411 echo "Failed to generate native image for System.Private.CoreLib."
415 if [ "$__BuildOS" == "Linux" ]; then
416 echo "Generating symbol file for System.Private.CoreLib.dll"
417 echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll"
418 $__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
419 if [ $? -ne 0 ]; then
420 echo "Failed to generate symbol file for System.Private.CoreLib."
428 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
429 echo "System.Private.CoreLib.dll build unsupported."
433 if [ $__SkipMSCorLib == 1 ]; then
434 echo "Skipping building System.Private.CoreLib."
438 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
442 if [[ "$__IbcTuning" -eq "" ]]; then
443 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
444 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
446 $__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
448 if [ $? -ne 0 ]; then
449 echo "Failed to build managed components."
453 if [ $__SkipCrossgen == 1 ]; then
454 echo "Skipping generating native image"
458 # The cross build generates a crossgen with the target architecture.
459 if [ $__CrossBuild == 0 ]; then
460 if [ $__SkipCoreCLR == 1 ]; then
464 # The architecture of host pc must be same architecture with target.
465 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
466 build_CoreLib_ni "$__BinDir/crossgen"
467 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
468 build_CoreLib_ni "$__BinDir/crossgen"
469 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
470 build_CoreLib_ni "$__BinDir/crossgen"
474 elif [ $__DoCrossArchBuild == 1 ]; then
475 if [[ ( "$__CrossArch" == "x86" ) && ( "$__BuildArch" == "arm" ) ]]; then
476 build_CoreLib_ni "$__CrossComponentBinDir/crossgen"
477 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "arm64" ) ]]; then
478 build_CoreLib_ni "$__CrossComponentBinDir/crossgen"
483 generate_NugetPackages()
485 # We can only generate nuget package if we also support building mscorlib as part of this build.
486 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
487 echo "Nuget package generation unsupported."
491 # Since we can build mscorlib for this OS, did we build the native components as well?
492 if [ $__SkipCoreCLR == 1 ]; then
493 echo "Unable to generate nuget packages since native components were not built."
497 echo "Generating nuget packages for "$__BuildOS
498 echo "DistroRid is "$__DistroRid
499 echo "ROOTFS_DIR is "$ROOTFS_DIR
501 $__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
503 if [ $? -ne 0 ]; then
504 echo "Failed to generate Nuget packages."
509 echo "Commencing CoreCLR Repo build"
511 # Argument types supported by this script:
513 # Build architecture - valid values are: x64, ARM.
514 # Build Type - valid values are: Debug, Checked, Release
516 # Set the default arguments for build
518 # Obtain the location of the bash script to figure out where the root of the repo is.
519 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
521 # Use uname to determine what the CPU is.
523 # Some Linux platforms report unknown for platform, but the arch for machine.
524 if [ "$CPUName" == "unknown" ]; then
530 echo "Unsupported CPU $CPUName detected, build might not succeed!"
541 echo "Unsupported CPU $CPUName detected, build might not succeed!"
556 echo "Unknown CPU $CPUName detected, configuring as if for x64"
562 # Use uname to determine what the OS is.
596 echo "Unsupported OS $OSName detected, configuring as if for Linux"
604 __IncludeTests=Include_Tests
607 # Set the various build properties here so that CMake and MSBuild can pick them up
608 __ProjectDir="$__ProjectRoot"
609 __SourceDir="$__ProjectDir/src"
610 __PackagesDir="${DotNetRestorePackagesPath:-${__ProjectDir}/packages}"
611 __RootBinDir="$__ProjectDir/bin"
612 __UnprocessedBuildArgs=
626 __SkipRestoreOptData=0
629 __ClangMajorVersion=0
630 __ClangMinorVersion=0
631 __NuGetPath="$__PackagesDir/NuGet.exe"
635 __SkipGenerateVersion=0
638 __msbuildonunsupportedplatform=0
639 __PgoOptDataVersion=""
640 __IbcOptDataVersion=""
642 # Get the number of processors available to the scheduler
643 # Other techniques such as `nproc` only get the number of
644 # processors available to a single process.
645 if [ `uname` = "FreeBSD" ]; then
646 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
647 elif [ `uname` = "NetBSD" ]; then
648 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
649 elif [ `uname` = "Darwin" ]; then
650 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
652 __NumProc=$(nproc --all)
656 if [ $# -le 0 ]; then
660 lowerI="$(echo $1 | awk '{print tolower($0)}')"
700 __CodeCoverage=Coverage
707 -portablebuild=false)
715 stripsymbols|-stripsymbols)
716 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
720 __ClangMajorVersion=3
721 __ClangMinorVersion=5
725 __ClangMajorVersion=3
726 __ClangMinorVersion=6
730 __ClangMajorVersion=3
731 __ClangMinorVersion=7
735 __ClangMajorVersion=3
736 __ClangMinorVersion=8
740 __ClangMajorVersion=3
741 __ClangMinorVersion=9
745 __ClangMajorVersion=4
746 __ClangMinorVersion=0
750 __ClangMajorVersion=5
751 __ClangMinorVersion=0
755 __ClangMajorVersion=6
756 __ClangMinorVersion=0
763 pgoinstrument|-pgoinstrument)
767 nopgooptimize|-nopgooptimize)
769 __SkipRestoreOptData=1
772 ibcinstrument|-ibcinstrument)
773 __IbcTuning="/Tuning"
776 configureonly|-configureonly)
782 skipconfigure|-skipconfigure)
786 skipnative|-skipnative)
787 # Use "skipnative" to use the same option name as build.cmd.
791 skipcoreclr|-skipcoreclr)
792 # Accept "skipcoreclr" for backwards-compatibility.
796 crosscomponent|-crosscomponent)
800 skipmscorlib|-skipmscorlib)
804 skipgenerateversion|-skipgenerateversion)
805 __SkipGenerateVersion=1
808 skiprestoreoptdata|-skiprestoreoptdata)
809 __SkipRestoreOptData=1
812 skipcrossgen|-skipcrossgen)
816 includetests|-includetests)
819 skiptests|-skiptests)
823 skipnuget|-skipnuget)
827 ignorewarnings|-ignorewarnings)
829 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
832 cmakeargs|-cmakeargs)
834 __cmakeargs="$__cmakeargs $2"
837 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
845 if [ ! -d $__RootBinDir ]; then
848 __RootBinParent=$(dirname $__RootBinDir)
849 __RootBinName=${__RootBinDir##*/}
850 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
853 echo "ERROR: 'bindir' requires a non-empty option argument"
857 msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
858 __msbuildonunsupportedplatform=1
865 echo "ERROR: 'numproc' requires a non-empty option argument"
874 echo "ERROR: 'osgroup' requires a non-empty option argument"
880 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
887 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
889 # Configure environment if we are doing a verbose build
890 if [ $__VerboseBuild == 1 ]; then
892 __RunArgs="$__RunArgs -verbose"
895 # Set default clang version
896 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
897 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
898 __ClangMajorVersion=5
899 __ClangMinorVersion=0
901 __ClangMajorVersion=3
902 __ClangMinorVersion=9
906 if [[ "$__BuildArch" == "armel" ]]; then
907 # Armel cross build is Tizen specific and does not support Portable RID build
911 if [ $__PortableBuild == 0 ]; then
912 __RunArgs="$__RunArgs -PortableBuild=false"
915 # Set dependent variables
916 __LogsDir="$__RootBinDir/Logs"
918 # init the host distro name
921 # Set the remaining variables based upon the determined build configuration
922 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
923 __PackagesBinDir="$__BinDir/.nuget"
924 __ToolsDir="$__RootBinDir/tools"
925 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
926 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
927 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
928 __isMSBuildOnNETCoreSupported=0
929 __CrossComponentBinDir="$__BinDir"
930 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
932 __CrossArch="$__HostArch"
933 if [[ "$__HostArch" == "x64" && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
936 if [ $__CrossBuild == 1 ]; then
937 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
939 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
940 __CrossgenExe="$__CrossComponentBinDir/crossgen"
942 # Init if MSBuild for .NET Core is supported for this platform
943 isMSBuildOnNETCoreSupported
945 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
946 # This is needed by CLI to function.
947 if [ -z "$HOME" ]; then
948 if [ ! -d "$__ProjectDir/temp_home" ]; then
951 export HOME=$__ProjectDir/temp_home
952 echo "HOME not defined; setting it to $HOME"
955 # Specify path to be set for CMAKE_INSTALL_PREFIX.
956 # This is where all built CoreClr libraries will copied to.
957 export __CMakeBinDir="$__BinDir"
959 # Configure environment if we are doing a cross compile.
960 if [ $__CrossBuild == 1 ]; then
961 export CROSSCOMPILE=1
962 if ! [[ -n "$ROOTFS_DIR" ]]; then
963 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
967 # init the target distro name
970 # Make the directories necessary for build if they don't exist
976 # Restore the package containing profile counts for profile-guided optimizations
979 # Generate event logging infrastructure sources
980 generate_event_logging
982 # Build the coreclr (native) components.
983 __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"
984 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
986 # Build cross-architecture components
987 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
988 build_cross_arch_component
991 # Build System.Private.CoreLib.
995 # Generate nuget packages
996 if [ $__SkipNuget != 1 ]; then
997 generate_NugetPackages
1003 echo "Repo successfully built."
1004 echo "Product binaries are available at $__BinDir"