Skip to content

Commit

Permalink
Add multiplatform support, closes #5 (#6)
Browse files Browse the repository at this point in the history
* Attempt to support Android, iOS, and Mac platforms

* Add fast noise binaries for linux and mac, 0.97-alpha

* Change FastNoise2.build.cs to not use expression-bodied property for compatbility
  • Loading branch information
DoubleDeez authored Jun 9, 2023
1 parent 6def188 commit 7b199db
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 15 deletions.
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");
}
}
}

0 comments on commit 7b199db

Please sign in to comment.