mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-06-30 19:03:42 -04:00
Dropping experimental netfx support
- Set libraries to target netstandard2.1 and updated tests to net5.0. Still learning about the new features. Libraries may also change to net5.0 later if the newer features are useful enough to include directly in the library. - Removing Platform.cs which was only used by netfx.
This commit is contained in:
@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Raylib_cs
|
||||
{
|
||||
public static class Platform
|
||||
{
|
||||
public static readonly IReadOnlyDictionary<string, ( PlatformID, bool)> SupportedPlatforms =
|
||||
new Dictionary<string, (PlatformID PlatformID, bool x64)>()
|
||||
{
|
||||
{"osx-x64", (PlatformID.MacOSX, true)},
|
||||
{"win-x64", (PlatformID.Win32NT, true)},
|
||||
{"win-x86", (PlatformID.Win32NT, false)},
|
||||
{"linux-x64", (PlatformID.Unix, true)},
|
||||
{"linux-x86", (PlatformID.Unix, false)},
|
||||
};
|
||||
|
||||
public static readonly List<(PlatformID, bool)> HasSupportedPlatformNativeLibrary =
|
||||
new List<(PlatformID, bool)>();
|
||||
|
||||
public static string NativeLibrarySubfolder { get; set; } = "native";
|
||||
public static string RuntimeLibraryFolder { get; set; } = "runtimes";
|
||||
|
||||
private static void DiscoverNativeLibraries()
|
||||
{
|
||||
var localFolders = Directory.GetDirectories(Directory.GetCurrentDirectory());
|
||||
if (!localFolders.Any(d =>
|
||||
string.Equals(d, RuntimeLibraryFolder, StringComparison.InvariantCultureIgnoreCase))) return;
|
||||
|
||||
// for each supported platform, see if the native library exists in the RuntimeLibraryFolder (for now this is any file that doesnt start with ".")
|
||||
foreach (var platform in SupportedPlatforms)
|
||||
{
|
||||
var localPlatformFolder = localFolders.FirstOrDefault(f =>
|
||||
string.Equals(f, platform.Key, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
if (localPlatformFolder == default) continue;
|
||||
|
||||
var localNativeLibraryFolder = Path.Combine(localPlatformFolder, NativeLibrarySubfolder);
|
||||
|
||||
if (!Directory.Exists(localNativeLibraryFolder))
|
||||
continue;
|
||||
|
||||
// if all the files in the NativeLibrarySubfolder start with "." then we have not found any native libraries
|
||||
if (Directory.GetFiles(localNativeLibraryFolder).All(f => f[0] == '.')) continue;
|
||||
|
||||
if (!HasSupportedPlatformNativeLibrary.Contains(platform.Value))
|
||||
HasSupportedPlatformNativeLibrary.Add(platform.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private static string DetectSystem()
|
||||
{
|
||||
Debug.WriteLine(
|
||||
$"System info: {Environment.NewLine}" +
|
||||
$"OS:{Environment.OSVersion.Platform:G}{Environment.NewLine}" +
|
||||
$"ServicePack:{Environment.OSVersion.ServicePack}{Environment.NewLine}" +
|
||||
$"Version:{Environment.OSVersion.Version}{Environment.NewLine}" +
|
||||
$"64OS?:{Environment.Is64BitOperatingSystem}{Environment.NewLine}" +
|
||||
$"64Proc?:{Environment.Is64BitProcess}");
|
||||
|
||||
var x = Environment.Is64BitProcess && Environment.Is64BitOperatingSystem ? "-x64" : "-x86";
|
||||
|
||||
switch (Environment.OSVersion.Platform)
|
||||
{
|
||||
case PlatformID.Unix:
|
||||
return "linux" + x;
|
||||
case PlatformID.Win32NT:
|
||||
return "win" + x;
|
||||
case PlatformID.MacOSX:
|
||||
return "osx" + x;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ResolveNativeLibraries()
|
||||
{
|
||||
DiscoverNativeLibraries();
|
||||
CopyNativeLibraryFilesToRoot(DetectSystem());
|
||||
}
|
||||
|
||||
private static void CopyNativeLibraryFilesToRoot(string platformString)
|
||||
{
|
||||
// native
|
||||
foreach (var file in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), RuntimeLibraryFolder,
|
||||
platformString, NativeLibrarySubfolder)))
|
||||
{
|
||||
File.Copy(file, AppDomain.CurrentDomain.BaseDirectory + $"{Path.GetFileName(file)}", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.1</TargetFrameworks>
|
||||
<Platforms>osx-x64;linux-x64;win-x64;win-x86;linux-x86</Platforms>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
</PropertyGroup>
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Easings.cs"/>
|
||||
<Compile Include="Platform.cs"/>
|
||||
<Compile Include="Raylib.cs"/>
|
||||
<Compile Include="Raymath.cs"/>
|
||||
<Compile Include="Rlgl.cs"/>
|
||||
@ -41,9 +40,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Raylib-cs.targets"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="runtimes\**" CopyToOutputDirectory="PreserveNewest" Link="runtimes\%(RecursiveDir)\%(Filename)%(Extension)"/>
|
||||
</ItemGroup>
|
||||
|
||||
|
Reference in New Issue
Block a user