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 "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 "-sequential: force a non-parallel build ^(default is to build in parallel"
47 echo " using all processors^)."
48 echo "-officialbuildid=^<ID^>: specify the official build ID to be used by this build."
49 echo "-Rebuild: passes /t:rebuild to the build projects."
50 echo "stripSymbols - Optional argument to strip native symbols during the build."
51 echo "skipgenerateversion - disable version generation even if MSBuild is supported."
52 echo "ignorewarnings - do not treat warnings as errors"
53 echo "cmakeargs - user-settable additional arguments passed to CMake."
54 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
55 echo "buildstandalonegc - builds the GC in a standalone mode. Can't be used with \"cmakeargs\"."
56 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
57 echo "numproc - set the number of build processes."
63 if [ "$__HostOS" == "Linux" ]; then
64 if [ ! -e /etc/os-release ]; then
65 echo "WARNING: Can not determine runtime id for current distro."
68 source /etc/os-release
69 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
76 if [ $__CrossBuild == 1 ]; then
77 if [ "$__BuildOS" == "Linux" ]; then
78 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
79 if [ -e $ROOTFS_DIR/android_platform ]; then
80 source $ROOTFS_DIR/android_platform
81 export __DistroRid="$RID"
83 echo "WARNING: Can not determine runtime id for current distro."
87 source $ROOTFS_DIR/etc/os-release
88 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
92 export __DistroRid="$__HostDistroRid"
95 # Portable builds target the base RID
96 if [ $__PortableBuild == 1 ]; then
97 if [ "$__BuildOS" == "Linux" ]; then
98 export __DistroRid="linux-$__BuildArch"
99 elif [ "$__BuildOS" == "OSX" ]; then
100 export __DistroRid="osx-$__BuildArch"
107 echo Setting up directories for build
109 mkdir -p "$__RootBinDir"
111 mkdir -p "$__LogsDir"
112 mkdir -p "$__IntermediatesDir"
114 if [ $__CrossBuild == 1 ]; then
115 mkdir -p "$__CrossComponentBinDir"
116 mkdir -p "$__CrossCompIntermediatesDir"
120 # Check the system to ensure the right prereqs are in place
124 echo "Checking prerequisites..."
126 # Check presence of CMake on the path
127 hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
130 # Minimum required version of clang is version 3.9 for arm/armel cross build
131 if [[ $__CrossBuild == 1 && ("$__BuildArch" == "arm" || "$__BuildArch" == "armel") ]]; then
132 if ! [[ "$__ClangMajorVersion" -gt "3" || ( $__ClangMajorVersion == 3 && $__ClangMinorVersion == 9 ) ]]; then
133 echo "Please install clang3.9 or latest for arm/armel cross build"; exit 1;
138 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; }
144 # if msbuild is not supported, then set __SkipRestoreOptData to 1
145 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipRestoreOptData=1; fi
146 # we only need optdata on a Release build
147 if [[ "$__BuildType" != "Release" ]]; then __SkipRestoreOptData=1; fi
149 if [ $__SkipRestoreOptData == 0 ]; then
150 echo "Restoring the OptimizationData package"
151 "$__ProjectRoot/run.sh" sync -optdata
153 echo "Failed to restore the optimization data package."
157 # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
158 local DotNetCli="$__ProjectRoot/Tools/dotnetcli/dotnet"
159 if [ ! -f $DotNetCli ]; then
160 echo "Assertion failed: dotnet CLI not found at '$DotNetCli'"
163 local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
164 __PgoOptDataVersion=$($DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo | sed 's/^\s*//')
165 __IbcOptDataVersion=$($DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo | sed 's/^\s*//')
169 generate_event_logging_sources()
171 if [ $__SkipCoreCLR == 1 ]; then
175 # Event Logging Infrastructure
176 __GeneratedIntermediate="$__IntermediatesDir/Generated"
177 __GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
178 __GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe_new"
180 if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
181 rm -rf "$__GeneratedIntermediateEventProvider"
184 if [[ -d "$__GeneratedIntermediateEventPipe" ]]; then
185 rm -rf "$__GeneratedIntermediateEventPipe"
188 if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
189 mkdir -p "$__GeneratedIntermediate/eventprovider"
192 if [[ ! -d "$__GeneratedIntermediate/eventpipe" ]]; then
193 mkdir -p "$__GeneratedIntermediate/eventpipe"
196 mkdir -p "$__GeneratedIntermediateEventProvider"
197 mkdir -p "$__GeneratedIntermediateEventPipe"
199 __PythonWarningFlags="-Wall"
200 if [[ $__IgnoreWarnings == 0 ]]; then
201 __PythonWarningFlags="$__PythonWarningFlags -Werror"
205 if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
206 echo "Laying out dynamically generated files consumed by the build system "
207 echo "Laying out dynamically generated Event Logging Test files"
208 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
210 if [[ $? != 0 ]]; then
216 echo "Laying out dynamically generated EventPipe Implementation"
217 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst"
218 if [[ $? != 0 ]]; then
226 #determine the logging system
229 echo "Laying out dynamically generated Event Logging Implementation of Lttng"
230 $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
231 if [[ $? != 0 ]]; then
240 echo "Cleaning the temp folder of dynamically generated Event Logging files"
241 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
242 if [[ $? != 0 ]]; then
246 rm -rf "$__GeneratedIntermediateEventProvider"
248 echo "Cleaning the temp folder of dynamically generated EventPipe files"
249 $PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventpipe\",\"$__GeneratedIntermediateEventPipe\")"
250 if [[ $? != 0 ]]; then
254 rm -rf "$__GeneratedIntermediateEventPipe"
261 intermediatesForBuild="$3"
262 extraCmakeArguments="$4"
265 if [ $skipCondition == 1 ]; then
266 echo "Skipping $message build."
270 # All set to commence the build
271 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
276 if [ $__UseNinja == 1 ]; then
278 buildFile="build.ninja"
279 if ! buildTool=$(command -v ninja || command -v ninja-build); then
280 echo "Unable to locate ninja!" 1>&2
285 if [ $__SkipConfigure == 0 ]; then
286 # if msbuild is not supported, then set __SkipGenerateVersion to 1
287 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
288 # Drop version.cpp file
289 __versionSourceFile="$intermediatesForBuild/version.cpp"
290 if [ $__SkipGenerateVersion == 0 ]; then
292 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile $__RunArgs $__UnprocessedBuildArgs
294 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
295 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
296 if [ -e $__versionSourceFile ]; then
297 read existingVersionSourceLine < $__versionSourceFile
299 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
300 echo $__versionSourceLine > $__versionSourceFile
305 pushd "$intermediatesForBuild"
306 # Regenerate the CMake solution
307 echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
308 "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
312 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
313 echo "Failed to generate $message build project!"
318 if [ $__ConfigureOnly == 1 ]; then
319 echo "Finish configuration & skipping $message build."
323 # Check that the makefiles were created.
324 pushd "$intermediatesForBuild"
326 echo "Executing $buildTool install -j $__NumProc"
328 $buildTool install -j $__NumProc
330 echo "Failed to build $message."
337 build_cross_arch_component()
339 __SkipCrossArchBuild=1
341 # check supported cross-architecture components host(__HostArch)/target(__BuildArch) pair
342 if [[ "$__BuildArch" == "arm" && "$__CrossArch" == "x86" ]]; then
343 export CROSSCOMPILE=0
344 __SkipCrossArchBuild=0
346 # building x64-host/arm-target cross-architecture component need to use cross toolchain of x86
347 if [ "$__HostArch" == "x64" ]; then
348 export CROSSCOMPILE=1
355 export __CMakeBinDir="$__CrossComponentBinDir"
356 export CROSSCOMPONENT=1
359 if [ $CROSSCOMPILE == 1 ]; then
360 TARGET_ROOTFS="$ROOTFS_DIR"
361 if [ -n "$CAC_ROOTFS_DIR" ]; then
362 export ROOTFS_DIR="$CAC_ROOTFS_DIR"
364 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__CrossArch"
368 __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"
369 build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
371 # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE
372 if [ -n "$TARGET_ROOTFS" ]; then
373 export ROOTFS_DIR="$TARGET_ROOTFS"
375 export CROSSCOMPONENT=
376 export CROSSCOMPILE=1
379 isMSBuildOnNETCoreSupported()
381 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
383 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
387 if [ "$__HostArch" == "x64" ]; then
388 if [ "$__HostOS" == "Linux" ]; then
389 __isMSBuildOnNETCoreSupported=1
390 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
391 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
393 if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
394 __isMSBuildOnNETCoreSupported=0
398 elif [ "$__HostOS" == "OSX" ]; then
399 __isMSBuildOnNETCoreSupported=1
407 if [ $__SkipCrossgen == 1 ]; then
408 echo "Skipping generating native image"
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
489 echo "DistroRid is "$__DistroRid
490 echo "ROOTFS_DIR is "$ROOTFS_DIR
492 $__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
494 if [ $? -ne 0 ]; then
495 echo "Failed to generate Nuget packages."
500 echo "Commencing CoreCLR Repo build"
502 # Argument types supported by this script:
504 # Build architecture - valid values are: x64, ARM.
505 # Build Type - valid values are: Debug, Checked, Release
507 # Set the default arguments for build
509 # Obtain the location of the bash script to figure out where the root of the repo is.
510 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
512 # Use uname to determine what the CPU is.
514 # Some Linux platforms report unknown for platform, but the arch for machine.
515 if [ "$CPUName" == "unknown" ]; then
521 echo "Unsupported CPU $CPUName detected, build might not succeed!"
532 echo "Unsupported CPU $CPUName detected, build might not succeed!"
543 echo "Unknown CPU $CPUName detected, configuring as if for x64"
549 # Use uname to determine what the OS is.
583 echo "Unsupported OS $OSName detected, configuring as if for Linux"
591 __IncludeTests=Include_Tests
594 # Set the various build properties here so that CMake and MSBuild can pick them up
595 __ProjectDir="$__ProjectRoot"
596 __SourceDir="$__ProjectDir/src"
597 __PackagesDir="$__ProjectDir/packages"
598 __RootBinDir="$__ProjectDir/bin"
599 __UnprocessedBuildArgs=
613 __SkipRestoreOptData=0
616 __ClangMajorVersion=0
617 __ClangMinorVersion=0
618 __NuGetPath="$__PackagesDir/NuGet.exe"
622 __SkipGenerateVersion=0
625 __msbuildonunsupportedplatform=0
626 __PgoOptDataVersion=""
627 __IbcOptDataVersion=""
629 # Get the number of processors available to the scheduler
630 # Other techniques such as `nproc` only get the number of
631 # processors available to a single process.
632 if [ `uname` = "FreeBSD" ]; then
633 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
634 elif [ `uname` = "NetBSD" ]; then
635 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
637 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
641 if [ $# -le 0 ]; then
645 lowerI="$(echo $1 | awk '{print tolower($0)}')"
685 __CodeCoverage=Coverage
692 -portablebuild=false)
701 __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
705 __ClangMajorVersion=3
706 __ClangMinorVersion=5
710 __ClangMajorVersion=3
711 __ClangMinorVersion=6
715 __ClangMajorVersion=3
716 __ClangMinorVersion=7
720 __ClangMajorVersion=3
721 __ClangMinorVersion=8
725 __ClangMajorVersion=3
726 __ClangMinorVersion=9
730 __ClangMajorVersion=4
731 __ClangMinorVersion=0
744 __SkipRestoreOptData=1
748 __IbcTuning="/Tuning"
762 # Use "skipnative" to use the same option name as build.cmd.
767 # Accept "skipcoreclr" for backwards-compatibility.
780 __SkipGenerateVersion=1
784 __SkipRestoreOptData=1
804 __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
809 __cmakeargs="$__cmakeargs $2"
812 echo "ERROR: 'cmakeargs' requires a non-empty option argument"
820 if [ ! -d $__RootBinDir ]; then
823 __RootBinParent=$(dirname $__RootBinDir)
824 __RootBinName=${__RootBinDir##*/}
825 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
828 echo "ERROR: 'bindir' requires a non-empty option argument"
833 __cmakeargs="$__cmakeargs -DFEATURE_STANDALONE_GC=1 -DFEATURE_STANDALONE_GC_ONLY=1"
835 msbuildonunsupportedplatform)
836 __msbuildonunsupportedplatform=1
843 echo "ERROR: 'numproc' requires a non-empty option argument"
848 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
855 __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
857 # Configure environment if we are doing a verbose build
858 if [ $__VerboseBuild == 1 ]; then
860 __RunArgs="$__RunArgs -verbose"
863 # Set default clang version
864 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
865 if [ $__CrossBuild == 1 ]; then
866 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
867 __ClangMajorVersion=3
868 __ClangMinorVersion=9
870 __ClangMajorVersion=3
871 __ClangMinorVersion=6
875 __ClangMajorVersion=3
876 __ClangMinorVersion=5
880 if [[ "$__BuildArch" == "armel" ]]; then
881 # Armel cross build is Tizen specific and does not support Portable RID build
885 if [ $__PortableBuild == 0 ]; then
886 __RunArgs="$__RunArgs -PortableBuild=false"
889 # Set dependent variables
890 __LogsDir="$__RootBinDir/Logs"
892 # init the host distro name
895 # Set the remaining variables based upon the determined build configuration
896 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
897 __PackagesBinDir="$__BinDir/.nuget"
898 __ToolsDir="$__RootBinDir/tools"
899 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
900 export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
901 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
902 __isMSBuildOnNETCoreSupported=0
903 __CrossComponentBinDir="$__BinDir"
904 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
906 __CrossArch="$__HostArch"
907 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
910 if [ $__CrossBuild == 1 ]; then
911 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
913 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
914 __CrossgenExe="$__CrossComponentBinDir/crossgen"
916 # Init if MSBuild for .NET Core is supported for this platform
917 isMSBuildOnNETCoreSupported
919 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
920 # This is needed by CLI to function.
921 if [ -z "$HOME" ]; then
922 if [ ! -d "$__ProjectDir/temp_home" ]; then
925 export HOME=$__ProjectDir/temp_home
926 echo "HOME not defined; setting it to $HOME"
929 # Specify path to be set for CMAKE_INSTALL_PREFIX.
930 # This is where all built CoreClr libraries will copied to.
931 export __CMakeBinDir="$__BinDir"
933 # Configure environment if we are doing a cross compile.
934 if [ $__CrossBuild == 1 ]; then
935 export CROSSCOMPILE=1
936 if ! [[ -n "$ROOTFS_DIR" ]]; then
937 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
941 # init the target distro name
944 # Make the directories necessary for build if they don't exist
950 # Restore the package containing profile counts for profile-guided optimizations
953 # Generate event logging infrastructure sources
954 generate_event_logging_sources
956 # Build the coreclr (native) components.
957 __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"
958 build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
960 # Build cross-architecture components
961 if [[ $__CrossBuild == 1 && $__DoCrossArchBuild == 1 ]]; then
962 build_cross_arch_component
965 # Build System.Private.CoreLib.
969 # Generate nuget packages
970 if [ $__SkipNuget != 1 ]; then
971 generate_NugetPackages
977 echo "Repo successfully built."
978 echo "Product binaries are available at $__BinDir"