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] [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 "pgoinstrument - generate instrumented code for profile guided optimization enabled binaries."
33 echo "ibcinstrument - generate IBC-tuning-enabled native images when invoking crossgen."
34 echo "configureonly - do not perform any builds; just configure the build."
35 echo "skipconfigure - skip build configuration."
36 echo "skipnative - do not build native components."
37 echo "skipmscorlib - do not build mscorlib.dll."
38 echo "skiptests - skip the tests in the 'tests' subdirectory."
39 echo "skipnuget - skip building nuget packages."
40 echo "skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations."
41 echo "portable - build for portable RID."
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 "cmakeargs - user-settable additional arguments passed to CMake."
52 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
53 echo "buildstandalonegc - builds the GC in a standalone mode. Can't be used with \"cmakeargs\"."
54 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
60 if [ "$__HostOS" == "Linux" ]; then
61 if [ ! -e /etc/os-release ]; then
62 echo "WARNING: Can not determine runtime id for current distro."
65 source /etc/os-release
66 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
73 if [ $__CrossBuild == 1 ]; then
74 if [ "$__BuildOS" == "Linux" ]; then
75 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
76 echo "WARNING: Can not determine runtime id for current distro."
79 source $ROOTFS_DIR/etc/os-release
80 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
84 export __DistroRid="$__HostDistroRid"
87 # Portable builds target the base RID
88 if [ $__PortableBuild == 1 ]; then
89 if [ "$__BuildOS" == "Linux" ]; then
90 export __DistroRid="linux-$__BuildArch"
91 elif [ "$__BuildOS" == "OSX" ]; then
92 export __DistroRid="osx-$__BuildArch"
99 echo Setting up directories for build
101 mkdir -p "$__RootBinDir"
103 mkdir -p "$__LogsDir"
104 mkdir -p "$__IntermediatesDir"
106 if [ $__CrossBuild == 1 ]; then
107 mkdir -p "$__CrossComponentBinDir"
108 mkdir -p "$__CrossCompIntermediatesDir"
112 # Check the system to ensure the right prereqs are in place
116 echo "Checking prerequisites..."
118 # Check presence of CMake on the path
119 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
122 # Minimum required version of clang is version 3.9 for arm/armel cross build
123 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
124 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
125 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
130 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; }
136 # if msbuild is not supported, then set __SkipRestoreOptData to 1
137 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipRestoreOptData=1; fi
138 if [ $__SkipRestoreOptData == 0 ]; then
139 echo "Restoring the OptimizationData package"
140 "$__ProjectRoot/run.sh" sync -optdata
142 echo "Failed to restore the optimization data package."
148 generate_event_logging_sources()
150 if [ $__SkipCoreCLR == 1 ]; then
154 # Event Logging Infrastructure
155 __GeneratedIntermediate="$__IntermediatesDir/Generated"
156 __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
157 __GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe_new"
159 if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
160 rm -rf "$__GeneratedIntermediateEventProvider"
163 if [[ -d "$__GeneratedIntermediateEventPipe" ]]; then
164 rm -rf "$__GeneratedIntermediateEventPipe"
167 if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
168 mkdir -p "$__GeneratedIntermediate/eventprovider"
171 if [[ ! -d "$__GeneratedIntermediate/eventpipe" ]]; then
172 mkdir -p "$__GeneratedIntermediate/eventpipe"
175 mkdir -p "$__GeneratedIntermediateEventProvider"
176 mkdir -p "$__GeneratedIntermediateEventPipe"
178 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
179 echo "Laying out dynamically generated files consumed by the build system "
180 echo "Laying out dynamically generated Event Logging Test files"
181 $PYTHON -B -Wall -Werror "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
183 if [[ $? != 0 ]]; then
189 echo "Laying out dynamically generated EventPipe Implementation"
190 $PYTHON -B -Wall -Werror "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst"
191 if [[ $? != 0 ]]; then
199 #determine the logging system
202 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
203 $PYTHON -B -Wall -Werror "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
204 if [[ $? != 0 ]]; then
213 echo "Cleaning the temp folder of dynamically generated Event Logging files"
214 $PYTHON -B -Wall -Werror -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
215 if [[ $? != 0 ]]; then
219 rm -rf "$__GeneratedIntermediateEventProvider"
221 echo "Cleaning the temp folder of dynamically generated EventPipe files"
222 $PYTHON -B -Wall -Werror -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventpipe\",\"$__GeneratedIntermediateEventPipe\")"
223 if [[ $? != 0 ]]; then
227 rm -rf "$__GeneratedIntermediateEventPipe"
234 intermediatesForBuild="$3"
235 extraCmakeArguments="$4"
238 if [ $skipCondition == 1 ]; then
239 echo "Skipping $message build."
243 # All set to commence the build
244 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
249 if [ $__UseNinja == 1 ]; then
251 buildFile="build.ninja"
252 if ! buildTool=$(command -v ninja || command -v ninja-build); then
253 echo "Unable to locate ninja!" 1>&2
258 if [ $__SkipConfigure == 0 ]; then
259 # if msbuild is not supported, then set __SkipGenerateVersion to 1
260 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
261 # Drop version.cpp file
262 __versionSourceFile="$intermediatesForBuild/version.cpp"
263 if [ $__SkipGenerateVersion == 0 ]; then
265 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile $__RunArgs $__UnprocessedBuildArgs
267 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
268 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
269 if [ -e $__versionSourceFile ]; then
270 read existingVersionSourceLine < $__versionSourceFile
272 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
273 echo $__versionSourceLine > $__versionSourceFile
278 pushd "$intermediatesForBuild"
279 # Regenerate the CMake solution
280 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
281 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
285 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
286 echo "Failed to generate $message build project!"
290 # Get the number of processors available to the scheduler
291 # Other techniques such as `nproc` only get the number of
292 # processors available to a single process.
293 if [ `uname` = "FreeBSD" ]; then
294 NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
295 elif [ `uname` = "NetBSD" ]; then
296 NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
298 NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
302 if [ $__ConfigureOnly == 1 ]; then
303 echo "Finish configuration & skipping $message build."
307 # Check that the makefiles were created.
308 pushd "$intermediatesForBuild"
310 echo "Executing $buildTool install -j $NumProc"
312 $buildTool install -j $NumProc
314 echo "Failed to build $message."
321 build_cross_arch_component()
323 __SkipCrossArchBuild=1
325 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
326 if [[ "$__BuildArch" == "arm" && "$__CrossArch" == "x86" ]]; then
327 export CROSSCOMPILE=0
328 __SkipCrossArchBuild=0
330 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
331 if [ "$__HostArch" == "x64" ]; then
332 export CROSSCOMPILE=1
339 export __CMakeBinDir="$__CrossComponentBinDir"
340 export CROSSCOMPONENT=1
343 if [ $CROSSCOMPILE == 1 ]; then
344 TARGET_ROOTFS="$ROOTFS_DIR"
345 if [ -n "$CAC_ROOTFS_DIR" ]; then
346 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
348 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
352 __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"
353 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
355 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
356 if [ -n "$TARGET_ROOTFS" ]; then
357 export ROOTFS_DIR="$TARGET_ROOTFS"
359 export CROSSCOMPONENT=
360 export CROSSCOMPILE=1
363 isMSBuildOnNETCoreSupported()
365 # This needs to be updated alongwith corresponding changes to netci.groovy.
366 __isMSBuildOnNETCoreSupported=0
368 if [ "$__HostArch" == "x64" ]; then
369 if [ "$__HostOS" == "Linux" ]; then
370 case "$__HostDistroRid" in
372 __isMSBuildOnNETCoreSupported=1
375 __isMSBuildOnNETCoreSupported=1
378 __isMSBuildOnNETCoreSupported=1
381 __isMSBuildOnNETCoreSupported=1
384 __isMSBuildOnNETCoreSupported=1
387 __isMSBuildOnNETCoreSupported=1
390 __isMSBuildOnNETCoreSupported=1
393 __isMSBuildOnNETCoreSupported=1
396 __isMSBuildOnNETCoreSupported=1
399 __isMSBuildOnNETCoreSupported=1
402 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
404 elif [ "$__HostOS" == "OSX" ]; then
405 __isMSBuildOnNETCoreSupported=1
412 if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
413 echo "Generating native image for System.Private.CoreLib."
414 $__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll
415 if [ $? -ne 0 ]; then
416 echo "Failed to generate native image for System.Private.CoreLib."
420 if [ "$__BuildOS" == "Linux" ]; then
421 echo "Generating symbol file for System.Private.CoreLib."
422 $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll
423 if [ $? -ne 0 ]; then
424 echo "Failed to generate symbol file for System.Private.CoreLib."
434 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
435 echo "System.Private.CoreLib.dll build unsupported."
439 if [ $__SkipMSCorLib == 1 ]; then
440 echo "Skipping building System.Private.CoreLib."
444 echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType"
448 if [[ "$__IbcTuning" -eq "" ]]; then
449 __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
450 __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
452 $__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
454 if [ $? -ne 0 ]; then
455 echo "Failed to build managed components."
459 # The cross build generates a crossgen with the target architecture.
460 if [ $__CrossBuild != 1 ]; then
461 # The architecture of host pc must be same architecture with target.
462 if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
464 elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
466 elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
474 generate_NugetPackages()
476 # We can only generate nuget package if we also support building mscorlib as part of this build.
477 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
478 echo "Nuget package generation unsupported."
482 # Since we can build mscorlib for this OS, did we build the native components as well?
483 if [ $__SkipCoreCLR == 1 ]; then
484 echo "Unable to generate nuget packages since native components were not built."
488 echo "Generating nuget packages for "$__BuildOS
491 $__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
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!"
542 echo "Unknown CPU $CPUName detected, configuring as if for x64"
548 # Use uname to determine what the OS is.
582 echo "Unsupported OS $OSName detected, configuring as if for Linux"
590 __IncludeTests=Include_Tests
592 # Set the various build properties here so that CMake and MSBuild can pick them up
593 __ProjectDir="$__ProjectRoot"
594 __SourceDir="$__ProjectDir/src"
595 __PackagesDir="$__ProjectDir/packages"
596 __RootBinDir="$__ProjectDir/bin"
597 __UnprocessedBuildArgs=
610 __SkipRestoreOptData=0
612 __ClangMajorVersion=0
613 __ClangMinorVersion=0
614 __NuGetPath="$__PackagesDir/NuGet.exe"
618 __SkipGenerateVersion=0
621 __msbuildonunsupportedplatform=0
622 __PgoOptDataVersion=""
623 __IbcOptDataVersion=""
626 if [ $# -le 0 ]; then
630 lowerI="$(echo $1 | awk '{print tolower($0)}')"
670 __CodeCoverage=Coverage
686 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
690 __ClangMajorVersion=3
691 __ClangMinorVersion=5
695 __ClangMajorVersion=3
696 __ClangMinorVersion=6
700 __ClangMajorVersion=3
701 __ClangMinorVersion=7
705 __ClangMajorVersion=3
706 __ClangMinorVersion=8
710 __ClangMajorVersion=3
711 __ClangMinorVersion=9
715 __ClangMajorVersion=4
716 __ClangMinorVersion=0
728 __IbcTuning="/Tuning"
742 # Use "skipnative" to use the same option name as build.cmd.
747 # Accept "skipcoreclr" for backwards-compatibility.
760 __SkipGenerateVersion=1
764 __SkipRestoreOptData=1
780 __cmakeargs="$__cmakeargs $2"
783 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
791 if [ ! -d $__RootBinDir ]; then
794 __RootBinParent=$(dirname $__RootBinDir)
795 __RootBinName=${__RootBinDir##*/}
796 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
799 echo "ERROR: 'bindir' requires a non-empty option argument"
804 __cmakeargs="-DFEATURE_STANDALONE_GC=1"
806 msbuildonunsupportedplatform)
807 __msbuildonunsupportedplatform=1
810 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
817 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
819 # Configure environment if we are doing a verbose build
820 if [ $__VerboseBuild == 1 ]; then
822 __RunArgs="$__RunArgs -verbose"
825 # Set default clang version
826 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
827 if [ $__CrossBuild == 1 ]; then
828 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
829 __ClangMajorVersion=3
830 __ClangMinorVersion=9
832 __ClangMajorVersion=3
833 __ClangMinorVersion=6
836 __ClangMajorVersion=3
837 __ClangMinorVersion=5
841 # Set dependent variables
842 __LogsDir="$__RootBinDir/Logs"
844 # init the host distro name
847 # Set the remaining variables based upon the determined build configuration
848 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
849 __PackagesBinDir="$__BinDir/.nuget"
850 __ToolsDir="$__RootBinDir/tools"
851 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
852 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
853 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
854 __isMSBuildOnNETCoreSupported=0
855 __CrossComponentBinDir="$__BinDir"
856 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
858 __CrossArch="$__HostArch"
859 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
862 if [ $__CrossBuild == 1 ]; then
863 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
865 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
866 __CrossgenExe="$__CrossComponentBinDir/crossgen"
868 # Init if MSBuild for .NET Core is supported for this platform
869 isMSBuildOnNETCoreSupported
871 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
872 # This is needed by CLI to function.
873 if [ -z "$HOME" ]; then
874 if [ ! -d "$__ProjectDir/temp_home" ]; then
877 export HOME=$__ProjectDir/temp_home
878 echo "HOME not defined; setting it to $HOME"
881 # Specify path to be set for CMAKE_INSTALL_PREFIX.
882 # This is where all built CoreClr libraries will copied to.
883 export __CMakeBinDir="$__BinDir"
885 # Configure environment if we are doing a cross compile.
886 if [ $__CrossBuild == 1 ]; then
887 export CROSSCOMPILE=1
888 if ! [[ -n "$ROOTFS_DIR" ]]; then
889 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
893 # Parse the optdata package version from its project.json file
894 optDataProjectJsonPath="$__ProjectRoot/src/.nuget/optdata/project.json"
895 if [ -f $optDataProjectJsonPath ]; then
896 __PgoOptDataVersion=$("$__ProjectRoot/extract-from-json.py" -rf $optDataProjectJsonPath dependencies optimization.PGO.CoreCLR)
897 __IbcOptDataVersion=$("$__ProjectRoot/extract-from-json.py" -rf $optDataProjectJsonPath dependencies optimization.IBC.CoreCLR)
900 # init the target distro name
903 # Make the directories necessary for build if they don't exist
909 # Restore the package containing profile counts for profile-guided optimizations
912 # Generate event logging infrastructure sources
913 generate_event_logging_sources
915 # Build the coreclr (native) components.
916 __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_VERSION=$__PgoOptDataVersion"
917 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
919 # Build cross-architecture components
920 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
921 build_cross_arch_component
924 # Build System.Private.CoreLib.
928 # Generate nuget packages
929 if [ $__SkipNuget != 1 ]; then
930 generate_NugetPackages
936 echo "Repo successfully built."
937 echo "Product binaries are available at $__BinDir"