3 # resolve python-version to use
4 if [ "$PYTHON" == "" ] ; then
5 if ! PYTHON=$(command -v python2.7 || command -v python2 || command -v python)
7 echo "Unable to locate build-dependency python2.x!" 1>&2
12 # validate python-dependency
13 # useful in case of explicitly set option.
14 if ! command -v $PYTHON > /dev/null
16 echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2
22 echo "Usage: $0 [BuildArch] [BuildType] [-verbose] [-coverage] [-cross] [-clangx.y] [-ninja] [-configureonly] [-skipconfigure] [-skipnative] [-skipmscorlib] [-skiptests] [-stripsymbols] [-ignorewarnings] [-cmakeargs] [-bindir]"
23 echo "BuildArch can be: -x64, -x86, -arm, -armel, -arm64"
24 echo "BuildType can be: -debug, -checked, -release"
25 echo "-coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
26 echo "-ninja - target ninja instead of GNU make"
27 echo "-clangx.y - optional argument to build using clang version x.y."
28 echo "-cross - optional argument to signify cross compilation,"
29 echo " - will use ROOTFS_DIR environment variable if set."
30 echo "-crosscomponent - optional argument to build cross-architecture component,"
31 echo " - will use CAC_ROOTFS_DIR environment variable if set."
32 echo "-nopgooptimize - do not use profile guided optimizations."
33 echo "-pgoinstrument - generate instrumented code for profile guided optimization enabled binaries."
34 echo "-ibcinstrument - generate IBC-tuning-enabled native images when invoking crossgen."
35 echo "-configureonly - do not perform any builds; just configure the build."
36 echo "-skipconfigure - skip build configuration."
37 echo "-skipnative - do not build native components."
38 echo "-skipmscorlib - do not build mscorlib.dll."
39 echo "-skiptests - skip the tests in the 'tests' subdirectory."
40 echo "-skipnuget - skip building nuget packages."
41 echo "-skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations."
42 echo "-skipcrossgen - skip native image generation"
43 echo "-verbose - optional argument to enable verbose build output."
44 echo "-skiprestore: skip restoring packages ^(default: packages are restored during build^)."
45 echo "-disableoss: Disable Open Source Signing for System.Private.CoreLib."
46 echo "-officialbuildid=^<ID^>: specify the official build ID to be used by this build."
47 echo "-Rebuild: passes /t:rebuild to the build projects."
48 echo "-stripSymbols - Optional argument to strip native symbols during the build."
49 echo "-skipgenerateversion - disable version generation even if MSBuild is supported."
50 echo "-ignorewarnings - do not treat warnings as errors"
51 echo "-cmakeargs - user-settable additional arguments passed to CMake."
52 echo "-bindir - output directory (defaults to $__ProjectRoot/bin)"
53 echo "-msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
54 echo "-numproc - set the number of build processes."
61 if [ "$__HostOS" == "Linux" ]; then
62 if [ -e /etc/os-release ]; then
63 source /etc/os-release
64 if [[ $ID == "alpine" || $ID == "rhel" ]]; then
65 # remove the last version digit
66 VERSION_ID=${VERSION_ID%.*}
68 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
69 elif [ -e /etc/redhat-release ]; then
70 local redhatRelease=$(</etc/redhat-release)
71 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
72 __HostDistroRid="rhel.6-$__HostArch"
76 if [ "$__HostOS" == "FreeBSD" ]; then
77 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
78 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
81 if [ "$__HostDistroRid" == "" ]; then
82 echo "WARNING: Can not determine runtime id for current distro."
88 if [ $__CrossBuild == 1 ]; then
89 if [ "$__BuildOS" == "Linux" ]; then
90 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
91 if [ -e $ROOTFS_DIR/android_platform ]; then
92 source $ROOTFS_DIR/android_platform
93 export __DistroRid="$RID"
95 echo "WARNING: Can not determine runtime id for current distro."
99 source $ROOTFS_DIR/etc/os-release
100 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
104 export __DistroRid="$__HostDistroRid"
107 if [ "$__BuildOS" == "OSX" ]; then
111 # Portable builds target the base RID
112 if [ $__PortableBuild == 1 ]; then
113 if [ "$__BuildOS" == "Linux" ]; then
114 export __DistroRid="linux-$__BuildArch"
115 elif [ "$__BuildOS" == "OSX" ]; then
116 export __DistroRid="osx-$__BuildArch"
117 elif [ "$__BuildOS" == "FreeBSD" ]; then
118 export __DistroRid="freebsd-$__BuildArch"
125 echo Setting up directories for build
127 mkdir -p "$__RootBinDir"
129 mkdir -p "$__LogsDir"
130 mkdir -p "$__IntermediatesDir"
132 if [ $__CrossBuild == 1 ]; then
133 mkdir -p "$__CrossComponentBinDir"
134 mkdir -p "$__CrossCompIntermediatesDir"
138 # Check the system to ensure the right prereqs are in place
142 echo "Checking prerequisites..."
144 # Check presence of CMake on the path
145 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
148 # Minimum required version of clang is version 3.9 for arm/armel cross build
149 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
150 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
151 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
156 hash clang-$__ClangMajorVersion.$__ClangMinorVersion 2>/dev/null || hash clang$__ClangMajorVersion$__ClangMinorVersion 2>/dev/null || hash clang 2>/dev/null || { echo >&2 "Please install clang-$__ClangMajorVersion.$__ClangMinorVersion before running this script"; exit 1; }
162 # we only need optdata on a Release build
163 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
165 if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
166 echo "Restoring the OptimizationData package"
167 "$__ProjectRoot/run.sh" build -optdata $__RunArgs $__UnprocessedBuildArgs
169 echo "Failed to restore the optimization data package."
174 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
175 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
176 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
177 if [ ! -f $DotNetCli ]; then
178 source "$__ProjectRoot/init-tools.sh"
180 echo "Failed to restore buildtools."
184 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
185 __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
186 __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
190 generate_event_logging_sources()
193 __ConsumingBuildSystem=$2
195 __OutputIncDir="$__OutputDir/src/inc"
196 __OutputEventingDir="$__OutputDir/eventing"
197 __OutputEventProviderDir="$__OutputEventingDir/eventprovider"
199 echo "Laying out dynamically generated files consumed by $__ConsumingBuildSystem"
200 echo "Laying out dynamically generated Event test files, etmdummy stub functions, and external linkages"
202 __PythonWarningFlags="-Wall"
203 if [[ $__IgnoreWarnings == 0 ]]; then
204 __PythonWarningFlags="$__PythonWarningFlags -Werror"
207 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventing.py" --inc $__OutputIncDir --dummy $__OutputIncDir/etmdummy.h --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --testdir "$__OutputEventProviderDir/tests"
208 if [[ $? != 0 ]]; then
212 echo "Laying out dynamically generated EventPipe Implementation"
213 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventingDir/eventpipe"
215 # determine the logging system
218 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
219 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genLttngProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventProviderDir"
220 if [[ $? != 0 ]]; then
225 echo "Laying out dummy event logging provider"
226 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genDummyProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventProviderDir"
227 if [[ $? != 0 ]]; then
234 generate_event_logging()
236 # Event Logging Infrastructure
237 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
238 generate_event_logging_sources "$__IntermediatesDir" "the native build system"
241 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
242 generate_event_logging_sources "$__CrossCompIntermediatesDir" "the crossarch build system"
250 intermediatesForBuild="$3"
251 extraCmakeArguments="$4"
254 if [ $skipCondition == 1 ]; then
255 echo "Skipping $message build."
259 # All set to commence the build
260 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
265 if [ $__UseNinja == 1 ]; then
267 buildFile="build.ninja"
268 if ! buildTool=$(command -v ninja || command -v ninja-build); then
269 echo "Unable to locate ninja!" 1>&2
274 if [ $__SkipConfigure == 0 ]; then
275 # if msbuild is not supported, then set __SkipGenerateVersion to 1
276 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
277 # Drop version.cpp file
278 __versionSourceFile="$intermediatesForBuild/version.cpp"
279 if [ $__SkipGenerateVersion == 0 ]; then
281 "$__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
283 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
284 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
285 if [ -e $__versionSourceFile ]; then
286 read existingVersionSourceLine < $__versionSourceFile
288 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
289 echo $__versionSourceLine > $__versionSourceFile
294 pushd "$intermediatesForBuild"
295 # Regenerate the CMake solution
296 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
297 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
301 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
302 echo "Failed to generate $message build project!"
307 if [ $__ConfigureOnly == 1 ]; then
308 echo "Finish configuration & skipping $message build."
312 # Check that the makefiles were created.
313 pushd "$intermediatesForBuild"
315 echo "Executing $buildTool install -j $__NumProc"
317 $buildTool install -j $__NumProc
319 echo "Failed to build $message."
326 build_cross_arch_component()
328 __SkipCrossArchBuild=1
330 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
331 if [[ ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") && "$__CrossArch" == "x86" ]]; then
332 export CROSSCOMPILE=0
333 __SkipCrossArchBuild=0
335 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
336 if [ "$__HostArch" == "x64" ]; then
337 export CROSSCOMPILE=1
344 export __CMakeBinDir="$__CrossComponentBinDir"
345 export CROSSCOMPONENT=1
348 if [ $CROSSCOMPILE == 1 ]; then
349 TARGET_ROOTFS="$ROOTFS_DIR"
350 if [ -n "$CAC_ROOTFS_DIR" ]; then
351 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
353 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
357 __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"
358 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
360 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
361 if [ -n "$TARGET_ROOTFS" ]; then
362 export ROOTFS_DIR="$TARGET_ROOTFS"
364 export CROSSCOMPONENT=
365 export CROSSCOMPILE=1
368 isMSBuildOnNETCoreSupported()
370 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
372 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
376 if [ "$__HostArch" == "x64" ]; then
377 if [ "$__HostOS" == "Linux" ]; then
378 __isMSBuildOnNETCoreSupported=1
379 # note: the RIDs below can use globbing patterns
380 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
381 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
383 if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
384 __isMSBuildOnNETCoreSupported=0
388 elif [ "$__HostOS" == "OSX" ]; then
389 __isMSBuildOnNETCoreSupported=1
397 local __CrossGenExec=$1
399 echo "Generating native image for System.Private.CoreLib.dll"
400 echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll"
401 $__CrossGenExec /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
402 if [ $? -ne 0 ]; then
403 echo "Failed to generate native image for System.Private.CoreLib."
407 if [ "$__BuildOS" == "Linux" ]; then
408 echo "Generating symbol file for System.Private.CoreLib.dll"
409 echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll"
410 $__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
411 if [ $? -ne 0 ]; then
412 echo "Failed to generate symbol file for System.Private.CoreLib."
420 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
421 echo "System.Private.CoreLib.dll build unsupported."
425 if [ $__SkipMSCorLib == 1 ]; then
426 echo "Skipping building System.Private.CoreLib."
430 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
434 if [[ "$__IbcTuning" -eq "" ]]; then
435 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
436 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
438 $__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
440 if [ $? -ne 0 ]; then
441 echo "Failed to build managed components."
445 if [ $__SkipCrossgen == 1 ]; then
446 echo "Skipping generating native image"
450 # The cross build generates a crossgen with the target architecture.
451 if [ $__CrossBuild == 0 ]; then
452 if [ $__SkipCoreCLR == 1 ]; then
456 # The architecture of host pc must be same architecture with target.
457 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
458 build_CoreLib_ni "$__BinDir/crossgen"
459 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
460 build_CoreLib_ni "$__BinDir/crossgen"
461 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
462 build_CoreLib_ni "$__BinDir/crossgen"
466 elif [ $__DoCrossArchBuild == 1 ]; then
467 if [[ ( "$__CrossArch" == "x86" ) && ( "$__BuildArch" == "arm" ) ]]; then
468 build_CoreLib_ni "$__CrossComponentBinDir/crossgen"
473 generate_NugetPackages()
475 # We can only generate nuget package if we also support building mscorlib as part of this build.
476 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
477 echo "Nuget package generation unsupported."
481 # Since we can build mscorlib for this OS, did we build the native components as well?
482 if [ $__SkipCoreCLR == 1 ]; then
483 echo "Unable to generate nuget packages since native components were not built."
487 echo "Generating nuget packages for "$__BuildOS
488 echo "DistroRid is "$__DistroRid
489 echo "ROOTFS_DIR is "$ROOTFS_DIR
491 $__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
493 if [ $? -ne 0 ]; then
494 echo "Failed to generate Nuget packages."
499 echo "Commencing CoreCLR Repo build"
501 # Argument types supported by this script:
503 # Build architecture - valid values are: x64, ARM.
504 # Build Type - valid values are: Debug, Checked, Release
506 # Set the default arguments for build
508 # Obtain the location of the bash script to figure out where the root of the repo is.
509 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
511 # Use uname to determine what the CPU is.
513 # Some Linux platforms report unknown for platform, but the arch for machine.
514 if [ "$CPUName" == "unknown" ]; then
520 echo "Unsupported CPU $CPUName detected, build might not succeed!"
531 echo "Unsupported CPU $CPUName detected, build might not succeed!"
546 echo "Unknown CPU $CPUName detected, configuring as if for x64"
552 # Use uname to determine what the OS is.
586 echo "Unsupported OS $OSName detected, configuring as if for Linux"
594 __IncludeTests=Include_Tests
597 # Set the various build properties here so that CMake and MSBuild can pick them up
598 __ProjectDir="$__ProjectRoot"
599 __SourceDir="$__ProjectDir/src"
600 __PackagesDir="${DotNetRestorePackagesPath:-${__ProjectDir}/packages}"
601 __RootBinDir="$__ProjectDir/bin"
602 __UnprocessedBuildArgs=
616 __SkipRestoreOptData=0
619 __ClangMajorVersion=0
620 __ClangMinorVersion=0
621 __NuGetPath="$__PackagesDir/NuGet.exe"
625 __SkipGenerateVersion=0
628 __msbuildonunsupportedplatform=0
629 __PgoOptDataVersion=""
630 __IbcOptDataVersion=""
632 # Get the number of processors available to the scheduler
633 # Other techniques such as `nproc` only get the number of
634 # processors available to a single process.
635 if [ `uname` = "FreeBSD" ]; then
636 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
637 elif [ `uname` = "NetBSD" ]; then
638 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
639 elif [ `uname` = "Darwin" ]; then
640 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
642 __NumProc=$(nproc --all)
646 if [ $# -le 0 ]; then
650 lowerI="$(echo $1 | awk '{print tolower($0)}')"
690 __CodeCoverage=Coverage
697 -portablebuild=false)
705 stripsymbols|-stripsymbols)
706 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
710 __ClangMajorVersion=3
711 __ClangMinorVersion=5
715 __ClangMajorVersion=3
716 __ClangMinorVersion=6
720 __ClangMajorVersion=3
721 __ClangMinorVersion=7
725 __ClangMajorVersion=3
726 __ClangMinorVersion=8
730 __ClangMajorVersion=3
731 __ClangMinorVersion=9
735 __ClangMajorVersion=4
736 __ClangMinorVersion=0
740 __ClangMajorVersion=5
741 __ClangMinorVersion=0
745 __ClangMajorVersion=6
746 __ClangMinorVersion=0
753 pgoinstrument|-pgoinstrument)
757 nopgooptimize|-nopgooptimize)
759 __SkipRestoreOptData=1
762 ibcinstrument|-ibcinstrument)
763 __IbcTuning="/Tuning"
766 configureonly|-configureonly)
772 skipconfigure|-skipconfigure)
776 skipnative|-skipnative)
777 # Use "skipnative" to use the same option name as build.cmd.
781 skipcoreclr|-skipcoreclr)
782 # Accept "skipcoreclr" for backwards-compatibility.
786 crosscomponent|-crosscomponent)
790 skipmscorlib|-skipmscorlib)
794 skipgenerateversion|-skipgenerateversion)
795 __SkipGenerateVersion=1
798 skiprestoreoptdata|-skiprestoreoptdata)
799 __SkipRestoreOptData=1
802 skipcrossgen|-skipcrossgen)
806 includetests|-includetests)
809 skiptests|-skiptests)
813 skipnuget|-skipnuget)
817 ignorewarnings|-ignorewarnings)
819 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
822 cmakeargs|-cmakeargs)
824 __cmakeargs="$__cmakeargs $2"
827 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
835 if [ ! -d $__RootBinDir ]; then
838 __RootBinParent=$(dirname $__RootBinDir)
839 __RootBinName=${__RootBinDir##*/}
840 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
843 echo "ERROR: 'bindir' requires a non-empty option argument"
847 msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
848 __msbuildonunsupportedplatform=1
855 echo "ERROR: 'numproc' requires a non-empty option argument"
864 echo "ERROR: 'osgroup' requires a non-empty option argument"
870 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
877 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
879 # Configure environment if we are doing a verbose build
880 if [ $__VerboseBuild == 1 ]; then
882 __RunArgs="$__RunArgs -verbose"
885 # Set default clang version
886 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
887 __ClangMajorVersion=3
888 __ClangMinorVersion=9
891 if [[ "$__BuildArch" == "armel" ]]; then
892 # Armel cross build is Tizen specific and does not support Portable RID build
896 if [ $__PortableBuild == 0 ]; then
897 __RunArgs="$__RunArgs -PortableBuild=false"
900 # Set dependent variables
901 __LogsDir="$__RootBinDir/Logs"
903 # init the host distro name
906 # Set the remaining variables based upon the determined build configuration
907 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
908 __PackagesBinDir="$__BinDir/.nuget"
909 __ToolsDir="$__RootBinDir/tools"
910 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
911 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
912 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
913 __isMSBuildOnNETCoreSupported=0
914 __CrossComponentBinDir="$__BinDir"
915 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
917 __CrossArch="$__HostArch"
918 if [[ "$__HostArch" == "x64" && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
921 if [ $__CrossBuild == 1 ]; then
922 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
924 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
925 __CrossgenExe="$__CrossComponentBinDir/crossgen"
927 # Init if MSBuild for .NET Core is supported for this platform
928 isMSBuildOnNETCoreSupported
930 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
931 # This is needed by CLI to function.
932 if [ -z "$HOME" ]; then
933 if [ ! -d "$__ProjectDir/temp_home" ]; then
936 export HOME=$__ProjectDir/temp_home
937 echo "HOME not defined; setting it to $HOME"
940 # Specify path to be set for CMAKE_INSTALL_PREFIX.
941 # This is where all built CoreClr libraries will copied to.
942 export __CMakeBinDir="$__BinDir"
944 # Configure environment if we are doing a cross compile.
945 if [ $__CrossBuild == 1 ]; then
946 export CROSSCOMPILE=1
947 if ! [[ -n "$ROOTFS_DIR" ]]; then
948 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
952 # init the target distro name
955 # Make the directories necessary for build if they don't exist
961 # Restore the package containing profile counts for profile-guided optimizations
964 # Generate event logging infrastructure sources
965 generate_event_logging
967 # Build the coreclr (native) components.
968 __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"
969 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
971 # Build cross-architecture components
972 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
973 build_cross_arch_component
976 # Build System.Private.CoreLib.
980 # Generate nuget packages
981 if [ $__SkipNuget != 1 ]; then
982 generate_NugetPackages
988 echo "Repo successfully built."
989 echo "Product binaries are available at $__BinDir"