7 # Some OS groups should default to use the portable packages
8 if [ "$__BuildOS" == "OSX" ]; then
12 if [ "$__HostOS" == "Linux" ]; then
13 if [ -e /etc/redhat-release ]; then
14 local redhatRelease=$(</etc/redhat-release)
15 if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
16 __HostDistroRid="rhel.6-$__HostArch"
20 elif [ -e /etc/os-release ]; then
21 source /etc/os-release
22 if [[ $ID == "alpine" ]]; then
23 __HostDistroRid="linux-musl-$__HostArch"
26 __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
29 elif [ "$__HostOS" == "FreeBSD" ]; then
30 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
31 __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
34 # Portable builds target the base RID
35 if [ "$__PortableBuild" == 1 ]; then
36 if [ "$__BuildOS" == "OSX" ]; then
37 export __HostDistroRid="osx-$__BuildArch"
38 elif [ "$__BuildOS" == "Linux" ]; then
39 export __HostDistroRid="linux-$__BuildArch"
43 if [ "$__HostDistroRid" == "" ]; then
44 echo "WARNING: Cannot determine runtime id for current distro."
47 echo "Setting __HostDistroRid to $__HostDistroRid"
52 if [ $__CrossBuild == 1 ]; then
53 if [ "$__BuildOS" == "Linux" ]; then
54 if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
55 if [ -e $ROOTFS_DIR/android_platform ]; then
56 source $ROOTFS_DIR/android_platform
57 export __DistroRid="$RID"
59 echo "WARNING: Cannot determine runtime id for current distro."
63 source $ROOTFS_DIR/etc/os-release
64 export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
68 export __DistroRid="$__HostDistroRid"
71 if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
72 export __DistroRid="ubuntu.14.04-$__BuildArch"
75 # Portable builds target the base RID
76 if [ "$__PortableBuild" == 1 ]; then
77 if [ "$__BuildOS" == "Linux" ]; then
78 export __DistroRid="linux-$__BuildArch"
79 export __RuntimeId="linux-$__BuildArch"
80 elif [ "$__BuildOS" == "OSX" ]; then
81 export __DistroRid="osx-$__BuildArch"
82 export __RuntimeId="osx-$__BuildArch"
86 echo "__DistroRid: " $__DistroRid
89 isMSBuildOnNETCoreSupported()
91 __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform
93 if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
97 if [ "$__HostArch" == "x64" ]; then
98 if [ "$__HostOS" == "Linux" ]; then
99 __isMSBuildOnNETCoreSupported=1
100 UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
101 for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
103 if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
104 __isMSBuildOnNETCoreSupported=0
108 elif [ "$__HostOS" == "OSX" ]; then
109 __isMSBuildOnNETCoreSupported=1
114 build_test_wrappers()
116 if [ $__BuildTestWrappers -ne -0 ]; then
117 echo "${__MsgPrefix}Creating test wrappers..."
119 export __Exclude="${__ProjectDir}/tests/issues.targets"
120 export __BuildLogRootName="Tests_XunitWrapper"
122 # Set up directories and file names
123 __BuildLogRootName=$subDirectoryName
124 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
125 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
126 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
128 buildVerbosity="Summary"
130 if [ $__VerboseBuild == 1 ]; then
131 buildVerbosity="Diag"
134 echo "${__DotNetCli}" msbuild "${__ProjectDir}/tests/runtest.proj" /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true /p:TargetsWindows=false /fileloggerparameters:"\"Verbosity=normal;LogFile=${__BuildLog}\"" /fileloggerparameters1:"\"WarningsOnly;LogFile=${__BuildWrn}\"" /fileloggerparameters2:"\"ErrorsOnly;LogFile=${__BuildErr}\"" /consoleloggerparameters:$buildVerbosity /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch
135 "${__DotNetCli}" msbuild "${__ProjectDir}/tests/runtest.proj" /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true /p:TargetsWindows=false /fileloggerparameters:"\"Verbosity=normal;LogFile=${__BuildLog}\"" /fileloggerparameters1:"\"WarningsOnly;LogFile=${__BuildWrn}\"" /fileloggerparameters2:"\"ErrorsOnly;LogFile=${__BuildErr}\"" /consoleloggerparameters:$buildVerbosity /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch
137 if [ $? -ne 0 ]; then
138 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
141 echo "XUnit Wrappers have been built."
142 echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
150 __TestDir=$__ProjectDir/tests
151 __ProjectFilesDir=$__TestDir
152 __TestBinDir=$__TestWorkingDir
154 if [ $__RebuildTests -ne 0 ]; then
155 if [ -d "${__TestBinDir}" ]; then
156 echo "Removing tests build dir: ${__TestBinDir}"
161 __CMakeBinDir="${__TestBinDir}"
163 if [ -z "$__TestIntermediateDir" ]; then
164 __TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
167 echo "__BuildOS: ${__BuildOS}"
168 echo "__BuildArch: ${__BuildArch}"
169 echo "__BuildType: ${__BuildType}"
170 echo "__TestIntermediateDir: ${__TestIntermediateDir}"
172 if [ ! -f "$__TestBinDir" ]; then
173 echo "Creating TestBinDir: ${__TestBinDir}"
174 mkdir -p $__TestBinDir
176 if [ ! -f "$__LogsDir" ]; then
177 echo "Creating LogsDir: ${__LogsDir}"
181 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
183 # =========================================================================================
185 # === Restore product binaries from packages
187 # =========================================================================================
189 build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
191 if [ -n "$__UpdateInvalidPackagesArg" ]; then
192 __up=-updateinvalidpackageversion
195 echo "${__MsgPrefix}Creating test overlay..."
197 if [ -z "$xUnitTestBinBase" ]; then
198 xUnitTestBinBase=$__TestWorkingDir
201 export CORE_ROOT=$xUnitTestBinBase/Tests/Core_Root
203 if [ -d "${CORE_ROOT}" ]; then
209 build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay"
211 chmod +x $__BinDir/corerun
212 chmod +x $__BinDir/crossgen
214 # Make sure to copy over the pulled down packages
215 cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
221 export TEST_HOST=$xUnitTestBinBase/testhost
223 if [ -d "${TEST_HOST}" ]; then
227 echo "${__MsgPrefix}Creating test overlay..."
230 build_MSBuild_projects "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost"
236 __TestDir=$__ProjectDir/tests
237 __ProjectFilesDir=$__TestDir
238 __TestBinDir=$__TestWorkingDir
240 if [ -f "${__TestWorkingDir}/build_info.json" ]; then
241 rm "${__TestWorkingDir}/build_info.json"
244 if [ $__RebuildTests -ne 0 ]; then
245 if [ -d "${__TestBinDir}" ]; then
246 echo "Removing tests build dir: ${__TestBinDir}"
251 export __CMakeBinDir="${__TestBinDir}"
252 if [ ! -d "${__TestIntermediatesDir}" ]; then
253 mkdir -p ${__TestIntermediatesDir}
256 __NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
257 if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
258 mkdir -p ${__NativeTestIntermediatesDir}
261 __ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
262 if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
263 mkdir -p ${__ManagedTestIntermediatesDir}
266 echo "__BuildOS: ${__BuildOS}"
267 echo "__BuildArch: ${__BuildArch}"
268 echo "__BuildType: ${__BuildType}"
269 echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
270 echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
271 echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
273 if [ ! -f "$__TestBinDir" ]; then
274 echo "Creating TestBinDir: ${__TestBinDir}"
275 mkdir -p $__TestBinDir
277 if [ ! -f "$__LogsDir" ]; then
278 echo "Creating LogsDir: ${__LogsDir}"
282 __BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
284 # =========================================================================================
286 # === Restore product binaries from packages
288 # =========================================================================================
290 if [ ${__SkipRestorePackages} != 1 ]; then
291 build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages"
294 if [ $__SkipNative != 1 ]; then
295 build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
297 if [ $? -ne 0 ]; then
298 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
303 if [ $__SkipManaged != 1 ]; then
304 echo "Starting the Managed Tests Build..."
306 build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
308 if [ $? -ne 0 ]; then
309 echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
312 echo "Checking the Managed Tests Build..."
314 build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/runtest.proj" "Check Test Build" "-ExtraParameters:/t:CheckTestBuild"
316 if [ $? -ne 0 ]; then
317 echo "${__MsgPrefix}Error: Check Test Build failed."
321 echo "Managed tests build success!"
327 if [ -n "$__UpdateInvalidPackagesArg" ]; then
328 __up=-updateinvalidpackageversion
331 echo "${__MsgPrefix}Creating test overlay..."
335 if [ $__ZipTests -ne 0 ]; then
336 echo "${__MsgPrefix}ZIP tests packages..."
337 build_MSBuild_projects "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
341 build_MSBuild_projects()
349 extraBuildParameters=("$@")
351 # Set up directories and file names
352 __BuildLogRootName=$subDirectoryName
353 __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
354 __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
355 __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
357 # Use binclashlogger by default if no other logger is specified
358 if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then
359 msbuildEventLogging=""
361 msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\""
364 if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
365 # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
366 # See https://github.com/Microsoft/msbuild/issues/2993
368 # __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
369 export __SkipPackageRestore=false
370 export __SkipTargetingPackBuild=false
371 export __BuildLoopCount=2
372 export __TestGroupToBuild=1
375 if [ -n "$__priority1" ]; then
376 export __BuildLoopCount=16
377 export __TestGroupToBuild=2
380 for (( slice=1 ; slice <= __BuildLoopCount; slice = slice + 1 ))
382 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
383 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
384 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
386 export TestBuildSlice=$slice
388 # Generate build command
389 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
390 buildArgs+=("$msbuildEventLogging")
391 buildArgs+=("${extraBuildParameters[@]}")
392 buildArgs+=("${__RunArgs[@]}")
393 buildArgs+=("${__UnprocessedBuildArgs[@]}")
395 echo "Building step '$stepName' slice=$slice via $buildCommand"
398 "$__ProjectRoot/run.sh" build "${buildArgs[@]}"
400 # Make sure everything is OK
401 if [ $? -ne 0 ]; then
402 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
408 export __SkipPackageRestore=true
409 export __SkipTargetingPackBuild=true
413 __msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
414 __msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
415 __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
417 # Generate build command
418 buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}")
419 buildArgs+=("$msbuildEventLogging")
420 buildArgs+=("${extraBuildParameters[@]}")
421 buildArgs+=("${__RunArgs[@]}")
422 buildArgs+=("${__UnprocessedBuildArgs[@]}")
424 echo "Building step '$stepName' via $buildCommand"
427 "$__ProjectRoot/run.sh" build "${buildArgs[@]}"
429 # Make sure everything is OK
430 if [ $? -ne 0 ]; then
431 echo "${__MsgPrefix}Failed to build $stepName. See the build logs:"
440 build_native_projects()
443 intermediatesForBuild="$2"
445 extraCmakeArguments="-DCLR_CMAKE_TARGET_OS=${__BuildOS} -DCLR_CMAKE_HOST_ARCH=${platformArch}"
446 message="native tests assets"
448 # All set to commence the build
449 echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
454 if [ $__UseNinja == 1 ]; then
456 buildFile="build.ninja"
457 if ! buildTool=$(command -v ninja || command -v ninja-build); then
458 echo "Unable to locate ninja!" 1>&2
463 if [ $__SkipConfigure == 0 ]; then
464 # if msbuild is not supported, then set __SkipGenerateVersion to 1
465 if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
466 # Drop version.cpp file
467 __versionSourceFile="$intermediatesForBuild/version.cpp"
468 if [ $__SkipGenerateVersion == 0 ]; then
470 "$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile -MsBuildEventLogging="/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log" $__RunArgs $__UnprocessedBuildArgs
472 # Generate the dummy version.cpp, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
473 __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
474 if [ -e $__versionSourceFile ]; then
475 read existingVersionSourceLine < $__versionSourceFile
477 if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
478 echo $__versionSourceLine > $__versionSourceFile
482 pushd "$intermediatesForBuild"
483 # Regenerate the CMake solution
484 # Force cross dir to point to project root cross dir, in case there is a cross build.
485 echo "Invoking CONFIG_DIR=\"$__ProjectRoot/cross\" \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
486 CONFIG_DIR="$__ProjectRoot/cross" "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__TestDir" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator "$extraCmakeArguments" "$__cmakeargs"
490 if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
491 echo "Failed to generate $message build project!"
496 if [ $__ConfigureOnly == 1 ]; then
497 echo "Finish configuration & skipping $message build."
501 pushd "$intermediatesForBuild"
503 echo "Executing $buildTool install -j $__NumProc"
505 $buildTool install -j $__NumProc
507 echo "Failed to build $message."
512 echo "Native tests build success!"
517 echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [runtests] [bindir]"
518 echo "BuildArch can be: x64, x86, arm, armel, arm64"
519 echo "BuildType can be: debug, checked, release"
520 echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
521 echo "ninja - target ninja instead of GNU make"
522 echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
523 echo "cross - optional argument to signify cross compilation,"
524 echo " - will use ROOTFS_DIR environment variable if set."
525 echo "crosscomponent - optional argument to build cross-architecture component,"
526 echo " - will use CAC_ROOTFS_DIR environment variable if set."
527 echo "portableLinux - build for Portable Linux Distribution"
528 echo "portablebuild - Use portable build."
529 echo "verbose - optional argument to enable verbose build output."
530 echo "rebuild - if tests have already been built - rebuild them"
531 echo "skipnative: skip the native tests build"
532 echo "skipmanaged: skip the managed section of the test build"
533 echo "buildtestwrappersonly - only build the test wrappers"
534 echo "generatelayoutonly - only pull down dependencies and build coreroot"
535 echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
536 echo "skiprestorepackages - skip package restore"
537 echo "runtests - run tests after building them"
538 echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
539 echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
540 echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
541 echo "priority1 - include priority=1 tests in the build"
546 # Obtain the location of the bash script to figure out where the root of the repo is.
547 __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
549 # Use uname to determine what the CPU is.
552 # Some Linux platforms report unknown for platform, but the arch for machine.
553 if [ "$CPUName" == "unknown" ]; then
559 echo "Unsupported CPU $CPUName detected, build might not succeed!"
570 echo "Unsupported CPU $CPUName detected, build might not succeed!"
581 echo "Unknown CPU $CPUName detected, configuring as if for x64"
587 # Use uname to determine what the OS is.
621 echo "Unsupported OS $OSName detected, configuring as if for Linux"
629 __IncludeTests=INCLUDE_TESTS
631 # Set the various build properties here so that CMake and MSBuild can pick them up
632 export __ProjectDir="$__ProjectRoot"
633 __SourceDir="$__ProjectDir/src"
634 __PackagesDir="$__ProjectDir/packages"
635 __RootBinDir="$__ProjectDir/bin"
636 __BuildToolsDir="$__ProjectDir/Tools"
637 __DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet"
638 __UnprocessedBuildArgs=
647 __SkipGenerateVersion=0
650 __ClangMajorVersion=0
651 __ClangMinorVersion=0
652 __NuGetPath="$__PackagesDir/NuGet.exe"
654 __SkipRestorePackages=0
658 __msbuildonunsupportedplatform=0
660 __NativeTestIntermediatesDir=
663 __BuildTestWrappers=1
664 __GenerateLayoutOnly=
665 __GenerateTestHostOnly=
667 __BuildTestWrappersOnly=
671 if [ $# -le 0 ]; then
675 lowerI="$(echo $1 | awk '{print tolower($0)}')"
715 __CodeCoverage=Coverage
727 if [ "$__BuildOS" == "Linux" ]; then
730 echo "ERROR: portableLinux not supported for non-Linux platforms."
740 __ClangMajorVersion=3
741 __ClangMinorVersion=5
745 __ClangMajorVersion=3
746 __ClangMinorVersion=6
750 __ClangMajorVersion=3
751 __ClangMinorVersion=7
755 __ClangMajorVersion=3
756 __ClangMinorVersion=8
760 __ClangMajorVersion=3
761 __ClangMinorVersion=9
765 __ClangMajorVersion=4
766 __ClangMinorVersion=0
770 __ClangMajorVersion=5
771 __ClangMinorVersion=0
775 __ClangMajorVersion=6
776 __ClangMinorVersion=0
791 skipnative|-skipnative)
795 skipmanaged|-skipmanaged)
797 __BuildTestWrappers=0
804 buildtestwrappersonly)
805 __BuildTestWrappersOnly=1
809 __GenerateLayoutOnly=1
811 generatetesthostonly)
812 __GenerateTestHostOnly=1
815 __SkipRestorePackages=1
821 if [ ! -d $__RootBinDir ]; then
824 __RootBinParent=$(dirname $__RootBinDir)
825 __RootBinName=${__RootBinDir##*/}
826 __RootBinDir="$(cd $__RootBinParent &>/dev/null && printf %s/%s $PWD $__RootBinName)"
829 echo "ERROR: 'bindir' requires a non-empty option argument"
834 msbuildonunsupportedplatform)
835 __msbuildonunsupportedplatform=1
839 __UnprocessedBuildArgs+=("-priority=1")
842 __UnprocessedBuildArgs+=("$1")
849 # Get the number of processors available to the scheduler
850 # Other techniques such as `nproc` only get the number of
851 # processors available to a single process.
852 if [ `uname` = "FreeBSD" ]; then
853 __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
854 elif [ `uname` = "NetBSD" ]; then
855 __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
856 elif [ `uname` = "Darwin" ]; then
857 __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
859 __NumProc=$(nproc --all)
862 __RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS")
864 # Configure environment if we are doing a verbose build
865 if [ $__VerboseBuild == 1 ]; then
867 __RunArgs+=("-verbose")
870 # Set default clang version
871 if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
872 if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
873 __ClangMajorVersion=5
874 __ClangMinorVersion=0
876 __ClangMajorVersion=3
877 __ClangMinorVersion=9
881 # Set dependent variables
882 __LogsDir="$__RootBinDir/Logs"
884 # init the host distro name
887 # Set the remaining variables based upon the determined build configuration
888 __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
889 __PackagesBinDir="$__BinDir/.nuget"
890 __TestDir="$__ProjectDir/tests"
891 __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
892 __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
893 __TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
894 __isMSBuildOnNETCoreSupported=0
895 __CrossComponentBinDir="$__BinDir"
896 __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
898 __CrossArch="$__HostArch"
899 if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
902 if [ $__CrossBuild == 1 ]; then
903 __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
905 __CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
906 __CrossgenExe="$__CrossComponentBinDir/crossgen"
908 isMSBuildOnNETCoreSupported
910 # CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
911 # This is needed by CLI to function.
912 if [ -z "$HOME" ]; then
913 if [ ! -d "$__ProjectDir/temp_home" ]; then
916 export HOME=$__ProjectDir/temp_home
917 echo "HOME not defined; setting it to $HOME"
920 # Configure environment if we are doing a cross compile.
921 if [ $__CrossBuild == 1 ]; then
922 export CROSSCOMPILE=1
923 if ! [[ -n "$ROOTFS_DIR" ]]; then
924 export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
928 # init the target distro name
931 # Override tool directory
933 __CoreClrVersion=1.1.0
934 __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/
936 if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
937 echo "Building Tests..."
939 elif [ ! -z "$__BuildTestWrappersOnly" ]; then
942 echo "Generating test layout..."
944 if [ ! -z "$__GenerateTestHostOnly" ]; then
945 echo "Generating test host..."
950 if [ $? -ne 0 ]; then
951 echo "Failed to build tests"
955 echo "${__MsgPrefix}Test build successful."
956 echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
958 __testNativeBinDir=$__IntermediatesDir/tests
960 if [ $__RunTests -ne 0 ]; then
964 echo "${__TestDir}/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$__sharedFxDir --testNativeBinDir=$__testNativeBinDir"
966 $__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir
968 echo "Tests run successful."
970 echo "To run all tests use 'tests/runtests.sh' where:"
971 echo " testRootDir = $__TestBinDir"
972 echo " coreClrBinDir = $__BinDir"
973 echo " coreFxBinDir = $CORE_ROOT"
974 echo " testNativeBinDir = $__testNativeBinDir"
975 echo " -------------------------------------------------- "
976 echo " Example runtest.sh command"
978 echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
979 echo " -------------------------------------------------- "
980 echo "To run single test use the following command:"
981 echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"