Files
UnrealEngineUWP/Engine/Source/Developer/TargetPlatform/Private/InstalledPlatformInfo.cpp
Ben Marsh c254db71a7 Copying //UE4/Dev-Build to //UE4/Main (Source: //UE4/Dev-Build @ 2944521)
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2909886 on 2016/03/15 by Matthew.Griffin

	Adding a build exception to give a message instead of crashing when trying to generate all project files from an installed build.

Change 2911727 on 2016/03/16 by Matthew.Griffin

	Added Platform Type and Architecture to Installed Platform Info
	Reworked the different IsValid... functions to use lamdas to reduce duplicated code looping and checking receipts
	Moved the code to write config file entries into InstalledPlatformInfo so that it can be reused by anyone wanting to make installed builds
	Added temporary hack to write Android architecture until I can get it from build process

Change 2913692 on 2016/03/17 by Ben.Marsh

	UAT: Move script to archive a build for UGS into a public folder.

Change 2915445 on 2016/03/18 by Ben.Marsh

	UAT: Reduce the number of redundant log warnings/errors after a reported build failure, and simplify calls to ParallelExecutor which don't need retrying.

Change 2915450 on 2016/03/18 by Ben.Marsh

	UAT: Suppress warning messages trying to kill child processes if the operation failed because it's already exited.

Change 2925830 on 2016/03/29 by Matthew.Griffin

	Added new selective download tags
	Added a test for whether installed platforms are missing required files so that we can try to open the launcher to the installer settings

Change 2926437 on 2016/03/29 by Ben.Marsh

	PR #2210: Fix "Rebuild.bat" for paths with parentheses (Contributed by amcofi)

Change 2927399 on 2016/03/30 by Matthew.Griffin

	Updating use of PDBCopy to look in VS2015 folder and fall back to VS2013 version if it doesn't exist.

Change 2933093 on 2016/04/05 by Ben.Marsh

	PR #2232: Updated copyright text to 2016 (Contributed by erikbye)

Change 2936221 on 2016/04/07 by Matthew.Griffin

	Adding checks on architecture for android config options

Change 2938021 on 2016/04/08 by Ben.Marsh

	UAT: Prevent UnauthorizedAccessException when enumerating crash files on Mac from a restricted user account.

Change 2939332 on 2016/04/11 by Matthew.Griffin

	Added AdditionalBundleResources to external file list so that they should be included in Launcher releases

Change 2939767 on 2016/04/11 by Ben.Marsh

	BuildGraph: Add a -preprocess option, which will cause the preprocessed and culled graph out to an XML file for debugging.

Change 2941611 on 2016/04/12 by Ben.Marsh

	UAT: Prevent warning about commands requiring P4 if -p4 is specified on the command line.

Change 2942037 on 2016/04/13 by Ben.Marsh

	UBT: Only print 'Detailed Action Stats' message footer if there were any detailed action stats.

Change 2942640 on 2016/04/13 by Ben.Marsh

	GUBP: Trigger GitHub promotions by triggering a new procedure rather than scanning for labels.

Change 2942728 on 2016/04/13 by Ben.Marsh

	BuildGraph: Rename "AgentGroup" to "Agent" for consistency with XML.

Change 2942735 on 2016/04/13 by Ben.Marsh

	BuildGraph: Few renames to match class names (Build.cs -> BuildGraph.cs, AgentGroup.cs -> Agent.cs)

Change 2943568 on 2016/04/14 by Ben.Marsh

	EC: Print out the log folder at the start of each job.

Change 2944421 on 2016/04/14 by Ben.Marsh

	EC: Add GitHub dashboard page which shows the current syncing state

#lockdown Nick.Penwarden

[CL 2944733 by Ben Marsh in Main branch]
2016-04-14 20:35:31 -04:00

256 lines
8.1 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "TargetPlatformPrivatePCH.h"
#include "InstalledPlatformInfo.h"
#include "PlatformInfo.h"
#include "DesktopPlatformModule.h"
#define LOCTEXT_NAMESPACE "InstalledPlatformInfo"
DEFINE_LOG_CATEGORY_STATIC(LogInstalledPlatforms, Log, All);
EProjectType EProjectTypeFromString(const FString& ProjectTypeName)
{
if (FCString::Strcmp(*ProjectTypeName, TEXT("Any")) == 0)
{
return EProjectType::Any;
}
else if (FCString::Strcmp(*ProjectTypeName, TEXT("Code")) == 0)
{
return EProjectType::Code;
}
else if (FCString::Strcmp(*ProjectTypeName, TEXT("Content")) == 0)
{
return EProjectType::Content;
}
else
{
return EProjectType::Unknown;
}
}
FInstalledPlatformInfo::FInstalledPlatformInfo()
{
TArray<FString> InstalledPlatforms;
GConfig->GetArray(TEXT("InstalledPlatforms"), TEXT("InstalledPlatformConfigurations"), InstalledPlatforms, GEngineIni);
for (FString& InstalledPlatform : InstalledPlatforms)
{
ParsePlatformConfiguration(InstalledPlatform);
}
}
void FInstalledPlatformInfo::ParsePlatformConfiguration(FString PlatformConfiguration)
{
// Trim whitespace at the beginning.
PlatformConfiguration = PlatformConfiguration.Trim();
// Remove brackets.
PlatformConfiguration.RemoveFromStart(TEXT("("));
PlatformConfiguration.RemoveFromEnd(TEXT(")"));
bool bCanCreateEntry = true;
FString ConfigurationName;
EBuildConfigurations::Type Configuration = EBuildConfigurations::Unknown;
if (FParse::Value(*PlatformConfiguration, TEXT("Configuration="), ConfigurationName))
{
Configuration = EBuildConfigurations::FromString(ConfigurationName);
}
if (Configuration == EBuildConfigurations::Unknown)
{
UE_LOG(LogInstalledPlatforms, Warning, TEXT("Unable to read configuration from %s"), *PlatformConfiguration);
bCanCreateEntry = false;
}
FString PlatformName;
if (!FParse::Value(*PlatformConfiguration, TEXT("PlatformName="), PlatformName))
{
UE_LOG(LogInstalledPlatforms, Warning, TEXT("Unable to read platform from %s"), *PlatformConfiguration);
bCanCreateEntry = false;
}
FString PlatformTypeName;
PlatformInfo::EPlatformType PlatformType = PlatformInfo::EPlatformType::Game;
if (FParse::Value(*PlatformConfiguration, TEXT("PlatformType="), PlatformTypeName))
{
PlatformType = PlatformInfo::EPlatformTypeFromString(PlatformTypeName);
}
FString Architecture;
FParse::Value(*PlatformConfiguration, TEXT("Architecture="), Architecture);
FString RequiredFile;
if (FParse::Value(*PlatformConfiguration, TEXT("RequiredFile="), RequiredFile))
{
RequiredFile = FPaths::Combine(*FPaths::RootDir(), *RequiredFile);
}
FString ProjectTypeName;
EProjectType ProjectType = EProjectType::Any;
if (FParse::Value(*PlatformConfiguration, TEXT("ProjectType="), ProjectTypeName))
{
ProjectType = EProjectTypeFromString(ProjectTypeName);
}
if (ProjectType == EProjectType::Unknown)
{
UE_LOG(LogInstalledPlatforms, Warning, TEXT("Unable to read project type from %s"), *PlatformConfiguration);
bCanCreateEntry = false;
}
bool bCanBeDisplayed = false;
FParse::Bool(*PlatformConfiguration, TEXT("bCanBeDisplayed="), bCanBeDisplayed);
if (bCanCreateEntry)
{
FInstalledPlatformConfiguration NewConfig = {Configuration, PlatformName, PlatformType, Architecture, RequiredFile, ProjectType, bCanBeDisplayed};
InstalledPlatformConfigurations.Add(NewConfig);
}
}
bool FInstalledPlatformInfo::IsValidConfiguration(const EBuildConfigurations::Type Configuration, EProjectType ProjectType) const
{
return ContainsValidConfiguration(
[Configuration, ProjectType](const FInstalledPlatformConfiguration& CurConfig)
{
return CurConfig.Configuration == Configuration
&& (ProjectType == EProjectType::Any || CurConfig.ProjectType == EProjectType::Any
|| CurConfig.ProjectType == ProjectType);
}
);
}
bool FInstalledPlatformInfo::IsValidPlatform(const FString& PlatformName, EProjectType ProjectType) const
{
return ContainsValidConfiguration(
[PlatformName, ProjectType](const FInstalledPlatformConfiguration& CurConfig)
{
return CurConfig.PlatformName == PlatformName
&& (ProjectType == EProjectType::Any || CurConfig.ProjectType == EProjectType::Any
|| CurConfig.ProjectType == ProjectType);
}
);
}
bool FInstalledPlatformInfo::IsValidPlatformAndConfiguration(const EBuildConfigurations::Type Configuration, const FString& PlatformName, EProjectType ProjectType) const
{
return ContainsValidConfiguration(
[Configuration, PlatformName, ProjectType](const FInstalledPlatformConfiguration& CurConfig)
{
return CurConfig.Configuration == Configuration
&& CurConfig.PlatformName == PlatformName
&& (ProjectType == EProjectType::Any || CurConfig.ProjectType == EProjectType::Any
|| CurConfig.ProjectType == ProjectType);
}
);
}
bool FInstalledPlatformInfo::CanDisplayPlatform(const FString& PlatformName, EProjectType ProjectType) const
{
return ContainsMatchingConfiguration(
[PlatformName, ProjectType](const FInstalledPlatformConfiguration& CurConfig)
{
return CurConfig.PlatformName == PlatformName && (CurConfig.bCanBeDisplayed
|| ProjectType == EProjectType::Any || CurConfig.ProjectType == EProjectType::Any
|| CurConfig.ProjectType == ProjectType);
}
);
}
bool FInstalledPlatformInfo::IsValidPlatformType(PlatformInfo::EPlatformType PlatformType) const
{
return ContainsValidConfiguration(
[PlatformType](const FInstalledPlatformConfiguration& CurConfig)
{
return CurConfig.PlatformType == PlatformType;
}
);
}
bool FInstalledPlatformInfo::IsValidPlatformArchitecture(const FString& PlatformName, const FString& Architecture) const
{
return ContainsValidConfiguration(
[PlatformName, Architecture](const FInstalledPlatformConfiguration& CurConfig)
{
return CurConfig.PlatformName == PlatformName && CurConfig.Architecture.Contains(Architecture);
}
);
}
bool FInstalledPlatformInfo::IsPlatformMissingRequiredFile(const FString& PlatformName) const
{
if (FApp::IsEngineInstalled())
{
return ContainsMatchingConfiguration(
[PlatformName](const FInstalledPlatformConfiguration& CurConfig)
{
return CurConfig.PlatformName == PlatformName
&& !CurConfig.RequiredFile.IsEmpty()
&& !FPaths::FileExists(CurConfig.RequiredFile);
}
);
}
return false;
}
bool FInstalledPlatformInfo::OpenInstallerOptions()
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform != nullptr)
{
FString CurrentIdentifier = DesktopPlatform->GetCurrentEngineIdentifier();
if (DesktopPlatform->IsStockEngineRelease(CurrentIdentifier))
{
if (FMessageDialog::Open(EAppMsgType::YesNo, LOCTEXT("NotInstalled_SelectedPlatform", "The Binaries for this Target Platform are not currently installed, would you like to use the Launcher to download them?")) == EAppReturnType::Yes)
{
// TODO: Ensure that this URL opens the launcher correctly before this is included in a release
FString InstallerURL = FString::Printf(TEXT("ue/library/engines/UE_%s/installer"), *DesktopPlatform->GetEngineDescription(CurrentIdentifier));
FOpenLauncherOptions OpenOptions(InstallerURL);
if (DesktopPlatform->OpenLauncher(OpenOptions))
{
return true;
}
}
}
}
return false;
}
bool FInstalledPlatformInfo::ContainsValidConfiguration(TFunctionRef<bool(const FInstalledPlatformConfiguration)> ConfigFilter) const
{
if (FApp::IsEngineInstalled())
{
for (const FInstalledPlatformConfiguration& PlatformConfiguration : InstalledPlatformConfigurations)
{
// Check whether filter accepts this configuration and it has required file
if (ConfigFilter(PlatformConfiguration)
&& (PlatformConfiguration.RequiredFile.IsEmpty()
|| FPaths::FileExists(PlatformConfiguration.RequiredFile)))
{
return true;
}
}
return false;
}
return true;
}
bool FInstalledPlatformInfo::ContainsMatchingConfiguration(TFunctionRef<bool(const FInstalledPlatformConfiguration)> ConfigFilter) const
{
if (FApp::IsEngineInstalled())
{
for (const FInstalledPlatformConfiguration& PlatformConfiguration : InstalledPlatformConfigurations)
{
// Check whether filter accepts this configuration
if (ConfigFilter(PlatformConfiguration))
{
return true;
}
}
return false;
}
return true;
}
#undef LOCTEXT_NAMESPACE