From dabce395157afdbc0bcc1c063374996cdef3f029 Mon Sep 17 00:00:00 2001 From: isawicca Date: Wed, 25 Nov 2026 11:48:13 -0500 Subject: [PATCH] Ship GNS natives in the package --- OTAPI.Patcher/NugetPackageBuilder.cs | 8 ++++++++ OTAPI.Patcher/Targets/PCServerTarget.cs | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/OTAPI.Patcher/NugetPackageBuilder.cs b/OTAPI.Patcher/NugetPackageBuilder.cs index 728f03fc..2b6aac03 100644 --- a/OTAPI.Patcher/NugetPackageBuilder.cs +++ b/OTAPI.Patcher/NugetPackageBuilder.cs @@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License using Mono.Cecil; using System; using System.IO; +using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; @@ -37,6 +38,7 @@ string GetNugetVersionFromAssembly() public string PackageName { get; set; } public string NuspecPath { get; set; } + public List<(string Source, string Target)> NativeFiles { get; } = new(); public NugetPackageBuilder(string packageName, string nuspecPath) { @@ -90,6 +92,12 @@ public void Build(ModFwModder modder) packageBuilder.AddFiles(AppContext.BaseDirectory, "OpenNAT.dll", dest); } + foreach (var (source, target) in NativeFiles) + { + if (File.Exists(source)) + packageBuilder.AddFiles(Path.GetDirectoryName(source), Path.GetFileName(source), target); + } + var output = Path.Combine(AppContext.BaseDirectory, PackageName); if (File.Exists(output)) diff --git a/OTAPI.Patcher/Targets/PCServerTarget.cs b/OTAPI.Patcher/Targets/PCServerTarget.cs index cdec9e3a..b135c364 100644 --- a/OTAPI.Patcher/Targets/PCServerTarget.cs +++ b/OTAPI.Patcher/Targets/PCServerTarget.cs @@ -57,6 +57,25 @@ public virtual void MergeReLogic(ModFwModder modder, string embeddedResources) modder.RelinkAssembly("ReLogic"); } + public virtual void RegisterNativeFiles(string vanillaDllPath) + { + var root = Path.GetDirectoryName(Path.GetDirectoryName(vanillaDllPath)!)!; + var natives = new (string Source, string Rid)[] + { + (Path.Combine(root, "Linux", "lib64", "libGNS_Wrapper.so"), "linux-x64"), + (Path.Combine(root, "Linux", "lib64", "libprotobuf.so.3.15.3.0"), "linux-x64"), + (Path.Combine(root, "Linux", "lib64", "libssl.so.1.1"), "linux-x64"), + (Path.Combine(root, "Linux", "lib64", "libcrypto.so.1.1"), "linux-x64"), + (Path.Combine(root, "Mac", "Terraria Server.app", "Contents", "MacOS", "osx", "libGNS_Wrapper.dylib"), "osx-x64"), + (Path.Combine(root, "Mac", "Terraria Server.app", "Contents", "MacOS", "osx", "libGNS_Wrapper.dylib"), "osx-arm64"), + }; + foreach (var (source, rid) in natives) + { + if (File.Exists(source)) + NugetPackager.NativeFiles.Add((source, Path.Combine("runtimes", rid, "native"))); + } + } + public virtual void AddVersion(ModFwModder modder) { modder.AddVersion(Common.GetVersion()); @@ -88,6 +107,7 @@ public async Task PatchAsync() Common.AddMarkdownFormatter(); var vanillaDllPath = await DownloadServerAsync(); + RegisterNativeFiles(vanillaDllPath); var vanillaName = Path.GetFileNameWithoutExtension(vanillaDllPath); Console.WriteLine("[OTAPI] Extracting embedded binaries and packing into one binary...");