You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb trivial #jira UE-151641 #rnx #preflight 64103cb1c41a0a2a770c96a4 - Although we now relaunch the tool with the correct project path (if not supplied) this was not enough to allow us to load the projects config files and so set up the DDC and source control etc properly. My original testing was picking up hacks in the programs config file that was allowing it to work. - FGenericPlatformMisc::ProjectDir has a bespoke path for standalone programs which means even if the uproject is on the cmdline it is ignored. - We probably should look into a way for a project to mark itself as being "project aware" but for now we can make use of the project path override system to make sure it is set correctly, which will fix the problem for now. [CL 24631824 by paul chipchase in ue5-main branch]
93 lines
2.9 KiB
C++
93 lines
2.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "UnrealVirtualizationTool.h"
|
|
|
|
#include "Modules/ModuleManager.h"
|
|
#include "RequiredProgramMainCPPInclude.h"
|
|
#include "UnrealVirtualizationToolApp.h"
|
|
|
|
IMPLEMENT_APPLICATION(UnrealVirtualizationTool, "UnrealVirtualizationTool");
|
|
|
|
DEFINE_LOG_CATEGORY(LogVirtualizationTool);
|
|
|
|
bool UnrealVirtualizationToolMain(int32 ArgC, TCHAR* ArgV[])
|
|
{
|
|
using namespace UE::Virtualization;
|
|
|
|
// Although standalone tools can set the project path via the cmdline this will not change the ProjectDir being
|
|
// used as standalone tools have a beespoke path in FGenericPlatformMisc::ProjectDir. We can work around this
|
|
// for now by doing our own parsing then using the project dir override feature.
|
|
// This is a band aid while we consider adding better support for project files/directories with stand alone tools.
|
|
if(ArgC >= 2)
|
|
{
|
|
FString Cmd(ArgV[1]);
|
|
|
|
if (!Cmd.IsEmpty() && !Cmd.StartsWith(TEXT("-")) && Cmd.EndsWith(FProjectDescriptor::GetExtension()))
|
|
{
|
|
FString ProjectDir = FPaths::GetPath(Cmd);
|
|
ProjectDir = FFileManagerGeneric::DefaultConvertToRelativePath(*ProjectDir);
|
|
|
|
// The path should end with a trailing slash (see FGenericPlatformMisc::ProjectDir) so we use
|
|
// NormalizeFilename not NormalizeDirectoryName as the latter will remove trailing slashes. We
|
|
// also need to add one if it is missing.
|
|
// We probably should move this path fixup code to 'FPlatformMisc::SetOverrideProjectDir'
|
|
FPaths::NormalizeFilename(ProjectDir);
|
|
if (!ProjectDir.EndsWith(TEXT("/")))
|
|
{
|
|
ProjectDir += TEXT("/");
|
|
}
|
|
|
|
FPlatformMisc::SetOverrideProjectDir(ProjectDir);
|
|
}
|
|
}
|
|
|
|
GEngineLoop.PreInit(ArgC, ArgV);
|
|
check(GConfig && GConfig->IsReadyForUse());
|
|
|
|
#if 0
|
|
while (!FPlatformMisc::IsDebuggerPresent())
|
|
{
|
|
FPlatformProcess::SleepNoStats(0.0f);
|
|
}
|
|
|
|
PLATFORM_BREAK();
|
|
#endif
|
|
|
|
FModuleManager::Get().StartProcessingNewlyLoadedObjects();
|
|
|
|
bool bRanSuccessfully = true;
|
|
|
|
FUnrealVirtualizationToolApp App;
|
|
|
|
EInitResult Result = App.Initialize();
|
|
if (Result == EInitResult::Success)
|
|
{
|
|
if (!App.Run())
|
|
{
|
|
UE_LOG(LogVirtualizationTool, Error, TEXT("UnrealVirtualizationTool ran with errors"));
|
|
bRanSuccessfully = false;
|
|
}
|
|
}
|
|
else if(Result == EInitResult::Error)
|
|
{
|
|
UE_LOG(LogVirtualizationTool, Error, TEXT("UnrealVirtualizationTool failed to initialize"));
|
|
bRanSuccessfully = false;
|
|
}
|
|
|
|
UE_CLOG(bRanSuccessfully, LogVirtualizationTool, Display, TEXT("UnrealVirtualizationTool ran successfully"));
|
|
|
|
// Even though we are exiting anyway we need to request an engine exit in order to get a clean shutdown
|
|
RequestEngineExit(TEXT("The process has finished"));
|
|
|
|
FEngineLoop::AppPreExit();
|
|
FModuleManager::Get().UnloadModulesAtShutdown();
|
|
FEngineLoop::AppExit();
|
|
|
|
return bRanSuccessfully;
|
|
}
|
|
|
|
INT32_MAIN_INT32_ARGC_TCHAR_ARGV()
|
|
{
|
|
FTaskTagScope Scope(ETaskTag::EGameThread);
|
|
return UnrealVirtualizationToolMain(ArgC, ArgV) ? 0 : 1;
|
|
} |