diff --git a/.gitignore b/.gitignore index 6fe650e2d1..d4bcde2eb7 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,4 @@ Dependencies/ __pycache__ .mypy_cache +MSBuild/Robust.Custom.targets diff --git a/MSBuild/Robust.DefineConstants.targets b/MSBuild/Robust.DefineConstants.targets index fb5cf49f28..bfa0122256 100644 --- a/MSBuild/Robust.DefineConstants.targets +++ b/MSBuild/Robust.DefineConstants.targets @@ -20,7 +20,4 @@ $(DefineConstants);FULL_RELEASE - - $(DefineConstants);X64 - diff --git a/MSBuild/Robust.Properties.targets b/MSBuild/Robust.Properties.targets index 8114b57187..605b219e56 100644 --- a/MSBuild/Robust.Properties.targets +++ b/MSBuild/Robust.Properties.targets @@ -1,4 +1,5 @@ + Windows_NT @@ -26,4 +27,16 @@ python3 py -3 + + + + netcoreapp3.0 + + + + + net472 + + + diff --git a/Robust.Client/GameController/GameController.Standalone.cs b/Robust.Client/GameController/GameController.Standalone.cs index f37e14facf..3ce0be0594 100644 --- a/Robust.Client/GameController/GameController.Standalone.cs +++ b/Robust.Client/GameController/GameController.Standalone.cs @@ -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; diff --git a/Robust.Client/Graphics/Clyde/Clyde.DllMap.cs b/Robust.Client/Graphics/Clyde/Clyde.DllMap.cs new file mode 100644 index 0000000000..38a527ce41 --- /dev/null +++ b/Robust.Client/Graphics/Clyde/Clyde.DllMap.cs @@ -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 _dllMapLinux = new Dictionary + { + {"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 _dllMapMacOS = new Dictionary + { + {"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 diff --git a/Robust.Client/Graphics/Clyde/Clyde.cs b/Robust.Client/Graphics/Clyde/Clyde.cs index 3ae045919e..31c6dfcb96 100644 --- a/Robust.Client/Graphics/Clyde/Clyde.cs +++ b/Robust.Client/Graphics/Clyde/Clyde.cs @@ -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; diff --git a/Robust.Client/Graphics/FontManager.cs b/Robust.Client/Graphics/FontManager.cs index 855491ef08..61b9129bef 100644 --- a/Robust.Client/Graphics/FontManager.cs +++ b/Robust.Client/Graphics/FontManager.cs @@ -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); diff --git a/Robust.Client/Robust.Client.csproj b/Robust.Client/Robust.Client.csproj index 6eacb12ce7..1786f37b64 100644 --- a/Robust.Client/Robust.Client.csproj +++ b/Robust.Client/Robust.Client.csproj @@ -1,12 +1,11 @@  - net472 7.3 false true Exe - x64;x86 + x64 false ../bin/Client @@ -43,6 +42,11 @@ + + + ..\..\packages\sharpfont\4.0.1\lib\net45\SharpFont.dll + + diff --git a/Robust.Client/UserInterface/FileDialogManager.cs b/Robust.Client/UserInterface/FileDialogManager.cs index 4815cee777..004e64633c 100644 --- a/Robust.Client/UserInterface/FileDialogManager.cs +++ b/Robust.Client/UserInterface/FileDialogManager.cs @@ -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 OpenFile() { #if LINUX diff --git a/Robust.Client/ViewVariables/Editors/ViewVariablesPropertyEditorVector2.cs b/Robust.Client/ViewVariables/Editors/ViewVariablesPropertyEditorVector2.cs index ad3fa49357..df2b56004a 100644 --- a/Robust.Client/ViewVariables/Editors/ViewVariablesPropertyEditorVector2.cs +++ b/Robust.Client/ViewVariables/Editors/ViewVariablesPropertyEditorVector2.cs @@ -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; diff --git a/Robust.Lite/Robust.Lite.csproj b/Robust.Lite/Robust.Lite.csproj index d830cc1e4b..0ea3e48d3e 100644 --- a/Robust.Lite/Robust.Lite.csproj +++ b/Robust.Lite/Robust.Lite.csproj @@ -1,11 +1,10 @@  - net472 7.3 false true - x64;x86 + x64 false ../bin/Lite diff --git a/Robust.Server/Program.cs b/Robust.Server/Program.cs index 81916b4206..ab80d39974 100644 --- a/Robust.Server/Program.cs +++ b/Robust.Server/Program.cs @@ -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(); diff --git a/Robust.Server/Robust.Server.csproj b/Robust.Server/Robust.Server.csproj index 04fdb3fff0..bf21501206 100644 --- a/Robust.Server/Robust.Server.csproj +++ b/Robust.Server/Robust.Server.csproj @@ -1,11 +1,10 @@  - net472 7.3 false Exe - x64;x86 + x64 false ../bin/Server diff --git a/Robust.Shared.Maths/Robust.Shared.Maths.csproj b/Robust.Shared.Maths/Robust.Shared.Maths.csproj index 08b73b2a6d..22644a9e42 100644 --- a/Robust.Shared.Maths/Robust.Shared.Maths.csproj +++ b/Robust.Shared.Maths/Robust.Shared.Maths.csproj @@ -1,13 +1,12 @@  - netstandard2.0 7.3 false false ../bin/Shared.Maths Debug;Release - x86;x64 + x64 diff --git a/Robust.Shared/DllMapHelper.cs b/Robust.Shared/DllMapHelper.cs new file mode 100644 index 0000000000..d6d196dd54 --- /dev/null +++ b/Robust.Shared/DllMapHelper.cs @@ -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 + } + } +} diff --git a/Robust.Shared/Noise/NoiseGenerator.cs b/Robust.Shared/Noise/NoiseGenerator.cs index 448d51b675..699dc8a170 100644 --- a/Robust.Shared/Noise/NoiseGenerator.cs +++ b/Robust.Shared/Noise/NoiseGenerator.cs @@ -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) diff --git a/Robust.Shared/Robust.Shared.csproj b/Robust.Shared/Robust.Shared.csproj index 60a922ed51..0d06abf55b 100644 --- a/Robust.Shared/Robust.Shared.csproj +++ b/Robust.Shared/Robust.Shared.csproj @@ -1,18 +1,17 @@  - net472 7.3 false false ../bin/Shared - x64;x86 + x64 true - + diff --git a/Robust.UnitTesting/Robust.UnitTesting.csproj b/Robust.UnitTesting/Robust.UnitTesting.csproj index 06efdc93bd..2a110ea369 100644 --- a/Robust.UnitTesting/Robust.UnitTesting.csproj +++ b/Robust.UnitTesting/Robust.UnitTesting.csproj @@ -1,10 +1,9 @@  - net472 7.3 false - x86;x64 + x64 false ../bin/UnitTesting true