Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Private/Commandlets/GenerateGatherManifestCommandlet.cpp
ryan durand 627baf970a Updating copyright for Engine Editor.
#rnx
#rb none


#ROBOMERGE-SOURCE: CL 10869241 via CL 10869527 via CL 10869904
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870586 by ryan durand in Main branch]
2019-12-26 15:33:43 -05:00

95 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Commandlets/GenerateGatherManifestCommandlet.h"
#include "Misc/Paths.h"
DEFINE_LOG_CATEGORY_STATIC(LogGenerateManifestCommandlet, Log, All);
/**
* UGenerateGatherManifestCommandlet
*/
UGenerateGatherManifestCommandlet::UGenerateGatherManifestCommandlet(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
int32 UGenerateGatherManifestCommandlet::Main( const FString& Params )
{
// Parse command line - we're interested in the param vals
TArray<FString> Tokens;
TArray<FString> Switches;
TMap<FString, FString> ParamVals;
UCommandlet::ParseCommandLine( *Params, Tokens, Switches, ParamVals );
// Set config file.
const FString* ParamVal = ParamVals.Find( FString( TEXT("Config") ) );
FString GatherTextConfigPath;
if ( ParamVal )
{
GatherTextConfigPath = *ParamVal;
}
else
{
UE_LOG( LogGenerateManifestCommandlet, Error, TEXT("No config specified.") );
return -1;
}
// Set config section.
ParamVal = ParamVals.Find( FString( TEXT("Section") ) );
FString SectionName;
if ( ParamVal )
{
SectionName = *ParamVal;
}
else
{
UE_LOG( LogGenerateManifestCommandlet, Error, TEXT("No config section specified.") );
return -1;
}
// Get destination path.
FString DestinationPath;
if( !GetPathFromConfig( *SectionName, TEXT("DestinationPath"), DestinationPath, GatherTextConfigPath ) )
{
UE_LOG( LogGenerateManifestCommandlet, Error, TEXT("No destination path specified.") );
return -1;
}
// Get manifest name.
FString ManifestName;
if( !GetStringFromConfig( *SectionName, TEXT("ManifestName"), ManifestName, GatherTextConfigPath ) )
{
UE_LOG( LogGenerateManifestCommandlet, Error, TEXT("No manifest name specified.") );
return -1;
}
//Grab any manifest dependencies
TArray<FString> ManifestDependenciesList;
GetPathArrayFromConfig(*SectionName, TEXT("ManifestDependencies"), ManifestDependenciesList, GatherTextConfigPath);
for (const FString& ManifestDependency : ManifestDependenciesList)
{
FText OutError;
if (!GatherManifestHelper->AddDependency(ManifestDependency, &OutError))
{
UE_LOG(LogGenerateManifestCommandlet, Error, TEXT("Failed to add a manifest dependency: %s"), *OutError.ToString());
return -1;
}
}
// Trim the manifest to remove any entries that came from a dependency
GatherManifestHelper->TrimManifest();
const FString ManifestPath = FPaths::ConvertRelativePathToFull(DestinationPath) / ManifestName;
FText ManifestSaveError;
if (!GatherManifestHelper->SaveManifest(ManifestPath, &ManifestSaveError))
{
UE_LOG(LogGenerateManifestCommandlet, Error, TEXT("%s"), *ManifestSaveError.ToString());
return -1;
}
return 0;
}