2019-12-26 23:01:54 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2016-06-29 18:00:01 -04:00
2018-01-20 11:19:29 -05:00
# include "ToolModes/MergeManifestMode.h"
2016-11-23 15:48:37 -05:00
# include "Interfaces/IBuildPatchServicesModule.h"
# include "BuildPatchTool.h"
# include "Misc/CommandLine.h"
# include "Misc/Paths.h"
2016-06-29 18:00:01 -04:00
using namespace BuildPatchTool ;
class FMergeManifestToolMode : public IToolMode
{
public :
2017-06-19 20:27:30 -04:00
FMergeManifestToolMode ( IBuildPatchServicesModule & InBpsInterface )
2016-06-29 18:00:01 -04:00
: BpsInterface ( InBpsInterface )
{ }
virtual ~ FMergeManifestToolMode ( )
{ }
virtual EReturnCode Execute ( ) override
{
// Parse commandline
if ( ProcessCommandline ( ) = = false )
{
return EReturnCode : : ArgumentProcessingError ;
}
// Print help if requested
if ( bHelp )
{
2018-09-25 10:11:35 -04:00
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " MERGE MANIFEST MODE " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " This tool supports generating a hotfix manifest from two existing manifest files. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " Required arguments: " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " -mode=MergeManifests Must be specified to launch the tool in merge manifests mode. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " -ManifestA= \" \" Specifies in quotes the file path to the base manifest. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " -ManifestB= \" \" Specifies in quotes the file path to the update manifest. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " -ManifestC= \" \" Specifies in quotes the file path to the output manifest. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " -BuildVersion= \" \" Specifies in quotes the new version string for the build being produced. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " Optional arguments: " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " -MergeFileList= \" \" Specifies in quotes, the path to a text file containing complete list of desired build root relative files followed by \\ t character, followed by A or B to select the manifest to pull from. These should be seperated by \\ r \\ n line endings. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " NB: If -MergeFileList is not specified, then union of all files will be selected, preferring ManifestB's version. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " NB: With the exception of the new version string for the build, all meta will be copied from only ManifestB. " ) ) ;
UE_LOG ( LogBuildPatchTool , Display , TEXT ( " " ) ) ;
2016-06-29 18:00:01 -04:00
return EReturnCode : : OK ;
}
// Run the merge manifest routine
2017-06-19 20:27:30 -04:00
bool bSuccess = BpsInterface . MergeManifests ( ManifestA , ManifestB , ManifestC , BuildVersion , MergeFileList ) ;
2016-06-29 18:00:01 -04:00
return bSuccess ? EReturnCode : : OK : EReturnCode : : ToolFailure ;
}
private :
bool ProcessCommandline ( )
{
2019-09-13 13:24:23 -04:00
# define PARSE_SWITCH(Switch) ParseSwitch(TEXT(#Switch "="), Switch, Switches)
2016-06-29 18:00:01 -04:00
TArray < FString > Tokens , Switches ;
FCommandLine : : Parse ( FCommandLine : : Get ( ) , Tokens , Switches ) ;
bHelp = ParseOption ( TEXT ( " help " ) , Switches ) ;
if ( bHelp )
{
return true ;
}
// Get all required parameters
if ( ! ( PARSE_SWITCH ( ManifestA )
& & PARSE_SWITCH ( ManifestB )
& & PARSE_SWITCH ( ManifestC )
& & PARSE_SWITCH ( BuildVersion ) ) )
{
UE_LOG ( LogBuildPatchTool , Error , TEXT ( " ManifestA, ManifestB, ManifestC, and BuildVersion are required parameters " ) ) ;
return false ;
}
2019-01-08 11:38:48 -05:00
NormalizeUriFile ( ManifestA ) ;
NormalizeUriFile ( ManifestB ) ;
NormalizeUriFile ( ManifestC ) ;
2016-06-29 18:00:01 -04:00
// Optional list to pick specific files, otherwise it is A stomped by B
PARSE_SWITCH ( MergeFileList ) ;
2019-01-08 11:38:48 -05:00
NormalizeUriFile ( MergeFileList ) ;
2016-06-29 18:00:01 -04:00
return true ;
# undef PARSE_SWITCH
}
private :
2017-06-19 20:27:30 -04:00
IBuildPatchServicesModule & BpsInterface ;
2016-06-29 18:00:01 -04:00
bool bHelp ;
FString ManifestA ;
FString ManifestB ;
FString ManifestC ;
FString BuildVersion ;
FString MergeFileList ;
} ;
2017-06-19 20:27:30 -04:00
BuildPatchTool : : IToolModeRef BuildPatchTool : : FMergeManifestToolModeFactory : : Create ( IBuildPatchServicesModule & BpsInterface )
2016-06-29 18:00:01 -04:00
{
return MakeShareable ( new FMergeManifestToolMode ( BpsInterface ) ) ;
}