2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
/*=============================================================================
CookCommandlet . cpp : Commandlet for cooking content
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
# pragma once
2014-05-29 17:11:10 -04:00
# include "Commandlets/Commandlet.h"
2014-03-14 14:13:41 -04:00
# include "CookCommandlet.generated.h"
2014-08-28 16:05:15 -04:00
UCLASS ( config = Editor )
2014-03-14 14:13:41 -04:00
class UCookCommandlet
: public UCommandlet
{
2015-03-17 06:17:32 -04:00
GENERATED_UCLASS_BODY ( )
2014-03-14 14:13:41 -04:00
2014-08-28 16:05:15 -04:00
/** List of asset types that will force GC after loading them during cook */
UPROPERTY ( config )
TArray < FString > FullGCAssetClassNames ;
2014-03-14 14:13:41 -04:00
/** If true, iterative cooking is being done */
bool bIterativeCooking ;
/** If true, packages are cooked compressed */
bool bCompressed ;
/** Prototype cook-on-the-fly server */
bool bCookOnTheFly ;
/** Cook everything */
bool bCookAll ;
/** Skip saving any packages in Engine/COntent/Editor* UNLESS TARGET HAS EDITORONLY DATA (in which case it will save those anyway) */
bool bSkipEditorContent ;
/** Test for UObject leaks */
bool bLeakTest ;
/** Save all cooked packages without versions. These are then assumed to be current version on load. This is dangerous but results in smaller patch sizes. */
bool bUnversioned ;
/** Generate manifests for building streaming install packages */
bool bGenerateStreamingInstallManifests ;
2015-04-20 11:15:20 -04:00
/** Error if we access engine content (useful for dlc) */
bool bErrorOnEngineContentUse ;
2015-04-20 15:58:06 -04:00
/** Use historical serialization system for generating package dependencies (use for historical reasons only this method has been depricated, only affects cooked manifests) */
bool bUseSerializationForGeneratingPackageDependencies ;
2014-03-14 14:13:41 -04:00
/** All commandline tokens */
TArray < FString > Tokens ;
/** All commandline switches */
TArray < FString > Switches ;
/** All commandline params */
FString Params ;
/**
* Cook on the fly routing for the commandlet
*
* @ param BindAnyPort Whether to bind on any port or the default port .
* @ param Timeout Length of time to wait for connections before attempting to close
* @ param bForceClose Whether or not the server should always shutdown after a timeout or after a user disconnects
*
* @ return true on success , false otherwise .
*/
2014-05-02 10:44:16 -04:00
bool CookOnTheFly ( FGuid InstanceId , int32 Timeout = 180 , bool bForceClose = false ) ;
2014-03-14 14:13:41 -04:00
/**
* Returns cooker output directory .
*
* @ param PlatformName Target platform name .
* @ return Cooker output directory for the specified platform .
*/
FString GetOutputDirectory ( const FString & PlatformName ) const ;
/**
* Get the given packages ' cooked ' timestamp ( i . e . account for dependencies )
*
* @ param InFilename The filename of the package
* @ param OutDateTime The timestamp the cooked file should have
*
* @ return bool true if the package timestamp was found , false if not
*/
bool GetPackageTimestamp ( const FString & InFilename , FDateTime & OutDateTime ) ;
/**
* Cook ( save ) the given package
*
* @ param Package The package to cook / save
* @ param SaveFlags The flags to pass to the SavePackage function
* @ param bOutWasUpToDate Upon return , if true then the cooked package was cached ( up to date )
*
* @ return bool true if packages was cooked
*/
bool SaveCookedPackage ( UPackage * Package , uint32 SaveFlags , bool & bOutWasUpToDate ) ;
2014-04-23 16:44:02 -04:00
/**
* Cook ( save ) the given package
*
* @ param Package The package to cook / save
* @ param SaveFlags The flags to pass to the SavePackage function
* @ param bOutWasUpToDate Upon return , if true then the cooked package was cached ( up to date )
* @ param TargetPlatformNames Only cook for target platforms which are included in this array ( if empty cook for all target platforms specified on commandline options )
* TargetPlatformNames is in and out value returns the platforms which the SaveCookedPackage function saved for
*
* @ return bool true if packages was cooked
*/
bool SaveCookedPackage ( UPackage * Package , uint32 SaveFlags , bool & bOutWasUpToDate , TArray < FString > & TargetPlatformNames ) ;
2014-03-14 14:13:41 -04:00
2014-04-23 16:44:02 -04:00
bool ShouldCook ( const FString & InFilename , const FString & InPlatformname = TEXT ( " " ) ) ;
2014-03-14 14:13:41 -04:00
public :
// Begin UCommandlet Interface
2014-06-13 06:14:46 -04:00
virtual int32 Main ( const FString & CmdLineParams ) override ;
2014-03-14 14:13:41 -04:00
// End UCommandlet Interface
private :
/** Holds the sandbox file wrapper to handle sandbox path conversion. */
TAutoPtr < class FSandboxPlatformFile > SandboxFile ;
/** We hook this up to a delegate to avoid reloading textures and whatnot */
TSet < FString > PackagesToNotReload ;
/** Leak test: last gc items */
TSet < FWeakObjectPtr > LastGCItems ;
void MaybeMarkPackageAsAlreadyLoaded ( UPackage * Package ) ;
2015-02-13 15:34:55 -05:00
/** See if the cooker has exceeded max memory allowance in this case the cooker should force a garbage collection */
2015-03-26 18:38:30 -04:00
bool HasExceededMaxMemory ( uint64 MaxMemoryAllowance ) const ;
2015-02-13 15:34:55 -05:00
2014-03-14 14:13:41 -04:00
/** Gets the output directory respecting any command line overrides */
FString GetOutputDirectoryOverride ( ) const ;
/** Cleans sandbox folders for all target platforms */
void CleanSandbox ( const TArray < ITargetPlatform * > & Platforms ) ;
/** Generates asset registry */
void GenerateAssetRegistry ( const TArray < ITargetPlatform * > & Platforms ) ;
/** Saves global shader map files */
void SaveGlobalShaderMapFiles ( const TArray < ITargetPlatform * > & Platforms ) ;
/** Collects all files to be cooked. This includes all commandline specified maps */
void CollectFilesToCook ( TArray < FString > & FilesInPath ) ;
/** Generates long package names for all files to be cooked */
void GenerateLongPackageNames ( TArray < FString > & FilesInPath ) ;
/** Cooks all files */
bool Cook ( const TArray < ITargetPlatform * > & Platforms , TArray < FString > & FilesInPath ) ;
2014-09-16 12:15:46 -04:00
/** Cooks all files newly (in a new way) */
bool NewCook ( const TArray < ITargetPlatform * > & Platforms , TArray < FString > & FilesInPath ) ;
/** Process deferred commands */
void ProcessDeferredCommands ( ) ;
2014-09-24 07:09:03 -04:00
/** Adds a unique package filename to cook. Rejects script packages. */
FORCEINLINE void AddFileToCook ( TArray < FString > & InOutFilesToCook , const FString & InFilename ) const
{
if ( ! FPackageName : : IsScriptPackage ( InFilename ) )
{
InOutFilesToCook . AddUnique ( InFilename ) ;
}
}
2015-03-17 06:17:32 -04:00
} ;