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"
64 export __RuntimeId="$__HostDistroRid"
67 if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
68 export __DistroRid="ubuntu.14.04-$__BuildArch"
71 # Portable builds target the base RID
72 if [ "$__PortableBuild" == 1 ]; then
73 if [ "$__BuildOS" == "Linux" ]; then
74 export __DistroRid="linux-$__BuildArch"
75 export __RuntimeId="linux-$__BuildArch"
76 elif [ "$__BuildOS" == "OSX" ]; then
77 export __DistroRid="osx-$__BuildArch"
78 export __RuntimeId="osx-$__BuildArch"
82 echo "__DistroRid: " $__DistroRid
85 isMSBuildOnNETCoreSupported()
87 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
89 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
93 if [ "$__HostArch" == "x64" ]; then
94 if [ "$__HostOS" == "Linux" ]; then
95 __isMSBuildOnNETCoreSupported=1
96 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
97 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
99 if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
100 __isMSBuildOnNETCoreSupported=0
104 elif [ "$__HostOS" == "OSX" ]; then
105 __isMSBuildOnNETCoreSupported=1
110 build_test_wrappers()
112 if [ $__BuildTestWrappers -ne -0 ]; then
113 echo "${__MsgPrefix}Creating test wrappers..."
115 export __Exclude="${__ProjectDir}/tests/issues.targets"
116 export __BuildLogRootName="Tests_XunitWrapper"
118 buildVerbosity="Summary"
120 if [ $__VerboseBuild == 1 ]; then
121 buildVerbosity="Diag"
124 # Set up directories and file names
125 __BuildLogRootName=$subDirectoryName
126 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
127 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
128 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
129 __MsbuildLog="/fileloggerparameters:\"Verbosity=normal;LogFile=${__BuildLog}\""
130 __MsbuildWrn="/fileloggerparameters1:\"WarningsOnly;LogFile=${__BuildWrn}\""
131 __MsbuildErr="/fileloggerparameters2:\"ErrorsOnly;LogFile=${__BuildErr}\""
132 __Logging="$__MsbuildLog $__MsbuildWrn $__MsbuildErr /consoleloggerparameters:$buildVerbosity"
134 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"
138 if [ $? -ne 0 ]; then
139 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
142 echo "XUnit Wrappers have been built."
143 echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
151 echo "${__MsgPrefix}Creating test overlay..."
153 __TestDir=$__ProjectDir/tests
154 __ProjectFilesDir=$__TestDir
155 __TestBinDir=$__TestWorkingDir
157 if [ $__RebuildTests -ne 0 ]; then
158 if [ -d "${__TestBinDir}" ]; then
159 echo "Removing tests build dir: ${__TestBinDir}"
164 __CMakeBinDir="${__TestBinDir}"
166 if [ -z "$__TestIntermediateDir" ]; then
167 __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
170 echo "__BuildOS: ${__BuildOS}"
171 echo "__BuildArch: ${__BuildArch}"
172 echo "__BuildType: ${__BuildType}"
173 echo "__TestIntermediateDir: ${__TestIntermediateDir}"
175 if [ ! -f "$__TestBinDir" ]; then
176 echo "Creating TestBinDir: ${__TestBinDir}"
177 mkdir -p $__TestBinDir
179 if [ ! -f "$__LogsDir" ]; then
180 echo "Creating LogsDir: ${__LogsDir}"
184 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
186 # =========================================================================================
188 # === Restore product binaries from packages
190 # =========================================================================================
192 build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
194 if [ -n "$__UpdateInvalidPackagesArg" ]; then
195 __up=-updateinvalidpackageversion
198 echo "${__MsgPrefix}Creating test overlay..."
200 if [ -z "$xUnitTestBinBase" ]; then
201 xUnitTestBinBase=$__TestWorkingDir
204 export CORE_ROOT=$xUnitTestBinBase/Tests/Core_Root
206 if [ -d "${CORE_ROOT}" ]; then
212 build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
214 chmod +x $__BinDir/corerun
215 chmod +x $__BinDir/crossgen
217 # Make sure to copy over the pulled down packages
218 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
223 echo "${__MsgPrefix}Generating test host..."
225 export TEST_HOST=$xUnitTestBinBase/testhost
227 if [ -d "${TEST_HOST}" ]; then
233 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
239 echo "${__MsgPrefix}Building Tests..."
241 __TestDir=$__ProjectDir/tests
242 __ProjectFilesDir=$__TestDir
243 __TestBinDir=$__TestWorkingDir
245 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
246 rm "${__TestWorkingDir}/build_info.json"
249 if [ $__RebuildTests -ne 0 ]; then
250 if [ -d "${__TestBinDir}" ]; then
251 echo "Removing tests build dir: ${__TestBinDir}"
256 export __CMakeBinDir="${__TestBinDir}"
257 if [ ! -d "${__TestIntermediatesDir}" ]; then
258 mkdir -p ${__TestIntermediatesDir}
261 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
262 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
263 mkdir -p ${__NativeTestIntermediatesDir}
266 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
267 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
268 mkdir -p ${__ManagedTestIntermediatesDir}
271 echo "__BuildOS: ${__BuildOS}"
272 echo "__BuildArch: ${__BuildArch}"
273 echo "__BuildType: ${__BuildType}"
274 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
275 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
276 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
278 if [ ! -f "$__TestBinDir" ]; then
279 echo "Creating TestBinDir: ${__TestBinDir}"
280 mkdir -p $__TestBinDir
282 if [ ! -f "$__LogsDir" ]; then
283 echo "Creating LogsDir: ${__LogsDir}"
287 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
289 # =========================================================================================
291 # === Restore product binaries from packages
293 # =========================================================================================
295 if [ ${__SkipRestorePackages} != 1 ]; then
296 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
299 if [ $__SkipNative != 1 ]; then
300 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
302 if [ $? -ne 0 ]; then
303 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
308 if [ $__SkipManaged != 1 ]; then
309 echo "Starting the Managed Tests Build..."
311 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
313 if [ $? -ne 0 ]; then
314 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
317 echo "Checking the Managed Tests Build..."
319 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "-ExtraParameters:/t:CheckTestBuild"
321 if [ $? -ne 0 ]; then
322 echo "${__MsgPrefix}Error: Check Test Build failed."
327 echo "Managed tests build success!"
332 if [ -n "$__UpdateInvalidPackagesArg" ]; then
333 __up=-updateinvalidpackageversion
338 if [ $__ZipTests -ne 0 ]; then
339 echo "${__MsgPrefix}ZIP tests packages..."
340 build_MSBuild_projects "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
344 build_MSBuild_projects()
352 extraBuildParameters=("$@")
354 # Set up directories and file names
355 __BuildLogRootName=$subDirectoryName
356 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
357 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
358 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
360 # Use binclashlogger by default if no other logger is specified
361 if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then
362 msbuildEventLogging=""
364 msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\""
367 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
368 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
369 # See https://github.com/Microsoft/msbuild/issues/2993
371 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
372 export __SkipPackageRestore=false
373 export __SkipTargetingPackBuild=false
374 export __BuildLoopCount=2
375 export __TestGroupToBuild=1
378 if [ -n "$__priority1" ]; then
379 export __BuildLoopCount=16
380 export __TestGroupToBuild=2
383 for (( slice=1 ; slice <= __BuildLoopCount; slice = slice + 1 ))
385 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
386 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
387 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
389 export TestBuildSlice=$slice
391 # Generate build command
392 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
393 buildArgs+=("$msbuildEventLogging")
394 buildArgs+=("${extraBuildParameters[@]}")
395 buildArgs+=("${__RunArgs[@]}")
396 buildArgs+=("${__UnprocessedBuildArgs[@]}")
398 nextCommand="\"$__ProjectRoot/run.sh\" build ${buildArgs[@]}"
399 echo "Building step '$stepName' slice=$slice via $nextCommand"
402 # Make sure everything is OK
403 if [ $? -ne 0 ]; then
404 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
410 export __SkipPackageRestore=true
411 export __SkipTargetingPackBuild=true
415 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
416 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
417 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
419 # Generate build command
420 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
421 buildArgs+=("$msbuildEventLogging")
422 buildArgs+=("${extraBuildParameters[@]}")
423 buildArgs+=("${__RunArgs[@]}")
424 buildArgs+=("${__UnprocessedBuildArgs[@]}")
426 nextCommand="\"$__ProjectRoot/run.sh\" build ${buildArgs[@]}"
427 echo "Building step '$stepName' via $nextCommand"
430 # Make sure everything is OK
431 if [ $? -ne 0 ]; then
432 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
441 build_native_projects()
444 intermediatesForBuild="$2"
446 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
447 message="native tests assets"
449 # All set to commence the build
450 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
455 if [ $__UseNinja == 1 ]; then
457 buildFile="build.ninja"
458 if ! buildTool=$(command -v ninja || command -v ninja-build); then
459 echo "Unable to locate ninja!" 1>&2
464 if [ $__SkipConfigure == 0 ]; then
465 # if msbuild is not supported, then set __SkipGenerateVersion to 1
466 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
467 # Drop version.cpp file
468 __versionSourceFile="$intermediatesForBuild/version.cpp"
469 if [ $__SkipGenerateVersion == 0 ]; then
471 "$__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
473 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
474 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
475 if [ -e $__versionSourceFile ]; then
476 read existingVersionSourceLine < $__versionSourceFile
478 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
479 echo $__versionSourceLine > $__versionSourceFile
483 pushd "$intermediatesForBuild"
484 # Regenerate the CMake solution
485 # Force cross dir to point to project root cross dir, in case there is a cross build.
486 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
487 echo "Invoking $nextCommand"
492 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
493 echo "Failed to generate $message build project!"
498 if [ $__ConfigureOnly == 1 ]; then
499 echo "Finish configuration & skipping $message build."
503 pushd "$intermediatesForBuild"
505 echo "Executing $buildTool install -j $__NumProc"
507 $buildTool install -j $__NumProc
509 echo "Failed to build $message."
514 echo "Native tests build success!"
519 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
520 echo "BuildArch can be: x64, x86, arm, armel, arm64"
521 echo "BuildType can be: debug, checked, release"
522 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
523 echo "ninja - target ninja instead of GNU make"
524 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
525 echo "cross - optional argument to signify cross compilation,"
526 echo " - will use ROOTFS_DIR environment variable if set."
527 echo "portableLinux - build for Portable Linux Distribution"
528 echo "portablebuild - Use portable build."
529 echo "verbose - optional argument to enable verbose build output."
530 echo "rebuild - if tests have already been built - rebuild them"
531 echo "skipnative: skip the native tests build"
532 echo "skipmanaged: skip the managed section of the test build"
533 echo "buildtestwrappersonly - only build the test wrappers"
534 echo "generatelayoutonly - only pull down dependencies and build coreroot"
535 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
536 echo "skiprestorepackages - skip package restore"
537 echo "runtests - run tests after building them"
538 echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
539 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
540 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
541 echo "priority1 - include priority=1 tests in the build"
546 # Obtain the location of the bash script to figure out where the root of the repo is.
547 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
549 # Use uname to determine what the CPU is.
552 # Some Linux platforms report unknown for platform, but the arch for machine.
553 if [ "$CPUName" == "unknown" ]; then
559 echo "Unsupported CPU $CPUName detected, build might not succeed!"
570 echo "Unsupported CPU $CPUName detected, build might not succeed!"
581 echo "Unknown CPU $CPUName detected, configuring as if for x64"
587 # Use uname to determine what the OS is.
621 echo "Unsupported OS $OSName detected, configuring as if for Linux"
629 __IncludeTests=INCLUDE_TESTS
631 # Set the various build properties here so that CMake and MSBuild can pick them up
632 export __ProjectDir="$__ProjectRoot"
633 __SourceDir="$__ProjectDir/src"
634 __PackagesDir="$__ProjectDir/packages"
635 __RootBinDir="$__ProjectDir/bin"
636 __BuildToolsDir="$__ProjectDir/Tools"
637 __DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet"
638 __UnprocessedBuildArgs=
647 __SkipGenerateVersion=0
650 __ClangMajorVersion=0
651 __ClangMinorVersion=0
652 __NuGetPath="$__PackagesDir/NuGet.exe"
654 __SkipRestorePackages=0
658 __msbuildonunsupportedplatform=0
660 __NativeTestIntermediatesDir=
663 __BuildTestWrappers=1
664 __GenerateLayoutOnly=
665 __GenerateTestHostOnly=
667 __BuildTestWrappersOnly=
671 if [ $# -le 0 ]; then
675 lowerI="$(echo $1 | awk '{print tolower($0)}')"
715 __CodeCoverage=Coverage
727 if [ "$__BuildOS" == "Linux" ]; then
730 echo "ERROR: portableLinux not supported for non-Linux platforms."
740 __ClangMajorVersion=3
741 __ClangMinorVersion=5
745 __ClangMajorVersion=3
746 __ClangMinorVersion=6
750 __ClangMajorVersion=3
751 __ClangMinorVersion=7
755 __ClangMajorVersion=3
756 __ClangMinorVersion=8
760 __ClangMajorVersion=3
761 __ClangMinorVersion=9
765 __ClangMajorVersion=4
766 __ClangMinorVersion=0
770 __ClangMajorVersion=5
771 __ClangMinorVersion=0
775 __ClangMajorVersion=6
776 __ClangMinorVersion=0
791 skipnative|-skipnative)
795 skipmanaged|-skipmanaged)
797 __BuildTestWrappers=0
804 buildtestwrappersonly)
805 __BuildTestWrappersOnly=1
809 __GenerateLayoutOnly=1
812 generatetesthostonly)
813 __GenerateTestHostOnly=1
817 __SkipRestorePackages=1
823 if [ ! -d $__RootBinDir ]; then
826 __RootBinParent=$(dirname $__RootBinDir)
827 __RootBinName=${__RootBinDir##*/}
828 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
831 echo "ERROR: 'bindir' requires a non-empty option argument"
836 msbuildonunsupportedplatform)
837 __msbuildonunsupportedplatform=1
842 __UnprocessedBuildArgs+=("-priority=1")
846 __UnprocessedBuildArgs+=("$1")
853 # Get the number of processors available to the scheduler
854 # Other techniques such as `nproc` only get the number of
855 # processors available to a single process.
856 if [ `uname` = "FreeBSD" ]; then
857 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
858 elif [ `uname` = "NetBSD" ]; then
859 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
860 elif [ `uname` = "Darwin" ]; then
861 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
863 __NumProc=$(nproc --all)
866 __RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")
868 # Configure environment if we are doing a verbose build
869 if [ $__VerboseBuild == 1 ]; then
871 __RunArgs+=("-verbose")
874 # Set default clang version
875 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
876 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
877 __ClangMajorVersion=5
878 __ClangMinorVersion=0
880 __ClangMajorVersion=3
881 __ClangMinorVersion=9
885 # Set dependent variables
886 __LogsDir="$__RootBinDir/Logs"
888 # init the host distro name
891 # Set the remaining variables based upon the determined build configuration
892 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
893 __PackagesBinDir="$__BinDir/.nuget"
894 __TestDir="$__ProjectDir/tests"
895 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
896 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
897 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
898 __isMSBuildOnNETCoreSupported=0
899 __CrossComponentBinDir="$__BinDir"
900 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
902 __CrossArch="$__HostArch"
903 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
906 if [ $__CrossBuild == 1 ]; then
907 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
909 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
910 __CrossgenExe="$__CrossComponentBinDir/crossgen"
912 isMSBuildOnNETCoreSupported
914 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
915 # This is needed by CLI to function.
916 if [ -z "$HOME" ]; then
917 if [ ! -d "$__ProjectDir/temp_home" ]; then
920 export HOME=$__ProjectDir/temp_home
921 echo "HOME not defined; setting it to $HOME"
924 # Configure environment if we are doing a cross compile.
925 if [ $__CrossBuild == 1 ]; then
926 export CROSSCOMPILE=1
927 if ! [[ -n "$ROOTFS_DIR" ]]; then
928 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
932 # init the target distro name
935 # Override tool directory
937 __CoreClrVersion=1.1.0
938 __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/
940 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
942 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
946 if [ ! -z "$__GenerateTestHostOnly" ]; then
951 if [ $? -ne 0 ]; then
952 echo "Failed to build tests"
956 echo "${__MsgPrefix}Test build successful."
957 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
959 __testNativeBinDir=$__IntermediatesDir/tests
961 if [ $__RunTests -ne 0 ]; then
965 nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
969 echo "Tests run successful."
971 echo "To run all tests use 'tests/runtests.sh' where:"
972 echo " testRootDir = $__TestBinDir"
973 echo " coreClrBinDir = $__BinDir"
974 echo " coreFxBinDir = $CORE_ROOT"
975 echo " testNativeBinDir = $__testNativeBinDir"
976 echo " -------------------------------------------------- "
977 echo " Example runtest.sh command"
979 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
980 echo " -------------------------------------------------- "
981 echo "To run single test use the following command:"
982 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"