mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-06-09 10:06:34 +02:00
Use hard links for macOS app bundles
Avoid needing to get executable path from MainModule, which broke the game when run with the dotnet command instead of the bin's apphost. Fixes tests.
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Robust.Shared.ContentPack
|
namespace Robust.Shared.ContentPack
|
||||||
@@ -17,20 +15,9 @@ namespace Robust.Shared.ContentPack
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string GetExecutableDirectory()
|
internal static string GetExecutableDirectory()
|
||||||
{
|
{
|
||||||
// TODO: remove this shitty hack, either through making it less hardcoded into shared,
|
// Fallback in case the above doesn't work ig?
|
||||||
// or by making our file structure less spaghetti somehow.
|
var assembly = typeof(PathHelpers).Assembly;
|
||||||
string location;
|
var location = assembly.Location;
|
||||||
if (Process.GetCurrentProcess().MainModule is { } mod)
|
|
||||||
{
|
|
||||||
location = mod.FileName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Fallback in case the above doesn't work ig?
|
|
||||||
var assembly = typeof(PathHelpers).Assembly;
|
|
||||||
location = assembly.Location;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (location == string.Empty)
|
if (location == string.Empty)
|
||||||
{
|
{
|
||||||
// See https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-5.0#remarks
|
// See https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.location?view=net-5.0#remarks
|
||||||
|
|||||||
@@ -98,9 +98,21 @@ def symlink_files(src_dir: str, dest_dir: str, relative: str):
|
|||||||
if not symlinkable_re.match(file):
|
if not symlinkable_re.match(file):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
src_path = p(src_dir, file)
|
||||||
dest_symlink = p(dest_dir, file)
|
dest_symlink = p(dest_dir, file)
|
||||||
if not os.path.islink(dest_symlink):
|
if os.path.isdir(src_path):
|
||||||
os.symlink(f"../../../{relative}{file}", dest_symlink)
|
# Symlink directories
|
||||||
|
if not os.path.islink(dest_symlink):
|
||||||
|
os.symlink(f"../../../{relative}{file}", dest_symlink)
|
||||||
|
else:
|
||||||
|
# Hardlink files
|
||||||
|
# (so that .NET doesn't report the real file path for assembly locations)
|
||||||
|
try:
|
||||||
|
os.remove(dest_symlink)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass # Fine
|
||||||
|
|
||||||
|
os.link(src_path, dest_symlink)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user