Files
UnrealEngineUWP/Engine/Source/Developer/Linux/LinuxTargetPlatform/Private/LinuxTargetPlatformModule.cpp
josh adams 3d282bf6e7 - Added early check before creating a TargetPlatform object if the PlatformInfo will be found (check a static function to see if it's usable before making it)
- Changed each platform's GetTargetPlatform[s] function
#rb none
#jira UE-78692
[FYI] bob.tellez


#ROBOMERGE-SOURCE: CL 7952099 via CL 7954770
#ROBOMERGE-BOT: (v393-7951996)

[CL 7954968 by josh adams in Main branch]
2019-08-12 18:12:07 -04:00

109 lines
2.5 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "UObject/Package.h"
#include "UObject/WeakObjectPtr.h"
#include "Interfaces/ITargetPlatformModule.h"
#include "LinuxTargetSettings.h"
#include "LinuxTargetDevice.h"
#include "LinuxTargetPlatform.h"
#include "ISettingsModule.h"
#define LOCTEXT_NAMESPACE "FLinuxTargetPlatformModule"
/**
* Holds the target platform singleton.
*/
static ITargetPlatform* Singleton = NULL;
/**
* Module for the Android target platform.
*/
class FLinuxTargetPlatformModule
: public ITargetPlatformModule
{
public:
/** Destructor. */
~FLinuxTargetPlatformModule( )
{
Singleton = NULL;
}
public:
// ITargetPlatformModule interface
virtual ITargetPlatform* GetTargetPlatform( ) override
{
if (Singleton == NULL && TLinuxTargetPlatform<FLinuxPlatformProperties<true, false, false> >::IsUsable())
{
Singleton = new TLinuxTargetPlatform<FLinuxPlatformProperties<true, false, false> >();
}
return Singleton;
}
public:
// IModuleInterface interface
virtual void StartupModule() override
{
TargetSettings = NewObject<ULinuxTargetSettings>(GetTransientPackage(), "LinuxTargetSettings", RF_Standalone);
// We need to manually load the config properties here, as this module is loaded before the UObject system is setup to do this
GConfig->GetArray(TEXT("/Script/LinuxTargetPlatform.LinuxTargetSettings"), TEXT("TargetedRHIs"), TargetSettings->TargetedRHIs, GEngineIni);
TargetSettings->AddToRoot();
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
{
SettingsModule->RegisterSettings("Project", "Platforms", "Linux",
LOCTEXT("TargetSettingsName", "Linux"),
LOCTEXT("TargetSettingsDescription", "Settings for Linux target platform"),
TargetSettings
);
}
}
virtual void ShutdownModule() override
{
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
{
SettingsModule->UnregisterSettings("Project", "Platforms", "Linux");
}
if (!GExitPurge)
{
// If we're in exit purge, this object has already been destroyed
TargetSettings->RemoveFromRoot();
}
else
{
TargetSettings = NULL;
}
}
private:
/** Holds the target settings. */
ULinuxTargetSettings* TargetSettings;
};
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE( FLinuxTargetPlatformModule, LinuxTargetPlatform);