#!/usr/bin/env bash
-initHostDistroRid()
-{
- __HostDistroRid=""
-
- # Some OS groups should default to use the portable packages
- if [ "$__BuildOS" == "OSX" ]; then
- __PortableBuild=1
- fi
-
- if [ "$__HostOS" == "Linux" ]; then
- if [ -e /etc/redhat-release ]; then
- __PortableBuild=1
- elif [ -e /etc/os-release ]; then
- source /etc/os-release
- if [[ $ID == "alpine" ]]; then
- __HostDistroRid="linux-musl-$__HostArch"
- else
- __PortableBuild=1
- __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
- fi
- fi
- elif [ "$__HostOS" == "FreeBSD" ]; then
- __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
- __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
- fi
-
- # Portable builds target the base RID
- if [ "$__PortableBuild" == 1 ]; then
- if [ "$__BuildOS" == "OSX" ]; then
- export __HostDistroRid="osx-$__BuildArch"
- elif [ "$__BuildOS" == "Linux" ]; then
- export __HostDistroRid="linux-$__BuildArch"
- fi
- fi
-
- if [ "$__HostDistroRid" == "" ]; then
- echo "WARNING: Cannot determine runtime id for current distro."
- fi
-
- echo "Setting __HostDistroRid to $__HostDistroRid"
-}
+__PortableBuild=1
initTargetDistroRid()
{
- if [ $__CrossBuild == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
- if [ -e $ROOTFS_DIR/android_platform ]; then
- source $ROOTFS_DIR/android_platform
- export __DistroRid="$RID"
- else
- echo "WARNING: Cannot determine runtime id for current distro."
- export __DistroRid=""
- fi
- else
- source $ROOTFS_DIR/etc/os-release
- export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
- fi
- fi
- else
- export __DistroRid="$__HostDistroRid"
- export __RuntimeId="$__HostDistroRid"
- fi
+ source init-distro-rid.sh
- if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
- export __DistroRid="ubuntu.14.04-$__BuildArch"
+ # Only pass ROOTFS_DIR if cross is specified.
+ if (( ${__CrossBuild} == 1 )); then
+ passedRootfsDir=${ROOTFS_DIR}
fi
- # Portable builds target the base RID
- if [ "$__PortableBuild" == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- export __DistroRid="linux-$__BuildArch"
- export __RuntimeId="linux-$__BuildArch"
- elif [ "$__BuildOS" == "OSX" ]; then
- export __DistroRid="osx-$__BuildArch"
- export __RuntimeId="osx-$__BuildArch"
- fi
- fi
-
- echo "__DistroRid: " $__DistroRid
+ initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir}
}
isMSBuildOnNETCoreSupported()
UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
do
- if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
+ if [ "${__DistroRid}" == "$UNSUPPORTED_RID" ]; then
__isMSBuildOnNETCoreSupported=0
break
fi
__Logging="$__MsbuildLog $__MsbuildWrn $__MsbuildErr /consoleloggerparameters:$buildVerbosity"
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"
- echo "$nextCommand"
eval $nextCommand
if [ $? -ne 0 ]; then
build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "/t:CreateTestOverlay"
chmod +x $__BinDir/corerun
- chmod +x $__BinDir/crossgen
+ chmod +x $__CrossgenExe
# Make sure to copy over the pulled down packages
cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
+
+ if [ "$__BuildOS" != "OSX" ]; then
+ nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --arch=$__BuildArch --outputDir=$CORE_ROOT"
+ echo "Resolve runtime dependences via $nextCommand"
+ eval $nextCommand
+ if [ $? != 0 ]; then
+ echo "${__MsgPrefix}Error: setup-stress-dependencies failed."
+ exit 1
+ fi
+ fi
+
+ # Precompile framework assemblies with crossgen if required
+ if [ $__DoCrossgen -ne 0 ]; then
+ precompile_coreroot_fx
+ fi
+}
+
+precompile_coreroot_fx()
+{
+ echo "${__MsgPrefix}Running crossgen on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"
+
+ # Read the exclusion file for this platform
+ skipCrossGenFiles=($(read_array "$(dirname "$0")/tests/skipCrossGenFiles.${__BuildArch}.txt"))
+
+ local overlayDir=$CORE_ROOT
+
+ filesToPrecompile=$(find -L $overlayDir -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -not -iname xunit.\* -type f)
+ for fileToPrecompile in ${filesToPrecompile}
+ do
+ local filename=${fileToPrecompile}
+ if is_skip_crossgen_test "$(basename $filename)"; then
+ continue
+ fi
+ echo Precompiling $filename
+ $__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr
+ local exitCode=$?
+ if [[ $exitCode != 0 ]]; then
+ if grep -q -e '0x80131018' $filename.stderr; then
+ printf "\n\t$filename is not a managed assembly.\n\n"
+ else
+ echo Unable to precompile $filename.
+ cat $filename.stdout
+ cat $filename.stderr
+ exit $exitCode
+ fi
+ else
+ rm $filename.{stdout,stderr}
+ fi
+ done
+}
+
+declare -a skipCrossGenFiles
+
+function is_skip_crossgen_test {
+ for skip in "${skipCrossGenFiles[@]}"; do
+ if [ "$1" == "$skip" ]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+# Get an array of items by reading the specified file line by line.
+function read_array {
+ local theArray=()
+
+ if [ ! -f "$1" ]; then
+ return
+ fi
+
+ # bash in Mac OS X doesn't support 'readarray', so using alternate way instead.
+ # readarray -t theArray < "$1"
+ # Any line that starts with '#' is ignored.
+ while IFS='' read -r line || [ -n "$line" ]; do
+ if [[ $line != "#"* ]]; then
+ theArray[${#theArray[@]}]=$line
+ fi
+ done < "$1"
+ echo ${theArray[@]}
}
generate_testhost()
fi
generate_layout
-
- if [ $__ZipTests -ne 0 ]; then
- echo "${__MsgPrefix}ZIP tests packages..."
- build_MSBuild_projects "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " "
- fi
}
build_MSBuild_projects()
# __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
export __SkipPackageRestore=false
export __SkipTargetingPackBuild=false
- export __BuildLoopCount=2
- export __TestGroupToBuild=1
+ export __NumberOfTestGroups=3
+
__AppendToLog=false
if [ -n "$__priority1" ]; then
- export __BuildLoopCount=16
- export __TestGroupToBuild=2
+ export __NumberOfTestGroups=10
fi
- for (( slice=1 ; slice <= __BuildLoopCount; slice = slice + 1 ))
+ for (( testGroupToBuild=1 ; testGroupToBuild <= __NumberOfTestGroups; testGroupToBuild = testGroupToBuild + 1 ))
do
__msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
__msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
__msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
- export TestBuildSlice=$slice
+ export __TestGroupToBuild=$testGroupToBuild
# Generate build command
buildArgs=("/nologo" "/verbosity:minimal" "/clp:Summary")
buildArgs+=("${__UnprocessedBuildArgs[@]}")
nextCommand="\"$__ProjectRoot/dotnet.sh\" msbuild ${buildArgs[@]}"
- echo "Building step '$stepName' slice=$slice via $nextCommand"
+ echo "Building step '$stepName' testGroupToBuild=$testGroupToBuild via $nextCommand"
eval $nextCommand
# Make sure everything is OK
__versionSourceFile="$intermediatesForBuild/version.c"
if [ $__SkipGenerateVersion == 0 ]; then
pwd
- $__ProjectRoot/dotnet.sh msbuild /nologo /verbosity:minimal /clp:Summary \
- /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true \
- /p:UsePartialNGENOptimization=false /maxcpucount \
- $__ProjectDir/build.proj /t:GenerateVersionHeader \
- /p:GenerateVersionHeader=true /p:NativeVersionSourceFile=$__versionSourceFile \
- /l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll\;LogFile=binclash.log \
- $__CommonMSBuildArgs $__UnprocessedBuildArgs
+ $__ProjectRoot/eng/common/msbuild.sh $__ProjectRoot/eng/empty.csproj \
+ /p:NativeVersionFile=$__versionSourceFile \
+ /p:ArcadeBuild=true /t:GenerateNativeVersionFile /restore \
+ $__CommonMSBuildArgs $__UnprocessedBuildArgs
+ if [ $? -ne 0 ]; then
+ echo "Failed to generate native version file."
+ exit $?
+ fi
else
# Generate the dummy version.c, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
__versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
pushd "$intermediatesForBuild"
# Regenerate the CMake solution
# Force cross dir to point to project root cross dir, in case there is a cross build.
- nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
+ scriptDir="$__ProjectRoot/src/pal/tools"
+ if [[ $__GccBuild == 0 ]]; then
+ nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-clang.sh\" \"$__TestDir\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
+ else
+ nextCommand="CONFIG_DIR=\"$__ProjectRoot/cross\" \"$scriptDir/gen-buildsys-gcc.sh\" \"$__TestDir\" \"$__GccMajorVersion\" \"$__GccMinorVersion\" $platformArch $scriptDir $__BuildType $__CodeCoverage $generator $extraCmakeArguments $__cmakeargs"
+ fi
echo "Invoking $nextCommand"
eval $nextCommand
popd
echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
echo "ninja - target ninja instead of GNU make"
echo "clangx.y - optional argument to build using clang version x.y - supported version 3.5 - 6.0"
+ echo "gccx.y - optional argument to build using gcc version x.y."
echo "cross - optional argument to signify cross compilation,"
echo " - will use ROOTFS_DIR environment variable if set."
echo "portableLinux - build for Portable Linux Distribution"
echo "generatelayoutonly - only pull down dependencies and build coreroot"
echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost"
echo "skiprestorepackages - skip package restore"
+ echo "crossgen - Precompiles the framework managed assemblies in coreroot"
echo "runtests - run tests after building them"
- echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
echo "priority1 - include priority=1 tests in the build"
# Set the various build properties here so that CMake and MSBuild can pick them up
export __ProjectDir="$__ProjectRoot"
__SourceDir="$__ProjectDir/src"
-__PackagesDir="$__ProjectDir/packages"
+__PackagesDir="$__ProjectDir/.packages"
__RootBinDir="$__ProjectDir/bin"
__BuildToolsDir="$__ProjectDir/Tools"
-__DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet"
+__DotNetCli="$__ProjectDir/dotnet.sh"
__UnprocessedBuildArgs=
__CommonMSBuildArgs=
__MSBCleanBuildArgs=
__CrossBuild=0
__ClangMajorVersion=0
__ClangMinorVersion=0
+__GccBuild=0
+__GccMajorVersion=0
+__GccMinorVersion=0
__NuGetPath="$__PackagesDir/NuGet.exe"
-__HostDistroRid=""
__SkipRestorePackages=0
__DistroRid=""
__cmakeargs=""
__PortableLinux=0
__msbuildonunsupportedplatform=0
-__ZipTests=0
__NativeTestIntermediatesDir=
__RunTests=0
__RebuildTests=0
__GenerateTestHostOnly=
__priority1=
__BuildTestWrappersOnly=
+__DoCrossgen=0
CORE_ROOT=
while :; do
__CrossBuild=1
;;
- portableBuild)
- __PortableBuild=1
+ portablebuild=false)
+ __PortableBuild=0
;;
portablelinux)
__ClangMinorVersion=0
;;
+ gcc5|-gcc5)
+ __GccMajorVersion=5
+ __GccMinorVersion=
+ __GccBuild=1
+ ;;
+
+ gcc6|-gcc6)
+ __GccMajorVersion=6
+ __GccMinorVersion=
+ __GccBuild=1
+ ;;
+
+ gcc7|-gcc7)
+ __GccMajorVersion=7
+ __GccMinorVersion=
+ __GccBuild=1
+ ;;
+
+ gcc8|-gcc8)
+ __GccMajorVersion=8
+ __GccMinorVersion=
+ __GccBuild=1
+ ;;
+
+ gcc|-gcc)
+ __GccMajorVersion=
+ __GccMinorVersion=
+ __GccBuild=1
+ ;;
+
ninja)
__UseNinja=1
;;
__BuildTestWrappers=0
;;
- ziptests)
- __ZipTests=1
- ;;
-
buildtestwrappersonly)
__BuildTestWrappersOnly=1
;;
__SkipRestorePackages=1
;;
+ crossgen)
+ __DoCrossgen=1
+ ;;
+
bindir)
if [ -n "$2" ]; then
__RootBinDir="$2"
__NumProc=$(nproc --all)
fi
-__CommonMSBuildArgs=("/p:__BuildArch=$__BuildArch" "/p:__BuildType=$__BuildType" "/p:__BuildOS=$__BuildOS")
+__CommonMSBuildArgs=("/p:__BuildArch=$__BuildArch" "/p:__BuildType=$__BuildType" "/p:__BuildOS=$__BuildOS" "/nodeReuse:false")
# Configure environment if we are doing a verbose build
if [ $__VerboseBuild == 1 ]; then
__LogsDir="$__RootBinDir/Logs"
__MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
-# init the host distro name
-initHostDistroRid
-
# Set the remaining variables based upon the determined build configuration
__BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
__PackagesBinDir="$__BinDir/.nuget"
__CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
__CrossArch="$__HostArch"
-if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
- __CrossArch="x86"
-fi
if [ $__CrossBuild == 1 ]; then
__CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
fi
# init the target distro name
initTargetDistroRid
-# Override tool directory
+if [ $__PortableBuild == 0 ]; then
+ __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
+fi
-__CoreClrVersion=1.1.0
-__sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/
+# Restore Build Tools
+source $__ProjectRoot/init-tools.sh
if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
build_Tests