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
15 elif [ -e /etc/os-release ]; then
16 source /etc/os-release
17 if [[ $ID == "alpine" ]]; then
18 __HostDistroRid="linux-musl-$__HostArch"
21 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
24 elif [ "$__HostOS" == "FreeBSD" ]; then
25 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
26 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
29 # Portable builds target the base RID
30 if [ "$__PortableBuild" == 1 ]; then
31 if [ "$__BuildOS" == "OSX" ]; then
32 export __HostDistroRid="osx-$__BuildArch"
33 elif [ "$__BuildOS" == "Linux" ]; then
34 export __HostDistroRid="linux-$__BuildArch"
38 if [ "$__HostDistroRid" == "" ]; then
39 echo "WARNING: Cannot determine runtime id for current distro."
42 echo "Setting __HostDistroRid to $__HostDistroRid"
47 if [ $__CrossBuild == 1 ]; then
48 if [ "$__BuildOS" == "Linux" ]; then
49 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
50 if [ -e $ROOTFS_DIR/android_platform ]; then
51 source $ROOTFS_DIR/android_platform
52 export __DistroRid="$RID"
54 echo "WARNING: Cannot determine runtime id for current distro."
58 source $ROOTFS_DIR/etc/os-release
59 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
63 export __DistroRid="$__HostDistroRid"
66 if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
67 export __DistroRid="ubuntu.14.04-$__BuildArch"
70 # Portable builds target the base RID
71 if [ "$__PortableBuild" == 1 ]; then
72 if [ "$__BuildOS" == "Linux" ]; then
73 export __DistroRid="linux-$__BuildArch"
74 export __RuntimeId="linux-$__BuildArch"
75 elif [ "$__BuildOS" == "OSX" ]; then
76 export __DistroRid="osx-$__BuildArch"
77 export __RuntimeId="osx-$__BuildArch"
81 echo "__DistroRid: " $__DistroRid
84 isMSBuildOnNETCoreSupported()
86 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
88 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
92 if [ "$__HostArch" == "x64" ]; then
93 if [ "$__HostOS" == "Linux" ]; then
94 __isMSBuildOnNETCoreSupported=1
95 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
96 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
98 if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
99 __isMSBuildOnNETCoreSupported=0
103 elif [ "$__HostOS" == "OSX" ]; then
104 __isMSBuildOnNETCoreSupported=1
109 build_test_wrappers()
111 if [ $__BuildTestWrappers -ne -0 ]; then
112 echo "${__MsgPrefix}Creating test wrappers..."
114 export __Exclude="${__ProjectDir}/tests/issues.targets"
115 export __BuildLogRootName="Tests_XunitWrapper"
117 buildVerbosity="Summary"
119 if [ $__VerboseBuild == 1 ]; then
120 buildVerbosity="Diag"
123 # Set up directories and file names
124 __BuildLogRootName=$subDirectoryName
125 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
126 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
127 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
128 __MsbuildLog="/fileloggerparameters:\"Verbosity=normal;LogFile=${__BuildLog}\""
129 __MsbuildWrn="/fileloggerparameters1:\"WarningsOnly;LogFile=${__BuildWrn}\""
130 __MsbuildErr="/fileloggerparameters2:\"ErrorsOnly;LogFile=${__BuildErr}\""
131 __Logging="$__MsbuildLog $__MsbuildWrn $__MsbuildErr /consoleloggerparameters:$buildVerbosity"
133 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"
137 if [ $? -ne 0 ]; then
138 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
141 echo "XUnit Wrappers have been built."
142 echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
150 echo "${__MsgPrefix}Creating test overlay..."
152 __TestDir=$__ProjectDir/tests
153 __ProjectFilesDir=$__TestDir
154 __TestBinDir=$__TestWorkingDir
156 if [ $__RebuildTests -ne 0 ]; then
157 if [ -d "${__TestBinDir}" ]; then
158 echo "Removing tests build dir: ${__TestBinDir}"
163 __CMakeBinDir="${__TestBinDir}"
165 if [ -z "$__TestIntermediateDir" ]; then
166 __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
169 echo "__BuildOS: ${__BuildOS}"
170 echo "__BuildArch: ${__BuildArch}"
171 echo "__BuildType: ${__BuildType}"
172 echo "__TestIntermediateDir: ${__TestIntermediateDir}"
174 if [ ! -f "$__TestBinDir" ]; then
175 echo "Creating TestBinDir: ${__TestBinDir}"
176 mkdir -p $__TestBinDir
178 if [ ! -f "$__LogsDir" ]; then
179 echo "Creating LogsDir: ${__LogsDir}"
183 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
185 # =========================================================================================
187 # === Restore product binaries from packages
189 # =========================================================================================
191 build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
193 if [ -n "$__UpdateInvalidPackagesArg" ]; then
194 __up=-updateinvalidpackageversion
197 echo "${__MsgPrefix}Creating test overlay..."
199 if [ -z "$xUnitTestBinBase" ]; then
200 xUnitTestBinBase=$__TestWorkingDir
203 export CORE_ROOT=$xUnitTestBinBase/Tests/Core_Root
205 if [ -d "${CORE_ROOT}" ]; then
211 build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
213 chmod +x $__BinDir/corerun
214 chmod +x $__BinDir/crossgen
216 # Make sure to copy over the pulled down packages
217 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
222 echo "${__MsgPrefix}Generating test host..."
224 export TEST_HOST=$xUnitTestBinBase/testhost
226 if [ -d "${TEST_HOST}" ]; then
232 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
238 echo "${__MsgPrefix}Building Tests..."
240 __TestDir=$__ProjectDir/tests
241 __ProjectFilesDir=$__TestDir
242 __TestBinDir=$__TestWorkingDir
244 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
245 rm "${__TestWorkingDir}/build_info.json"
248 if [ $__RebuildTests -ne 0 ]; then
249 if [ -d "${__TestBinDir}" ]; then
250 echo "Removing tests build dir: ${__TestBinDir}"
255 export __CMakeBinDir="${__TestBinDir}"
256 if [ ! -d "${__TestIntermediatesDir}" ]; then
257 mkdir -p ${__TestIntermediatesDir}
260 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
261 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
262 mkdir -p ${__NativeTestIntermediatesDir}
265 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
266 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
267 mkdir -p ${__ManagedTestIntermediatesDir}
270 echo "__BuildOS: ${__BuildOS}"
271 echo "__BuildArch: ${__BuildArch}"
272 echo "__BuildType: ${__BuildType}"
273 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
274 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
275 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
277 if [ ! -f "$__TestBinDir" ]; then
278 echo "Creating TestBinDir: ${__TestBinDir}"
279 mkdir -p $__TestBinDir
281 if [ ! -f "$__LogsDir" ]; then
282 echo "Creating LogsDir: ${__LogsDir}"
286 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
288 # =========================================================================================
290 # === Restore product binaries from packages
292 # =========================================================================================
294 if [ ${__SkipRestorePackages} != 1 ]; then
295 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
298 if [ $__SkipNative != 1 ]; then
299 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
301 if [ $? -ne 0 ]; then
302 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
307 if [ $__SkipManaged != 1 ]; then
308 echo "Starting the Managed Tests Build..."
310 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
312 if [ $? -ne 0 ]; then
313 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
316 echo "Checking the Managed Tests Build..."
318 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "-ExtraParameters:/t:CheckTestBuild"
320 if [ $? -ne 0 ]; then
321 echo "${__MsgPrefix}Error: Check Test Build failed."
326 echo "Managed tests build success!"
331 if [ -n "$__UpdateInvalidPackagesArg" ]; then
332 __up=-updateinvalidpackageversion
337 if [ $__ZipTests -ne 0 ]; then
338 echo "${__MsgPrefix}ZIP tests packages..."
339 build_MSBuild_projects "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
343 build_MSBuild_projects()
351 extraBuildParameters=("$@")
353 # Set up directories and file names
354 __BuildLogRootName=$subDirectoryName
355 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
356 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
357 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
359 # Use binclashlogger by default if no other logger is specified
360 if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then
361 msbuildEventLogging=""
363 msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\""
366 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
367 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
368 # See https://github.com/Microsoft/msbuild/issues/2993
370 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
371 export __SkipPackageRestore=false
372 export __SkipTargetingPackBuild=false
373 export __BuildLoopCount=2
374 export __TestGroupToBuild=1
377 if [ -n "$__priority1" ]; then
378 export __BuildLoopCount=16
379 export __TestGroupToBuild=2
382 for (( slice=1 ; slice <= __BuildLoopCount; slice = slice + 1 ))
384 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
385 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
386 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
388 export TestBuildSlice=$slice
390 # Generate build command
391 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
392 buildArgs+=("$msbuildEventLogging")
393 buildArgs+=("${extraBuildParameters[@]}")
394 buildArgs+=("${__RunArgs[@]}")
395 buildArgs+=("${__UnprocessedBuildArgs[@]}")
397 nextCommand="\"$__ProjectRoot/run.sh\" build ${buildArgs[@]}"
398 echo "Building step '$stepName' slice=$slice via $nextCommand"
401 # Make sure everything is OK
402 if [ $? -ne 0 ]; then
403 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
409 export __SkipPackageRestore=true
410 export __SkipTargetingPackBuild=true
414 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
415 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
416 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
418 # Generate build command
419 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
420 buildArgs+=("$msbuildEventLogging")
421 buildArgs+=("${extraBuildParameters[@]}")
422 buildArgs+=("${__RunArgs[@]}")
423 buildArgs+=("${__UnprocessedBuildArgs[@]}")
425 nextCommand="\"$__ProjectRoot/run.sh\" build ${buildArgs[@]}"
426 echo "Building step '$stepName' via $nextCommand"
429 # Make sure everything is OK
430 if [ $? -ne 0 ]; then
431 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
440 build_native_projects()
443 intermediatesForBuild="$2"
445 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
446 message="native tests assets"
448 # All set to commence the build
449 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
454 if [ $__UseNinja == 1 ]; then
456 buildFile="build.ninja"
457 if ! buildTool=$(command -v ninja || command -v ninja-build); then
458 echo "Unable to locate ninja!" 1>&2
463 if [ $__SkipConfigure == 0 ]; then
464 # if msbuild is not supported, then set __SkipGenerateVersion to 1
465 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
466 # Drop version.cpp file
467 __versionSourceFile="$intermediatesForBuild/version.cpp"
468 if [ $__SkipGenerateVersion == 0 ]; then
470 "$__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
472 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
473 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
474 if [ -e $__versionSourceFile ]; then
475 read existingVersionSourceLine < $__versionSourceFile
477 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
478 echo $__versionSourceLine > $__versionSourceFile
482 pushd "$intermediatesForBuild"
483 # Regenerate the CMake solution
484 # Force cross dir to point to project root cross dir, in case there is a cross build.
485 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
486 echo "Invoking $nextCommand"
491 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
492 echo "Failed to generate $message build project!"
497 if [ $__ConfigureOnly == 1 ]; then
498 echo "Finish configuration & skipping $message build."
502 pushd "$intermediatesForBuild"
504 echo "Executing $buildTool install -j $__NumProc"
506 $buildTool install -j $__NumProc
508 echo "Failed to build $message."
513 echo "Native tests build success!"
518 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
519 echo "BuildArch can be: x64, x86, arm, armel, arm64"
520 echo "BuildType can be: debug, checked, release"
521 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
522 echo "ninja - target ninja instead of GNU make"
523 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
524 echo "cross - optional argument to signify cross compilation,"
525 echo " - will use ROOTFS_DIR environment variable if set."
526 echo "portableLinux - build for Portable Linux Distribution"
527 echo "portablebuild - Use portable build."
528 echo "verbose - optional argument to enable verbose build output."
529 echo "rebuild - if tests have already been built - rebuild them"
530 echo "skipnative: skip the native tests build"
531 echo "skipmanaged: skip the managed section of the test build"
532 echo "buildtestwrappersonly - only build the test wrappers"
533 echo "generatelayoutonly - only pull down dependencies and build coreroot"
534 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
535 echo "skiprestorepackages - skip package restore"
536 echo "runtests - run tests after building them"
537 echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
538 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
539 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
540 echo "priority1 - include priority=1 tests in the build"
545 # Obtain the location of the bash script to figure out where the root of the repo is.
546 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
548 # Use uname to determine what the CPU is.
551 # Some Linux platforms report unknown for platform, but the arch for machine.
552 if [ "$CPUName" == "unknown" ]; then
558 echo "Unsupported CPU $CPUName detected, build might not succeed!"
569 echo "Unsupported CPU $CPUName detected, build might not succeed!"
580 echo "Unknown CPU $CPUName detected, configuring as if for x64"
586 # Use uname to determine what the OS is.
620 echo "Unsupported OS $OSName detected, configuring as if for Linux"
628 __IncludeTests=INCLUDE_TESTS
630 # Set the various build properties here so that CMake and MSBuild can pick them up
631 export __ProjectDir="$__ProjectRoot"
632 __SourceDir="$__ProjectDir/src"
633 __PackagesDir="$__ProjectDir/packages"
634 __RootBinDir="$__ProjectDir/bin"
635 __BuildToolsDir="$__ProjectDir/Tools"
636 __DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet"
637 __UnprocessedBuildArgs=
646 __SkipGenerateVersion=0
649 __ClangMajorVersion=0
650 __ClangMinorVersion=0
651 __NuGetPath="$__PackagesDir/NuGet.exe"
653 __SkipRestorePackages=0
657 __msbuildonunsupportedplatform=0
659 __NativeTestIntermediatesDir=
662 __BuildTestWrappers=1
663 __GenerateLayoutOnly=
664 __GenerateTestHostOnly=
666 __BuildTestWrappersOnly=
670 if [ $# -le 0 ]; then
674 lowerI="$(echo $1 | awk '{print tolower($0)}')"
714 __CodeCoverage=Coverage
726 if [ "$__BuildOS" == "Linux" ]; then
729 echo "ERROR: portableLinux not supported for non-Linux platforms."
739 __ClangMajorVersion=3
740 __ClangMinorVersion=5
744 __ClangMajorVersion=3
745 __ClangMinorVersion=6
749 __ClangMajorVersion=3
750 __ClangMinorVersion=7
754 __ClangMajorVersion=3
755 __ClangMinorVersion=8
759 __ClangMajorVersion=3
760 __ClangMinorVersion=9
764 __ClangMajorVersion=4
765 __ClangMinorVersion=0
769 __ClangMajorVersion=5
770 __ClangMinorVersion=0
774 __ClangMajorVersion=6
775 __ClangMinorVersion=0
790 skipnative|-skipnative)
794 skipmanaged|-skipmanaged)
796 __BuildTestWrappers=0
803 buildtestwrappersonly)
804 __BuildTestWrappersOnly=1
808 __GenerateLayoutOnly=1
811 generatetesthostonly)
812 __GenerateTestHostOnly=1
816 __SkipRestorePackages=1
822 if [ ! -d $__RootBinDir ]; then
825 __RootBinParent=$(dirname $__RootBinDir)
826 __RootBinName=${__RootBinDir##*/}
827 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
830 echo "ERROR: 'bindir' requires a non-empty option argument"
835 msbuildonunsupportedplatform)
836 __msbuildonunsupportedplatform=1
841 __UnprocessedBuildArgs+=("-priority=1")
845 __UnprocessedBuildArgs+=("$1")
852 # Get the number of processors available to the scheduler
853 # Other techniques such as `nproc` only get the number of
854 # processors available to a single process.
855 if [ `uname` = "FreeBSD" ]; then
856 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
857 elif [ `uname` = "NetBSD" ]; then
858 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
859 elif [ `uname` = "Darwin" ]; then
860 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
862 __NumProc=$(nproc --all)
865 __RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")
867 # Configure environment if we are doing a verbose build
868 if [ $__VerboseBuild == 1 ]; then
870 __RunArgs+=("-verbose")
873 # Set default clang version
874 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
875 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
876 __ClangMajorVersion=5
877 __ClangMinorVersion=0
879 __ClangMajorVersion=3
880 __ClangMinorVersion=9
884 # Set dependent variables
885 __LogsDir="$__RootBinDir/Logs"
887 # init the host distro name
890 # Set the remaining variables based upon the determined build configuration
891 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
892 __PackagesBinDir="$__BinDir/.nuget"
893 __TestDir="$__ProjectDir/tests"
894 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
895 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
896 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
897 __isMSBuildOnNETCoreSupported=0
898 __CrossComponentBinDir="$__BinDir"
899 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
901 __CrossArch="$__HostArch"
902 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
905 if [ $__CrossBuild == 1 ]; then
906 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
908 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
909 __CrossgenExe="$__CrossComponentBinDir/crossgen"
911 isMSBuildOnNETCoreSupported
913 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
914 # This is needed by CLI to function.
915 if [ -z "$HOME" ]; then
916 if [ ! -d "$__ProjectDir/temp_home" ]; then
919 export HOME=$__ProjectDir/temp_home
920 echo "HOME not defined; setting it to $HOME"
923 # Configure environment if we are doing a cross compile.
924 if [ $__CrossBuild == 1 ]; then
925 export CROSSCOMPILE=1
926 if ! [[ -n "$ROOTFS_DIR" ]]; then
927 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
931 # init the target distro name
934 # Override tool directory
936 __CoreClrVersion=1.1.0
937 __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/
939 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
941 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
945 if [ ! -z "$__GenerateTestHostOnly" ]; then
950 if [ $? -ne 0 ]; then
951 echo "Failed to build tests"
955 echo "${__MsgPrefix}Test build successful."
956 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
958 __testNativeBinDir=$__IntermediatesDir/tests
960 if [ $__RunTests -ne 0 ]; then
964 nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
968 echo "Tests run successful."
970 echo "To run all tests use 'tests/runtests.sh' where:"
971 echo " testRootDir = $__TestBinDir"
972 echo " coreClrBinDir = $__BinDir"
973 echo " coreFxBinDir = $CORE_ROOT"
974 echo " testNativeBinDir = $__testNativeBinDir"
975 echo " -------------------------------------------------- "
976 echo " Example runtest.sh command"
978 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
979 echo " -------------------------------------------------- "
980 echo "To run single test use the following command:"
981 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"