.NET Core support.

This commit is contained in:
Pieter-Jan Briers
2019-08-02 02:07:03 +02:00
parent bcf60c404d
commit c0eca4f6c2
18 changed files with 215 additions and 77 deletions
+1
View File
@@ -92,3 +92,4 @@ Dependencies/
__pycache__
.mypy_cache
MSBuild/Robust.Custom.targets
-3
View File
@@ -20,7 +20,4 @@
<PropertyGroup Condition="'$(FullRelease)' == 'True'">
<DefineConstants>$(DefineConstants);FULL_RELEASE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x64'">
<DefineConstants>$(DefineConstants);X64</DefineConstants>
</PropertyGroup>
</Project>
+13
View File
@@ -1,4 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<Import Project="Robust.Custom.targets" Condition="Exists('Robust.Custom.targets')"/>
<!-- MSBuild hurts and I can't find a foolproof way to detect platform. -->
<PropertyGroup>
<OS Condition="'$(OS)' == ''">Windows_NT</OS>
@@ -26,4 +27,16 @@
<Python>python3</Python>
<Python Condition="'$(ActualOS)' == 'Windows'">py -3</Python>
</PropertyGroup>
<Choose>
<When Condition="'$(UseNetCore)' == 'true'">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
</Otherwise>
</Choose>
</Project>
@@ -1,9 +1,6 @@
using System;
using System.Linq;
using System.Threading;
using Robust.Client.Interfaces;
using Robust.Client.Utility;
using Robust.Shared;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Log;
@@ -21,10 +18,6 @@ namespace Robust.Client
public static void Main()
{
#if !X64
throw new InvalidOperationException("The client cannot start outside x64.");
#endif
IoCManager.InitThread();
DisplayMode mode;
@@ -0,0 +1,70 @@
#if NETCOREAPP
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using OpenTK.Graphics.OpenGL;
namespace Robust.Client.Graphics.Clyde
{
internal partial class Clyde
{
static Clyde()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}
NativeLibrary.SetDllImportResolver(typeof(GL).Assembly, (name, assembly, path) =>
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
&& _dllMapLinux.TryGetValue(name, out var mappedName))
{
return NativeLibrary.Load(mappedName);
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
&& _dllMapMacOS.TryGetValue(name, out mappedName))
{
return NativeLibrary.Load(mappedName);
}
return IntPtr.Zero;
});
}
[SuppressMessage("ReSharper", "StringLiteralTypo")]
private static readonly Dictionary<string, string> _dllMapLinux = new Dictionary<string, string>
{
{"opengl32.dll", "libGL.so.1"},
{"glu32.dll", "libGLU.so.1"},
{"openal32.dll", "libopenal.so.1"},
{"alut.dll", "libalut.so.0"},
{"opencl.dll", "libOpenCL.so"},
{"libX11", "libX11.so.6"},
{"libXi", "libXi.so.6"},
{"SDL2.dll", "libSDL2-2.0.so.0"}
};
[SuppressMessage("ReSharper", "StringLiteralTypo")]
private static readonly Dictionary<string, string> _dllMapMacOS = new Dictionary<string, string>
{
{"opengl32.dll", "/System/Library/Frameworks/OpenGL.framework/OpenGL"},
{"openal32.dll", "/System/Library/Frameworks/OpenAL.framework/OpenAL"},
{"alut.dll", "/System/Library/Frameworks/OpenAL.framework/OpenAL"},
{"libGLES.dll", "/System/Library/Frameworks/OpenGLES.framework/OpenGLES"},
{"libGLESv1_CM.dll", "/System/Library/Frameworks/OpenGLES.framework/OpenGLES"},
{"libGLESv2.dll", "/System/Library/Frameworks/OpenGLES.framework/OpenGLES"},
{"opencl.dll", "/System/Library/Frameworks/OpenCL.framework/OpenCL"},
{"SDL2.dll", "libSDL2.dylib"},
{"libGL.so.1", "/usr/X11/lib/libGL.dylib"},
{"libXcursor.so.1", "/usr/X11/lib/libXcursor.dylib"},
{"libXinerama", "/usr/X11/lib/libXinerama.dylib"},
{"libX11", "/usr/X11/lib/libX11.dylib"},
{"libXrandr.so.2", "/usr/X11/lib/libXrandr.dylib"},
{"libXi", "/usr/X11/lib/libXi.dylib"}
};
}
}
#endif
+6 -3
View File
@@ -115,7 +115,7 @@ namespace Robust.Client.Graphics.Clyde
_window.Title = title;
}
public override void Initialize(bool lite=false)
public override void Initialize(bool lite = false)
{
_lite = lite;
_initWindow();
@@ -245,10 +245,12 @@ namespace Robust.Client.Graphics.Clyde
_gameController.TextEntered(new TextEventArgs(eventArgs.KeyChar));
};
#if !NETCOREAPP
using (var iconFile = _resourceCache.ContentFileRead("/Textures/Logo/icon.ico"))
{
_window.Icon = new Icon(iconFile);
}
#endif
_initOpenGL();
}
@@ -597,7 +599,7 @@ namespace Robust.Client.Graphics.Clyde
if (!_lite)
{
LightRenderTarget = CreateRenderTarget(_lightMapSize(), RenderTargetColorFormat.Rgba16F,
name: "LightRenderTarget");
name: "LightRenderTarget");
}
}
@@ -759,7 +761,8 @@ namespace Robust.Client.Graphics.Clyde
private sealed class ClydeDebugInfo : IClydeDebugInfo
{
public ClydeDebugInfo(Version openGLVersion, Version minimumVersion, string renderer, string vendor, string versionString)
public ClydeDebugInfo(Version openGLVersion, Version minimumVersion, string renderer, string vendor,
string versionString)
{
OpenGLVersion = openGLVersion;
MinimumVersion = minimumVersion;
+7
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using JetBrains.Annotations;
using Robust.Client.Interfaces.Graphics;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
@@ -33,6 +34,12 @@ namespace Robust.Client.Graphics
_library = new Library();
}
static FontManager()
{
DllMapHelper.RegisterExplicitMap(typeof(Library).Assembly, "freetype6", "libfreetype.so.6",
"/Library/Frameworks/Mono.framework/Libraries/libfreetype.6.dylib");
}
public IFontFaceHandle Load(Stream stream)
{
var face = new Face(_library, stream.CopyToArray(), 0);
+6 -2
View File
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<Platforms>x64;x86</Platforms>
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/Client</OutputPath>
</PropertyGroup>
@@ -43,6 +42,11 @@
<ItemGroup>
<EmbeddedResource Include="Graphics\RSI\RSISchema.json" />
</ItemGroup>
<ItemGroup>
<Reference Include="SharpFont, Version=4.0.1.200, Culture=neutral, PublicKeyToken=48add4c483071cdf">
<HintPath>..\..\packages\sharpfont\4.0.1\lib\net45\SharpFont.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="..\MSBuild\Robust.Engine.targets" />
<Target Name="RobustAfterBuild" DependsOnTargets="CopySS14Noise;CopyMiscDependencies;CopySwnfd" AfterTargets="Build" />
</Project>
@@ -6,8 +6,10 @@ using System.Threading.Tasks;
using JetBrains.Annotations;
using Robust.Client.Interfaces.Console;
using Robust.Client.Interfaces.UserInterface;
using Robust.Shared;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Noise;
using Robust.Shared.Utility;
namespace Robust.Client.UserInterface
@@ -31,6 +33,11 @@ namespace Robust.Client.UserInterface
private bool _checkedKDialogAvailable;
#endif
static FileDialogManager()
{
DllMapHelper.RegisterSimpleMap(typeof(NoiseGenerator).Assembly, "swnfd");
}
public async Task<string> OpenFile()
{
#if LINUX
@@ -1,6 +1,5 @@
using System;
using System.Globalization;
using System.Runtime.Remoting.Messaging;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
+1 -2
View File
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64;x86</Platforms>
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/Lite</OutputPath>
</PropertyGroup>
+7 -50
View File
@@ -1,53 +1,13 @@
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Server.Interfaces;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.GameState;
using Robust.Server.Interfaces.Maps;
using Robust.Server.Interfaces.Placement;
using Robust.Server.Interfaces.Player;
using Robust.Server.Maps;
using Robust.Server.Placement;
using Robust.Server.Player;
using Robust.Server.Prototypes;
using Robust.Server.Reflection;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Log;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.Interfaces.Timers;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timers;
using Robust.Shared.Timing;
using System;
using System;
using System.Collections.Generic;
using System.Reflection;
using Robust.Shared.Interfaces.Resources;
using Robust.Server.Console;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.ServerStatus;
using Robust.Server.Interfaces.Timing;
using Robust.Server.ServerStatus;
using Robust.Server.Timing;
using Robust.Server.ViewVariables;
using Robust.Server.Interfaces;
using Robust.Shared.ContentPack;
using Robust.Shared.Interfaces.Log;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared;
using Robust.Shared.Asynchronous;
using Robust.Shared.Exceptions;
using Robust.Shared.Localization;
namespace Robust.Server
{
@@ -55,9 +15,6 @@ namespace Robust.Server
{
internal static void Main(string[] args)
{
#if !X64
throw new InvalidOperationException("The server cannot start outside x64.");
#endif
IoCManager.InitThread();
ServerIoC.RegisterIoC();
IoCManager.BuildGraph();
+1 -2
View File
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<Platforms>x64;x86</Platforms>
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/Server</OutputPath>
</PropertyGroup>
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/Shared.Maths</OutputPath>
<Configurations>Debug;Release</Configurations>
<Platforms>x86;x64</Platforms>
<Platforms>x64</Platforms>
</PropertyGroup>
<Import Project="..\MSBuild\Robust.DefineConstants.targets" />
<ItemGroup>
+87
View File
@@ -0,0 +1,87 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Robust.Shared
{
internal static class DllMapHelper
{
[Conditional("NETCOREAPP")]
public static void RegisterSimpleMap(Assembly assembly, string baseName)
{
#if NETCOREAPP
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// DLL names should line up on Windows by default.
// So a hook won't do anything.
return;
}
NativeLibrary.SetDllImportResolver(assembly, (name, _, __) =>
{
if (name == baseName)
{
var assemblyDir = Path.GetDirectoryName(assembly.Location);
string libName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
libName = $"lib{baseName}.so";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
libName = $"lib{baseName}.dylib";
}
else
{
throw new NotSupportedException();
}
return NativeLibrary.Load(Path.Join(assemblyDir, libName));
}
return IntPtr.Zero;
});
#endif
}
[Conditional("NETCOREAPP")]
public static void RegisterExplicitMap(Assembly assembly, string baseName, string linuxName, string macName)
{
#if NETCOREAPP
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// DLL names should line up on Windows by default.
// So a hook won't do anything.
return;
}
NativeLibrary.SetDllImportResolver(assembly, (name, _, __) =>
{
if (name == baseName)
{
string libName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
libName = linuxName;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
libName = macName;
}
else
{
throw new NotSupportedException();
}
return NativeLibrary.Load(libName);
}
return IntPtr.Zero;
});
#endif
}
}
}
+5
View File
@@ -15,6 +15,11 @@ namespace Robust.Shared.Noise
Ridged = 1
}
static NoiseGenerator()
{
DllMapHelper.RegisterSimpleMap(typeof(NoiseGenerator).Assembly, "ss14_noise");
}
private IntPtr _nativeGenerator;
public NoiseGenerator(NoiseType type)
+2 -3
View File
@@ -1,18 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/Shared</OutputPath>
<Platforms>x64;x86</Platforms>
<Platforms>x64</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<Import Project="..\MSBuild\Robust.DefineConstants.targets" />
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.1" />
<PackageReference Include="Mono.Cecil" Version="0.10.3" />
<PackageReference Include="Mono.Cecil" Version="0.10.4" />
<PackageReference Include="NetSerializer" Version="4.1.0" />
<PackageReference Include="Nett" Version="0.11.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
+1 -2
View File
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Properties.targets" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>false</IsPackable>
<Platforms>x86;x64</Platforms>
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../bin/UnitTesting</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>