Skip to content

Commit

Permalink
Add support for building dotnet CLI on RHEL.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sridhar-MS authored and Sridhar Periyasamy committed Mar 2, 2016
1 parent ab5df03 commit 3a4ce0a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},

"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23728"
"NETStandard.Library": "1.0.0-rc2-23811"
},

"frameworks": {
Expand Down
15 changes: 14 additions & 1 deletion scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public static bool IsCentOS
}
}

public static bool IsRHEL
{
get
{
var osname = PlatformServices.Default.Runtime.OperatingSystem;
return string.Equals(osname, "rhel", StringComparison.OrdinalIgnoreCase);
}
}

private static BuildPlatform DetermineCurrentPlatform()
{
if (IsWindows)
Expand All @@ -66,10 +75,14 @@ private static BuildPlatform DetermineCurrentPlatform()
{
return BuildPlatform.CentOS;
}
else if (IsRHEL)
{
return BuildPlatform.RHEL;
}
else
{
return default(BuildPlatform);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum BuildPlatform
Windows = 1,
OSX = 2,
Ubuntu = 3,
CentOS = 4
CentOS = 4,
RHEL = 5
}
}
}
54 changes: 19 additions & 35 deletions scripts/dotnet-cli-build/CompileTargets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ private static BuildTargetResult CopyAppDeps(BuildTargetContext c, string output
// Find toolchain package
string packageId;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (CurrentPlatform.IsWindows)
{
if (IsWinx86)
if (CurrentArchitecture.Isx86)
{
// https://github.com/dotnet/cli/issues/1550
c.Warn("Native compilation is not yet working on Windows x86");
Expand All @@ -249,24 +249,16 @@ private static BuildTargetResult CopyAppDeps(BuildTargetContext c, string output

packageId = "toolchain.win7-x64.Microsoft.DotNet.AppDep";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
else if (CurrentPlatform.IsUbuntu)
{
var osname = PlatformServices.Default.Runtime.OperatingSystem;
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}");
}
packageId = "toolchain.ubuntu.14.04-x64.Microsoft.DotNet.AppDep";
}
else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL)
{
c.Warn($"Native compilation is not yet working on {CurrentPlatform.Current}");
return c.Success();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
else if (CurrentPlatform.IsOSX)
{
packageId = "toolchain.osx.10.10-x64.Microsoft.DotNet.AppDep";
}
Expand Down Expand Up @@ -296,28 +288,20 @@ private static BuildTargetResult Crossgen(BuildTargetContext c, string outputDir
// Find crossgen
string arch = PlatformServices.Default.Runtime.RuntimeArchitecture;
string packageId;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (CurrentPlatform.IsWindows)
{
packageId = $"runtime.win7-{arch}.Microsoft.NETCore.Runtime.CoreCLR";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
else if (CurrentPlatform.IsUbuntu)
{
var osname = PlatformServices.Default.Runtime.OperatingSystem;
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}");
}
packageId = "runtime.ubuntu.14.04-x64.Microsoft.NETCore.Runtime.CoreCLR";
}
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 (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
else if (CurrentPlatform.IsOSX)
{
packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR";
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/obtain/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ current_os()
echo "ubuntu"
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
echo "centos"
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then
echo "rhel.7"
fi
fi
}
Expand Down
17 changes: 9 additions & 8 deletions test/EndToEnd/EndToEndTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public void TestDotnetIncrementalBuild()
[Fact]
public void TestDotnetBuildNativeRyuJit()
{
if(IsCentOS())
if(IsCentOSorRHEL())
{
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
return;
}

Expand All @@ -105,9 +105,9 @@ public void TestDotnetBuildNativeRyuJit()
[Fact]
public void TestDotnetBuildNativeCpp()
{
if(IsCentOS())
if(IsCentOSorRHEL())
{
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
return;
}

Expand All @@ -127,9 +127,9 @@ public void TestDotnetBuildNativeCpp()
[Fact]
public void TestDotnetCompileNativeCppIncremental()
{
if (IsCentOS())
if (IsCentOSorRHEL())
{
Console.WriteLine("Skipping native compilation tests on CentOS - https://github.com/dotnet/cli/issues/453");
Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453");
return;
}

Expand Down Expand Up @@ -236,15 +236,16 @@ private static void SetupStaticTestProject()
Directory.SetCurrentDirectory(currentDirectory);
}

private bool IsCentOS()
private bool IsCentOSorRHEL()
{
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
const string OSIDFILE = "/etc/os-release";

if(File.Exists(OSIDFILE))
{
return File.ReadAllText(OSIDFILE).ToLower().Contains("centos");
string osidcontent = File.ReadAllText(OSIDFILE).ToLower();
return osidcontent.Contains("centos") || osidcontent.Contains("rhel");
}
}

Expand Down

0 comments on commit 3a4ce0a

Please sign in to comment.