Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions OTAPI.Patcher/NugetPackageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,6 +38,7 @@ string GetNugetVersionFromAssembly<TType>()

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)
{
Expand Down Expand Up @@ -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))
Expand Down
20 changes: 20 additions & 0 deletions OTAPI.Patcher/Targets/PCServerTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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...");
Expand Down