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
154 # Make sure to copy over the pulled down packages
155 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
157 if [ $__SkipStressDependencies == 0 ]; then
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."
169 # Precompile framework assemblies with crossgen if required
170 if [ $__DoCrossgen -ne 0 ]; then
171 chmod +x $__CrossgenExe
172 precompile_coreroot_fx
176 precompile_coreroot_fx()
178 echo "${__MsgPrefix}Running crossgen on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"
180 # Read the exclusion file for this platform
181 skipCrossGenFiles=($(read_array "$(dirname "$0")/tests/skipCrossGenFiles.${__BuildArch}.txt"))
183 local overlayDir=$CORE_ROOT
185 filesToPrecompile=$(find -L $overlayDir -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -not -iname xunit.\* -type f)
186 for fileToPrecompile in ${filesToPrecompile}
188 local filename=${fileToPrecompile}
189 if is_skip_crossgen_test "$(basename $filename)"; then
192 echo Precompiling $filename
193 $__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr
195 if [[ $exitCode != 0 ]]; then
196 if grep -q -e '0x80131018' $filename.stderr; then
197 printf "\n\t$filename is not a managed assembly.\n\n"
199 echo Unable to precompile $filename.
205 rm $filename.{stdout,stderr}
210 declare -a skipCrossGenFiles
212 function is_skip_crossgen_test {
213 for skip in "${skipCrossGenFiles[@]}"; do
214 if [ "$1" == "$skip" ]; then
221 # Get an array of items by reading the specified file line by line.
222 function read_array {
225 if [ ! -f "$1" ]; then
229 # bash in Mac OS X doesn't support 'readarray', so using alternate way instead.
230 # readarray -t theArray < "$1"
231 # Any line that starts with '#' is ignored.
232 while IFS='' read -r line || [ -n "$line" ]; do
233 if [[ $line != "#"* ]]; then
234 theArray[${#theArray[@]}]=$line
242 echo "${__MsgPrefix}Generating test host..."
244 export TEST_HOST=$xUnitTestBinBase/testhost
246 if [ -d "${TEST_HOST}" ]; then
252 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "/t:CreateTestHost"
258 echo "${__MsgPrefix}Building Tests..."
260 __TestDir=$__ProjectDir/tests
261 __ProjectFilesDir=$__TestDir
262 __TestBinDir=$__TestWorkingDir
264 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
265 rm "${__TestWorkingDir}/build_info.json"
268 if [ $__RebuildTests -ne 0 ]; then
269 if [ -d "${__TestBinDir}" ]; then
270 echo "Removing tests build dir: ${__TestBinDir}"
275 export __CMakeBinDir="${__TestBinDir}"
276 if [ ! -d "${__TestIntermediatesDir}" ]; then
277 mkdir -p ${__TestIntermediatesDir}
280 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
281 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
282 mkdir -p ${__NativeTestIntermediatesDir}
285 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
286 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
287 mkdir -p ${__ManagedTestIntermediatesDir}
290 echo "__BuildOS: ${__BuildOS}"
291 echo "__BuildArch: ${__BuildArch}"
292 echo "__BuildType: ${__BuildType}"
293 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
294 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
295 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
297 if [ ! -f "$__TestBinDir" ]; then
298 echo "Creating TestBinDir: ${__TestBinDir}"
299 mkdir -p $__TestBinDir
301 if [ ! -f "$__LogsDir" ]; then
302 echo "Creating LogsDir: ${__LogsDir}"
305 if [ ! -f "$__MsbuildDebugLogsDir" ]; then
306 echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
307 mkdir -p $__MsbuildDebugLogsDir
310 # Set up the directory for MSBuild debug logs.
311 export MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
313 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
315 # =========================================================================================
317 # === Restore product binaries from packages
319 # =========================================================================================
321 if [ ${__SkipRestorePackages} != 1 ]; then
322 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
324 if [ $? -ne 0 ]; then
325 echo "${__ErrMsgPrefix}${__MsgPrefix}Error: package restoration failed. Refer to the build log files for details (above)"
330 if [ $__SkipNative != 1 ]; then
331 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
333 if [ $? -ne 0 ]; then
334 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
339 if [ $__SkipManaged != 1 ]; then
340 echo "Starting the Managed Tests Build..."
342 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
344 if [ $? -ne 0 ]; then
345 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
348 echo "Checking the Managed Tests Build..."
350 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "/t:CheckTestBuild"
352 if [ $? -ne 0 ]; then
353 echo "${__MsgPrefix}Error: Check Test Build failed."
358 echo "Managed tests build success!"
363 if [ -n "$__UpdateInvalidPackagesArg" ]; then
364 __up="/t:UpdateInvalidPackageVersions"
367 if [[ "$__SkipGenerateLayout" != 1 ]]; then
372 build_MSBuild_projects()
380 extraBuildParameters=("$@")
382 # Set up directories and file names
383 __BuildLogRootName=$subDirectoryName
384 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
385 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
386 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
388 # Use binclashlogger by default if no other logger is specified
389 if [[ "${extraBuildParameters[*]}" == *"/l:"* ]]; then
390 __msbuildEventLogging=
392 __msbuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll\;LogFile=binclash.log"
395 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
396 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
397 # See https://github.com/Microsoft/msbuild/issues/2993
399 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
400 export __SkipPackageRestore=false
401 export __SkipTargetingPackBuild=false
402 export __NumberOfTestGroups=3
406 if [ -n "$__priority1" ]; then
407 export __NumberOfTestGroups=10
410 for (( testGroupToBuild=1 ; testGroupToBuild <= __NumberOfTestGroups; testGroupToBuild = testGroupToBuild + 1 ))
412 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
413 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
414 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
416 export __TestGroupToBuild=$testGroupToBuild
418 # Generate build command
419 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
420 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
421 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
423 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
424 buildArgs+=("$__msbuildEventLogging")
425 buildArgs+=("${extraBuildParameters[@]}")
426 buildArgs+=("${__CommonMSBuildArgs[@]}")
427 buildArgs+=("${__UnprocessedBuildArgs[@]}")
428 buildArgs+=("/p:__SkipPackageRestore=true");
430 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
431 echo "Building step '$stepName' testGroupToBuild=$testGroupToBuild via $nextCommand"
434 # Make sure everything is OK
435 if [ $? -ne 0 ]; then
436 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
442 export __SkipPackageRestore=true
443 export __SkipTargetingPackBuild=true
447 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
448 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
449 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
451 # Generate build command
452 buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
453 buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
454 buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
456 buildArgs+=("$projectName" "${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
457 buildArgs+=("$__msbuildEventLogging")
458 buildArgs+=("${extraBuildParameters[@]}")
459 buildArgs+=("${__CommonMSBuildArgs[@]}")
460 buildArgs+=("${__UnprocessedBuildArgs[@]}")
462 nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
463 echo "Building step '$stepName' via $nextCommand"
466 # Make sure everything is OK
467 if [ $? -ne 0 ]; then
468 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
477 build_native_projects()
480 intermediatesForBuild="$2"
482 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
483 message="native tests assets"
485 # All set to commence the build
486 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
491 if [ $__UseNinja == 1 ]; then
493 buildFile="build.ninja"
494 if ! buildTool=$(command -v ninja || command -v ninja-build); then
495 echo "Unable to locate ninja!" 1>&2
500 if [ $__SkipConfigure == 0 ]; then
501 # if msbuild is not supported, then set __SkipGenerateVersion to 1
502 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
503 # Drop version.c file
504 __versionSourceFile="$intermediatesForBuild/version.c"
505 if [ $__SkipGenerateVersion == 0 ]; then
507 $__ProjectRoot/eng/common/msbuild.sh $__ProjectRoot/eng/empty.csproj \
508 /p:NativeVersionFile=$__versionSourceFile \
509 /p:ArcadeBuild=true /t:GenerateNativeVersionFile /restore \
510 $__CommonMSBuildArgs $__UnprocessedBuildArgs
511 if [ $? -ne 0 ]; then
512 echo "Failed to generate native version file."
516 # Generate the dummy version.c, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
517 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
518 if [ -e $__versionSourceFile ]; then
519 read existingVersionSourceLine < $__versionSourceFile
521 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
522 echo $__versionSourceLine > $__versionSourceFile
526 pushd "$intermediatesForBuild"
527 # Regenerate the CMake solution
528 # Force cross dir to point to project root cross dir, in case there is a cross build.
529 scriptDir="$__ProjectRoot/src/pal/tools"
530 if [[ $__GccBuild == 0 ]]; then
531 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion \"$__ClangMinorVersion\" $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
533 nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-gcc.sh\" \"$__TestDir\" \"$__GccMajorVersion\" \"$__GccMinorVersion\" $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
535 echo "Invoking $nextCommand"
540 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
541 echo "Failed to generate $message build project!"
546 if [ $__ConfigureOnly == 1 ]; then
547 echo "Finish configuration & skipping $message build."
551 pushd "$intermediatesForBuild"
553 echo "Executing $buildTool install -j $__NumProc"
555 $buildTool install -j $__NumProc
557 echo "Failed to build $message."
562 echo "Native tests build success!"
567 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
568 echo "BuildArch can be: x64, x86, arm, armel, arm64"
569 echo "BuildType can be: debug, checked, release"
570 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
571 echo "ninja - target ninja instead of GNU make"
572 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
573 echo "gccx.y - optional argument to build using gcc version x.y."
574 echo "cross - optional argument to signify cross compilation,"
575 echo " - will use ROOTFS_DIR environment variable if set."
576 echo "portableLinux - build for Portable Linux Distribution"
577 echo "portablebuild - Use portable build."
578 echo "verbose - optional argument to enable verbose build output."
579 echo "rebuild - if tests have already been built - rebuild them"
580 echo "skipnative: skip the native tests build"
581 echo "skipmanaged: skip the managed section of the test build"
582 echo "buildtestwrappersonly - only build the test wrappers"
583 echo "generatelayoutonly - only pull down dependencies and build coreroot"
584 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
585 echo "skiprestorepackages - skip package restore"
586 echo "crossgen - Precompiles the framework managed assemblies in coreroot"
587 echo "runtests - run tests after building them"
588 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
589 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
590 echo "priority1 - include priority=1 tests in the build"
591 echo "skipgenerateversion - disable version generation even if MSBuild is supported."
592 echo "skipstressdependencies - disable build of libcoredistools.so for x64."
593 echo "skipgeneratelayout - Do not generate the Core_Root layout."
598 # Obtain the location of the bash script to figure out where the root of the repo is.
599 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
601 # Use uname to determine what the CPU is.
604 # Some Linux platforms report unknown for platform, but the arch for machine.
605 if [ "$CPUName" == "unknown" ]; then
611 echo "Unsupported CPU $CPUName detected, build might not succeed!"
622 echo "Unsupported CPU $CPUName detected, build might not succeed!"
633 echo "Unknown CPU $CPUName detected, configuring as if for x64"
639 # Use uname to determine what the OS is.
673 echo "Unsupported OS $OSName detected, configuring as if for Linux"
681 __IncludeTests=INCLUDE_TESTS
683 # Set the various build properties here so that CMake and MSBuild can pick them up
684 export __ProjectDir="$__ProjectRoot"
685 __SourceDir="$__ProjectDir/src"
686 __PackagesDir="$__ProjectDir/.packages"
687 __RootBinDir="$__ProjectDir/bin"
688 __BuildToolsDir="$__ProjectDir/Tools"
689 __DotNetCli="$__ProjectDir/dotnet.sh"
690 __UnprocessedBuildArgs=
699 __SkipGenerateVersion=0
700 __SkipStressDependencies=0
701 __SkipGenerateLayout=0
704 __ClangMajorVersion=0
705 __ClangMinorVersion=0
709 __NuGetPath="$__PackagesDir/NuGet.exe"
710 __SkipRestorePackages=0
714 __msbuildonunsupportedplatform=0
715 __NativeTestIntermediatesDir=
718 __BuildTestWrappers=1
719 __GenerateLayoutOnly=
720 __GenerateTestHostOnly=
722 __BuildTestWrappersOnly=
727 if [ $# -le 0 ]; then
731 lowerI="$(echo $1 | awk '{print tolower($0)}')"
771 __CodeCoverage=Coverage
783 if [ "$__BuildOS" == "Linux" ]; then
786 echo "ERROR: portableLinux not supported for non-Linux platforms."
796 __ClangMajorVersion=3
797 __ClangMinorVersion=5
801 __ClangMajorVersion=3
802 __ClangMinorVersion=6
806 __ClangMajorVersion=3
807 __ClangMinorVersion=7
811 __ClangMajorVersion=3
812 __ClangMinorVersion=8
816 __ClangMajorVersion=3
817 __ClangMinorVersion=9
821 __ClangMajorVersion=4
822 __ClangMinorVersion=0
826 __ClangMajorVersion=5
827 __ClangMinorVersion=0
831 __ClangMajorVersion=6
832 __ClangMinorVersion=0
836 __ClangMajorVersion=7
841 __ClangMajorVersion=8
846 __ClangMajorVersion=9
851 __ClangMajorVersion=10
897 skipnative|-skipnative)
901 skipmanaged|-skipmanaged)
903 __BuildTestWrappers=0
906 buildtestwrappersonly)
907 __BuildTestWrappersOnly=1
911 __GenerateLayoutOnly=1
914 generatetesthostonly)
915 __GenerateTestHostOnly=1
919 __SkipRestorePackages=1
929 if [ ! -d $__RootBinDir ]; then
932 __RootBinParent=$(dirname $__RootBinDir)
933 __RootBinName=${__RootBinDir##*/}
934 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
937 echo "ERROR: 'bindir' requires a non-empty option argument"
942 msbuildonunsupportedplatform)
943 __msbuildonunsupportedplatform=1
948 __UnprocessedBuildArgs+=("/p:CLRTestPriorityToBuild=1")
952 __SkipGenerateVersion=1
955 skipstressdependencies)
956 __SkipStressDependencies=1
960 __SkipGenerateLayout=1
964 __UnprocessedBuildArgs+=("$1")
971 # Get the number of processors available to the scheduler
972 # Other techniques such as `nproc` only get the number of
973 # processors available to a single process.
974 if [ `uname` = "FreeBSD" ]; then
975 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
976 elif [ `uname` = "NetBSD" ]; then
977 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
978 elif [ `uname` = "Darwin" ]; then
979 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
981 __NumProc=$(nproc --all)
984 __CommonMSBuildArgs=("/p:__BuildArch=$__BuildArch" "/p:__BuildType=$__BuildType" "/p:__BuildOS=$__BuildOS" "/nodeReuse:false")
986 # Configure environment if we are doing a verbose build
987 if [ $__VerboseBuild == 1 ]; then
989 __CommonMSBuildArgs+=("/v:detailed")
992 # Set default clang version
993 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
994 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
995 __ClangMajorVersion=5
996 __ClangMinorVersion=0
998 __ClangMajorVersion=3
999 __ClangMinorVersion=9
1003 # Set dependent variables
1004 __LogsDir="$__RootBinDir/Logs"
1005 __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
1007 # Set the remaining variables based upon the determined build configuration
1008 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
1009 __PackagesBinDir="$__BinDir/.nuget"
1010 __TestDir="$__ProjectDir/tests"
1011 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
1012 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
1013 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
1014 __isMSBuildOnNETCoreSupported=0
1015 __CrossComponentBinDir="$__BinDir"
1016 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
1018 __CrossArch="$__HostArch"
1019 if [ $__CrossBuild == 1 ]; then
1020 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
1022 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
1023 __CrossgenExe="$__CrossComponentBinDir/crossgen"
1025 isMSBuildOnNETCoreSupported
1027 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
1028 # This is needed by CLI to function.
1029 if [ -z "$HOME" ]; then
1030 if [ ! -d "$__ProjectDir/temp_home" ]; then
1033 export HOME=$__ProjectDir/temp_home
1034 echo "HOME not defined; setting it to $HOME"
1037 # Configure environment if we are doing a cross compile.
1038 if [ $__CrossBuild == 1 ]; then
1039 export CROSSCOMPILE=1
1040 if ! [[ -n "$ROOTFS_DIR" ]]; then
1041 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
1045 # init the target distro name
1048 if [ $__PortableBuild == 0 ]; then
1049 __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
1052 # Restore Build Tools
1053 source $__ProjectRoot/init-tools.sh
1055 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
1057 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
1061 if [ ! -z "$__GenerateTestHostOnly" ]; then
1066 if [ $? -ne 0 ]; then
1067 echo "Failed to build tests"
1071 echo "${__MsgPrefix}Test build successful."
1072 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
1074 __testNativeBinDir=$__IntermediatesDir/tests
1076 if [ $__RunTests -ne 0 ]; then
1080 nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
1084 echo "Tests run successful."
1086 echo "To run all tests use 'tests/runtests.sh' where:"
1087 echo " testRootDir = $__TestBinDir"
1088 echo " coreClrBinDir = $__BinDir"
1089 echo " coreFxBinDir = $CORE_ROOT"
1090 echo " testNativeBinDir = $__testNativeBinDir"
1091 echo " -------------------------------------------------- "
1092 echo " Example runtest.sh command"
1094 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
1095 echo " -------------------------------------------------- "
1096 echo "To run single test use the following command:"
1097 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"