This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[WIP - Do not merge] Generate Microsoft.NETCore.Runtime.CoreCLR nuget packages #3043
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,24 @@ usage() | |
exit 1 | ||
} | ||
|
||
initDistroName() | ||
{ | ||
if [ "$__BuildOS" == "Linux" ]; then | ||
# Detect Distro | ||
if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then | ||
export __DistroName=ubuntu | ||
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then | ||
export __DistroName=rhel | ||
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then | ||
export __DistroName=rhel | ||
elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then | ||
export __DistroName=debian | ||
else | ||
export __DistroName="" | ||
fi | ||
fi | ||
} | ||
|
||
setup_dirs() | ||
{ | ||
echo Setting up directories for build | ||
|
@@ -162,50 +180,49 @@ build_coreclr() | |
fi | ||
} | ||
|
||
build_mscorlib() | ||
restoreBuildTools() | ||
{ | ||
hash mono 2> /dev/null || { echo >&2 "Skipping mscorlib.dll build since Mono is not installed."; return; } | ||
|
||
if [ $__SkipMSCorLib == 1 ]; then | ||
echo "Skipping mscorlib.dll build." | ||
return | ||
echo "Restoring BuildTools..." | ||
$__ProjectRoot/init-tools.sh | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to restore BuildTools." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Temporary hack to make dnu restore more reliable. This is specifically for dnu beta 5 since this issue should already be addressed in later versions of dnu. | ||
export MONO_THREADS_PER_CPU=2000 | ||
isMSBuildOnNETCoreSupported() | ||
{ | ||
__isMSBuildOnNETCoreSupported=0 | ||
|
||
echo "Commencing build of mscorlib components for $__BuildOS.$__BuildArch.$__BuildType" | ||
if [ "$__BuildOS" == "Linux" ]; then | ||
if [ "$__DistroName" == "ubuntu" ]; then | ||
__isMSBuildOnNETCoreSupported=1 | ||
fi | ||
elif [ "$__BuildOS" == "OSX" ]; then | ||
__isMSBuildOnNETCoreSupported=1 | ||
fi | ||
} | ||
|
||
# Pull NuGet.exe down if we don't have it already | ||
if [ ! -e "$__NuGetPath" ]; then | ||
hash curl 2>/dev/null || hash wget 2>/dev/null || { echo >&2 echo "cURL or wget is required to build mscorlib." ; exit 1; } | ||
build_mscorlib() | ||
{ | ||
|
||
echo "Restoring NuGet.exe..." | ||
if [ $__isMSBuildOnNETCoreSupported == 0 ]; then | ||
echo "Mscorlib.dll build unsupported." | ||
return | ||
fi | ||
|
||
# curl has HTTPS CA trust-issues less often than wget, so lets try that first. | ||
which curl > /dev/null 2> /dev/null | ||
if [ $? -ne 0 ]; then | ||
mkdir -p $__PackagesDir | ||
wget -q -O $__NuGetPath https://api.nuget.org/downloads/nuget.exe | ||
else | ||
curl -sSL --create-dirs -o $__NuGetPath https://api.nuget.org/downloads/nuget.exe | ||
fi | ||
# CI_TODO: Until we switch CI to stop building mscorlib for platforms supported by isMSBuildOnNETCoreSupported function, | ||
# we should ignore skipping building mscorlib. | ||
# if [ $__SkipMSCorLib == 1 ]; then | ||
# echo "Skipping building mscorlib." | ||
# return | ||
# fi | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Failed to restore NuGet.exe." | ||
exit 1 | ||
fi | ||
fi | ||
# Restore buildTools | ||
|
||
# Grab the MSBuild package if we don't have it already | ||
if [ ! -e "$__MSBuildPath" ]; then | ||
echo "Restoring MSBuild..." | ||
$__ProjectRoot/init-tools.sh | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to restore MSBuild." | ||
exit 1 | ||
fi | ||
fi | ||
restoreBuildTools | ||
|
||
echo "Commencing build of mscorlib components for $__BuildOS.$__BuildArch.$__BuildType" | ||
|
||
# Invoke MSBuild | ||
$__ProjectRoot/Tools/corerun "$__MSBuildPath" /nologo "$__ProjectRoot/build.proj" /verbosity:minimal "/fileloggerparameters:Verbosity=normal;LogFile=$__LogsDir/MSCorLib_$__BuildOS__$__BuildArch__$__BuildType.log" /t:Build /p:__BuildOS=$__BuildOS /p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__IntermediatesDir=$__IntermediatesDir /p:UseRoslynCompiler=true /p:BuildNugetPackage=false /p:UseSharedCompilation=false | ||
|
@@ -225,6 +242,38 @@ build_mscorlib() | |
fi | ||
} | ||
|
||
generate_NugetPackages() | ||
{ | ||
# We can only generate nuget package if we also support building mscorlib as part of this build. | ||
if [ $__isMSBuildOnNETCoreSupported == 0 ]; then | ||
echo "Microsoft.NETCore.Runtime.CoreCLR nuget package generation unsupported." | ||
return | ||
fi | ||
|
||
# Since we can build mscorlib for this OS, did we build the native components as well? | ||
if [ $__SkipCoreCLR == 1 ]; then | ||
echo "Unable to generate Microsoft.NETCore.Runtime.CoreCLR nuget package since native components were not built." | ||
return | ||
fi | ||
|
||
# CI_TODO: Until we switch CI to stop building mscorlib for platforms supported by isMSBuildOnNETCoreSupported function, | ||
# we should ignore skipping building mscorlib. | ||
# if [ $__SkipMSCorLib == 1 ]; then | ||
# echo "Unable to generate Microsoft.NETCore.Runtime.CoreCLR nuget package since mscorlib was not built." | ||
# return | ||
# fi | ||
|
||
echo "Generating nuget packages for "$__BuildOS | ||
|
||
# Invoke MSBuild | ||
$__ProjectRoot/Tools/corerun "$__MSBuildPath" /nologo "$__ProjectRoot/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/Microsoft.NETCore.Runtime.CoreCLR.builds" /verbosity:minimal "/fileloggerparameters:Verbosity=normal;LogFile=$__LogsDir/Nuget_$__BuildOS__$__BuildArch__$__BuildType.log" /t:Build /p:__BuildOS=$__BuildOS /p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__IntermediatesDir=$__IntermediatesDir /p:UseRoslynCompiler=true /p:BuildNugetPackage=false /p:UseSharedCompilation=false | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Failed to generate Nuget packages." | ||
exit 1 | ||
fi | ||
} | ||
|
||
echo "Commencing CoreCLR Repo build" | ||
|
||
# Argument types supported by this script: | ||
|
@@ -240,7 +289,7 @@ __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
# Use uname to determine what the CPU is. | ||
CPUName=$(uname -p) | ||
# Some Linux platforms report unknown for platform, but the arch for machine. | ||
if [ $CPUName = "unknown" ]; then | ||
if [ $CPUName == "unknown" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shell portability issue. This will fail on NetBSD. |
||
CPUName=$(uname -m) | ||
fi | ||
|
||
|
@@ -327,6 +376,7 @@ __ClangMajorVersion=3 | |
__ClangMinorVersion=5 | ||
__MSBuildPath=$__ProjectRoot/Tools/MSBuild.exe | ||
__NuGetPath="$__PackagesDir/NuGet.exe" | ||
__DistroName="" | ||
|
||
for i in "$@" | ||
do | ||
|
@@ -443,13 +493,30 @@ if [[ $__ConfigureOnly == 1 && $__SkipConfigure == 1 ]]; then | |
exit 1 | ||
fi | ||
|
||
# init the distro name | ||
initDistroName | ||
|
||
# Set the remaining variables based upon the determined build configuration | ||
__BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType" | ||
__PackagesBinDir="$__BinDir/.nuget" | ||
__ToolsDir="$__RootBinDir/tools" | ||
__TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType" | ||
export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType" | ||
__TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType" | ||
__isMSBuildOnNETCoreSupported=0 | ||
|
||
# Init if MSBuild for .NET Core is supported for this platform | ||
isMSBuildOnNETCoreSupported | ||
|
||
# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set. | ||
# This is needed by CLI to function. | ||
if [ -z "$HOME" ]; then | ||
if [ ! -d "$__ProjectDir/temp_home" ]; then | ||
mkdir temp_home | ||
fi | ||
export HOME=$__ProjectDir/temp_home | ||
echo "HOME not defined; setting it to $HOME" | ||
fi | ||
|
||
# Specify path to be set for CMAKE_INSTALL_PREFIX. | ||
# This is where all built CoreClr libraries will copied to. | ||
|
@@ -489,6 +556,11 @@ build_coreclr | |
|
||
build_mscorlib | ||
|
||
# Generate nuget packages | ||
|
||
generate_NugetPackages | ||
|
||
|
||
# Build complete | ||
|
||
echo "Repo successfully built." | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell portability issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the most portable way is:
[ "x$var" = "xVALUE" ]
-- empty strings may behave differently in diverse shells.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We specify bash above. Is this a real issue across bash's?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I forgot that we enforce bash.