7 # Some OS groups should default to use the portable packages
8 if [ "$__BuildOS" == "OSX" ]; then
12 if [ "$__HostOS" == "Linux" ]; then
13 if [ -e /etc/redhat-release ]; then
14 local redhatRelease=$(</etc/redhat-release)
15 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
16 __HostDistroRid="rhel.6-$__HostArch"
20 elif [ -e /etc/os-release ]; then
21 source /etc/os-release
22 if [[ $ID == "alpine" ]]; then
23 __HostDistroRid="linux-musl-$__HostArch"
26 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
29 elif [ "$__HostOS" == "FreeBSD" ]; then
30 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
31 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
34 # Portable builds target the base RID
35 if [ "$__PortableBuild" == 1 ]; then
36 if [ "$__BuildOS" == "OSX" ]; then
37 export __HostDistroRid="osx-$__BuildArch"
38 elif [ "$__BuildOS" == "Linux" ]; then
39 export __HostDistroRid="linux-$__BuildArch"
43 if [ "$__HostDistroRid" == "" ]; then
44 echo "WARNING: Cannot determine runtime id for current distro."
47 echo "Setting __HostDistroRid to $__HostDistroRid"
52 if [ $__CrossBuild == 1 ]; then
53 if [ "$__BuildOS" == "Linux" ]; then
54 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
55 if [ -e $ROOTFS_DIR/android_platform ]; then
56 source $ROOTFS_DIR/android_platform
57 export __DistroRid="$RID"
59 echo "WARNING: Cannot determine runtime id for current distro."
63 source $ROOTFS_DIR/etc/os-release
64 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
68 export __DistroRid="$__HostDistroRid"
71 if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
72 export __DistroRid="ubuntu.14.04-$__BuildArch"
75 # Portable builds target the base RID
76 if [ "$__PortableBuild" == 1 ]; then
77 if [ "$__BuildOS" == "Linux" ]; then
78 export __DistroRid="linux-$__BuildArch"
79 export __RuntimeId="linux-$__BuildArch"
80 elif [ "$__BuildOS" == "OSX" ]; then
81 export __DistroRid="osx-$__BuildArch"
82 export __RuntimeId="osx-$__BuildArch"
86 echo "__DistroRid: " $__DistroRid
89 isMSBuildOnNETCoreSupported()
91 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
93 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
97 if [ "$__HostArch" == "x64" ]; then
98 if [ "$__HostOS" == "Linux" ]; then
99 __isMSBuildOnNETCoreSupported=1
100 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
101 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
103 if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
104 __isMSBuildOnNETCoreSupported=0
108 elif [ "$__HostOS" == "OSX" ]; then
109 __isMSBuildOnNETCoreSupported=1
114 build_test_wrappers()
116 if [ $__BuildTestWrappers -ne -0 ]; then
117 echo "${__MsgPrefix}Creating test wrappers..."
119 export __Exclude="${__ProjectDir}/tests/issues.targets"
120 export __BuildLogRootName="Tests_XunitWrapper"
122 buildVerbosity="Summary"
124 if [ $__VerboseBuild == 1 ]; then
125 buildVerbosity="Diag"
128 # Set up directories and file names
129 __BuildLogRootName=$subDirectoryName
130 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
131 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
132 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
133 __MsbuildLog="/fileloggerparameters:\"Verbosity=normal;LogFile=${__BuildLog}\""
134 __MsbuildWrn="/fileloggerparameters1:\"WarningsOnly;LogFile=${__BuildWrn}\""
135 __MsbuildErr="/fileloggerparameters2:\"ErrorsOnly;LogFile=${__BuildErr}\""
136 __Logging="$__MsbuildLog $__MsbuildWrn $__MsbuildErr /consoleloggerparameters:$buildVerbosity"
138 nextCommand="\"${__DotNetCli}\" msbuild \"${__ProjectDir}/tests/runtest.proj\" /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true /p:TargetsWindows=false $__Logging /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch"
142 if [ $? -ne 0 ]; then
143 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
146 echo "XUnit Wrappers have been built."
147 echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
155 echo "${__MsgPrefix}Creating test overlay..."
157 __TestDir=$__ProjectDir/tests
158 __ProjectFilesDir=$__TestDir
159 __TestBinDir=$__TestWorkingDir
161 if [ $__RebuildTests -ne 0 ]; then
162 if [ -d "${__TestBinDir}" ]; then
163 echo "Removing tests build dir: ${__TestBinDir}"
168 __CMakeBinDir="${__TestBinDir}"
170 if [ -z "$__TestIntermediateDir" ]; then
171 __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
174 echo "__BuildOS: ${__BuildOS}"
175 echo "__BuildArch: ${__BuildArch}"
176 echo "__BuildType: ${__BuildType}"
177 echo "__TestIntermediateDir: ${__TestIntermediateDir}"
179 if [ ! -f "$__TestBinDir" ]; then
180 echo "Creating TestBinDir: ${__TestBinDir}"
181 mkdir -p $__TestBinDir
183 if [ ! -f "$__LogsDir" ]; then
184 echo "Creating LogsDir: ${__LogsDir}"
188 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
190 # =========================================================================================
192 # === Restore product binaries from packages
194 # =========================================================================================
196 build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
198 if [ -n "$__UpdateInvalidPackagesArg" ]; then
199 __up=-updateinvalidpackageversion
202 echo "${__MsgPrefix}Creating test overlay..."
204 if [ -z "$xUnitTestBinBase" ]; then
205 xUnitTestBinBase=$__TestWorkingDir
208 export CORE_ROOT=$xUnitTestBinBase/Tests/Core_Root
210 if [ -d "${CORE_ROOT}" ]; then
216 build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
218 chmod +x $__BinDir/corerun
219 chmod +x $__BinDir/crossgen
221 # Make sure to copy over the pulled down packages
222 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
227 echo "${__MsgPrefix}Generating test host..."
229 export TEST_HOST=$xUnitTestBinBase/testhost
231 if [ -d "${TEST_HOST}" ]; then
237 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
243 echo "${__MsgPrefix}Building Tests..."
245 __TestDir=$__ProjectDir/tests
246 __ProjectFilesDir=$__TestDir
247 __TestBinDir=$__TestWorkingDir
249 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
250 rm "${__TestWorkingDir}/build_info.json"
253 if [ $__RebuildTests -ne 0 ]; then
254 if [ -d "${__TestBinDir}" ]; then
255 echo "Removing tests build dir: ${__TestBinDir}"
260 export __CMakeBinDir="${__TestBinDir}"
261 if [ ! -d "${__TestIntermediatesDir}" ]; then
262 mkdir -p ${__TestIntermediatesDir}
265 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
266 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
267 mkdir -p ${__NativeTestIntermediatesDir}
270 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
271 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
272 mkdir -p ${__ManagedTestIntermediatesDir}
275 echo "__BuildOS: ${__BuildOS}"
276 echo "__BuildArch: ${__BuildArch}"
277 echo "__BuildType: ${__BuildType}"
278 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
279 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
280 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
282 if [ ! -f "$__TestBinDir" ]; then
283 echo "Creating TestBinDir: ${__TestBinDir}"
284 mkdir -p $__TestBinDir
286 if [ ! -f "$__LogsDir" ]; then
287 echo "Creating LogsDir: ${__LogsDir}"
291 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
293 # =========================================================================================
295 # === Restore product binaries from packages
297 # =========================================================================================
299 if [ ${__SkipRestorePackages} != 1 ]; then
300 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
303 if [ $__SkipNative != 1 ]; then
304 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
306 if [ $? -ne 0 ]; then
307 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
312 if [ $__SkipManaged != 1 ]; then
313 echo "Starting the Managed Tests Build..."
315 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
317 if [ $? -ne 0 ]; then
318 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
321 echo "Checking the Managed Tests Build..."
323 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "-ExtraParameters:/t:CheckTestBuild"
325 if [ $? -ne 0 ]; then
326 echo "${__MsgPrefix}Error: Check Test Build failed."
331 echo "Managed tests build success!"
336 if [ -n "$__UpdateInvalidPackagesArg" ]; then
337 __up=-updateinvalidpackageversion
342 if [ $__ZipTests -ne 0 ]; then
343 echo "${__MsgPrefix}ZIP tests packages..."
344 build_MSBuild_projects "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
348 build_MSBuild_projects()
356 extraBuildParameters=("$@")
358 # Set up directories and file names
359 __BuildLogRootName=$subDirectoryName
360 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
361 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
362 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
364 # Use binclashlogger by default if no other logger is specified
365 if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then
366 msbuildEventLogging=""
368 msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\""
371 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
372 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
373 # See https://github.com/Microsoft/msbuild/issues/2993
375 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
376 export __SkipPackageRestore=false
377 export __SkipTargetingPackBuild=false
378 export __BuildLoopCount=2
379 export __TestGroupToBuild=1
382 if [ -n "$__priority1" ]; then
383 export __BuildLoopCount=16
384 export __TestGroupToBuild=2
387 for (( slice=1 ; slice <= __BuildLoopCount; slice = slice + 1 ))
389 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
390 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
391 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
393 export TestBuildSlice=$slice
395 # Generate build command
396 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
397 buildArgs+=("$msbuildEventLogging")
398 buildArgs+=("${extraBuildParameters[@]}")
399 buildArgs+=("${__RunArgs[@]}")
400 buildArgs+=("${__UnprocessedBuildArgs[@]}")
402 nextCommand="\"$__ProjectRoot/run.sh\" build ${buildArgs[@]}"
403 echo "Building step '$stepName' slice=$slice via $nextCommand"
406 # Make sure everything is OK
407 if [ $? -ne 0 ]; then
408 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
414 export __SkipPackageRestore=true
415 export __SkipTargetingPackBuild=true
419 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
420 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
421 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
423 # Generate build command
424 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
425 buildArgs+=("$msbuildEventLogging")
426 buildArgs+=("${extraBuildParameters[@]}")
427 buildArgs+=("${__RunArgs[@]}")
428 buildArgs+=("${__UnprocessedBuildArgs[@]}")
430 nextCommand="\"$__ProjectRoot/run.sh\" build ${buildArgs[@]}"
431 echo "Building step '$stepName' via $nextCommand"
434 # Make sure everything is OK
435 if [ $? -ne 0 ]; then
436 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
445 build_native_projects()
448 intermediatesForBuild="$2"
450 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
451 message="native tests assets"
453 # All set to commence the build
454 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
459 if [ $__UseNinja == 1 ]; then
461 buildFile="build.ninja"
462 if ! buildTool=$(command -v ninja || command -v ninja-build); then
463 echo "Unable to locate ninja!" 1>&2
468 if [ $__SkipConfigure == 0 ]; then
469 # if msbuild is not supported, then set __SkipGenerateVersion to 1
470 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
471 # Drop version.cpp file
472 __versionSourceFile="$intermediatesForBuild/version.cpp"
473 if [ $__SkipGenerateVersion == 0 ]; then
475 "$__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
477 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
478 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
479 if [ -e $__versionSourceFile ]; then
480 read existingVersionSourceLine < $__versionSourceFile
482 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
483 echo $__versionSourceLine > $__versionSourceFile
487 pushd "$intermediatesForBuild"
488 # Regenerate the CMake solution
489 # Force cross dir to point to project root cross dir, in case there is a cross build.
490 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
491 echo "Invoking $nextCommand"
496 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
497 echo "Failed to generate $message build project!"
502 if [ $__ConfigureOnly == 1 ]; then
503 echo "Finish configuration & skipping $message build."
507 pushd "$intermediatesForBuild"
509 echo "Executing $buildTool install -j $__NumProc"
511 $buildTool install -j $__NumProc
513 echo "Failed to build $message."
518 echo "Native tests build success!"
523 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
524 echo "BuildArch can be: x64, x86, arm, armel, arm64"
525 echo "BuildType can be: debug, checked, release"
526 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
527 echo "ninja - target ninja instead of GNU make"
528 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
529 echo "cross - optional argument to signify cross compilation,"
530 echo " - will use ROOTFS_DIR environment variable if set."
531 echo "crosscomponent - optional argument to build cross-architecture component,"
532 echo " - will use CAC_ROOTFS_DIR environment variable if set."
533 echo "portableLinux - build for Portable Linux Distribution"
534 echo "portablebuild - Use portable build."
535 echo "verbose - optional argument to enable verbose build output."
536 echo "rebuild - if tests have already been built - rebuild them"
537 echo "skipnative: skip the native tests build"
538 echo "skipmanaged: skip the managed section of the test build"
539 echo "buildtestwrappersonly - only build the test wrappers"
540 echo "generatelayoutonly - only pull down dependencies and build coreroot"
541 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
542 echo "skiprestorepackages - skip package restore"
543 echo "runtests - run tests after building them"
544 echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
545 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
546 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
547 echo "priority1 - include priority=1 tests in the build"
552 # Obtain the location of the bash script to figure out where the root of the repo is.
553 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
555 # Use uname to determine what the CPU is.
558 # Some Linux platforms report unknown for platform, but the arch for machine.
559 if [ "$CPUName" == "unknown" ]; then
565 echo "Unsupported CPU $CPUName detected, build might not succeed!"
576 echo "Unsupported CPU $CPUName detected, build might not succeed!"
587 echo "Unknown CPU $CPUName detected, configuring as if for x64"
593 # Use uname to determine what the OS is.
627 echo "Unsupported OS $OSName detected, configuring as if for Linux"
635 __IncludeTests=INCLUDE_TESTS
637 # Set the various build properties here so that CMake and MSBuild can pick them up
638 export __ProjectDir="$__ProjectRoot"
639 __SourceDir="$__ProjectDir/src"
640 __PackagesDir="$__ProjectDir/packages"
641 __RootBinDir="$__ProjectDir/bin"
642 __BuildToolsDir="$__ProjectDir/Tools"
643 __DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet"
644 __UnprocessedBuildArgs=
653 __SkipGenerateVersion=0
656 __ClangMajorVersion=0
657 __ClangMinorVersion=0
658 __NuGetPath="$__PackagesDir/NuGet.exe"
660 __SkipRestorePackages=0
664 __msbuildonunsupportedplatform=0
666 __NativeTestIntermediatesDir=
669 __BuildTestWrappers=1
670 __GenerateLayoutOnly=
671 __GenerateTestHostOnly=
673 __BuildTestWrappersOnly=
677 if [ $# -le 0 ]; then
681 lowerI="$(echo $1 | awk '{print tolower($0)}')"
721 __CodeCoverage=Coverage
733 if [ "$__BuildOS" == "Linux" ]; then
736 echo "ERROR: portableLinux not supported for non-Linux platforms."
746 __ClangMajorVersion=3
747 __ClangMinorVersion=5
751 __ClangMajorVersion=3
752 __ClangMinorVersion=6
756 __ClangMajorVersion=3
757 __ClangMinorVersion=7
761 __ClangMajorVersion=3
762 __ClangMinorVersion=8
766 __ClangMajorVersion=3
767 __ClangMinorVersion=9
771 __ClangMajorVersion=4
772 __ClangMinorVersion=0
776 __ClangMajorVersion=5
777 __ClangMinorVersion=0
781 __ClangMajorVersion=6
782 __ClangMinorVersion=0
797 skipnative|-skipnative)
801 skipmanaged|-skipmanaged)
803 __BuildTestWrappers=0
810 buildtestwrappersonly)
811 __BuildTestWrappersOnly=1
815 __GenerateLayoutOnly=1
818 generatetesthostonly)
819 __GenerateTestHostOnly=1
823 __SkipRestorePackages=1
829 if [ ! -d $__RootBinDir ]; then
832 __RootBinParent=$(dirname $__RootBinDir)
833 __RootBinName=${__RootBinDir##*/}
834 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
837 echo "ERROR: 'bindir' requires a non-empty option argument"
842 msbuildonunsupportedplatform)
843 __msbuildonunsupportedplatform=1
848 __UnprocessedBuildArgs+=("-priority=1")
852 __UnprocessedBuildArgs+=("$1")
859 # Get the number of processors available to the scheduler
860 # Other techniques such as `nproc` only get the number of
861 # processors available to a single process.
862 if [ `uname` = "FreeBSD" ]; then
863 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
864 elif [ `uname` = "NetBSD" ]; then
865 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
866 elif [ `uname` = "Darwin" ]; then
867 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
869 __NumProc=$(nproc --all)
872 __RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")
874 # Configure environment if we are doing a verbose build
875 if [ $__VerboseBuild == 1 ]; then
877 __RunArgs+=("-verbose")
880 # Set default clang version
881 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
882 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
883 __ClangMajorVersion=5
884 __ClangMinorVersion=0
886 __ClangMajorVersion=3
887 __ClangMinorVersion=9
891 # Set dependent variables
892 __LogsDir="$__RootBinDir/Logs"
894 # init the host distro name
897 # Set the remaining variables based upon the determined build configuration
898 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
899 __PackagesBinDir="$__BinDir/.nuget"
900 __TestDir="$__ProjectDir/tests"
901 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
902 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
903 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
904 __isMSBuildOnNETCoreSupported=0
905 __CrossComponentBinDir="$__BinDir"
906 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
908 __CrossArch="$__HostArch"
909 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
912 if [ $__CrossBuild == 1 ]; then
913 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
915 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
916 __CrossgenExe="$__CrossComponentBinDir/crossgen"
918 isMSBuildOnNETCoreSupported
920 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
921 # This is needed by CLI to function.
922 if [ -z "$HOME" ]; then
923 if [ ! -d "$__ProjectDir/temp_home" ]; then
926 export HOME=$__ProjectDir/temp_home
927 echo "HOME not defined; setting it to $HOME"
930 # Configure environment if we are doing a cross compile.
931 if [ $__CrossBuild == 1 ]; then
932 export CROSSCOMPILE=1
933 if ! [[ -n "$ROOTFS_DIR" ]]; then
934 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
938 # init the target distro name
941 # Override tool directory
943 __CoreClrVersion=1.1.0
944 __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/
946 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
948 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
952 if [ ! -z "$__GenerateTestHostOnly" ]; then
957 if [ $? -ne 0 ]; then
958 echo "Failed to build tests"
962 echo "${__MsgPrefix}Test build successful."
963 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
965 __testNativeBinDir=$__IntermediatesDir/tests
967 if [ $__RunTests -ne 0 ]; then
971 nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
975 echo "Tests run successful."
977 echo "To run all tests use 'tests/runtests.sh' where:"
978 echo " testRootDir = $__TestBinDir"
979 echo " coreClrBinDir = $__BinDir"
980 echo " coreFxBinDir = $CORE_ROOT"
981 echo " testNativeBinDir = $__testNativeBinDir"
982 echo " -------------------------------------------------- "
983 echo " Example runtest.sh command"
985 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
986 echo " -------------------------------------------------- "
987 echo "To run single test use the following command:"
988 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"