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
116 __TestDir=$__ProjectDir/tests
117 __ProjectFilesDir=$__TestDir
118 __TestBinDir=$__TestWorkingDir
120 if [ $__RebuildTests -ne 0 ]; then
121 if [ -d "${__TestBinDir}" ]; then
122 echo "Removing tests build dir: ${__TestBinDir}"
127 __CMakeBinDir="${__TestBinDir}"
129 if [ -z "$__TestIntermediateDir" ]; then
130 __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
133 echo "__BuildOS: ${__BuildOS}"
134 echo "__BuildArch: ${__BuildArch}"
135 echo "__BuildType: ${__BuildType}"
136 echo "__TestIntermediateDir: ${__TestIntermediateDir}"
138 if [ ! -f "$__TestBinDir" ]; then
139 echo "Creating TestBinDir: ${__TestBinDir}"
140 mkdir -p $__TestBinDir
142 if [ ! -f "$__LogsDir" ]; then
143 echo "Creating LogsDir: ${__LogsDir}"
147 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
149 # =========================================================================================
151 # === Restore product binaries from packages
153 # =========================================================================================
155 build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
157 if [ -n "$__UpdateInvalidPackagesArg" ]; then
158 __up=-updateinvalidpackageversion
161 echo "${__MsgPrefix}Creating test overlay..."
163 if [ -z "$xUnitTestBinBase" ]; then
164 xUnitTestBinBase=$__TestWorkingDir
167 export CORE_ROOT=$xUnitTestBinBase/Tests/Core_Root
169 if [ -d "${CORE_ROOT}" ]; then
175 build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
177 chmod +x $__BinDir/corerun
178 chmod +x $__BinDir/crossgen
180 # Make sure to copy over the pulled down packages
181 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
187 export TEST_HOST=$xUnitTestBinBase/testhost
189 if [ -d "${TEST_HOST}" ]; then
193 echo "${__MsgPrefix}Creating test overlay..."
196 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
202 __TestDir=$__ProjectDir/tests
203 __ProjectFilesDir=$__TestDir
204 __TestBinDir=$__TestWorkingDir
206 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
207 rm "${__TestWorkingDir}/build_info.json"
210 if [ $__RebuildTests -ne 0 ]; then
211 if [ -d "${__TestBinDir}" ]; then
212 echo "Removing tests build dir: ${__TestBinDir}"
217 export __CMakeBinDir="${__TestBinDir}"
218 if [ ! -d "${__TestIntermediatesDir}" ]; then
219 mkdir -p ${__TestIntermediatesDir}
222 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
223 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
224 mkdir -p ${__NativeTestIntermediatesDir}
227 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
228 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
229 mkdir -p ${__ManagedTestIntermediatesDir}
232 echo "__BuildOS: ${__BuildOS}"
233 echo "__BuildArch: ${__BuildArch}"
234 echo "__BuildType: ${__BuildType}"
235 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
236 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
237 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
239 if [ ! -f "$__TestBinDir" ]; then
240 echo "Creating TestBinDir: ${__TestBinDir}"
241 mkdir -p $__TestBinDir
243 if [ ! -f "$__LogsDir" ]; then
244 echo "Creating LogsDir: ${__LogsDir}"
248 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
250 # =========================================================================================
252 # === Restore product binaries from packages
254 # =========================================================================================
256 if [ ${__SkipRestorePackages} != 1 ]; then
257 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
260 if [ $__SkipNative != 1 ]; then
261 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
263 if [ $? -ne 0 ]; then
264 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
269 if [ $__SkipManaged != 1 ]; then
270 echo "Starting the Managed Tests Build..."
272 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
274 if [ $? -ne 0 ]; then
275 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
278 echo "Checking the Managed Tests Build..."
280 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "-ExtraParameters:/t:CheckTestBuild"
282 if [ $? -ne 0 ]; then
283 echo "${__MsgPrefix}Error: Check Test Build failed."
287 echo "Managed tests build success!"
291 if [ $__BuildTestWrappers -ne -0 ]; then
292 echo "${__MsgPrefix}Creating test wrappers..."
294 export __Exclude="${__ProjectDir}/tests/issues.targets"
295 export __BuildLogRootName="Tests_XunitWrapper"
297 # Set up directories and file names
298 __BuildLogRootName=$subDirectoryName
299 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
300 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
301 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
303 buildVerbosity="Summary"
305 if [ $__VerboseBuild == 1 ]; then
306 buildVerbosity="Diag"
309 echo "${__DotNetCli}" msbuild "${__ProjectDir}/tests/runtest.proj" /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true /p:TargetsWindows=false /fileloggerparameters:"\"Verbosity=normal;LogFile=${__BuildLog}\"" /fileloggerparameters1:"\"WarningsOnly;LogFile=${__BuildWrn}\"" /fileloggerparameters2:"\"ErrorsOnly;LogFile=${__BuildErr}\"" /consoleloggerparameters:$buildVerbosity /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch
310 "${__DotNetCli}" msbuild "${__ProjectDir}/tests/runtest.proj" /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true /p:TargetsWindows=false /fileloggerparameters:"\"Verbosity=normal;LogFile=${__BuildLog}\"" /fileloggerparameters1:"\"WarningsOnly;LogFile=${__BuildWrn}\"" /fileloggerparameters2:"\"ErrorsOnly;LogFile=${__BuildErr}\"" /consoleloggerparameters:$buildVerbosity /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch
312 if [ $? -ne 0 ]; then
313 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
316 echo "XUnit Wrappers have been built."
317 echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
322 if [ -n "$__UpdateInvalidPackagesArg" ]; then
323 __up=-updateinvalidpackageversion
326 echo "${__MsgPrefix}Creating test overlay..."
330 if [ $__ZipTests -ne 0 ]; then
331 echo "${__MsgPrefix}ZIP tests packages..."
332 build_MSBuild_projects "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
336 build_MSBuild_projects()
344 extraBuildParameters=("$@")
346 # Set up directories and file names
347 __BuildLogRootName=$subDirectoryName
348 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
349 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
350 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
352 # Use binclashlogger by default if no other logger is specified
353 if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then
354 msbuildEventLogging=""
356 msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\""
359 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
360 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
361 # See https://github.com/Microsoft/msbuild/issues/2993
363 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
364 export __SkipPackageRestore=false
365 export __SkipTargetingPackBuild=false
366 export __BuildLoopCount=2
367 export __TestGroupToBuild=1
370 if [ -n "$__priority1" ]; then
371 export __BuildLoopCount=16
372 export __TestGroupToBuild=2
375 for (( slice=1 ; slice <= __BuildLoopCount; slice = slice + 1 ))
377 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
378 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
379 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
381 export TestBuildSlice=$slice
383 # Generate build command
384 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
385 buildArgs+=("$msbuildEventLogging")
386 buildArgs+=("${extraBuildParameters[@]}")
387 buildArgs+=("${__RunArgs[@]}")
388 buildArgs+=("${__UnprocessedBuildArgs[@]}")
390 echo "Building step '$stepName' slice=$slice via $buildCommand"
393 "$__ProjectRoot/run.sh" build "${buildArgs[@]}"
395 # Make sure everything is OK
396 if [ $? -ne 0 ]; then
397 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
403 export __SkipPackageRestore=true
404 export __SkipTargetingPackBuild=true
408 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
409 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
410 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
412 # Generate build command
413 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
414 buildArgs+=("$msbuildEventLogging")
415 buildArgs+=("${extraBuildParameters[@]}")
416 buildArgs+=("${__RunArgs[@]}")
417 buildArgs+=("${__UnprocessedBuildArgs[@]}")
419 echo "Building step '$stepName' via $buildCommand"
422 "$__ProjectRoot/run.sh" build "${buildArgs[@]}"
424 # Make sure everything is OK
425 if [ $? -ne 0 ]; then
426 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
435 build_native_projects()
438 intermediatesForBuild="$2"
440 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
441 message="native tests assets"
443 # All set to commence the build
444 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
449 if [ $__UseNinja == 1 ]; then
451 buildFile="build.ninja"
452 if ! buildTool=$(command -v ninja || command -v ninja-build); then
453 echo "Unable to locate ninja!" 1>&2
458 if [ $__SkipConfigure == 0 ]; then
459 # if msbuild is not supported, then set __SkipGenerateVersion to 1
460 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
461 # Drop version.cpp file
462 __versionSourceFile="$intermediatesForBuild/version.cpp"
463 if [ $__SkipGenerateVersion == 0 ]; then
465 "$__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
467 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
468 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
469 if [ -e $__versionSourceFile ]; then
470 read existingVersionSourceLine < $__versionSourceFile
472 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
473 echo $__versionSourceLine > $__versionSourceFile
477 pushd "$intermediatesForBuild"
478 # Regenerate the CMake solution
479 # Force cross dir to point to project root cross dir, in case there is a cross build.
480 echo "Invoking CONFIG_DIR=\"$__ProjectRoot/cross\" \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
481 CONFIG_DIR="$__ProjectRoot/cross" "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__TestDir" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator "$extraCmakeArguments" "$__cmakeargs"
485 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
486 echo "Failed to generate $message build project!"
491 if [ $__ConfigureOnly == 1 ]; then
492 echo "Finish configuration & skipping $message build."
496 pushd "$intermediatesForBuild"
498 echo "Executing $buildTool install -j $__NumProc"
500 $buildTool install -j $__NumProc
502 echo "Failed to build $message."
507 echo "Native tests build success!"
512 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
513 echo "BuildArch can be: x64, x86, arm, armel, arm64"
514 echo "BuildType can be: debug, checked, release"
515 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
516 echo "ninja - target ninja instead of GNU make"
517 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
518 echo "cross - optional argument to signify cross compilation,"
519 echo " - will use ROOTFS_DIR environment variable if set."
520 echo "crosscomponent - optional argument to build cross-architecture component,"
521 echo " - will use CAC_ROOTFS_DIR environment variable if set."
522 echo "portableLinux - build for Portable Linux Distribution"
523 echo "portablebuild - Use portable build."
524 echo "verbose - optional argument to enable verbose build output."
525 echo "rebuild - if tests have already been built - rebuild them"
526 echo "skipnative: skip the native tests build"
527 echo "skipmanaged: skip the managed section of the test build"
528 echo "generatelayoutonly - only pull down dependencies and build coreroot"
529 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
530 echo "skiprestorepackages - skip package restore"
531 echo "runtests - run tests after building them"
532 echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
533 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
534 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
535 echo "priority1 - include priority=1 tests in the build"
540 # Obtain the location of the bash script to figure out where the root of the repo is.
541 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
543 # Use uname to determine what the CPU is.
546 # Some Linux platforms report unknown for platform, but the arch for machine.
547 if [ "$CPUName" == "unknown" ]; then
553 echo "Unsupported CPU $CPUName detected, build might not succeed!"
564 echo "Unsupported CPU $CPUName detected, build might not succeed!"
575 echo "Unknown CPU $CPUName detected, configuring as if for x64"
581 # Use uname to determine what the OS is.
615 echo "Unsupported OS $OSName detected, configuring as if for Linux"
623 __IncludeTests=INCLUDE_TESTS
625 # Set the various build properties here so that CMake and MSBuild can pick them up
626 export __ProjectDir="$__ProjectRoot"
627 __SourceDir="$__ProjectDir/src"
628 __PackagesDir="$__ProjectDir/packages"
629 __RootBinDir="$__ProjectDir/bin"
630 __BuildToolsDir="$__ProjectDir/Tools"
631 __DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet"
632 __UnprocessedBuildArgs=
641 __SkipGenerateVersion=0
644 __ClangMajorVersion=0
645 __ClangMinorVersion=0
646 __NuGetPath="$__PackagesDir/NuGet.exe"
648 __SkipRestorePackages=0
652 __msbuildonunsupportedplatform=0
654 __NativeTestIntermediatesDir=
657 __BuildTestWrappers=1
658 __GenerateLayoutOnly=
659 __GenerateTestHostOnly=
664 if [ $# -le 0 ]; then
668 lowerI="$(echo $1 | awk '{print tolower($0)}')"
708 __CodeCoverage=Coverage
720 if [ "$__BuildOS" == "Linux" ]; then
723 echo "ERROR: portableLinux not supported for non-Linux platforms."
733 __ClangMajorVersion=3
734 __ClangMinorVersion=5
738 __ClangMajorVersion=3
739 __ClangMinorVersion=6
743 __ClangMajorVersion=3
744 __ClangMinorVersion=7
748 __ClangMajorVersion=3
749 __ClangMinorVersion=8
753 __ClangMajorVersion=3
754 __ClangMinorVersion=9
758 __ClangMajorVersion=4
759 __ClangMinorVersion=0
763 __ClangMajorVersion=5
764 __ClangMinorVersion=0
768 __ClangMajorVersion=6
769 __ClangMinorVersion=0
784 skipnative|-skipnative)
788 skipmanaged|-skipmanaged)
790 __BuildTestWrappers=0
798 __GenerateLayoutOnly=1
800 generatetesthostonly)
801 __GenerateTestHostOnly=1
804 __SkipRestorePackages=1
810 if [ ! -d $__RootBinDir ]; then
813 __RootBinParent=$(dirname $__RootBinDir)
814 __RootBinName=${__RootBinDir##*/}
815 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
818 echo "ERROR: 'bindir' requires a non-empty option argument"
823 msbuildonunsupportedplatform)
824 __msbuildonunsupportedplatform=1
828 __UnprocessedBuildArgs+=("-priority=1")
831 __UnprocessedBuildArgs+=("$1")
838 # Get the number of processors available to the scheduler
839 # Other techniques such as `nproc` only get the number of
840 # processors available to a single process.
841 if [ `uname` = "FreeBSD" ]; then
842 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
843 elif [ `uname` = "NetBSD" ]; then
844 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
845 elif [ `uname` = "Darwin" ]; then
846 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
848 __NumProc=$(nproc --all)
851 __RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")
853 # Configure environment if we are doing a verbose build
854 if [ $__VerboseBuild == 1 ]; then
856 __RunArgs+=("-verbose")
859 # Set default clang version
860 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
861 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
862 __ClangMajorVersion=5
863 __ClangMinorVersion=0
865 __ClangMajorVersion=3
866 __ClangMinorVersion=9
870 # Set dependent variables
871 __LogsDir="$__RootBinDir/Logs"
873 # init the host distro name
876 # Set the remaining variables based upon the determined build configuration
877 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
878 __PackagesBinDir="$__BinDir/.nuget"
879 __TestDir="$__ProjectDir/tests"
880 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
881 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
882 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
883 __isMSBuildOnNETCoreSupported=0
884 __CrossComponentBinDir="$__BinDir"
885 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
887 __CrossArch="$__HostArch"
888 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
891 if [ $__CrossBuild == 1 ]; then
892 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
894 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
895 __CrossgenExe="$__CrossComponentBinDir/crossgen"
897 isMSBuildOnNETCoreSupported
899 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
900 # This is needed by CLI to function.
901 if [ -z "$HOME" ]; then
902 if [ ! -d "$__ProjectDir/temp_home" ]; then
905 export HOME=$__ProjectDir/temp_home
906 echo "HOME not defined; setting it to $HOME"
909 # Configure environment if we are doing a cross compile.
910 if [ $__CrossBuild == 1 ]; then
911 export CROSSCOMPILE=1
912 if ! [[ -n "$ROOTFS_DIR" ]]; then
913 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
917 # init the target distro name
920 # Override tool directory
922 __CoreClrVersion=1.1.0
923 __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/
925 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") ]]; then
926 echo "Building Tests..."
929 echo "Generating test layout..."
931 if [ ! -z "$__GenerateTestHostOnly" ]; then
932 echo "Generating test host..."
937 if [ $? -ne 0 ]; then
938 echo "Failed to build tests"
942 echo "${__MsgPrefix}Test build successful."
943 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
945 __testNativeBinDir=$__IntermediatesDir/tests
947 if [ $__RunTests -ne 0 ]; then
951 echo "${__TestDir}/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$__sharedFxDir --testNativeBinDir=$__testNativeBinDir"
953 $__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir
955 echo "Tests run successful."
957 echo "To run all tests use 'tests/runtests.sh' where:"
958 echo " testRootDir = $__TestBinDir"
959 echo " coreClrBinDir = $__BinDir"
960 echo " coreFxBinDir = $CORE_ROOT"
961 echo " testNativeBinDir = $__testNativeBinDir"
962 echo " -------------------------------------------------- "
963 echo " Example runtest.sh command"
965 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
966 echo " -------------------------------------------------- "
967 echo "To run single test use the following command:"
968 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"