Merge pull request #1667 from Sridhar-MS/rhel

Add support for building dotnet CLI on RHEL.
This commit is contained in:
Sridhar Periyasamy 2016-03-08 09:35:30 -08:00
commit d5748854fb
5 changed files with 59 additions and 79 deletions

View file

@ -48,6 +48,15 @@ namespace Microsoft.DotNet.Cli.Build.Framework
} }
} }
public static bool IsRHEL
{
get
{
var osname = PlatformServices.Default.Runtime.OperatingSystem;
return string.Equals(osname, "rhel", StringComparison.OrdinalIgnoreCase);
}
}
private static BuildPlatform DetermineCurrentPlatform() private static BuildPlatform DetermineCurrentPlatform()
{ {
if (IsWindows) if (IsWindows)
@ -66,10 +75,14 @@ namespace Microsoft.DotNet.Cli.Build.Framework
{ {
return BuildPlatform.CentOS; return BuildPlatform.CentOS;
} }
else if (IsRHEL)
{
return BuildPlatform.RHEL;
}
else else
{ {
return default(BuildPlatform); return default(BuildPlatform);
} }
} }
} }
} }

View file

@ -5,6 +5,7 @@ namespace Microsoft.DotNet.Cli.Build.Framework
Windows = 1, Windows = 1,
OSX = 2, OSX = 2,
Ubuntu = 3, Ubuntu = 3,
CentOS = 4 CentOS = 4,
RHEL = 5
} }
} }

View file

@ -238,9 +238,9 @@ namespace Microsoft.DotNet.Cli.Build
// Find toolchain package // Find toolchain package
string packageId; string packageId;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (CurrentPlatform.IsWindows)
{ {
if (IsWinx86) if (CurrentArchitecture.Isx86)
{ {
// https://github.com/dotnet/cli/issues/1550 // https://github.com/dotnet/cli/issues/1550
c.Warn("Native compilation is not yet working on Windows x86"); c.Warn("Native compilation is not yet working on Windows x86");
@ -249,24 +249,16 @@ namespace Microsoft.DotNet.Cli.Build
packageId = "toolchain.win7-x64.Microsoft.DotNet.AppDep"; packageId = "toolchain.win7-x64.Microsoft.DotNet.AppDep";
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) else if (CurrentPlatform.IsUbuntu)
{ {
var osname = PlatformServices.Default.Runtime.OperatingSystem; packageId = "toolchain.ubuntu.14.04-x64.Microsoft.DotNet.AppDep";
if (string.Equals(osname, "ubuntu", StringComparison.OrdinalIgnoreCase))
{
packageId = "toolchain.ubuntu.14.04-x64.Microsoft.DotNet.AppDep";
}
else if (string.Equals(osname, "centos", StringComparison.OrdinalIgnoreCase))
{
c.Warn("Native compilation is not yet working on CentOS");
return c.Success();
}
else
{
return c.Failed($"Unknown Linux Distro: {osname}");
}
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL)
{
c.Warn($"Native compilation is not yet working on {CurrentPlatform.Current}");
return c.Success();
}
else if (CurrentPlatform.IsOSX)
{ {
packageId = "toolchain.osx.10.10-x64.Microsoft.DotNet.AppDep"; packageId = "toolchain.osx.10.10-x64.Microsoft.DotNet.AppDep";
} }
@ -296,28 +288,20 @@ namespace Microsoft.DotNet.Cli.Build
// Find crossgen // Find crossgen
string arch = PlatformServices.Default.Runtime.RuntimeArchitecture; string arch = PlatformServices.Default.Runtime.RuntimeArchitecture;
string packageId; string packageId;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (CurrentPlatform.IsWindows)
{ {
packageId = $"runtime.win7-{arch}.Microsoft.NETCore.Runtime.CoreCLR"; packageId = $"runtime.win7-{arch}.Microsoft.NETCore.Runtime.CoreCLR";
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) else if (CurrentPlatform.IsUbuntu)
{ {
var osname = PlatformServices.Default.Runtime.OperatingSystem; packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR";
if (string.Equals(osname, "ubuntu", StringComparison.OrdinalIgnoreCase))
{
packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR";
}
else if (string.Equals(osname, "centos", StringComparison.OrdinalIgnoreCase))
{
// CentOS runtime is in the runtime.rhel.7-x64... package.
packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR";
}
else
{
return c.Failed($"Unknown Linux Distro: {osname}");
}
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL)
{
// CentOS runtime is in the runtime.rhel.7-x64... package.
packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR";
}
else if (CurrentPlatform.IsOSX)
{ {
packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR"; packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR";
} }

View file

@ -83,6 +83,8 @@ current_os()
echo "ubuntu" echo "ubuntu"
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
echo "centos" echo "centos"
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then
echo "rhel.7"
fi fi
fi fi
} }

View file

@ -83,15 +83,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
[Fact] [Fact]
public void TestDotnetBuildNativeRyuJit() public void TestDotnetBuildNativeRyuJit()
{ {
if(IsCentOS()) if(!IsNativeCompilationSupported())
{ {
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
return;
}
if (IsWinX86())
{
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
return; return;
} }
@ -105,15 +98,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
[Fact] [Fact]
public void TestDotnetBuildNativeCpp() public void TestDotnetBuildNativeCpp()
{ {
if(IsCentOS()) if(!IsNativeCompilationSupported())
{ {
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
return;
}
if (IsWinX86())
{
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
return; return;
} }
@ -127,15 +113,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
[Fact] [Fact]
public void TestDotnetCompileNativeCppIncremental() public void TestDotnetCompileNativeCppIncremental()
{ {
if (IsCentOS()) if(!IsNativeCompilationSupported())
{ {
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
return;
}
if (IsWinX86())
{
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
return; return;
} }
@ -236,25 +215,26 @@ namespace Microsoft.DotNet.Tests.EndToEnd
Directory.SetCurrentDirectory(currentDirectory); Directory.SetCurrentDirectory(currentDirectory);
} }
private bool IsCentOS() private bool IsNativeCompilationSupported()
{ {
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) bool isSupported = true;
var platform = PlatformServices.Default.Runtime.OperatingSystem.ToLower();
switch (platform)
{ {
const string OSIDFILE = "/etc/os-release"; case "centos":
case "rhel":
if(File.Exists(OSIDFILE)) Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
{ isSupported = false;
return File.ReadAllText(OSIDFILE).ToLower().Contains("centos"); break;
} case "windows":
Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550");
isSupported = RuntimeInformation.ProcessArchitecture != Architecture.X86;
break;
default:
break;
} }
return false; return isSupported;
}
private bool IsWinX86()
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
RuntimeInformation.ProcessArchitecture == Architecture.X86;
} }
private static DateTime GetLastWriteTimeUtcOfDirectoryFiles(string outputDirectory) private static DateTime GetLastWriteTimeUtcOfDirectoryFiles(string outputDirectory)