7 source init-distro-rid.sh
9 # Only pass ROOTFS_DIR if cross is specified.
10 if (( ${__CrossBuild} == 1 )); then
11 passedRootfsDir=${ROOTFS_DIR}
14 initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir}
17 isMSBuildOnNETCoreSupported()
19 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
21 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
25 if [ "$__HostArch" == "x64" ]; then
26 if [ "$__HostOS" == "Linux" ]; then
27 __isMSBuildOnNETCoreSupported=1
28 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
29 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
31 if [ "${__DistroRid}" == "$UNSUPPORTED_RID" ]; then
32 __isMSBuildOnNETCoreSupported=0
36 elif [ "$__HostOS" == "OSX" ]; then
37 __isMSBuildOnNETCoreSupported=1
44 if [ $__BuildTestWrappers -ne -0 ]; then
45 echo "${__MsgPrefix}Creating test wrappers..."
47 export __Exclude="${__ProjectDir}/tests/issues.targets"
48 export __BuildLogRootName="Tests_XunitWrapper"
50 buildVerbosity="Summary"
52 if [ $__VerboseBuild == 1 ]; then
56 # Set up directories and file names
57 __BuildLogRootName=$subDirectoryName
58 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
59 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
60 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
61 __MsbuildLog="/fileloggerparameters:\"Verbosity=normal;LogFile=${__BuildLog}\""
62 __MsbuildWrn="/fileloggerparameters1:\"WarningsOnly;LogFile=${__BuildWrn}\""
63 __MsbuildErr="/fileloggerparameters2:\"ErrorsOnly;LogFile=${__BuildErr}\""
64 __Logging="$__MsbuildLog $__MsbuildWrn $__MsbuildErr /consoleloggerparameters:$buildVerbosity"
66 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"
70 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
73 echo "XUnit Wrappers have been built."
74 echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
82 echo "${__MsgPrefix}Creating test overlay..."
84 __TestDir=$__ProjectDir/tests
85 __ProjectFilesDir=$__TestDir
86 __TestBinDir=$__TestWorkingDir
88 if [ $__RebuildTests -ne 0 ]; then
89 if [ -d "${__TestBinDir}" ]; then
90 echo "Removing tests build dir: ${__TestBinDir}"
95 __CMakeBinDir="${__TestBinDir}"
97 if [ -z "$__TestIntermediateDir" ]; then
98 __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
101 echo "__BuildOS: ${__BuildOS}"
102 echo "__BuildArch: ${__BuildArch}"
103 echo "__BuildType: ${__BuildType}"
104 echo "__TestIntermediateDir: ${__TestIntermediateDir}"
106 if [ ! -f "$__TestBinDir" ]; then
107 echo "Creating TestBinDir: ${__TestBinDir}"
108 mkdir -p $__TestBinDir
110 if [ ! -f "$__LogsDir" ]; then
111 echo "Creating LogsDir: ${__LogsDir}"
114 if [ ! -f "$__MsbuildDebugLogsDir" ]; then
115 echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
116 mkdir -p $__MsbuildDebugLogsDir
119 # Set up the directory for MSBuild debug logs.
120 export MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
122 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
124 # =========================================================================================
126 # === Restore product binaries from packages
128 # =========================================================================================
130 build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
132 if [ -n "$__UpdateInvalidPackagesArg" ]; then
133 __up="/t:UpdateInvalidPackageVersions"
136 echo "${__MsgPrefix}Creating test overlay..."
138 if [ -z "$xUnitTestBinBase" ]; then
139 xUnitTestBinBase=$__TestWorkingDir
142 export CORE_ROOT=$xUnitTestBinBase/Tests/Core_Root
144 if [ -d "${CORE_ROOT}" ]; then
150 build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "/t:CreateTestOverlay"
152 chmod +x $__BinDir/corerun
153 chmod +x $__BinDir/crossgen
155 # Make sure to copy over the pulled down packages
156 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
158 nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --outputDir=$CORE_ROOT"
159 echo "Resolve runtime dependences via $nextCommand"
165 echo "${__MsgPrefix}Generating test host..."
167 export TEST_HOST=$xUnitTestBinBase/testhost
169 if [ -d "${TEST_HOST}" ]; then
175 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "/t:CreateTestHost"
181 echo "${__MsgPrefix}Building Tests..."
183 __TestDir=$__ProjectDir/tests
184 __ProjectFilesDir=$__TestDir
185 __TestBinDir=$__TestWorkingDir
187 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
188 rm "${__TestWorkingDir}/build_info.json"
191 if [ $__RebuildTests -ne 0 ]; then
192 if [ -d "${__TestBinDir}" ]; then
193 echo "Removing tests build dir: ${__TestBinDir}"
198 export __CMakeBinDir="${__TestBinDir}"
199 if [ ! -d "${__TestIntermediatesDir}" ]; then
200 mkdir -p ${__TestIntermediatesDir}
203 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
204 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
205 mkdir -p ${__NativeTestIntermediatesDir}
208 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
209 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
210 mkdir -p ${__ManagedTestIntermediatesDir}
213 echo "__BuildOS: ${__BuildOS}"
214 echo "__BuildArch: ${__BuildArch}"
215 echo "__BuildType: ${__BuildType}"
216 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
217 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
218 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
220 if [ ! -f "$__TestBinDir" ]; then
221 echo "Creating TestBinDir: ${__TestBinDir}"
222 mkdir -p $__TestBinDir
224 if [ ! -f "$__LogsDir" ]; then
225 echo "Creating LogsDir: ${__LogsDir}"
228 if [ ! -f "$__MsbuildDebugLogsDir" ]; then
229 echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
230 mkdir -p $__MsbuildDebugLogsDir
233 # Set up the directory for MSBuild debug logs.
234 export MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
236 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
238 # =========================================================================================
240 # === Restore product binaries from packages
242 # =========================================================================================
244 if [ ${__SkipRestorePackages} != 1 ]; then
245 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
248 if [ $__SkipNative != 1 ]; then
249 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
251 if [ $? -ne 0 ]; then
252 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
257 if [ $__SkipManaged != 1 ]; then
258 echo "Starting the Managed Tests Build..."
260 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
262 if [ $? -ne 0 ]; then
263 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
266 echo "Checking the Managed Tests Build..."
268 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "/t:CheckTestBuild"
270 if [ $? -ne 0 ]; then
271 echo "${__MsgPrefix}Error: Check Test Build failed."
276 echo "Managed tests build success!"
281 if [ -n "$__UpdateInvalidPackagesArg" ]; then
282 __up="/t:UpdateInvalidPackageVersions"
288 build_MSBuild_projects()
296 extraBuildParameters=("$@")
298 # Set up directories and file names
299 __BuildLogRootName=$subDirectoryName
300 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
301 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
302 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
304 # Use binclashlogger by default if no other logger is specified
305 if [[ "${extraBuildParameters[*]}" == *"/l:"* ]]; then
306 __msbuildEventLogging=
308 __msbuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll\;LogFile=binclash.log"
311 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
312 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
313 # See https://github.com/Microsoft/msbuild/issues/2993
315 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
316 export __SkipPackageRestore=false
317 export __SkipTargetingPackBuild=false
318 export __NumberOfTestGroups=3
322 if [ -n "$__priority1" ]; then
323 export __NumberOfTestGroups=10
326 for (( testGroupToBuild=1 ; testGroupToBuild <= __NumberOfTestGroups; testGroupToBuild = testGroupToBuild + 1 ))
328 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
329 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
330 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
332 export __TestGroupToBuild=$testGroupToBuild
334 # Generate build command
335 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
336 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
337 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
339 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
340 buildArgs+=("$__msbuildEventLogging")
341 buildArgs+=("${extraBuildParameters[@]}")
342 buildArgs+=("${__CommonMSBuildArgs[@]}")
343 buildArgs+=("${__UnprocessedBuildArgs[@]}")
345 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
346 echo "Building step '$stepName' testGroupToBuild=$testGroupToBuild via $nextCommand"
349 # Make sure everything is OK
350 if [ $? -ne 0 ]; then
351 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
357 export __SkipPackageRestore=true
358 export __SkipTargetingPackBuild=true
362 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
363 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
364 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
366 # Generate build command
367 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
368 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
369 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
371 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
372 buildArgs+=("$__msbuildEventLogging")
373 buildArgs+=("${extraBuildParameters[@]}")
374 buildArgs+=("${__CommonMSBuildArgs[@]}")
375 buildArgs+=("${__UnprocessedBuildArgs[@]}")
377 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
378 echo "Building step '$stepName' via $nextCommand"
381 # Make sure everything is OK
382 if [ $? -ne 0 ]; then
383 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
392 build_native_projects()
395 intermediatesForBuild="$2"
397 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
398 message="native tests assets"
400 # All set to commence the build
401 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
406 if [ $__UseNinja == 1 ]; then
408 buildFile="build.ninja"
409 if ! buildTool=$(command -v ninja || command -v ninja-build); then
410 echo "Unable to locate ninja!" 1>&2
415 if [ $__SkipConfigure == 0 ]; then
416 # if msbuild is not supported, then set __SkipGenerateVersion to 1
417 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
418 # Drop version.c file
419 __versionSourceFile="$intermediatesForBuild/version.c"
420 if [ $__SkipGenerateVersion == 0 ]; then
422 $__ProjectRoot/dotnet.sh msbuild /nologo /verbosity:minimal /clp:Summary \
423 /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true \
424 /p:UsePartialNGENOptimization=false /maxcpucount \
425 $__ProjectDir/build.proj /t:GenerateVersionHeader \
426 /p:GenerateVersionHeader=true /p:NativeVersionSourceFile=$__versionSourceFile \
427 /l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll\;LogFile=binclash.log \
428 $__CommonMSBuildArgs $__UnprocessedBuildArgs
430 # Generate the dummy version.c, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
431 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
432 if [ -e $__versionSourceFile ]; then
433 read existingVersionSourceLine < $__versionSourceFile
435 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
436 echo $__versionSourceLine > $__versionSourceFile
440 pushd "$intermediatesForBuild"
441 # Regenerate the CMake solution
442 # Force cross dir to point to project root cross dir, in case there is a cross build.
443 scriptDir="$__ProjectRoot/src/pal/tools"
444 if [[ $__GccBuild == 0 ]]; then
445 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
447 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-gcc.sh\" \"$__TestDir\" \"$__GccMajorVersion\" \"$__GccMinorVersion\" $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
449 echo "Invoking $nextCommand"
454 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
455 echo "Failed to generate $message build project!"
460 if [ $__ConfigureOnly == 1 ]; then
461 echo "Finish configuration & skipping $message build."
465 pushd "$intermediatesForBuild"
467 echo "Executing $buildTool install -j $__NumProc"
469 $buildTool install -j $__NumProc
471 echo "Failed to build $message."
476 echo "Native tests build success!"
481 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
482 echo "BuildArch can be: x64, x86, arm, armel, arm64"
483 echo "BuildType can be: debug, checked, release"
484 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
485 echo "ninja - target ninja instead of GNU make"
486 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
487 echo "gccx.y - optional argument to build using gcc version x.y."
488 echo "cross - optional argument to signify cross compilation,"
489 echo " - will use ROOTFS_DIR environment variable if set."
490 echo "portableLinux - build for Portable Linux Distribution"
491 echo "portablebuild - Use portable build."
492 echo "verbose - optional argument to enable verbose build output."
493 echo "rebuild - if tests have already been built - rebuild them"
494 echo "skipnative: skip the native tests build"
495 echo "skipmanaged: skip the managed section of the test build"
496 echo "buildtestwrappersonly - only build the test wrappers"
497 echo "generatelayoutonly - only pull down dependencies and build coreroot"
498 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
499 echo "skiprestorepackages - skip package restore"
500 echo "runtests - run tests after building them"
501 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
502 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
503 echo "priority1 - include priority=1 tests in the build"
508 # Obtain the location of the bash script to figure out where the root of the repo is.
509 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
511 # Use uname to determine what the CPU is.
514 # Some Linux platforms report unknown for platform, but the arch for machine.
515 if [ "$CPUName" == "unknown" ]; then
521 echo "Unsupported CPU $CPUName detected, build might not succeed!"
532 echo "Unsupported CPU $CPUName detected, build might not succeed!"
543 echo "Unknown CPU $CPUName detected, configuring as if for x64"
549 # Use uname to determine what the OS is.
583 echo "Unsupported OS $OSName detected, configuring as if for Linux"
591 __IncludeTests=INCLUDE_TESTS
593 # Set the various build properties here so that CMake and MSBuild can pick them up
594 export __ProjectDir="$__ProjectRoot"
595 __SourceDir="$__ProjectDir/src"
596 __PackagesDir="$__ProjectDir/packages"
597 __RootBinDir="$__ProjectDir/bin"
598 __BuildToolsDir="$__ProjectDir/Tools"
599 __DotNetCli="$__ProjectDir/dotnet.sh"
600 __UnprocessedBuildArgs=
609 __SkipGenerateVersion=0
612 __ClangMajorVersion=0
613 __ClangMinorVersion=0
617 __NuGetPath="$__PackagesDir/NuGet.exe"
618 __SkipRestorePackages=0
622 __msbuildonunsupportedplatform=0
623 __NativeTestIntermediatesDir=
626 __BuildTestWrappers=1
627 __GenerateLayoutOnly=
628 __GenerateTestHostOnly=
630 __BuildTestWrappersOnly=
634 if [ $# -le 0 ]; then
638 lowerI="$(echo $1 | awk '{print tolower($0)}')"
678 __CodeCoverage=Coverage
690 if [ "$__BuildOS" == "Linux" ]; then
693 echo "ERROR: portableLinux not supported for non-Linux platforms."
703 __ClangMajorVersion=3
704 __ClangMinorVersion=5
708 __ClangMajorVersion=3
709 __ClangMinorVersion=6
713 __ClangMajorVersion=3
714 __ClangMinorVersion=7
718 __ClangMajorVersion=3
719 __ClangMinorVersion=8
723 __ClangMajorVersion=3
724 __ClangMinorVersion=9
728 __ClangMajorVersion=4
729 __ClangMinorVersion=0
733 __ClangMajorVersion=5
734 __ClangMinorVersion=0
738 __ClangMajorVersion=6
739 __ClangMinorVersion=0
784 skipnative|-skipnative)
788 skipmanaged|-skipmanaged)
790 __BuildTestWrappers=0
793 buildtestwrappersonly)
794 __BuildTestWrappersOnly=1
798 __GenerateLayoutOnly=1
801 generatetesthostonly)
802 __GenerateTestHostOnly=1
806 __SkipRestorePackages=1
812 if [ ! -d $__RootBinDir ]; then
815 __RootBinParent=$(dirname $__RootBinDir)
816 __RootBinName=${__RootBinDir##*/}
817 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
820 echo "ERROR: 'bindir' requires a non-empty option argument"
825 msbuildonunsupportedplatform)
826 __msbuildonunsupportedplatform=1
831 __UnprocessedBuildArgs+=("/p:CLRTestPriorityToBuild=1")
835 __UnprocessedBuildArgs+=("$1")
842 # Get the number of processors available to the scheduler
843 # Other techniques such as `nproc` only get the number of
844 # processors available to a single process.
845 if [ `uname` = "FreeBSD" ]; then
846 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
847 elif [ `uname` = "NetBSD" ]; then
848 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
849 elif [ `uname` = "Darwin" ]; then
850 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
852 __NumProc=$(nproc --all)
855 __CommonMSBuildArgs=("/p:__BuildArch=$__BuildArch" "/p:__BuildType=$__BuildType" "/p:__BuildOS=$__BuildOS")
857 # Configure environment if we are doing a verbose build
858 if [ $__VerboseBuild == 1 ]; then
860 __CommonMSBuildArgs+=("/v:detailed")
863 # Set default clang version
864 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
865 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
866 __ClangMajorVersion=5
867 __ClangMinorVersion=0
869 __ClangMajorVersion=3
870 __ClangMinorVersion=9
874 # Set dependent variables
875 __LogsDir="$__RootBinDir/Logs"
876 __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
878 # Set the remaining variables based upon the determined build configuration
879 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
880 __PackagesBinDir="$__BinDir/.nuget"
881 __TestDir="$__ProjectDir/tests"
882 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
883 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
884 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
885 __isMSBuildOnNETCoreSupported=0
886 __CrossComponentBinDir="$__BinDir"
887 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
889 __CrossArch="$__HostArch"
890 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
893 if [ $__CrossBuild == 1 ]; then
894 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
896 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
897 __CrossgenExe="$__CrossComponentBinDir/crossgen"
899 isMSBuildOnNETCoreSupported
901 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
902 # This is needed by CLI to function.
903 if [ -z "$HOME" ]; then
904 if [ ! -d "$__ProjectDir/temp_home" ]; then
907 export HOME=$__ProjectDir/temp_home
908 echo "HOME not defined; setting it to $HOME"
911 # Configure environment if we are doing a cross compile.
912 if [ $__CrossBuild == 1 ]; then
913 export CROSSCOMPILE=1
914 if ! [[ -n "$ROOTFS_DIR" ]]; then
915 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
919 # init the target distro name
922 # Override tool directory
924 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
926 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
930 if [ ! -z "$__GenerateTestHostOnly" ]; then
935 if [ $? -ne 0 ]; then
936 echo "Failed to build tests"
940 echo "${__MsgPrefix}Test build successful."
941 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
943 __testNativeBinDir=$__IntermediatesDir/tests
945 if [ $__RunTests -ne 0 ]; then
949 nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
953 echo "Tests run successful."
955 echo "To run all tests use 'tests/runtests.sh' where:"
956 echo " testRootDir = $__TestBinDir"
957 echo " coreClrBinDir = $__BinDir"
958 echo " coreFxBinDir = $CORE_ROOT"
959 echo " testNativeBinDir = $__testNativeBinDir"
960 echo " -------------------------------------------------- "
961 echo " Example runtest.sh command"
963 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
964 echo " -------------------------------------------------- "
965 echo "To run single test use the following command:"
966 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"