Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiplatform support, closes #5 #6

Merged
merged 3 commits into from
Jun 9, 2023
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Saved/
# Ignore the headers and cpp files in the clang toolchain on Linux
Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/**

!/Binaries/ThirdParty/FastNoise2/Win64/*
!/Binaries/ThirdParty/FastNoise2/**
!/Source/ThirdParty/FastNoise2/Win64/Release/FastNoise.lib
!/Source/ThirdParty/FastNoise2/Win64/Debug/FastNoiseD.lib
!Resources/*
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
136 changes: 122 additions & 14 deletions Source/ThirdParty/FastNoise2/FastNoise2.build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,136 @@ public FastNoise2(ReadOnlyTargetRules Target) : base(Target)
Type = ModuleType.External;
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "include"));

string platformString = Target.Platform.ToString();
PublicAdditionalLibraries.Add(LibraryPath);

// Add the import library
if (Target.Configuration == UnrealTargetConfiguration.Debug)
if (Target.Platform.IsInGroup(UnrealPlatformGroup.Microsoft))
{
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, platformString, "Debug", "FastNoiseD.lib"));

// Delay-load the DLL, so we can load it from the right place first
PublicDelayLoadDLLs.Add("FastNoiseD.dll");
PublicDelayLoadDLLs.Add(LibraryName + RuntimeLibExtension);
}

// Ensure that the DLL is staged along with the executable
RuntimeDependencies.Add(RuntimePath);
}

private string ConfigName
{
get
{
return Target.Configuration == UnrealTargetConfiguration.Debug ? "Debug" : "Release";
}
}

// Ensure that the DLL is staged along with the executable
RuntimeDependencies.Add(Path.Combine("$(PluginDir)", "Binaries", "ThirdParty", "FastNoise2", platformString, "FastNoiseD.dll"));
private string PlatformString
{
get
{
return Target.Platform.ToString();
}
else
}

private string RuntimePath
{
get
{
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, platformString, "Release", "FastNoise.lib"));
return Path.Combine("$(PluginDir)", "Binaries", "ThirdParty", "FastNoise2", PlatformString, LibraryName + RuntimeLibExtension);
}
}

// Delay-load the DLL, so we can load it from the right place first
PublicDelayLoadDLLs.Add("FastNoise.dll");
private string LibraryPath
{
get
{
if (Target.Platform.IsInGroup(UnrealPlatformGroup.Microsoft))
{
return Path.Combine(ModuleDirectory, PlatformString, ConfigName, LibraryName + LibraryExtension);
}
else
{
return RuntimePath;
}
}
}

private string LibraryName
{
get
{
if (Target.Configuration == UnrealTargetConfiguration.Debug)
{
if (Target.Platform == UnrealTargetPlatform.Mac ||
Target.Platform == UnrealTargetPlatform.IOS ||
Target.Platform == UnrealTargetPlatform.Android ||
Target.Platform == UnrealTargetPlatform.Linux ||
Target.Platform == UnrealTargetPlatform.LinuxArm64)
{
return "libFastNoiseD";
}
else if (Target.Platform.IsInGroup(UnrealPlatformGroup.Microsoft))
{
return "FastNoiseD";
}
}
else
{

if (Target.Platform == UnrealTargetPlatform.Mac ||
Target.Platform == UnrealTargetPlatform.IOS ||
Target.Platform == UnrealTargetPlatform.Android ||
Target.Platform == UnrealTargetPlatform.Linux ||
Target.Platform == UnrealTargetPlatform.LinuxArm64)
{
return "libFastNoise";
}
else if (Target.Platform.IsInGroup(UnrealPlatformGroup.Microsoft))
{
return "FastNoise";
}
}

throw new BuildException("Unsupported platform");
}
}

private string LibraryExtension
{
get
{
if (Target.Platform.IsInGroup(UnrealPlatformGroup.Microsoft))
{
return ".lib";
}
else
{
return RuntimeLibExtension;
}
}
}

private string RuntimeLibExtension
{
get
{
if (Target.Platform == UnrealTargetPlatform.Mac)
{
return ".dylib";
}
else if (Target.Platform == UnrealTargetPlatform.IOS)
{
return ".framework";
}
else if (Target.Platform == UnrealTargetPlatform.Android ||
Target.Platform == UnrealTargetPlatform.Linux ||
Target.Platform == UnrealTargetPlatform.LinuxArm64)
{
return ".so";
}
else if (Target.Platform.IsInGroup(UnrealPlatformGroup.Microsoft))
{
return ".dll";
}

// Ensure that the DLL is staged along with the executable
RuntimeDependencies.Add(Path.Combine("$(PluginDir)", "Binaries", "ThirdParty", "FastNoise2", platformString, "FastNoise.dll"));
throw new BuildException("Unsupported platform");
}
}
}