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 $__CrossgenExe
155 # Make sure to copy over the pulled down packages
156 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
158 if [ "$__BuildOS" != "OSX" ]; then
159 nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --outputDir=$CORE_ROOT"
160 echo "Resolve runtime dependences via $nextCommand"
164 # Precompile framework assemblies with crossgen if required
165 if [ $__DoCrossgen -ne 0 ]; then
166 precompile_coreroot_fx
170 precompile_coreroot_fx()
172 echo "${__MsgPrefix}Running crossgen on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"
174 # Read the exclusion file for this platform
175 skipCrossGenFiles=($(read_array "$(dirname "$0")/tests/skipCrossGenFiles.${__BuildArch}.txt"))
177 local overlayDir=$CORE_ROOT
179 filesToPrecompile=$(find -L $overlayDir -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -not -iname xunit.\* -type f)
180 for fileToPrecompile in ${filesToPrecompile}
182 local filename=${fileToPrecompile}
183 if is_skip_crossgen_test "$(basename $filename)"; then
186 echo Precompiling $filename
187 $__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr
189 if [[ $exitCode != 0 ]]; then
190 if grep -q -e '0x80131018' $filename.stderr; then
191 printf "\n\t$filename is not a managed assembly.\n\n"
193 echo Unable to precompile $filename.
199 rm $filename.{stdout,stderr}
204 declare -a skipCrossGenFiles
206 function is_skip_crossgen_test {
207 for skip in "${skipCrossGenFiles[@]}"; do
208 if [ "$1" == "$skip" ]; then
215 # Get an array of items by reading the specified file line by line.
216 function read_array {
219 if [ ! -f "$1" ]; then
223 # bash in Mac OS X doesn't support 'readarray', so using alternate way instead.
224 # readarray -t theArray < "$1"
225 # Any line that starts with '#' is ignored.
226 while IFS='' read -r line || [ -n "$line" ]; do
227 if [[ $line != "#"* ]]; then
228 theArray[${#theArray[@]}]=$line
236 echo "${__MsgPrefix}Generating test host..."
238 export TEST_HOST=$xUnitTestBinBase/testhost
240 if [ -d "${TEST_HOST}" ]; then
246 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "/t:CreateTestHost"
252 echo "${__MsgPrefix}Building Tests..."
254 __TestDir=$__ProjectDir/tests
255 __ProjectFilesDir=$__TestDir
256 __TestBinDir=$__TestWorkingDir
258 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
259 rm "${__TestWorkingDir}/build_info.json"
262 if [ $__RebuildTests -ne 0 ]; then
263 if [ -d "${__TestBinDir}" ]; then
264 echo "Removing tests build dir: ${__TestBinDir}"
269 export __CMakeBinDir="${__TestBinDir}"
270 if [ ! -d "${__TestIntermediatesDir}" ]; then
271 mkdir -p ${__TestIntermediatesDir}
274 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
275 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
276 mkdir -p ${__NativeTestIntermediatesDir}
279 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
280 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
281 mkdir -p ${__ManagedTestIntermediatesDir}
284 echo "__BuildOS: ${__BuildOS}"
285 echo "__BuildArch: ${__BuildArch}"
286 echo "__BuildType: ${__BuildType}"
287 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
288 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
289 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
291 if [ ! -f "$__TestBinDir" ]; then
292 echo "Creating TestBinDir: ${__TestBinDir}"
293 mkdir -p $__TestBinDir
295 if [ ! -f "$__LogsDir" ]; then
296 echo "Creating LogsDir: ${__LogsDir}"
299 if [ ! -f "$__MsbuildDebugLogsDir" ]; then
300 echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
301 mkdir -p $__MsbuildDebugLogsDir
304 # Set up the directory for MSBuild debug logs.
305 export MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
307 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
309 # =========================================================================================
311 # === Restore product binaries from packages
313 # =========================================================================================
315 if [ ${__SkipRestorePackages} != 1 ]; then
316 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
319 if [ $__SkipNative != 1 ]; then
320 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
322 if [ $? -ne 0 ]; then
323 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
328 if [ $__SkipManaged != 1 ]; then
329 echo "Starting the Managed Tests Build..."
331 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
333 if [ $? -ne 0 ]; then
334 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
337 echo "Checking the Managed Tests Build..."
339 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "/t:CheckTestBuild"
341 if [ $? -ne 0 ]; then
342 echo "${__MsgPrefix}Error: Check Test Build failed."
347 echo "Managed tests build success!"
352 if [ -n "$__UpdateInvalidPackagesArg" ]; then
353 __up="/t:UpdateInvalidPackageVersions"
359 build_MSBuild_projects()
367 extraBuildParameters=("$@")
369 # Set up directories and file names
370 __BuildLogRootName=$subDirectoryName
371 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
372 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
373 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
375 # Use binclashlogger by default if no other logger is specified
376 if [[ "${extraBuildParameters[*]}" == *"/l:"* ]]; then
377 __msbuildEventLogging=
379 __msbuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll\;LogFile=binclash.log"
382 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
383 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
384 # See https://github.com/Microsoft/msbuild/issues/2993
386 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
387 export __SkipPackageRestore=false
388 export __SkipTargetingPackBuild=false
389 export __NumberOfTestGroups=3
393 if [ -n "$__priority1" ]; then
394 export __NumberOfTestGroups=10
397 for (( testGroupToBuild=1 ; testGroupToBuild <= __NumberOfTestGroups; testGroupToBuild = testGroupToBuild + 1 ))
399 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
400 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
401 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
403 export __TestGroupToBuild=$testGroupToBuild
405 # Generate build command
406 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
407 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
408 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
410 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
411 buildArgs+=("$__msbuildEventLogging")
412 buildArgs+=("${extraBuildParameters[@]}")
413 buildArgs+=("${__CommonMSBuildArgs[@]}")
414 buildArgs+=("${__UnprocessedBuildArgs[@]}")
416 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
417 echo "Building step '$stepName' testGroupToBuild=$testGroupToBuild via $nextCommand"
420 # Make sure everything is OK
421 if [ $? -ne 0 ]; then
422 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
428 export __SkipPackageRestore=true
429 export __SkipTargetingPackBuild=true
433 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
434 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
435 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
437 # Generate build command
438 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
439 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
440 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
442 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
443 buildArgs+=("$__msbuildEventLogging")
444 buildArgs+=("${extraBuildParameters[@]}")
445 buildArgs+=("${__CommonMSBuildArgs[@]}")
446 buildArgs+=("${__UnprocessedBuildArgs[@]}")
448 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
449 echo "Building step '$stepName' via $nextCommand"
452 # Make sure everything is OK
453 if [ $? -ne 0 ]; then
454 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
463 build_native_projects()
466 intermediatesForBuild="$2"
468 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
469 message="native tests assets"
471 # All set to commence the build
472 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
477 if [ $__UseNinja == 1 ]; then
479 buildFile="build.ninja"
480 if ! buildTool=$(command -v ninja || command -v ninja-build); then
481 echo "Unable to locate ninja!" 1>&2
486 if [ $__SkipConfigure == 0 ]; then
487 # if msbuild is not supported, then set __SkipGenerateVersion to 1
488 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
489 # Drop version.c file
490 __versionSourceFile="$intermediatesForBuild/version.c"
491 if [ $__SkipGenerateVersion == 0 ]; then
493 $__ProjectRoot/eng/common/msbuild.sh $__ProjectRoot/eng/empty.proj \
494 /p:NativeVersionFile=$__versionSourceFile \
495 /p:ArcadeBuild=true /t:GenerateNativeVersionFile /restore \
496 $__CommonMSBuildArgs $__UnprocessedBuildArgs
497 if [ $? -ne 0 ]; then
498 echo "Failed to generate native version file."
502 # Generate the dummy version.c, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
503 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
504 if [ -e $__versionSourceFile ]; then
505 read existingVersionSourceLine < $__versionSourceFile
507 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
508 echo $__versionSourceLine > $__versionSourceFile
512 pushd "$intermediatesForBuild"
513 # Regenerate the CMake solution
514 # Force cross dir to point to project root cross dir, in case there is a cross build.
515 scriptDir="$__ProjectRoot/src/pal/tools"
516 if [[ $__GccBuild == 0 ]]; then
517 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
519 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-gcc.sh\" \"$__TestDir\" \"$__GccMajorVersion\" \"$__GccMinorVersion\" $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
521 echo "Invoking $nextCommand"
526 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
527 echo "Failed to generate $message build project!"
532 if [ $__ConfigureOnly == 1 ]; then
533 echo "Finish configuration & skipping $message build."
537 pushd "$intermediatesForBuild"
539 echo "Executing $buildTool install -j $__NumProc"
541 $buildTool install -j $__NumProc
543 echo "Failed to build $message."
548 echo "Native tests build success!"
553 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
554 echo "BuildArch can be: x64, x86, arm, armel, arm64"
555 echo "BuildType can be: debug, checked, release"
556 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
557 echo "ninja - target ninja instead of GNU make"
558 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
559 echo "gccx.y - optional argument to build using gcc version x.y."
560 echo "cross - optional argument to signify cross compilation,"
561 echo " - will use ROOTFS_DIR environment variable if set."
562 echo "portableLinux - build for Portable Linux Distribution"
563 echo "portablebuild - Use portable build."
564 echo "verbose - optional argument to enable verbose build output."
565 echo "rebuild - if tests have already been built - rebuild them"
566 echo "skipnative: skip the native tests build"
567 echo "skipmanaged: skip the managed section of the test build"
568 echo "buildtestwrappersonly - only build the test wrappers"
569 echo "generatelayoutonly - only pull down dependencies and build coreroot"
570 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
571 echo "skiprestorepackages - skip package restore"
572 echo "crossgen - Precompiles the framework managed assemblies in coreroot"
573 echo "runtests - run tests after building them"
574 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
575 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
576 echo "priority1 - include priority=1 tests in the build"
581 # Obtain the location of the bash script to figure out where the root of the repo is.
582 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
584 # Use uname to determine what the CPU is.
587 # Some Linux platforms report unknown for platform, but the arch for machine.
588 if [ "$CPUName" == "unknown" ]; then
594 echo "Unsupported CPU $CPUName detected, build might not succeed!"
605 echo "Unsupported CPU $CPUName detected, build might not succeed!"
616 echo "Unknown CPU $CPUName detected, configuring as if for x64"
622 # Use uname to determine what the OS is.
656 echo "Unsupported OS $OSName detected, configuring as if for Linux"
664 __IncludeTests=INCLUDE_TESTS
666 # Set the various build properties here so that CMake and MSBuild can pick them up
667 export __ProjectDir="$__ProjectRoot"
668 __SourceDir="$__ProjectDir/src"
669 __PackagesDir="$__ProjectDir/.packages"
670 __RootBinDir="$__ProjectDir/bin"
671 __BuildToolsDir="$__ProjectDir/Tools"
672 __DotNetCli="$__ProjectDir/dotnet.sh"
673 __UnprocessedBuildArgs=
682 __SkipGenerateVersion=0
685 __ClangMajorVersion=0
686 __ClangMinorVersion=0
690 __NuGetPath="$__PackagesDir/NuGet.exe"
691 __SkipRestorePackages=0
695 __msbuildonunsupportedplatform=0
696 __NativeTestIntermediatesDir=
699 __BuildTestWrappers=1
700 __GenerateLayoutOnly=
701 __GenerateTestHostOnly=
703 __BuildTestWrappersOnly=
708 if [ $# -le 0 ]; then
712 lowerI="$(echo $1 | awk '{print tolower($0)}')"
752 __CodeCoverage=Coverage
764 if [ "$__BuildOS" == "Linux" ]; then
767 echo "ERROR: portableLinux not supported for non-Linux platforms."
777 __ClangMajorVersion=3
778 __ClangMinorVersion=5
782 __ClangMajorVersion=3
783 __ClangMinorVersion=6
787 __ClangMajorVersion=3
788 __ClangMinorVersion=7
792 __ClangMajorVersion=3
793 __ClangMinorVersion=8
797 __ClangMajorVersion=3
798 __ClangMinorVersion=9
802 __ClangMajorVersion=4
803 __ClangMinorVersion=0
807 __ClangMajorVersion=5
808 __ClangMinorVersion=0
812 __ClangMajorVersion=6
813 __ClangMinorVersion=0
858 skipnative|-skipnative)
862 skipmanaged|-skipmanaged)
864 __BuildTestWrappers=0
867 buildtestwrappersonly)
868 __BuildTestWrappersOnly=1
872 __GenerateLayoutOnly=1
875 generatetesthostonly)
876 __GenerateTestHostOnly=1
880 __SkipRestorePackages=1
890 if [ ! -d $__RootBinDir ]; then
893 __RootBinParent=$(dirname $__RootBinDir)
894 __RootBinName=${__RootBinDir##*/}
895 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
898 echo "ERROR: 'bindir' requires a non-empty option argument"
903 msbuildonunsupportedplatform)
904 __msbuildonunsupportedplatform=1
909 __UnprocessedBuildArgs+=("/p:CLRTestPriorityToBuild=1")
913 __UnprocessedBuildArgs+=("$1")
920 # Get the number of processors available to the scheduler
921 # Other techniques such as `nproc` only get the number of
922 # processors available to a single process.
923 if [ `uname` = "FreeBSD" ]; then
924 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
925 elif [ `uname` = "NetBSD" ]; then
926 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
927 elif [ `uname` = "Darwin" ]; then
928 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
930 __NumProc=$(nproc --all)
933 __CommonMSBuildArgs=("/p:__BuildArch=$__BuildArch" "/p:__BuildType=$__BuildType" "/p:__BuildOS=$__BuildOS")
935 # Configure environment if we are doing a verbose build
936 if [ $__VerboseBuild == 1 ]; then
938 __CommonMSBuildArgs+=("/v:detailed")
941 # Set default clang version
942 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
943 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
944 __ClangMajorVersion=5
945 __ClangMinorVersion=0
947 __ClangMajorVersion=3
948 __ClangMinorVersion=9
952 # Set dependent variables
953 __LogsDir="$__RootBinDir/Logs"
954 __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
956 # Set the remaining variables based upon the determined build configuration
957 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
958 __PackagesBinDir="$__BinDir/.nuget"
959 __TestDir="$__ProjectDir/tests"
960 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
961 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
962 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
963 __isMSBuildOnNETCoreSupported=0
964 __CrossComponentBinDir="$__BinDir"
965 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
967 __CrossArch="$__HostArch"
968 if [ $__CrossBuild == 1 ]; then
969 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
971 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
972 __CrossgenExe="$__CrossComponentBinDir/crossgen"
974 isMSBuildOnNETCoreSupported
976 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
977 # This is needed by CLI to function.
978 if [ -z "$HOME" ]; then
979 if [ ! -d "$__ProjectDir/temp_home" ]; then
982 export HOME=$__ProjectDir/temp_home
983 echo "HOME not defined; setting it to $HOME"
986 # Configure environment if we are doing a cross compile.
987 if [ $__CrossBuild == 1 ]; then
988 export CROSSCOMPILE=1
989 if ! [[ -n "$ROOTFS_DIR" ]]; then
990 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
994 # init the target distro name
997 # Override tool directory
999 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
1001 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
1005 if [ ! -z "$__GenerateTestHostOnly" ]; then
1010 if [ $? -ne 0 ]; then
1011 echo "Failed to build tests"
1015 echo "${__MsgPrefix}Test build successful."
1016 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
1018 __testNativeBinDir=$__IntermediatesDir/tests
1020 if [ $__RunTests -ne 0 ]; then
1024 nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
1028 echo "Tests run successful."
1030 echo "To run all tests use 'tests/runtests.sh' where:"
1031 echo " testRootDir = $__TestBinDir"
1032 echo " coreClrBinDir = $__BinDir"
1033 echo " coreFxBinDir = $CORE_ROOT"
1034 echo " testNativeBinDir = $__testNativeBinDir"
1035 echo " -------------------------------------------------- "
1036 echo " Example runtest.sh command"
1038 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
1039 echo " -------------------------------------------------- "
1040 echo "To run single test use the following command:"
1041 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"