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\" --arch=$__BuildArch --outputDir=$CORE_ROOT"
160 echo "Resolve runtime dependences via $nextCommand"
163 echo "${__MsgPrefix}Error: setup-stress-dependencies failed."
168 # Precompile framework assemblies with crossgen if required
169 if [ $__DoCrossgen -ne 0 ]; then
170 precompile_coreroot_fx
174 precompile_coreroot_fx()
176 echo "${__MsgPrefix}Running crossgen on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"
178 # Read the exclusion file for this platform
179 skipCrossGenFiles=($(read_array "$(dirname "$0")/tests/skipCrossGenFiles.${__BuildArch}.txt"))
181 local overlayDir=$CORE_ROOT
183 filesToPrecompile=$(find -L $overlayDir -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -not -iname xunit.\* -type f)
184 for fileToPrecompile in ${filesToPrecompile}
186 local filename=${fileToPrecompile}
187 if is_skip_crossgen_test "$(basename $filename)"; then
190 echo Precompiling $filename
191 $__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr
193 if [[ $exitCode != 0 ]]; then
194 if grep -q -e '0x80131018' $filename.stderr; then
195 printf "\n\t$filename is not a managed assembly.\n\n"
197 echo Unable to precompile $filename.
203 rm $filename.{stdout,stderr}
208 declare -a skipCrossGenFiles
210 function is_skip_crossgen_test {
211 for skip in "${skipCrossGenFiles[@]}"; do
212 if [ "$1" == "$skip" ]; then
219 # Get an array of items by reading the specified file line by line.
220 function read_array {
223 if [ ! -f "$1" ]; then
227 # bash in Mac OS X doesn't support 'readarray', so using alternate way instead.
228 # readarray -t theArray < "$1"
229 # Any line that starts with '#' is ignored.
230 while IFS='' read -r line || [ -n "$line" ]; do
231 if [[ $line != "#"* ]]; then
232 theArray[${#theArray[@]}]=$line
240 echo "${__MsgPrefix}Generating test host..."
242 export TEST_HOST=$xUnitTestBinBase/testhost
244 if [ -d "${TEST_HOST}" ]; then
250 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "/t:CreateTestHost"
256 echo "${__MsgPrefix}Building Tests..."
258 __TestDir=$__ProjectDir/tests
259 __ProjectFilesDir=$__TestDir
260 __TestBinDir=$__TestWorkingDir
262 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
263 rm "${__TestWorkingDir}/build_info.json"
266 if [ $__RebuildTests -ne 0 ]; then
267 if [ -d "${__TestBinDir}" ]; then
268 echo "Removing tests build dir: ${__TestBinDir}"
273 export __CMakeBinDir="${__TestBinDir}"
274 if [ ! -d "${__TestIntermediatesDir}" ]; then
275 mkdir -p ${__TestIntermediatesDir}
278 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
279 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
280 mkdir -p ${__NativeTestIntermediatesDir}
283 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
284 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
285 mkdir -p ${__ManagedTestIntermediatesDir}
288 echo "__BuildOS: ${__BuildOS}"
289 echo "__BuildArch: ${__BuildArch}"
290 echo "__BuildType: ${__BuildType}"
291 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
292 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
293 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
295 if [ ! -f "$__TestBinDir" ]; then
296 echo "Creating TestBinDir: ${__TestBinDir}"
297 mkdir -p $__TestBinDir
299 if [ ! -f "$__LogsDir" ]; then
300 echo "Creating LogsDir: ${__LogsDir}"
303 if [ ! -f "$__MsbuildDebugLogsDir" ]; then
304 echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
305 mkdir -p $__MsbuildDebugLogsDir
308 # Set up the directory for MSBuild debug logs.
309 export MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
311 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
313 # =========================================================================================
315 # === Restore product binaries from packages
317 # =========================================================================================
319 if [ ${__SkipRestorePackages} != 1 ]; then
320 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
323 if [ $__SkipNative != 1 ]; then
324 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
326 if [ $? -ne 0 ]; then
327 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
332 if [ $__SkipManaged != 1 ]; then
333 echo "Starting the Managed Tests Build..."
335 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
337 if [ $? -ne 0 ]; then
338 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
341 echo "Checking the Managed Tests Build..."
343 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "/t:CheckTestBuild"
345 if [ $? -ne 0 ]; then
346 echo "${__MsgPrefix}Error: Check Test Build failed."
351 echo "Managed tests build success!"
356 if [ -n "$__UpdateInvalidPackagesArg" ]; then
357 __up="/t:UpdateInvalidPackageVersions"
363 build_MSBuild_projects()
371 extraBuildParameters=("$@")
373 # Set up directories and file names
374 __BuildLogRootName=$subDirectoryName
375 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
376 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
377 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
379 # Use binclashlogger by default if no other logger is specified
380 if [[ "${extraBuildParameters[*]}" == *"/l:"* ]]; then
381 __msbuildEventLogging=
383 __msbuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll\;LogFile=binclash.log"
386 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
387 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
388 # See https://github.com/Microsoft/msbuild/issues/2993
390 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
391 export __SkipPackageRestore=false
392 export __SkipTargetingPackBuild=false
393 export __NumberOfTestGroups=3
397 if [ -n "$__priority1" ]; then
398 export __NumberOfTestGroups=10
401 for (( testGroupToBuild=1 ; testGroupToBuild <= __NumberOfTestGroups; testGroupToBuild = testGroupToBuild + 1 ))
403 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
404 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
405 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
407 export __TestGroupToBuild=$testGroupToBuild
409 # Generate build command
410 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
411 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
412 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
414 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
415 buildArgs+=("$__msbuildEventLogging")
416 buildArgs+=("${extraBuildParameters[@]}")
417 buildArgs+=("${__CommonMSBuildArgs[@]}")
418 buildArgs+=("${__UnprocessedBuildArgs[@]}")
420 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
421 echo "Building step '$stepName' testGroupToBuild=$testGroupToBuild via $nextCommand"
424 # Make sure everything is OK
425 if [ $? -ne 0 ]; then
426 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
432 export __SkipPackageRestore=true
433 export __SkipTargetingPackBuild=true
437 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
438 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
439 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
441 # Generate build command
442 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
443 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
444 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
446 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
447 buildArgs+=("$__msbuildEventLogging")
448 buildArgs+=("${extraBuildParameters[@]}")
449 buildArgs+=("${__CommonMSBuildArgs[@]}")
450 buildArgs+=("${__UnprocessedBuildArgs[@]}")
452 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
453 echo "Building step '$stepName' via $nextCommand"
456 # Make sure everything is OK
457 if [ $? -ne 0 ]; then
458 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
467 build_native_projects()
470 intermediatesForBuild="$2"
472 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
473 message="native tests assets"
475 # All set to commence the build
476 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
481 if [ $__UseNinja == 1 ]; then
483 buildFile="build.ninja"
484 if ! buildTool=$(command -v ninja || command -v ninja-build); then
485 echo "Unable to locate ninja!" 1>&2
490 if [ $__SkipConfigure == 0 ]; then
491 # if msbuild is not supported, then set __SkipGenerateVersion to 1
492 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
493 # Drop version.c file
494 __versionSourceFile="$intermediatesForBuild/version.c"
495 if [ $__SkipGenerateVersion == 0 ]; then
497 $__ProjectRoot/eng/common/msbuild.sh $__ProjectRoot/eng/empty.csproj \
498 /p:NativeVersionFile=$__versionSourceFile \
499 /p:ArcadeBuild=true /t:GenerateNativeVersionFile /restore \
500 $__CommonMSBuildArgs $__UnprocessedBuildArgs
501 if [ $? -ne 0 ]; then
502 echo "Failed to generate native version file."
506 # Generate the dummy version.c, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
507 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
508 if [ -e $__versionSourceFile ]; then
509 read existingVersionSourceLine < $__versionSourceFile
511 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
512 echo $__versionSourceLine > $__versionSourceFile
516 pushd "$intermediatesForBuild"
517 # Regenerate the CMake solution
518 # Force cross dir to point to project root cross dir, in case there is a cross build.
519 scriptDir="$__ProjectRoot/src/pal/tools"
520 if [[ $__GccBuild == 0 ]]; then
521 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
523 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-gcc.sh\" \"$__TestDir\" \"$__GccMajorVersion\" \"$__GccMinorVersion\" $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
525 echo "Invoking $nextCommand"
530 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
531 echo "Failed to generate $message build project!"
536 if [ $__ConfigureOnly == 1 ]; then
537 echo "Finish configuration & skipping $message build."
541 pushd "$intermediatesForBuild"
543 echo "Executing $buildTool install -j $__NumProc"
545 $buildTool install -j $__NumProc
547 echo "Failed to build $message."
552 echo "Native tests build success!"
557 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
558 echo "BuildArch can be: x64, x86, arm, armel, arm64"
559 echo "BuildType can be: debug, checked, release"
560 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
561 echo "ninja - target ninja instead of GNU make"
562 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
563 echo "gccx.y - optional argument to build using gcc version x.y."
564 echo "cross - optional argument to signify cross compilation,"
565 echo " - will use ROOTFS_DIR environment variable if set."
566 echo "portableLinux - build for Portable Linux Distribution"
567 echo "portablebuild - Use portable build."
568 echo "verbose - optional argument to enable verbose build output."
569 echo "rebuild - if tests have already been built - rebuild them"
570 echo "skipnative: skip the native tests build"
571 echo "skipmanaged: skip the managed section of the test build"
572 echo "buildtestwrappersonly - only build the test wrappers"
573 echo "generatelayoutonly - only pull down dependencies and build coreroot"
574 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
575 echo "skiprestorepackages - skip package restore"
576 echo "crossgen - Precompiles the framework managed assemblies in coreroot"
577 echo "runtests - run tests after building them"
578 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
579 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
580 echo "priority1 - include priority=1 tests in the build"
585 # Obtain the location of the bash script to figure out where the root of the repo is.
586 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
588 # Use uname to determine what the CPU is.
591 # Some Linux platforms report unknown for platform, but the arch for machine.
592 if [ "$CPUName" == "unknown" ]; then
598 echo "Unsupported CPU $CPUName detected, build might not succeed!"
609 echo "Unsupported CPU $CPUName detected, build might not succeed!"
620 echo "Unknown CPU $CPUName detected, configuring as if for x64"
626 # Use uname to determine what the OS is.
660 echo "Unsupported OS $OSName detected, configuring as if for Linux"
668 __IncludeTests=INCLUDE_TESTS
670 # Set the various build properties here so that CMake and MSBuild can pick them up
671 export __ProjectDir="$__ProjectRoot"
672 __SourceDir="$__ProjectDir/src"
673 __PackagesDir="$__ProjectDir/.packages"
674 __RootBinDir="$__ProjectDir/bin"
675 __BuildToolsDir="$__ProjectDir/Tools"
676 __DotNetCli="$__ProjectDir/dotnet.sh"
677 __UnprocessedBuildArgs=
686 __SkipGenerateVersion=0
689 __ClangMajorVersion=0
690 __ClangMinorVersion=0
694 __NuGetPath="$__PackagesDir/NuGet.exe"
695 __SkipRestorePackages=0
699 __msbuildonunsupportedplatform=0
700 __NativeTestIntermediatesDir=
703 __BuildTestWrappers=1
704 __GenerateLayoutOnly=
705 __GenerateTestHostOnly=
707 __BuildTestWrappersOnly=
712 if [ $# -le 0 ]; then
716 lowerI="$(echo $1 | awk '{print tolower($0)}')"
756 __CodeCoverage=Coverage
768 if [ "$__BuildOS" == "Linux" ]; then
771 echo "ERROR: portableLinux not supported for non-Linux platforms."
781 __ClangMajorVersion=3
782 __ClangMinorVersion=5
786 __ClangMajorVersion=3
787 __ClangMinorVersion=6
791 __ClangMajorVersion=3
792 __ClangMinorVersion=7
796 __ClangMajorVersion=3
797 __ClangMinorVersion=8
801 __ClangMajorVersion=3
802 __ClangMinorVersion=9
806 __ClangMajorVersion=4
807 __ClangMinorVersion=0
811 __ClangMajorVersion=5
812 __ClangMinorVersion=0
816 __ClangMajorVersion=6
817 __ClangMinorVersion=0
862 skipnative|-skipnative)
866 skipmanaged|-skipmanaged)
868 __BuildTestWrappers=0
871 buildtestwrappersonly)
872 __BuildTestWrappersOnly=1
876 __GenerateLayoutOnly=1
879 generatetesthostonly)
880 __GenerateTestHostOnly=1
884 __SkipRestorePackages=1
894 if [ ! -d $__RootBinDir ]; then
897 __RootBinParent=$(dirname $__RootBinDir)
898 __RootBinName=${__RootBinDir##*/}
899 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
902 echo "ERROR: 'bindir' requires a non-empty option argument"
907 msbuildonunsupportedplatform)
908 __msbuildonunsupportedplatform=1
913 __UnprocessedBuildArgs+=("/p:CLRTestPriorityToBuild=1")
917 __UnprocessedBuildArgs+=("$1")
924 # Get the number of processors available to the scheduler
925 # Other techniques such as `nproc` only get the number of
926 # processors available to a single process.
927 if [ `uname` = "FreeBSD" ]; then
928 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
929 elif [ `uname` = "NetBSD" ]; then
930 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
931 elif [ `uname` = "Darwin" ]; then
932 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
934 __NumProc=$(nproc --all)
937 __CommonMSBuildArgs=("/p:__BuildArch=$__BuildArch" "/p:__BuildType=$__BuildType" "/p:__BuildOS=$__BuildOS" "/nodeReuse:false")
939 # Configure environment if we are doing a verbose build
940 if [ $__VerboseBuild == 1 ]; then
942 __CommonMSBuildArgs+=("/v:detailed")
945 # Set default clang version
946 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
947 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
948 __ClangMajorVersion=5
949 __ClangMinorVersion=0
951 __ClangMajorVersion=3
952 __ClangMinorVersion=9
956 # Set dependent variables
957 __LogsDir="$__RootBinDir/Logs"
958 __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
960 # Set the remaining variables based upon the determined build configuration
961 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
962 __PackagesBinDir="$__BinDir/.nuget"
963 __TestDir="$__ProjectDir/tests"
964 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
965 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
966 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
967 __isMSBuildOnNETCoreSupported=0
968 __CrossComponentBinDir="$__BinDir"
969 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
971 __CrossArch="$__HostArch"
972 if [ $__CrossBuild == 1 ]; then
973 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
975 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
976 __CrossgenExe="$__CrossComponentBinDir/crossgen"
978 isMSBuildOnNETCoreSupported
980 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
981 # This is needed by CLI to function.
982 if [ -z "$HOME" ]; then
983 if [ ! -d "$__ProjectDir/temp_home" ]; then
986 export HOME=$__ProjectDir/temp_home
987 echo "HOME not defined; setting it to $HOME"
990 # Configure environment if we are doing a cross compile.
991 if [ $__CrossBuild == 1 ]; then
992 export CROSSCOMPILE=1
993 if ! [[ -n "$ROOTFS_DIR" ]]; then
994 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
998 # init the target distro name
1001 if [ $__PortableBuild == 0 ]; then
1002 __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
1005 # Restore Build Tools
1006 source $__ProjectRoot/init-tools.sh
1008 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
1010 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
1014 if [ ! -z "$__GenerateTestHostOnly" ]; then
1019 if [ $? -ne 0 ]; then
1020 echo "Failed to build tests"
1024 echo "${__MsgPrefix}Test build successful."
1025 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
1027 __testNativeBinDir=$__IntermediatesDir/tests
1029 if [ $__RunTests -ne 0 ]; then
1033 nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
1037 echo "Tests run successful."
1039 echo "To run all tests use 'tests/runtests.sh' where:"
1040 echo " testRootDir = $__TestBinDir"
1041 echo " coreClrBinDir = $__BinDir"
1042 echo " coreFxBinDir = $CORE_ROOT"
1043 echo " testNativeBinDir = $__testNativeBinDir"
1044 echo " -------------------------------------------------- "
1045 echo " Example runtest.sh command"
1047 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
1048 echo " -------------------------------------------------- "
1049 echo "To run single test use the following command:"
1050 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"