-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Unreal] Fix for Shipping Builds (#112)
* Changes to allow plugin to work in Shipping Builds * Add files via upload SourceTree is case-insensitive on Windows, fixin * Remove duplicated directory * Platform whitelist, mac support, compilation fix. * Finalization steps * Mac fix * Tabs/Spaces consistency. * Updated build.py #89 * .gitignore (headers) * Renamed folder to lowercase * Removed duplicates * Revert to lowercase
- Loading branch information
Showing
14 changed files
with
229 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
examples/unrealstatus/Plugins/discordrpc/Source/DiscordRpc/DiscordRpc.Build.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. | ||
|
||
using UnrealBuildTool; | ||
using System.IO; | ||
|
||
public class DiscordRpc : ModuleRules | ||
{ | ||
#if WITH_FORWARDED_MODULE_RULES_CTOR | ||
public DiscordRpc(ReadOnlyTargetRules Target) : base(Target) | ||
#else | ||
public DiscordRpc(TargetInfo Target) | ||
#endif | ||
{ | ||
Definitions.Add("DISCORD_DYNAMIC_LIB=1"); | ||
|
||
PublicIncludePaths.AddRange( | ||
new string[] { | ||
"DiscordRpc/Public" | ||
} | ||
); | ||
|
||
PrivateIncludePaths.AddRange( | ||
new string[] { | ||
"DiscordRpc/Private" | ||
} | ||
); | ||
|
||
PublicDependencyModuleNames.AddRange( | ||
new string[] | ||
{ | ||
"Core", | ||
"DiscordRpcLibrary" | ||
} | ||
); | ||
|
||
PrivateDependencyModuleNames.AddRange( | ||
new string[] | ||
{ | ||
"CoreUObject", | ||
"Engine", | ||
"Slate", | ||
"SlateCore", | ||
"Projects" | ||
} | ||
); | ||
|
||
DynamicallyLoadedModuleNames.AddRange( | ||
new string[] | ||
{ | ||
// ... add any modules that your module loads dynamically here ... | ||
} | ||
); | ||
|
||
string BaseDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "Source", "ThirdParty", "DiscordRpcLibrary")); | ||
PublicIncludePaths.Add(Path.Combine(BaseDirectory, "Include")); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
examples/unrealstatus/Plugins/discordrpc/Source/DiscordRpc/Private/DiscordRpc.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. | ||
|
||
#include "DiscordRpcPrivatePCH.h" | ||
#include "IPluginManager.h" | ||
#include "ModuleManager.h" | ||
|
||
#define LOCTEXT_NAMESPACE "FDiscordRpcModule" | ||
|
||
void FDiscordRpcModule::StartupModule() | ||
{ | ||
#if !PLATFORM_LINUX | ||
#if defined(DISCORD_DYNAMIC_LIB) | ||
// Get the base directory of this plugin | ||
FString BaseDir = IPluginManager::Get().FindPlugin("DiscordRpc")->GetBaseDir(); | ||
const FString SDKDir = FPaths::Combine(*BaseDir, TEXT("Source"), TEXT("ThirdParty"), TEXT("DiscordRpcLibrary")); | ||
#if PLATFORM_WINDOWS | ||
const FString LibName = TEXT("discord-rpc"); | ||
const FString LibDir = FPaths::Combine(*SDKDir, TEXT("Win64")); | ||
if (!LoadDependency(LibDir, LibName, DiscordRpcLibraryHandle)) { | ||
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT(LOCTEXT_NAMESPACE, "Failed to load DiscordRpc plugin. Plug-in will not be functional.")); | ||
FreeDependency(DiscordRpcLibraryHandle); | ||
} | ||
#elif PLATFORM_MAC | ||
const FString LibName = TEXT("libdiscord-rpc"); | ||
const FString LibDir = FPaths::Combine(*SDKDir, TEXT("Mac")); | ||
if (!LoadDependency(LibDir, LibName, DiscordRpcLibraryHandle)) { | ||
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT(LOCTEXT_NAMESPACE, "Failed to load DiscordRpc plugin. Plug-in will not be functional.")); | ||
FreeDependency(DiscordRpcLibraryHandle); | ||
} | ||
#endif | ||
#endif | ||
#endif | ||
} | ||
|
||
void FDiscordRpcModule::ShutdownModule() | ||
{ | ||
// Free the dll handle | ||
#if !PLATFORM_LINUX | ||
#if defined(DISCORD_DYNAMIC_LIB) | ||
FreeDependency(DiscordRpcLibraryHandle); | ||
#endif | ||
#endif | ||
} | ||
|
||
bool FDiscordRpcModule::LoadDependency(const FString& Dir, const FString& Name, void*& Handle) | ||
{ | ||
FString Lib = Name + TEXT(".") + FPlatformProcess::GetModuleExtension(); | ||
FString Path = Dir.IsEmpty() ? *Lib : FPaths::Combine(*Dir, *Lib); | ||
|
||
Handle = FPlatformProcess::GetDllHandle(*Path); | ||
|
||
if (Handle == nullptr) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void FDiscordRpcModule::FreeDependency(void*& Handle) | ||
{ | ||
if (Handle != nullptr) | ||
{ | ||
FPlatformProcess::FreeDllHandle(Handle); | ||
Handle = nullptr; | ||
} | ||
} | ||
|
||
#undef LOCTEXT_NAMESPACE | ||
|
||
IMPLEMENT_MODULE(FDiscordRpcModule, DiscordRpc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/unrealstatus/Plugins/discordrpc/Source/DiscordRpc/Private/DiscordRpcPrivatePCH.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "Core.h" | ||
#include "DiscordRpc.h" |
20 changes: 20 additions & 0 deletions
20
examples/unrealstatus/Plugins/discordrpc/Source/DiscordRpc/Public/DiscordRpc.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "ModuleManager.h" | ||
|
||
class FDiscordRpcModule : public IModuleInterface { | ||
public: | ||
/** IModuleInterface implementation */ | ||
virtual void StartupModule() override; | ||
virtual void ShutdownModule() override; | ||
|
||
private: | ||
/** Handle to the test dll we will load */ | ||
void* DiscordRpcLibraryHandle; | ||
|
||
/** StartupModule is covered with defines, these functions are the place to put breakpoints */ | ||
static bool LoadDependency(const FString& Dir, const FString& Name, void*& Handle); | ||
static void FreeDependency(void*& Handle); | ||
}; |
2 changes: 0 additions & 2 deletions
2
...e/discordrpc/Public/DiscordRpcBlueprint.h → ...e/DiscordRpc/Public/DiscordRpcBlueprint.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
|
59 changes: 59 additions & 0 deletions
59
...lstatus/Plugins/discordrpc/Source/ThirdParty/DiscordRpcLibrary/DiscordRpcLibrary.Build.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
using System.IO; | ||
using UnrealBuildTool; | ||
|
||
public class DiscordRpcLibrary : ModuleRules | ||
{ | ||
#if WITH_FORWARDED_MODULE_RULES_CTOR | ||
public DiscordRpcLibrary(ReadOnlyTargetRules Target) : base(Target) | ||
#else | ||
public DiscordRpcLibrary(TargetInfo Target) | ||
#endif | ||
{ | ||
Type = ModuleType.External; | ||
Definitions.Add("DISCORD_DYNAMIC_LIB=1"); | ||
|
||
string BaseDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "ThirdParty", "DiscordRpcLibrary")); | ||
|
||
if (Target.Platform == UnrealTargetPlatform.Win64) | ||
{ | ||
string lib = Path.Combine(BaseDirectory, "Win64"); | ||
|
||
// Include headers | ||
PublicIncludePaths.Add(Path.Combine(BaseDirectory, "Include")); | ||
|
||
// Add the import library | ||
PublicLibraryPaths.Add(lib); | ||
PublicAdditionalLibraries.Add(Path.Combine(lib, "discord-rpc.lib")); | ||
|
||
// Dynamic | ||
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(lib, "discord-rpc.dll"))); | ||
PublicDelayLoadDLLs.Add("discord-rpc.dll"); | ||
} | ||
else if (Target.Platform == UnrealTargetPlatform.Linux) | ||
{ | ||
string lib = Path.Combine(BaseDirectory, "Linux", "x86_64-unknown-linux-gnu"); | ||
|
||
// Include headers | ||
PublicIncludePaths.Add(Path.Combine(BaseDirectory, "Include")); | ||
|
||
// Add the import library | ||
PublicLibraryPaths.Add(lib); | ||
PublicAdditionalLibraries.Add(Path.Combine(lib, "libdiscord-rpc.so")); | ||
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(lib, "libdiscord-rpc.so"))); | ||
} | ||
else if (Target.Platform == UnrealTargetPlatform.Mac) | ||
{ | ||
string lib = Path.Combine(BaseDirectory, "Mac"); | ||
|
||
// Include headers | ||
PublicIncludePaths.Add(Path.Combine(BaseDirectory, "Include")); | ||
|
||
// Add the import library | ||
PublicLibraryPaths.Add(lib); | ||
PublicAdditionalLibraries.Add(Path.Combine(lib, "libdiscord-rpc.dylib")); | ||
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(lib, "libdiscord-rpc.dylib"))); | ||
} | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
...lstatus/Plugins/discordrpc/Source/ThirdParty/discordrpcLibrary/discordrpcLibrary.Build.cs
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.