Skip to content

Commit

Permalink
Prepare build cs for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilGronek authored and Xavrax committed Aug 14, 2024
1 parent 5de719e commit ce8d717
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
19 changes: 17 additions & 2 deletions Source/PubnubLibrary/Private/PubnubLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@

#include "PubnubLibrary.h"
#include "Core.h"
#include "Kismet/KismetSystemLibrary.h"
#include "Interfaces/IPluginManager.h"

#define LOCTEXT_NAMESPACE "FPubnubLibraryModule"

void FPubnubLibraryModule::StartupModule()
{
#if PLATFORM_MAC
FString BaseDir = IPluginManager::Get().FindPlugin("PubnubChat")->GetBaseDir();
FString LibraryPath;
LibraryPath = FPaths::Combine(*BaseDir, TEXT("Source/ThirdParty/sdk/lib/macos/libpubnub-chat.dylib"));


ChatSDKLibraryHandle = !LibraryPath.IsEmpty() ? FPlatformProcess::GetDllHandle(*LibraryPath) : nullptr;

if (!ChatSDKLibraryHandle)
{
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("ChatSDKModuleHandle", "Failed to load pubnub third party library"));
}
#endif
}

void FPubnubLibraryModule::ShutdownModule()
{

#if PLATFORM_MAC
FPlatformProcess::FreeDllHandle(ChatSDKLibraryHandle);
ChatSDKLibraryHandle = nullptr;
#endif
}

#undef LOCTEXT_NAMESPACE
Expand Down
1 change: 1 addition & 0 deletions Source/PubnubLibrary/Public/PubnubLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class FPubnubLibraryModule : public IModuleInterface
virtual void StartupModule() override;
virtual void ShutdownModule() override;

void* PubnubLibraryHandle;
};
46 changes: 18 additions & 28 deletions Source/ThirdParty/sdk/PubNubModule/PubNubModule.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,29 @@ public PubNubModule(ReadOnlyTargetRules Target) : base(Target)
{
Type = ModuleType.External;

string extention = null;
string PlatformLib = null;
string binary = null;
string buildLocation = null;
if(Target.Platform == UnrealTargetPlatform.Win64)
{
extention = StaticLink ? "lib" : "dll";
PlatformLib = OpenSsl ? "openssl" : "windows";
binary = $"pubnub.{extention}";
buildLocation = "Lib/win64";
}
else if(Target.Platform == UnrealTargetPlatform.Mac)
{
extention = StaticLink ? "a" : "dylib";
PlatformLib = OpenSsl ? "openssl" : "posix";
binary = $"libpubnub.{extention}";
buildLocation = "Lib/MacOS";
}
else
{
extention = StaticLink ? "a" : "so";
PlatformLib = OpenSsl ? "openssl" : "posix";
binary = $"libpubnub.{extention}";
buildLocation = "Lib/Linux";
}

if (OpenSsl) {
if (OpenSsl) {
PublicDependencyModuleNames.AddRange(new string[] { "OpenSSL" });
}

var SDKPath = Path.Combine(new string[] { ModuleDirectory, ".." });



if (Target.Platform == UnrealTargetPlatform.Win64)
{
string BuildLocation = "Lib/win64";
PublicAdditionalLibraries.Add(Path.Combine(SDKPath, BuildLocation, "pubnub.lib"));

}
else if(Target.Platform == UnrealTargetPlatform.Mac)
{
PublicDelayLoadDLLs.Add(Path.Combine(SDKPath, "lib", "macos", "libpubnub.dylib"));
RuntimeDependencies.Add("$(PluginDir)/Source/ThirdParty/sdk/lib/macos/libpubnub.dylib");
}

string PlatformLib = "openssl";


PublicAdditionalLibraries.Add(Path.Combine(SDKPath, buildLocation, binary));
PublicIncludePaths.AddRange(
new string[] {
SDKPath,
Expand Down

0 comments on commit ce8d717

Please sign in to comment.