3 # resolve python-version to use
4 if [ "$PYTHON" == "" ] ; then
5 if ! PYTHON=$(command -v python || command -v python2 || command -v python 2.7)
7 echo "Unable to locate build-dependency python2.x!" 1>&2
12 # validate python-dependency
13 # useful in case of explicitly set option.
14 if ! command -v $PYTHON > /dev/null
16 echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2
22 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [configureonly] [skipconfigure] [skipnative] [skipmscorlib] [skiptests] [stripsymbols] [ignorewarnings] [cmakeargs] [bindir]"
23 echo "BuildArch can be: x64, x86, arm, armel, arm64"
24 echo "BuildType can be: debug, checked, release"
25 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
26 echo "ninja - target ninja instead of GNU make"
27 echo "clangx.y - optional argument to build using clang version x.y."
28 echo "cross - optional argument to signify cross compilation,"
29 echo " - will use ROOTFS_DIR environment variable if set."
30 echo "crosscomponent - optional argument to build cross-architecture component,"
31 echo " - will use CAC_ROOTFS_DIR environment variable if set."
32 echo "nopgooptimize - do not use profile guided optimizations."
33 echo "pgoinstrument - generate instrumented code for profile guided optimization enabled binaries."
34 echo "ibcinstrument - generate IBC-tuning-enabled native images when invoking crossgen."
35 echo "configureonly - do not perform any builds; just configure the build."
36 echo "skipconfigure - skip build configuration."
37 echo "skipnative - do not build native components."
38 echo "skipmscorlib - do not build mscorlib.dll."
39 echo "skiptests - skip the tests in the 'tests' subdirectory."
40 echo "skipnuget - skip building nuget packages."
41 echo "skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations."
42 echo "verbose - optional argument to enable verbose build output."
43 echo "-skiprestore: skip restoring packages ^(default: packages are restored during build^)."
44 echo "-disableoss: Disable Open Source Signing for System.Private.CoreLib."
45 echo "-sequential: force a non-parallel build ^(default is to build in parallel"
46 echo " using all processors^)."
47 echo "-officialbuildid=^<ID^>: specify the official build ID to be used by this build."
48 echo "-Rebuild: passes /t:rebuild to the build projects."
49 echo "stripSymbols - Optional argument to strip native symbols during the build."
50 echo "skipgenerateversion - disable version generation even if MSBuild is supported."
51 echo "ignorewarnings - do not treat warnings as errors"
52 echo "cmakeargs - user-settable additional arguments passed to CMake."
53 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
54 echo "buildstandalonegc - builds the GC in a standalone mode. Can't be used with \"cmakeargs\"."
55 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
56 echo "numproc - set the number of build processes."
62 if [ "$__HostOS" == "Linux" ]; then
63 if [ ! -e /etc/os-release ]; then
64 echo "WARNING: Can not determine runtime id for current distro."
67 source /etc/os-release
68 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
75 if [ $__CrossBuild == 1 ]; then
76 if [ "$__BuildOS" == "Linux" ]; then
77 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
78 if [ -e $ROOTFS_DIR/android_platform ]; then
79 source $ROOTFS_DIR/android_platform
80 export __DistroRid="$RID"
82 echo "WARNING: Can not determine runtime id for current distro."
86 source $ROOTFS_DIR/etc/os-release
87 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
91 export __DistroRid="$__HostDistroRid"
94 # Portable builds target the base RID
95 if [ $__PortableBuild == 1 ]; then
96 if [ "$__BuildOS" == "Linux" ]; then
97 export __DistroRid="linux-$__BuildArch"
98 elif [ "$__BuildOS" == "OSX" ]; then
99 export __DistroRid="osx-$__BuildArch"
106 echo Setting up directories for build
108 mkdir -p "$__RootBinDir"
110 mkdir -p "$__LogsDir"
111 mkdir -p "$__IntermediatesDir"
113 if [ $__CrossBuild == 1 ]; then
114 mkdir -p "$__CrossComponentBinDir"
115 mkdir -p "$__CrossCompIntermediatesDir"
119 # Check the system to ensure the right prereqs are in place
123 echo "Checking prerequisites..."
125 # Check presence of CMake on the path
126 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
129 # Minimum required version of clang is version 3.9 for arm/armel cross build
130 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
131 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
132 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
137 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; }
143 # if msbuild is not supported, then set __SkipRestoreOptData to 1
144 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipRestoreOptData=1; fi
145 # we only need optdata on a Release build
146 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
148 if [ $__SkipRestoreOptData == 0 ]; then
149 echo "Restoring the OptimizationData package"
150 "$__ProjectRoot/run.sh" sync -optdata
152 echo "Failed to restore the optimization data package."
156 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
157 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
158 if [ ! -f $DotNetCli ]; then
159 echo "Assertion failed: dotnet CLI not found at '$DotNetCli'"
162 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
163 __PgoOptDataVersion=$($DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
164 __IbcOptDataVersion=$($DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
168 generate_event_logging_sources()
170 if [ $__SkipCoreCLR == 1 ]; then
174 # Event Logging Infrastructure
175 __GeneratedIntermediate="$__IntermediatesDir/Generated"
176 __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
177 __GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe_new"
179 if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
180 rm -rf "$__GeneratedIntermediateEventProvider"
183 if [[ -d "$__GeneratedIntermediateEventPipe" ]]; then
184 rm -rf "$__GeneratedIntermediateEventPipe"
187 if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
188 mkdir -p "$__GeneratedIntermediate/eventprovider"
191 if [[ ! -d "$__GeneratedIntermediate/eventpipe" ]]; then
192 mkdir -p "$__GeneratedIntermediate/eventpipe"
195 mkdir -p "$__GeneratedIntermediateEventProvider"
196 mkdir -p "$__GeneratedIntermediateEventPipe"
198 __PythonWarningFlags="-Wall"
199 if [[ $__IgnoreWarnings == 0 ]]; then
200 __PythonWarningFlags="$__PythonWarningFlags -Werror"
204 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
205 echo "Laying out dynamically generated files consumed by the build system "
206 echo "Laying out dynamically generated Event Logging Test files"
207 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
209 if [[ $? != 0 ]]; then
215 echo "Laying out dynamically generated EventPipe Implementation"
216 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst"
217 if [[ $? != 0 ]]; then
225 #determine the logging system
228 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
229 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
230 if [[ $? != 0 ]]; then
239 echo "Cleaning the temp folder of dynamically generated Event Logging files"
240 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
241 if [[ $? != 0 ]]; then
245 rm -rf "$__GeneratedIntermediateEventProvider"
247 echo "Cleaning the temp folder of dynamically generated EventPipe files"
248 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventpipe\",\"$__GeneratedIntermediateEventPipe\")"
249 if [[ $? != 0 ]]; then
253 rm -rf "$__GeneratedIntermediateEventPipe"
260 intermediatesForBuild="$3"
261 extraCmakeArguments="$4"
264 if [ $skipCondition == 1 ]; then
265 echo "Skipping $message build."
269 # All set to commence the build
270 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
275 if [ $__UseNinja == 1 ]; then
277 buildFile="build.ninja"
278 if ! buildTool=$(command -v ninja || command -v ninja-build); then
279 echo "Unable to locate ninja!" 1>&2
284 if [ $__SkipConfigure == 0 ]; then
285 # if msbuild is not supported, then set __SkipGenerateVersion to 1
286 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
287 # Drop version.cpp file
288 __versionSourceFile="$intermediatesForBuild/version.cpp"
289 if [ $__SkipGenerateVersion == 0 ]; then
291 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile $__RunArgs $__UnprocessedBuildArgs
293 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
294 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
295 if [ -e $__versionSourceFile ]; then
296 read existingVersionSourceLine < $__versionSourceFile
298 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
299 echo $__versionSourceLine > $__versionSourceFile
304 pushd "$intermediatesForBuild"
305 # Regenerate the CMake solution
306 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
307 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
311 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
312 echo "Failed to generate $message build project!"
317 if [ $__ConfigureOnly == 1 ]; then
318 echo "Finish configuration & skipping $message build."
322 # Check that the makefiles were created.
323 pushd "$intermediatesForBuild"
325 echo "Executing $buildTool install -j $__NumProc"
327 $buildTool install -j $__NumProc
329 echo "Failed to build $message."
336 build_cross_arch_component()
338 __SkipCrossArchBuild=1
340 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
341 if [[ "$__BuildArch" == "arm" && "$__CrossArch" == "x86" ]]; then
342 export CROSSCOMPILE=0
343 __SkipCrossArchBuild=0
345 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
346 if [ "$__HostArch" == "x64" ]; then
347 export CROSSCOMPILE=1
354 export __CMakeBinDir="$__CrossComponentBinDir"
355 export CROSSCOMPONENT=1
358 if [ $CROSSCOMPILE == 1 ]; then
359 TARGET_ROOTFS="$ROOTFS_DIR"
360 if [ -n "$CAC_ROOTFS_DIR" ]; then
361 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
363 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
367 __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"
368 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
370 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
371 if [ -n "$TARGET_ROOTFS" ]; then
372 export ROOTFS_DIR="$TARGET_ROOTFS"
374 export CROSSCOMPONENT=
375 export CROSSCOMPILE=1
378 isMSBuildOnNETCoreSupported()
380 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
382 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
386 if [ "$__HostArch" == "x64" ]; then
387 if [ "$__HostOS" == "Linux" ]; then
388 __isMSBuildOnNETCoreSupported=1
389 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
390 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
392 if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
393 __isMSBuildOnNETCoreSupported=0
397 elif [ "$__HostOS" == "OSX" ]; then
398 __isMSBuildOnNETCoreSupported=1
406 if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
407 echo "Generating native image for System.Private.CoreLib."
408 $__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
409 if [ $? -ne 0 ]; then
410 echo "Failed to generate native image for System.Private.CoreLib."
414 if [ "$__BuildOS" == "Linux" ]; then
415 echo "Generating symbol file for System.Private.CoreLib."
416 $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
417 if [ $? -ne 0 ]; then
418 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 -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 # The cross build generates a crossgen with the target architecture.
454 if [ $__CrossBuild != 1 ]; then
455 # The architecture of host pc must be same architecture with target.
456 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
458 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
460 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
468 generate_NugetPackages()
470 # We can only generate nuget package if we also support building mscorlib as part of this build.
471 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
472 echo "Nuget package generation unsupported."
476 # Since we can build mscorlib for this OS, did we build the native components as well?
477 if [ $__SkipCoreCLR == 1 ]; then
478 echo "Unable to generate nuget packages since native components were not built."
482 echo "Generating nuget packages for "$__BuildOS
483 echo "DistroRid is "$__DistroRid
484 echo "ROOTFS_DIR is "$ROOTFS_DIR
486 $__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
488 if [ $? -ne 0 ]; then
489 echo "Failed to generate Nuget packages."
494 echo "Commencing CoreCLR Repo build"
496 # Argument types supported by this script:
498 # Build architecture - valid values are: x64, ARM.
499 # Build Type - valid values are: Debug, Checked, Release
501 # Set the default arguments for build
503 # Obtain the location of the bash script to figure out where the root of the repo is.
504 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
506 # Use uname to determine what the CPU is.
508 # Some Linux platforms report unknown for platform, but the arch for machine.
509 if [ "$CPUName" == "unknown" ]; then
515 echo "Unsupported CPU $CPUName detected, build might not succeed!"
526 echo "Unsupported CPU $CPUName detected, build might not succeed!"
537 echo "Unknown CPU $CPUName detected, configuring as if for x64"
543 # Use uname to determine what the OS is.
577 echo "Unsupported OS $OSName detected, configuring as if for Linux"
585 __IncludeTests=Include_Tests
588 # Set the various build properties here so that CMake and MSBuild can pick them up
589 __ProjectDir="$__ProjectRoot"
590 __SourceDir="$__ProjectDir/src"
591 __PackagesDir="$__ProjectDir/packages"
592 __RootBinDir="$__ProjectDir/bin"
593 __UnprocessedBuildArgs=
607 __SkipRestoreOptData=0
609 __ClangMajorVersion=0
610 __ClangMinorVersion=0
611 __NuGetPath="$__PackagesDir/NuGet.exe"
615 __SkipGenerateVersion=0
618 __msbuildonunsupportedplatform=0
619 __PgoOptDataVersion=""
620 __IbcOptDataVersion=""
622 # Get the number of processors available to the scheduler
623 # Other techniques such as `nproc` only get the number of
624 # processors available to a single process.
625 if [ `uname` = "FreeBSD" ]; then
626 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
627 elif [ `uname` = "NetBSD" ]; then
628 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
630 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
634 if [ $# -le 0 ]; then
638 lowerI="$(echo $1 | awk '{print tolower($0)}')"
678 __CodeCoverage=Coverage
685 -portablebuild=false)
694 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
698 __ClangMajorVersion=3
699 __ClangMinorVersion=5
703 __ClangMajorVersion=3
704 __ClangMinorVersion=6
708 __ClangMajorVersion=3
709 __ClangMinorVersion=7
713 __ClangMajorVersion=3
714 __ClangMinorVersion=8
718 __ClangMajorVersion=3
719 __ClangMinorVersion=9
723 __ClangMajorVersion=4
724 __ClangMinorVersion=0
737 __SkipRestoreOptData=1
741 __IbcTuning="/Tuning"
755 # Use "skipnative" to use the same option name as build.cmd.
760 # Accept "skipcoreclr" for backwards-compatibility.
773 __SkipGenerateVersion=1
777 __SkipRestoreOptData=1
793 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
798 __cmakeargs="$__cmakeargs $2"
801 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
809 if [ ! -d $__RootBinDir ]; then
812 __RootBinParent=$(dirname $__RootBinDir)
813 __RootBinName=${__RootBinDir##*/}
814 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
817 echo "ERROR: 'bindir' requires a non-empty option argument"
822 __cmakeargs="$__cmakeargs -DFEATURE_STANDALONE_GC=1 -DFEATURE_STANDALONE_GC_ONLY=1"
824 msbuildonunsupportedplatform)
825 __msbuildonunsupportedplatform=1
832 echo "ERROR: 'numproc' requires a non-empty option argument"
837 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
844 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
846 # Configure environment if we are doing a verbose build
847 if [ $__VerboseBuild == 1 ]; then
849 __RunArgs="$__RunArgs -verbose"
852 # Set default clang version
853 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
854 if [ $__CrossBuild == 1 ]; then
855 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
856 __ClangMajorVersion=3
857 __ClangMinorVersion=9
859 __ClangMajorVersion=3
860 __ClangMinorVersion=6
864 __ClangMajorVersion=3
865 __ClangMinorVersion=5
869 if [[ "$__BuildArch" == "armel" ]]; then
870 # Armel cross build is Tizen specific and does not support Portable RID build
874 if [ $__PortableBuild == 0 ]; then
875 __RunArgs="$__RunArgs -PortableBuild=false"
878 # Set dependent variables
879 __LogsDir="$__RootBinDir/Logs"
881 # init the host distro name
884 # Set the remaining variables based upon the determined build configuration
885 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
886 __PackagesBinDir="$__BinDir/.nuget"
887 __ToolsDir="$__RootBinDir/tools"
888 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
889 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
890 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
891 __isMSBuildOnNETCoreSupported=0
892 __CrossComponentBinDir="$__BinDir"
893 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
895 __CrossArch="$__HostArch"
896 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
899 if [ $__CrossBuild == 1 ]; then
900 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
902 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
903 __CrossgenExe="$__CrossComponentBinDir/crossgen"
905 # Init if MSBuild for .NET Core is supported for this platform
906 isMSBuildOnNETCoreSupported
908 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
909 # This is needed by CLI to function.
910 if [ -z "$HOME" ]; then
911 if [ ! -d "$__ProjectDir/temp_home" ]; then
914 export HOME=$__ProjectDir/temp_home
915 echo "HOME not defined; setting it to $HOME"
918 # Specify path to be set for CMAKE_INSTALL_PREFIX.
919 # This is where all built CoreClr libraries will copied to.
920 export __CMakeBinDir="$__BinDir"
922 # Configure environment if we are doing a cross compile.
923 if [ $__CrossBuild == 1 ]; then
924 export CROSSCOMPILE=1
925 if ! [[ -n "$ROOTFS_DIR" ]]; then
926 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
930 # init the target distro name
933 # Make the directories necessary for build if they don't exist
939 # Restore the package containing profile counts for profile-guided optimizations
942 # Generate event logging infrastructure sources
943 generate_event_logging_sources
945 # Build the coreclr (native) components.
946 __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"
947 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
949 # Build cross-architecture components
950 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
951 build_cross_arch_component
954 # Build System.Private.CoreLib.
958 # Generate nuget packages
959 if [ $__SkipNuget != 1 ]; then
960 generate_NugetPackages
966 echo "Repo successfully built."
967 echo "Product binaries are available at $__BinDir"