diff --git a/HotPatcher/Source/CmdHandler/Private/CmdHandler.cpp b/HotPatcher/Source/CmdHandler/Private/CmdHandler.cpp index 9c1b5600..71e1b6e2 100644 --- a/HotPatcher/Source/CmdHandler/Private/CmdHandler.cpp +++ b/HotPatcher/Source/CmdHandler/Private/CmdHandler.cpp @@ -46,7 +46,7 @@ bool AddMultiCookerBackendToConfig(const FString& DDCAddr) { Section->Remove(*Key); } - UE_LOG(LogCmdHandler, Display, TEXT("Override Section MultiCookerDDC key: %s to %d."),*Key,*Value); + UE_LOG(LogCmdHandler, Display, TEXT("Override Section MultiCookerDDC key: %s to %s."),*Key,*Value); Section->Add(*Key,FConfigValue(*Value)); }; @@ -57,7 +57,7 @@ bool AddMultiCookerBackendToConfig(const FString& DDCAddr) UpdateKeyLambda(MultiCookerDDCBackendSection,TEXT("Boot"),TEXT("(Type=Boot, Filename=\"%GAMEDIR%DerivedDataCache/Boot.ddc\", MaxCacheSize=512)")); FString DDC = FString::Printf( - TEXT("(Type=FileSystem, ReadOnly=false, Clean=true, Flush=false, DeleteUnused=false, UnusedFileAge=10, FoldersToClean=10, MaxFileChecksPerSec=1, Path=%s, EnvPathOverride=UE-SharedDataCachePath, EditorOverrideSetting=SharedDerivedDataCache)"), + TEXT("(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, DeleteUnused=false, UnusedFileAge=10, FoldersToClean=10, MaxFileChecksPerSec=1, Path=%s, EnvPathOverride=UE-SharedDataCachePath, EditorOverrideSetting=SharedDerivedDataCache)"), *DDCAddr ); UpdateKeyLambda(MultiCookerDDCBackendSection,TEXT("Shared"),DDC); diff --git a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/CommandletHelper.cpp b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/CommandletHelper.cpp index 880a4a6b..ce7c4dbf 100644 --- a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/CommandletHelper.cpp +++ b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/CommandletHelper.cpp @@ -182,3 +182,17 @@ TArray CommandletHelper::GetCookCommandletTargetPlatformName() return result; } + + +void CommandletHelper::ModifyTargetPlatforms(const FString& InParams,const FString& InToken,TArray& OutTargetPlatforms,bool Replace) +{ + TArray TargetPlatforms = CommandletHelper::ParserPlatforms(InParams,InToken); + if(TargetPlatforms.Num()) + { + if(Replace){ + OutTargetPlatforms = TargetPlatforms; + }else{ + for(ETargetPlatform Platform:TargetPlatforms){ OutTargetPlatforms.AddUnique(Platform); } + } + } +}; \ No newline at end of file diff --git a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp index c02be636..8d0f2504 100644 --- a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp +++ b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp @@ -34,6 +34,7 @@ int32 UHotSingleCookerCommandlet::Main(const FString& Params) TMap KeyValues = THotPatcherTemplateHelper::GetCommandLineParamsMap(Params); THotPatcherTemplateHelper::ReplaceProperty(*ExportSingleCookerSetting, KeyValues); + CommandletHelper::ModifyTargetPlatforms(Params,TARGET_PLATFORMS_OVERRIDE,ExportSingleCookerSetting->CookTargetPlatforms,true); if(ExportSingleCookerSetting->bDisplayConfig) { FString FinalConfig; diff --git a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/HotPatcherCommandlet.cpp b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/HotPatcherCommandlet.cpp index df4bb57f..68c8dd6a 100644 --- a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/HotPatcherCommandlet.cpp +++ b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/HotPatcherCommandlet.cpp @@ -40,9 +40,9 @@ int32 UHotPatcherCommandlet::Main(const FString& Params) bool bExportStatus = false; if (FFileHelper::LoadFileToString(JsonContent, *config_path)) { - - if(IsRunningCommandlet()) + if(IsRunningCommandlet() && !FParse::Param(FCommandLine::Get(), TEXT("NoSearchAllAssets"))) { + SCOPED_NAMED_EVENT_TEXT("SearchAllAssets",FColor::Red); FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked(TEXT("AssetRegistry")); AssetRegistryModule.Get().SearchAllAssets(true); } @@ -63,6 +63,7 @@ int32 UHotPatcherCommandlet::Main(const FString& Params) ExportPatchSetting->PakTargetPlatforms.AddUnique(Platform); } } + CommandletHelper::ModifyTargetPlatforms(Params,TARGET_PLATFORMS_OVERRIDE,ExportPatchSetting->PakTargetPlatforms,true); ExportPatchSetting->GetAssetScanConfigRef().AssetIncludeFilters.Append(CommandletHelper::ParserPatchFilters(Params,TEXT("AssetIncludeFilters"))); ExportPatchSetting->GetAssetScanConfigRef().AssetIgnoreFilters.Append(CommandletHelper::ParserPatchFilters(Params,TEXT("AssetIgnoreFilters"))); diff --git a/HotPatcher/Source/HotPatcherCore/HotPatcherCore.Build.cs b/HotPatcher/Source/HotPatcherCore/HotPatcherCore.Build.cs index 2a7ef94e..b2b6b676 100644 --- a/HotPatcher/Source/HotPatcherCore/HotPatcherCore.Build.cs +++ b/HotPatcher/Source/HotPatcherCore/HotPatcherCore.Build.cs @@ -61,7 +61,8 @@ public HotPatcherCore(ReadOnlyTargetRules Target) : base(Target) "InputCore", "CoreUObject", "Engine", - "Sockets" + "Sockets", + "DerivedDataCache" // ... add private dependencies that you statically link with here ... } ); @@ -189,8 +190,8 @@ public HotPatcherCore(ReadOnlyTargetRules Target) : base(Target) PublicDefinitions.AddRange(new string[] { "TOOL_NAME=\"HotPatcher\"", - "CURRENT_VERSION_ID=80", - "CURRENT_PATCH_ID=1", + "CURRENT_VERSION_ID=81", + "CURRENT_PATCH_ID=0", "REMOTE_VERSION_FILE=\"https://imzlp.com/opensource/version.json\"" }); } diff --git a/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp b/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp index b6f0bb7a..c73cf0c4 100644 --- a/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp +++ b/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp @@ -281,6 +281,13 @@ void USingleCookerProxy::ExecCookCluster(const FCookCluster& CookCluster) { SCOPED_NAMED_EVENT_TEXT("ExecCookCluster",FColor::Red); + // for GC + { + UE_LOG(LogHotPatcher,Display,TEXT("ExecuteCookCluster Try GC...")); + GEngine->ForceGarbageCollection(false); + CollectGarbage(RF_NoFlags, false); + } + CookedClusterCount++; UE_LOG(LogHotPatcher,Display,TEXT("ExecuteCookCluster %d with %d assets, total cluster %d"),CookedClusterCount,CookCluster.AssetDetails.Num(),ClusterCount); @@ -372,11 +379,7 @@ void USingleCookerProxy::ExecCookCluster(const FCookCluster& CookCluster) // CleanClusterCachedPlatformData(CookCluster); UFlibShaderCodeLibraryHelper::WaitShaderCompilingComplete(); UFlibHotPatcherCoreHelper::WaitForAsyncFileWrites(); - // for GC - { - GEngine->ForceGarbageCollection(true); - CollectGarbage(RF_NoFlags, true); - } + UFlibHotPatcherCoreHelper::WaitDDCComplete(); } void USingleCookerProxy::Tick(float DeltaTime) diff --git a/HotPatcher/Source/HotPatcherCore/Private/CreatePatch/PatcherProxy.cpp b/HotPatcher/Source/HotPatcherCore/Private/CreatePatch/PatcherProxy.cpp index 63928de6..cdf506f8 100644 --- a/HotPatcher/Source/HotPatcherCore/Private/CreatePatch/PatcherProxy.cpp +++ b/HotPatcher/Source/HotPatcherCore/Private/CreatePatch/PatcherProxy.cpp @@ -138,7 +138,8 @@ namespace PatchWorker for(const auto& TrackPackage:PackageTrackerByDiff->GetTrackResult()) { bool bSkiped = FAssetDependenciesParser::IsForceSkipAsset(TrackPackage.Key.ToString(),ForceSkipTypes,IgnoreFilters,ForceSkipFilters,ForceSkipAssets,true); - if(!bSkiped) + bool bContainInBaseVersion = FTrackPackageAction::IsAssetContainIn(Context.BaseVersion.AssetInfo,TrackPackage.Value); + if(!bSkiped && !bContainInBaseVersion) { TrackerAssetDetails.AddUnique(TrackPackage.Value); Context.AddAsset(ChunkInfo.ChunkName,TrackPackage.Value); @@ -146,12 +147,44 @@ namespace PatchWorker } } } + static bool IsAssetContainIn(const FAssetDependenciesInfo& InAssetInfo,const FAssetDetail& InAssetDetail) + { + bool bContainInBaseVersion = false; + FSoftObjectPath SoftObjectPath{InAssetDetail.PackagePath}; + FAssetDetail BaseAssetDetail; + bool bHasInBase = InAssetInfo.GetAssetDetailByPackageName(SoftObjectPath.GetLongPackageName(),BaseAssetDetail); + if(bHasInBase) + { + bContainInBaseVersion = (BaseAssetDetail.Guid == InAssetDetail.Guid); + } + return bContainInBaseVersion; + } private: FHotPatcherPatchContext& Context; const FChunkInfo& ChunkInfo; TArray Platforms; TSharedPtr PackageTrackerByDiff; }; + + template + void ExportStructToFile(FHotPatcherPatchContext& Context,T& Settings,const FString& SaveTo,bool bNotify,const FString& NotifyName) + { + FString SerializedJsonStr; + THotPatcherTemplateHelper::TSerializeStructAsJsonString(Settings,SerializedJsonStr); + if (FFileHelper::SaveStringToFile(SerializedJsonStr, *SaveTo)) + { + if(::IsRunningCommandlet()) + { + FString Msg = FString::Printf(TEXT("Export %s to %s."),*NotifyName,*SaveTo); + Context.OnPaking.Broadcast(TEXT("SavedPatchConfig"),Msg); + }else if(bNotify) + { + FString MsgStr = FString::Printf(TEXT("Export %s to Successfuly."),*NotifyName); + FText Msg = UKismetTextLibrary::Conv_StringToText(MsgStr); + FHotPatcherDelegates::Get().GetNotifyFileGenerated().Broadcast(Msg, SaveTo); + } + } + }; } #define ADD_PATCH_WORKER(FUNC_NAME) AddPatchWorker(ANSI_TO_TCHAR(#FUNC_NAME),&FUNC_NAME); @@ -201,7 +234,7 @@ void UPatcherProxy::Shutdown() bool UPatcherProxy::DoExport() { - SCOPED_NAMED_EVENT_TEXT("UPatcherProxy::DoExport",FColor::Red); + FScopedNamedEventStatic DoExportTag(FColor::Red,*FString::Printf(TEXT("DoExport_%s"),*GetSettingObject()->VersionId)); PatchContext = MakeShareable(new FHotPatcherPatchContext); PatchContext->PatchProxy = this; PatchContext->OnPaking.AddLambda([this](const FString& One,const FString& Msg){this->OnPaking.Broadcast(One,Msg);}); @@ -504,7 +537,8 @@ namespace PatchWorker { for(auto& Chunk:Context.PakChunks) { - FString SavePath = FPaths::Combine(Context.GetSettingObject()->GetSaveAbsPath(),Context.CurrentVersion.VersionId,PlatformName,TEXT("Metadatas"),PlatformName,TEXT("Metadata/ShaderLibrarySource")); + FString ChunkSavedDir = Context.GetSettingObject()->GetChunkSavedDir(Context.CurrentVersion.VersionId,Context.CurrentVersion.BaseVersionId,Chunk.ChunkName,PlatformName); + FString SavePath = FPaths::Combine(ChunkSavedDir,TEXT("Metadatas"),PlatformName,TEXT("Metadata/ShaderLibrarySource")); TArray FoundShaderLibs = UFlibShaderCodeLibraryHelper::FindCookedShaderLibByPlatform(PlatformName,SavePath); if(Context.PakChunks.Num()) @@ -564,16 +598,26 @@ namespace PatchWorker const TArray& ChunkAssets = ChunkAssetsDescrible.Assets.GetAssetDetails(); Context.PatchProxy->GetPatcherResult().PatcherAssetDetails.Append(ChunkAssets); - - if(Context.GetSettingObject()->IsCookPatchAssets()) + bool bSharedShaderLibrary = Context.GetSettingObject()->GetCookShaderOptions().bSharedShaderLibrary; + if(Context.GetSettingObject()->IsCookPatchAssets() || bSharedShaderLibrary) { + TArray AllShaderAssets; + bool bOnlyCookShaders = !Context.GetSettingObject()->IsCookPatchAssets() && bSharedShaderLibrary; + if(bOnlyCookShaders) // only cook shaders + { + SCOPED_NAMED_EVENT_TEXT("ParserAllShaderAssets",FColor::Red); + TSet ShadersClasses = UFlibHotPatcherCoreHelper::GetAllMaterialClassesNames(); + for(const auto& Asset:ChunkAssets){ + if(ShadersClasses.Contains(Asset.AssetType)){ AllShaderAssets.Add(Asset);} + } + } FTrackPackageAction TrackChunkPackageAction(Context,Chunk,TArray{Platform}); FSingleCookerSettings EmptySetting; EmptySetting.MissionID = 0; EmptySetting.MissionName = FString::Printf(TEXT("%s_Cooker_%s"),FApp::GetProjectName(),*Chunk.ChunkName); EmptySetting.ShaderLibName = Chunk.GetShaderLibraryName(); EmptySetting.CookTargetPlatforms = TArray{Platform}; - EmptySetting.CookAssets = ChunkAssets; + EmptySetting.CookAssets = bOnlyCookShaders ? AllShaderAssets: ChunkAssets; // EmptySetting.ForceSkipClasses = {}; EmptySetting.bPackageTracker = Context.GetSettingObject()->IsPackageTracker(); EmptySetting.ShaderOptions.bSharedShaderLibrary = Context.GetSettingObject()->GetCookShaderOptions().bSharedShaderLibrary; @@ -582,22 +626,17 @@ namespace PatchWorker EmptySetting.IoStoreSettings = Context.GetSettingObject()->GetIoStoreSettings(); EmptySetting.IoStoreSettings.bStorageBulkDataInfo = false;// dont save platform context data to disk EmptySetting.bSerializeAssetRegistry = Context.GetSettingObject()->GetSerializeAssetRegistryOptions().bSerializeAssetRegistry; - EmptySetting.bPreGeneratePlatformData = false; - EmptySetting.bWaitEachAssetCompleted = false; - EmptySetting.bConcurrentSave = false; + EmptySetting.bPreGeneratePlatformData = Context.GetSettingObject()->IsCookParallelSerialize(); + EmptySetting.bWaitEachAssetCompleted = Context.GetSettingObject()->IsCookParallelSerialize(); + EmptySetting.bConcurrentSave = Context.GetSettingObject()->IsCookParallelSerialize(); // for current impl arch EmptySetting.bForceCookInOneFrame = true; - EmptySetting.NumberOfAssetsPerFrame = 200; + EmptySetting.NumberOfAssetsPerFrame = Context.GetSettingObject()->CookAdvancedOptions.NumberOfAssetsPerFrame; EmptySetting.bDisplayConfig = false; EmptySetting.StorageCookedDir = Context.GetSettingObject()->GetStorageCookedDir();//FPaths::Combine(FPaths::ConvertRelativePathToFull(FPaths::ProjectSavedDir()),TEXT("Cooked")); - FReplacePakRegular PakSaveDirRegular{ - Context.CurrentVersion.VersionId, - Context.CurrentVersion.BaseVersionId, - Chunk.ChunkName, - PlatformName - }; - FString ReplacedPakSaveDirRegular = UFlibHotPatcherCoreHelper::ReplacePakRegular(PakSaveDirRegular,Context.GetSettingObject()->GetPakSaveDirRegular()); - EmptySetting.StorageMetadataDir = FPaths::Combine(Context.GetSettingObject()->GetSaveAbsPath(),ReplacedPakSaveDirRegular,TEXT("Metadatas")); + + FString ChunkSavedDir = Context.GetSettingObject()->GetChunkSavedDir(Context.CurrentVersion.VersionId,Context.CurrentVersion.BaseVersionId,Chunk.ChunkName,PlatformName); + EmptySetting.StorageMetadataDir = FPaths::Combine(ChunkSavedDir,TEXT("Metadatas")); #if WITH_PACKAGE_CONTEXT EmptySetting.bOverrideSavePackageContext = true; EmptySetting.PlatformSavePackageContexts = Context.PatchProxy->GetPlatformSavePackageContexts(); @@ -610,8 +649,10 @@ namespace PatchWorker for(const auto& AssetDetail:AdditionalCluster.AssetDetails) { FSoftObjectPath ObjectPath{AssetDetail.PackagePath}; + bool bContainInBaseVersion = FTrackPackageAction::IsAssetContainIn(Context.BaseVersion.AssetInfo,AssetDetail); + FString ReceiveReason; - if(!Context.GetSettingObject()->GetAssetScanConfig().IsMatchForceSkip(ObjectPath,ReceiveReason)) + if(!Context.GetSettingObject()->GetAssetScanConfig().IsMatchForceSkip(ObjectPath,ReceiveReason) && !bContainInBaseVersion) { Context.PatchProxy->GetPatcherResult().PatcherAssetDetails.Add(AssetDetail); Context.VersionDiff.AssetDiffInfo.AddAssetDependInfo.AddAssetsDetail(AssetDetail); @@ -653,9 +694,7 @@ namespace PatchWorker FString ChunkAssetRegistryName = Context.GetSettingObject()->GetSerializeAssetRegistryOptions().GetAssetRegistryNameRegular(Chunk.ChunkName); // // Save the generated registry FString AssetRegistryPath = FPaths::Combine( - Context.GetSettingObject()->GetSaveAbsPath(), - Context.NewVersionChunk.ChunkName, - PlatformName, + Context.GetSettingObject()->GetChunkSavedDir(Context.CurrentVersion.VersionId,Context.BaseVersion.VersionId,Context.NewVersionChunk.ChunkName,PlatformName), ChunkAssetRegistryName); if(UFlibHotPatcherCoreHelper::SerializeAssetRegistryByDetails(Context.PatchProxy->GetAssetRegistry(),PlatformName,ChunkAssets, AssetRegistryPath)) { @@ -693,6 +732,7 @@ namespace PatchWorker } break; } + default:{} }; } return true; @@ -892,14 +932,8 @@ namespace PatchWorker Context.OnPaking.Broadcast(TEXT("ExportPatch"),*Dialog.ToString()); Context.UnrealPakSlowTask->EnterProgressFrame(1.0, Dialog); } - FReplacePakRegular PakSaveDirRegular{ - Context.CurrentVersion.VersionId, - Context.CurrentVersion.BaseVersionId, - Chunk.ChunkName, - PlatformName - }; - FString ReplacedPakSaveDirRegular = UFlibHotPatcherCoreHelper::ReplacePakRegular(PakSaveDirRegular,Context.GetSettingObject()->GetPakSaveDirRegular()); - FString ChunkSaveBasePath = FPaths::Combine(Context.GetSettingObject()->GetSaveAbsPath(),ReplacedPakSaveDirRegular); + + FString ChunkSaveBasePath = Context.GetSettingObject()->GetChunkSavedDir(Context.CurrentVersion.VersionId,Context.CurrentVersion.BaseVersionId,Chunk.ChunkName,PlatformName); TArray ChunkPakListCommands; { @@ -996,7 +1030,14 @@ namespace PatchWorker // add extern file to pak(version file) SinglePakForChunk.PakCommands.Append(Context.AdditionalFileToPak); - const FString ChunkPakName = UFlibHotPatcherCoreHelper::ReplacePakRegular(PakSaveDirRegular,Context.GetSettingObject()->GetPakNameRegular()); + FReplacePakRegular PakPathRegular{ + Context.CurrentVersion.VersionId, + Context.CurrentVersion.BaseVersionId, + Chunk.ChunkName, + PlatformName + }; + + const FString ChunkPakName = UFlibHotPatcherCoreHelper::ReplacePakRegular(PakPathRegular,Context.GetSettingObject()->GetPakNameRegular()); SinglePakForChunk.ChunkStoreName = ChunkPakName; SinglePakForChunk.StorageDirectory = ChunkSaveBasePath; Chunk.GetPakFileProxys().Add(SinglePakForChunk); @@ -1107,11 +1148,12 @@ namespace PatchWorker { if(::IsRunningCommandlet()) { - FString Msg = FString::Printf(TEXT("Successed to Package the patch as %s."),*PakSavePath); + FString Msg = FString::Printf(TEXT("Package the Patch as %s."),*PakSavePath); Context.OnPaking.Broadcast(TEXT("SavedPakFile"),Msg); }else { - FText Msg = LOCTEXT("SavedPakFileMsg_PackageSuccessed", "Successed to Package the patch as Pak."); + FString MsgStr = FString::Printf(TEXT("Package %s for %s Successfuly."),*Chunk.ChunkName,*PlatformName); + FText Msg = UKismetTextLibrary::Conv_StringToText(MsgStr); FHotPatcherDelegates::Get().GetNotifyFileGenerated().Broadcast(Msg,PakSavePath); } FPakFileInfo CurrentPakInfo; @@ -1300,29 +1342,34 @@ namespace PatchWorker auto SavePatchDiffJsonLambda = [&Context](const FHotPatcherVersion& InSaveVersion, const FPatchVersionDiff& InDiff)->bool { bool bStatus = false; - if (Context.GetSettingObject()->IsSaveDiffAnalysis()) + for(ETargetPlatform Platform:Context.GetSettingObject()->PakTargetPlatforms) { - auto SerializeChangedAssetInfo = [](const FPatchVersionDiff& InAssetInfo)->FString + FString PlatformName = THotPatcherTemplateHelper::GetEnumNameByValue(Platform); + if (Context.GetSettingObject()->IsSaveDiffAnalysis()) { - FString AddAssets; - THotPatcherTemplateHelper::TSerializeStructAsJsonString(InAssetInfo,AddAssets); - return AddAssets; - }; + auto SerializeChangedAssetInfo = [](const FPatchVersionDiff& InAssetInfo)->FString + { + FString AddAssets; + THotPatcherTemplateHelper::TSerializeStructAsJsonString(InAssetInfo,AddAssets); + return AddAssets; + }; - FString SerializeDiffInfo = SerializeChangedAssetInfo(InDiff); + FString SerializeDiffInfo = SerializeChangedAssetInfo(InDiff); - // FString::Printf(TEXT("%s"),*SerializeDiffInfo); + // FString::Printf(TEXT("%s"),*SerializeDiffInfo); - FString SaveDiffToFile = FPaths::Combine( - Context.GetSettingObject()->GetCurrentVersionSavePath(), - FString::Printf(TEXT("%s_%s_Diff.json"), *InSaveVersion.BaseVersionId, *InSaveVersion.VersionId) - ); - if (UFlibAssetManageHelper::SaveStringToFile(SaveDiffToFile, SerializeDiffInfo)) - { - bStatus = true; + FString SaveDiffToFile = FPaths::Combine( + // Context.GetSettingObject()->GetCurrentVersionSavePath(), + Context.GetSettingObject()->GetChunkSavedDir(InSaveVersion.VersionId,InSaveVersion.BaseVersionId,TEXT(""),PlatformName), + FString::Printf(TEXT("%s_%s_Diff.json"), *InSaveVersion.BaseVersionId, *InSaveVersion.VersionId) + ); + if (UFlibAssetManageHelper::SaveStringToFile(SaveDiffToFile, SerializeDiffInfo)) + { + bStatus = true; - FString Msg = FString::Printf(TEXT("Succeed to export New Patch Diff Info."),*SaveDiffToFile); - Context.OnPaking.Broadcast(TEXT("SavePatchDiffInfo"),Msg); + FString Msg = FString::Printf(TEXT("Succeed to export New Patch Diff Info."),*SaveDiffToFile); + Context.OnPaking.Broadcast(TEXT("SavePatchDiffInfo"),Msg); + } } } return bStatus; @@ -1376,11 +1423,11 @@ namespace PatchWorker { if(::IsRunningCommandlet()) { - FString Msg = FString::Printf(TEXT("Succeed to export New Release Info to %s."),*SaveCurrentVersionToFile); + FString Msg = FString::Printf(TEXT("Export NewRelease to %s."),*SaveCurrentVersionToFile); Context.OnPaking.Broadcast(TEXT("SavePatchDiffInfo"),Msg); }else { - auto Msg = LOCTEXT("SavePatchDiffInfo", "Succeed to export New Release Info."); + auto Msg = LOCTEXT("SavePatchDiffInfo", "Export NewRelease Successfuly."); FHotPatcherDelegates::Get().GetNotifyFileGenerated().Broadcast(Msg, SaveCurrentVersionToFile); } } @@ -1392,6 +1439,13 @@ namespace PatchWorker bool SavePakFileInfoWorker(FHotPatcherPatchContext& Context) { SCOPED_NAMED_EVENT_TEXT("SavePakFileInfoWorker",FColor::Red); + const FPatherResult& PatherResult = Context.PatchProxy->GetPatcherResult(); + FString PakResultPath = FPaths::Combine( + Context.GetSettingObject()->GetCurrentVersionSavePath(), + FString::Printf(TEXT("%s_PakResults.json"),*Context.CurrentVersion.VersionId) + ); + ExportStructToFile(Context,PatherResult,PakResultPath,true,TEXT("PakResults")); + if(!Context.GetSettingObject()->IsStoragePakFileInfo()) return true; if(Context.GetSettingObject()) @@ -1419,11 +1473,11 @@ namespace PatchWorker { if(::IsRunningCommandlet()) { - FString Msg = FString::Printf(TEXT("Successed to Export the Pak File info to ."),*SavePakFilesPath); + FString Msg = FString::Printf(TEXT("Export PakFileInfo to %s."),*SavePakFilesPath); Context.OnPaking.Broadcast(TEXT("SavedPakFileMsg"),Msg); }else { - FText Msg = LOCTEXT("SavedPakFileMsg_ExportSuccessed", "Successed to Export the Pak File info."); + FText Msg = LOCTEXT("SavedPakFileMsg_ExportSuccessed", "Export PakFileInfo Successfuly."); FHotPatcherDelegates::Get().GetNotifyFileGenerated().Broadcast(Msg, SavePakFilesPath); } } @@ -1447,27 +1501,29 @@ namespace PatchWorker { Context.UnrealPakSlowTask->EnterProgressFrame(1.0, DiaLogMsg); } - - FString SaveConfigPath = FPaths::Combine( - Context.GetSettingObject()->GetCurrentVersionSavePath(), - FString::Printf(TEXT("%s_PatchConfig.json"),*Context.CurrentVersion.VersionId) - ); - if (Context.GetSettingObject()->IsSaveConfig()) { - FString SerializedJsonStr; - THotPatcherTemplateHelper::TSerializeStructAsJsonString(*Context.GetSettingObject(),SerializedJsonStr); - if (FFileHelper::SaveStringToFile(SerializedJsonStr, *SaveConfigPath)) + TArray PakTargetPlatforms = Context.GetSettingObject()->GetPakTargetPlatforms(); + for(ETargetPlatform Platform:PakTargetPlatforms) { - if(::IsRunningCommandlet()) - { - FString Msg = FString::Printf(TEXT("Successed to Export the Patch Config to %s."),*SaveConfigPath); - Context.OnPaking.Broadcast(TEXT("SavedPatchConfig"),Msg); - }else - { - FText Msg = LOCTEXT("SavedPatchConfig", "Successed to Export the Patch Config."); - FHotPatcherDelegates::Get().GetNotifyFileGenerated().Broadcast(Msg, SaveConfigPath); - } + FString PlatformName = THotPatcherTemplateHelper::GetEnumNameByValue(Platform); + FString SavedBaseDir = Context.GetSettingObject()->GetChunkSavedDir(Context.CurrentVersion.VersionId,Context.CurrentVersion.BaseVersionId,Context.GetSettingObject()->GetVersionId(),PlatformName); + FString SaveConfigPath = FPaths::Combine( + SavedBaseDir, + FString::Printf(TEXT("%s_%s_PatchConfig.json"),*PlatformName,*Context.CurrentVersion.VersionId) + ); + FExportPatchSettings TempPatchSettings = *Context.GetSettingObject(); + TempPatchSettings.PakTargetPlatforms.Empty(); + TempPatchSettings.PakTargetPlatforms.Add(Platform); + ExportStructToFile(Context,TempPatchSettings,SaveConfigPath,false,TEXT("PatchConfig")); + } + if(PakTargetPlatforms.Num()) + { + FString SaveConfigPath = FPaths::Combine( + Context.GetSettingObject()->GetCurrentVersionSavePath(), + FString::Printf(TEXT("%s_PatchConfig.json"),*Context.CurrentVersion.VersionId) + ); + ExportStructToFile(Context,*Context.GetSettingObject(),SaveConfigPath,true,TEXT("PatchConfig")); } } @@ -1517,7 +1573,7 @@ namespace PatchWorker SCOPED_NAMED_EVENT_TEXT("OnFaildDispatchWorker",FColor::Red); if (!Context.GetPakFileNum()) { - UE_LOG(LogHotPatcher, Error, TEXT("The Patch not contain any invalie file!")); + UE_LOG(LogHotPatcher, Warning, TEXT("The Patch not contain any invalie file!")); Context.OnShowMsg.Broadcast(TEXT("The Patch not contain any invalie file!")); } else diff --git a/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp b/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp index b03b4ad5..2abfca35 100644 --- a/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp +++ b/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp @@ -34,6 +34,8 @@ #include "ProfilingDebugging/LoadTimeTracker.h" #include "UObject/ConstructorHelpers.h" #include "Misc/EngineVersionComparison.h" +#include "Misc/CoreMisc.h" +#include "DerivedDataCacheInterface.h" DEFINE_LOG_CATEGORY(LogHotPatcherCoreHelper); @@ -69,12 +71,13 @@ void UFlibHotPatcherCoreHelper::CheckInvalidCookFilesByAssetDependenciesInfo( FAssetData CurrentAssetData; UFlibAssetManageHelper::GetSingleAssetsData(AssetDetail.PackagePath.ToString(),CurrentAssetData); - if(!CurrentAssetData.GetAsset()->IsValidLowLevelFast()) - { - UE_LOG(LogHotPatcherCoreHelper,Warning,TEXT("%s is invalid Asset Uobject"),*CurrentAssetData.PackageName.ToString()); - continue; - } - if (CurrentAssetData.GetAsset()->HasAnyMarks(OBJECTMARK_EditorOnly)) + + // if(!CurrentAssetData.GetAsset()->IsValidLowLevelFast()) + // { + // UE_LOG(LogHotPatcherCoreHelper,Warning,TEXT("%s is invalid Asset Uobject"),*CurrentAssetData.PackageName.ToString()); + // continue; + // } + if ((CurrentAssetData.PackageFlags & PKG_EditorOnly)!=0) { UE_LOG(LogHotPatcherCoreHelper,Warning,TEXT("Miss %s it's EditorOnly Assets!"),*CurrentAssetData.PackageName.ToString()); continue; @@ -952,52 +955,7 @@ FString UFlibHotPatcherCoreHelper::PatchSummary(const FPatchVersionDiff& DiffInf FString UFlibHotPatcherCoreHelper::ReplacePakRegular(const FReplacePakRegular& RegularConf, const FString& InRegular) { - struct FResularOperator - { - FResularOperator(const FString& InName,TFunction InOperator) - :Name(InName),Do(InOperator){} - FString Name; - TFunction Do; - }; - - TArray RegularOpList; - RegularOpList.Emplace(TEXT("{VERSION}"),[&RegularConf]()->FString{return RegularConf.VersionId;}); - RegularOpList.Emplace(TEXT("{BASEVERSION}"),[&RegularConf]()->FString{return RegularConf.BaseVersionId;}); - RegularOpList.Emplace(TEXT("{PLATFORM}"),[&RegularConf]()->FString{return RegularConf.PlatformName;}); - RegularOpList.Emplace(TEXT("{CHUNKNAME}"),[&RegularConf,InRegular]()->FString - { - if(InRegular.Contains(TEXT("{VERSION}")) && - InRegular.Contains(TEXT("{CHUNKNAME}")) && - RegularConf.VersionId.Equals(RegularConf.ChunkName)) - { - return TEXT(""); - } - else - { - return RegularConf.ChunkName; - } - }); - - auto CustomPakNameRegular = [](const TArray& Operators,const FString& Regular)->FString - { - FString Result = Regular; - for(auto& Operator:Operators) - { - Result = Result.Replace(*Operator.Name,*(Operator.Do())); - } - auto ReplaceDoubleLambda = [](FString& Src,const FString& From,const FString& To) - { - while(Src.Contains(From)) - { - Src = Src.Replace(*From,*To); - } - }; - ReplaceDoubleLambda(Result,TEXT("__"),TEXT("_")); - ReplaceDoubleLambda(Result,TEXT("--"),TEXT("-")); - return Result; - }; - - return CustomPakNameRegular(RegularOpList,InRegular); + return UFlibPatchParserHelper::ReplacePakRegular(RegularConf,InRegular); } bool UFlibHotPatcherCoreHelper::CheckSelectedAssetsCookStatus(const FString& OverrideCookedDir,const TArray& PlatformNames, const FAssetDependenciesInfo& SelectedAssets, FString& OutMsg) @@ -1989,6 +1947,12 @@ void UFlibHotPatcherCoreHelper::WaitForAsyncFileWrites() WaitThreadWorker->Join(); } +void UFlibHotPatcherCoreHelper::WaitDDCComplete() +{ + SCOPED_NAMED_EVENT_TEXT("WaitDDCComplete",FColor::Red); + GetDerivedDataCacheRef().WaitForQuiescence(true); +} + bool UFlibHotPatcherCoreHelper::IsCanCookPackage(const FString& LongPackageName) { bool bResult = false; @@ -2048,7 +2012,7 @@ TArray UFlibHotPatcherCoreHelper::GetProjectNotAssetDirCon TArray result; const UProjectPackagingSettings* const PackagingSettings = GetDefault(); - FString BasePath = FString::Printf(TEXT("../../../%s/Content/%s"),FApp::GetProjectName()); + FString BasePath = FString::Printf(TEXT("../../../%s/Content/"),FApp::GetProjectName()); auto FixPath = [](const FString& BasePath,const FString& Path)->FString { FString result; diff --git a/HotPatcher/Source/HotPatcherCore/Public/CommandletBase/CommandletHelper.h b/HotPatcher/Source/HotPatcherCore/Public/CommandletBase/CommandletHelper.h index 3672ef35..a911566f 100644 --- a/HotPatcher/Source/HotPatcherCore/Public/CommandletBase/CommandletHelper.h +++ b/HotPatcher/Source/HotPatcherCore/Public/CommandletBase/CommandletHelper.h @@ -5,6 +5,7 @@ #define PATCHER_CONFIG_PARAM_NAME TEXT("-config=") #define ADD_PATCH_PLATFORMS TEXT("AddPatchPlatforms") +#define TARGET_PLATFORMS_OVERRIDE TEXT("TargetPlatformsOverride") DECLARE_LOG_CATEGORY_EXTERN(LogHotPatcherCommandlet, All, All); @@ -26,4 +27,5 @@ namespace CommandletHelper HOTPATCHERCORE_API bool IsCookCommandlet(); HOTPATCHERCORE_API TArray GetCookCommandletTargetPlatforms(); HOTPATCHERCORE_API TArray GetCookCommandletTargetPlatformName(); + HOTPATCHERCORE_API void ModifyTargetPlatforms(const FString& InParams,const FString& InToken,TArray& OutTargetPlatforms,bool Replace); } diff --git a/HotPatcher/Source/HotPatcherCore/Public/CreatePatch/PatcherProxy.h b/HotPatcher/Source/HotPatcherCore/Public/CreatePatch/PatcherProxy.h index 47068003..fa71cfdf 100644 --- a/HotPatcher/Source/HotPatcherCore/Public/CreatePatch/PatcherProxy.h +++ b/HotPatcher/Source/HotPatcherCore/Public/CreatePatch/PatcherProxy.h @@ -24,14 +24,6 @@ DECLARE_MULTICAST_DELEGATE_FourParams(FOnPakListGenerated,FHotPatcherPatchContex DECLARE_MULTICAST_DELEGATE_FourParams(FAddPatchWorkerEvent,FHotPatcherPatchContext&,FChunkInfo&,ETargetPlatform,TArray&); -USTRUCT() -struct HOTPATCHERCORE_API FPatherResult -{ - GENERATED_BODY() - UPROPERTY() - TArray PatcherAssetDetails; -}; - UCLASS() class HOTPATCHERCORE_API UPatcherProxy:public UHotPatcherProxyBase { @@ -50,7 +42,7 @@ class HOTPATCHERCORE_API UPatcherProxy:public UHotPatcherProxyBase } FORCEINLINE const FPatchWorkers& GetPatchWorkers()const{ return PatchWorkers; } FORCEINLINE FPatherResult& GetPatcherResult(){ return PatcherResult; } - + public: FOnPakListGenerated OnPakListGenerated; diff --git a/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h b/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h index dae45068..2b773b62 100644 --- a/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h +++ b/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h @@ -59,17 +59,6 @@ struct FProjectPackageAssetCollection TArray NeverCookPackages; }; - -struct HOTPATCHERCORE_API FReplacePakRegular -{ - FReplacePakRegular()=default; - FReplacePakRegular(const FString& InVersionId,const FString& InBaseVersionId,const FString& InChunkName,const FString& InPlatformName): - VersionId(InVersionId),BaseVersionId(InBaseVersionId),ChunkName(InChunkName),PlatformName(InPlatformName){} - FString VersionId; - FString BaseVersionId; - FString ChunkName; - FString PlatformName; -}; /** * */ @@ -242,7 +231,7 @@ class HOTPATCHERCORE_API UFlibHotPatcherCoreHelper : public UBlueprintFunctionLi static FProjectPackageAssetCollection ImportProjectSettingsPackages(); static void WaitForAsyncFileWrites(); - + static void WaitDDCComplete(); static bool IsCanCookPackage(const FString& LongPackageName); static void ImportProjectSettingsToScannerConfig(FAssetScanConfig& AssetScanConfig); diff --git a/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportPatchSettings.cpp b/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportPatchSettings.cpp index 203f9186..0e1658e5 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportPatchSettings.cpp +++ b/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportPatchSettings.cpp @@ -120,10 +120,32 @@ bool FExportPatchSettings::GetBaseVersionInfo(FHotPatcherVersion& OutBaseVersion return bDeserializeStatus; } +FString FExportPatchSettings::GetChunkSavedDir(const FString& InVersionId,const FString& InBaseVersionId,const FString& InChunkName,const FString& InPlatformName)const +{ + FReplacePakRegular TmpPakPathRegular{ + InVersionId, + InBaseVersionId, + InChunkName, + InPlatformName + }; + FString ReplacedPakPathRegular = UFlibPatchParserHelper::ReplacePakRegular(TmpPakPathRegular,GetPakPathRegular()); + return FPaths::Combine(GetSaveAbsPath(),ReplacedPakPathRegular); +} FString FExportPatchSettings::GetCurrentVersionSavePath() const { - FString CurrentVersionSavePath = FPaths::Combine(GetSaveAbsPath(), /*const_cast(this)->GetNewPatchVersionInfo().*/VersionId); + FString CurrentVersionSavePath; + if(GetPakTargetPlatforms().Num()) + { + FString PlatformName = THotPatcherTemplateHelper::GetEnumNameByValue(GetPakTargetPlatforms()[0]); + FString SavedBaseDir = GetChunkSavedDir(GetVersionId(),TEXT(""),GetVersionId(),PlatformName); + CurrentVersionSavePath = FPaths::Combine(SavedBaseDir,TEXT("..")); + } + else + { + CurrentVersionSavePath = FPaths::Combine(GetSaveAbsPath(), /*const_cast(this)->GetNewPatchVersionInfo().*/VersionId); + } + FPaths::NormalizeFilename(CurrentVersionSavePath); return CurrentVersionSavePath; } diff --git a/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportReleaseSettings.cpp b/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportReleaseSettings.cpp index aa19f2f8..4f86b0e0 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportReleaseSettings.cpp +++ b/HotPatcher/Source/HotPatcherRuntime/Private/CreatePatch/FExportReleaseSettings.cpp @@ -40,6 +40,7 @@ void FExportReleaseSettings::Init() { PakFileConf->PakFiles.AddUnique(FPaths::ConvertRelativePathToFull(PakFile.FilePath)); } + PakFileConf->AESKey = PlatformPakList.AESKey; if(!!PakFileConf->PakFiles.Num()) { FReleasePakParser PakFileParser; diff --git a/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp b/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp index 26126f08..ab5f27b3 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp +++ b/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp @@ -1175,8 +1175,8 @@ void UFlibAssetManageHelper::ExcludeContentForAssetDependenciesDetail(FAssetDepe FString MatchRule; for(const auto& Rule:ExcludeRules) { - if(matchMod == EHotPatcherMatchModEx::StartWith && AssetKeys[index].StartsWith(Rule)|| - matchMod == EHotPatcherMatchModEx::Equal && AssetKeys[index].Equals(Rule) + if((matchMod == EHotPatcherMatchModEx::StartWith && AssetKeys[index].StartsWith(Rule)) || + (matchMod == EHotPatcherMatchModEx::Equal && AssetKeys[index].Equals(Rule)) ) { MatchRule = Rule; @@ -1290,6 +1290,7 @@ UPackage* UFlibAssetManageHelper::LoadPackage(UPackage* InOuter, const TCHAR* In #if ENGINE_MINOR_VERSION < 26 FScopedNamedEvent CookPackageEvent(FColor::Red,*FString::Printf(TEXT("LoadPackage %s"),InLongPackageName)); #endif + UE_LOG(LogHotPatcher,Verbose,TEXT("Load %s,outer %s"),InLongPackageName,InOuter ? *InOuter->GetFullName():TEXT("null")); return ::LoadPackage(InOuter,InLongPackageName,LoadFlags,InReaderOverride); } @@ -1529,6 +1530,7 @@ bool UFlibAssetManageHelper::HasClassObjInPackage(UPackage* Package,UClass* Find TArray UFlibAssetManageHelper::GetAssetDetailsByClass(TArray& AllAssetDetails, UClass* Class, bool RemoveFromSrc) { + SCOPED_NAMED_EVENT_TEXT("GetAssetDetailsByClass",FColor::Red); return THotPatcherTemplateHelper::GetArrayBySrcWithCondition(AllAssetDetails,[&](FAssetDetail AssetDetail)->bool { return AssetDetail.AssetType.IsEqual(*Class->GetName()); diff --git a/HotPatcher/Source/HotPatcherRuntime/Private/FlibPakHelper.cpp b/HotPatcher/Source/HotPatcherRuntime/Private/FlibPakHelper.cpp index e30161cc..fb7d7bd0 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Private/FlibPakHelper.cpp +++ b/HotPatcher/Source/HotPatcherRuntime/Private/FlibPakHelper.cpp @@ -227,12 +227,15 @@ void UFlibPakHelper::ReloadShaderbytecode() } -bool UFlibPakHelper::LoadShaderbytecode(const FString& LibraryName, const FString& LibraryDir) +bool UFlibPakHelper::LoadShaderbytecode(const FString& LibraryName, const FString& LibraryDir,bool bNative) { bool result = true; FString FinalLibraryDir = LibraryDir; #if PLATFORM_IOS - FinalLibraryDir = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*LibraryDir);; + if(bNative) + { + FinalLibraryDir = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*LibraryDir); + } #endif #if ENGINE_MAJOR_VERSION > 4 || ENGINE_MINOR_VERSION >= 23 result = FShaderCodeLibrary::OpenLibrary(LibraryName, LibraryDir); diff --git a/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp b/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp index e433339c..775823f3 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp +++ b/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp @@ -2141,18 +2141,26 @@ bool UFlibPatchParserHelper::IsValidPatchSettings(const FExportPatchSettings* Pa return bCanExport; } +FString UFlibPatchParserHelper::GetTargetPlatformsStr(const TArray& Platforms) +{ + FString PlatformArrayStr; + TArray UniquePlatforms; + for(ETargetPlatform Platform:Platforms){ UniquePlatforms.AddUnique(Platform);} + for(ETargetPlatform Platform:UniquePlatforms) + { + FString PlatformName = THotPatcherTemplateHelper::GetEnumNameByValue(Platform); + PlatformArrayStr += FString::Printf(TEXT("%s+"),*PlatformName); + } + PlatformArrayStr.RemoveFromEnd(TEXT("+")); + return PlatformArrayStr; +} + FString UFlibPatchParserHelper::GetTargetPlatformsCmdLine(const TArray& Platforms) { FString Result; if(Platforms.Num()) { - FString PlatformArrayStr; - for(ETargetPlatform Platform:Platforms) - { - FString PlatformName = THotPatcherTemplateHelper::GetEnumNameByValue(Platform); - PlatformArrayStr += FString::Printf(TEXT("%s+"),*PlatformName); - } - PlatformArrayStr.RemoveFromEnd(TEXT("+")); + FString PlatformArrayStr = UFlibPatchParserHelper::GetTargetPlatformsStr(Platforms); if(!PlatformArrayStr.IsEmpty()) { Result = FString::Printf(TEXT("-TargetPlatform=%s"),*PlatformArrayStr); @@ -2227,4 +2235,54 @@ bool UFlibPatchParserHelper::GetCmdletBoolValue(const FString& Token, bool& OutV } } return bHasToken; -} \ No newline at end of file +} + +FString UFlibPatchParserHelper::ReplacePakRegular(const FReplacePakRegular& RegularConf, const FString& InRegular) +{ + struct FResularOperator + { + FResularOperator(const FString& InName,TFunction InOperator) + :Name(InName),Do(InOperator){} + FString Name; + TFunction Do; + }; + + TArray RegularOpList; + RegularOpList.Emplace(TEXT("{VERSION}"),[&RegularConf]()->FString{return RegularConf.VersionId;}); + RegularOpList.Emplace(TEXT("{BASEVERSION}"),[&RegularConf]()->FString{return RegularConf.BaseVersionId;}); + RegularOpList.Emplace(TEXT("{PLATFORM}"),[&RegularConf]()->FString{return RegularConf.PlatformName;}); + RegularOpList.Emplace(TEXT("{CHUNKNAME}"),[&RegularConf,InRegular]()->FString + { + if(InRegular.Contains(TEXT("{VERSION}")) && + InRegular.Contains(TEXT("{CHUNKNAME}")) && + RegularConf.VersionId.Equals(RegularConf.ChunkName)) + { + return TEXT(""); + } + else + { + return RegularConf.ChunkName; + } + }); + + auto CustomPakNameRegular = [](const TArray& Operators,const FString& Regular)->FString + { + FString Result = Regular; + for(auto& Operator:Operators) + { + Result = Result.Replace(*Operator.Name,*(Operator.Do())); + } + auto ReplaceDoubleLambda = [](FString& Src,const FString& From,const FString& To) + { + while(Src.Contains(From)) + { + Src = Src.Replace(*From,*To); + } + }; + ReplaceDoubleLambda(Result,TEXT("__"),TEXT("_")); + ReplaceDoubleLambda(Result,TEXT("--"),TEXT("-")); + return Result; + }; + + return CustomPakNameRegular(RegularOpList,InRegular); +} diff --git a/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FChunkInfo.h b/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FChunkInfo.h index 01b7e246..427f8ea6 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FChunkInfo.h +++ b/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FChunkInfo.h @@ -116,6 +116,8 @@ struct HOTPATCHERRUNTIME_API FChunkInfo } UPROPERTY(EditAnywhere,BlueprintReadWrite) FString ChunkName; + UPROPERTY(EditAnywhere,BlueprintReadWrite) + FString ChunkAliasName; UPROPERTY(EditAnywhere,BlueprintReadWrite) int32 Priority = -1; UPROPERTY(EditAnywhere, BlueprintReadWrite) diff --git a/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FPackageTracker.h b/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FPackageTracker.h index e1ce5c3d..5d74d5f4 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FPackageTracker.h +++ b/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FPackageTracker.h @@ -2,8 +2,6 @@ #include "FlibAssetManageHelper.h" #include "CoreMinimal.h" #include "UObject/UObjectArray.h" -#include "HAL/PlatformFilemanager.h" -#include "HAL/FileManager.h" #include "HotPatcherLog.h" struct FPackageTrackerBase : public FUObjectArray::FUObjectCreateListener, public FUObjectArray::FUObjectDeleteListener diff --git a/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FlibPakHelper.h b/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FlibPakHelper.h index eabcc84a..35f73762 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FlibPakHelper.h +++ b/HotPatcher/Source/HotPatcherRuntime/Public/BaseTypes/FlibPakHelper.h @@ -74,7 +74,7 @@ class HOTPATCHERRUNTIME_API UFlibPakHelper : public UBlueprintFunctionLibrary UFUNCTION(BlueprintCallable,Exec) static void ReloadShaderbytecode(); UFUNCTION(BlueprintCallable,Exec) - static bool LoadShaderbytecode(const FString& LibraryName, const FString& LibraryDir); + static bool LoadShaderbytecode(const FString& LibraryName, const FString& LibraryDir,bool bNative = false); UFUNCTION(BlueprintCallable,Exec) static bool LoadShaderbytecodeInDefaultDir(const FString& LibraryName); UFUNCTION(BlueprintCallable,Exec) diff --git a/HotPatcher/Source/HotPatcherRuntime/Public/CreatePatch/FExportPatchSettings.h b/HotPatcher/Source/HotPatcherRuntime/Public/CreatePatch/FExportPatchSettings.h index 2693367a..be93131b 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Public/CreatePatch/FExportPatchSettings.h +++ b/HotPatcher/Source/HotPatcherRuntime/Public/CreatePatch/FExportPatchSettings.h @@ -35,7 +35,24 @@ #include "FExportPatchSettings.generated.h" +USTRUCT() +struct HOTPATCHERRUNTIME_API FPatherResult +{ + GENERATED_BODY() + UPROPERTY() + TArray PatcherAssetDetails; +}; +USTRUCT(BlueprintType) +struct FCookAdvancedOptions +{ + GENERATED_BODY() + // ConcurrentSave for cooking + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool bCookParallelSerialize = false; + UPROPERTY(EditAnywhere, BlueprintReadWrite) + int32 NumberOfAssetsPerFrame = 100; +}; /** Singleton wrapper to allow for using the setting structure in SSettingsView */ USTRUCT(BlueprintType) @@ -98,8 +115,8 @@ struct HOTPATCHERRUNTIME_API FExportPatchSettings:public FHotPatcherSettingBase FORCEINLINE bool IsCustomPakNameRegular()const {return bCustomPakNameRegular;} FORCEINLINE FString GetPakNameRegular()const { return PakNameRegular;} - FORCEINLINE bool IsCustomPakSaveDirRegular()const {return bCustomPakSaveDirRegular;} - FORCEINLINE FString GetPakSaveDirRegular()const { return PakSaveDirRegular;} + FORCEINLINE bool IsCustomPakPathRegular()const {return bCustomPakPathRegular;} + FORCEINLINE FString GetPakPathRegular()const { return PakPathRegular;} FORCEINLINE bool IsCookPatchAssets()const {return bCookPatchAssets;} FORCEINLINE bool IsIgnoreDeletedAssetsInfo()const {return bIgnoreDeletedAssetsInfo;} FORCEINLINE bool IsSaveDeletedAssetsToNewReleaseJson()const {return bStorageDeletedAssetsToNewReleaseJson;} @@ -126,6 +143,7 @@ struct HOTPATCHERRUNTIME_API FExportPatchSettings:public FHotPatcherSettingBase FORCEINLINE bool IsImportProjectSettings()const{ return bImportProjectSettings; } virtual FString GetCombinedAdditionalCommandletArgs()const override; + virtual bool IsCookParallelSerialize() const { return CookAdvancedOptions.bCookParallelSerialize; } public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BaseVersion") bool bByBaseVersion = false; @@ -198,6 +216,8 @@ struct HOTPATCHERRUNTIME_API FExportPatchSettings:public FHotPatcherSettingBase */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options") bool bCookPatchAssets = true; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options", meta=(EditCondition = "bCookPatchAssets")) + FCookAdvancedOptions CookAdvancedOptions; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options", meta=(EditCondition = "bCookPatchAssets")) FCookShaderOptions CookShaderOptions; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options", meta=(EditCondition = "bCookPatchAssets")) @@ -228,10 +248,10 @@ struct HOTPATCHERRUNTIME_API FExportPatchSettings:public FHotPatcherSettingBase UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options",meta=(EditCondition = "bCustomPakNameRegular")) FString PakNameRegular = TEXT("{VERSION}_{CHUNKNAME}_{PLATFORM}_001_P"); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options") - bool bCustomPakSaveDirRegular = false; + bool bCustomPakPathRegular = false; // Can use value: {VERSION} {BASEVERSION} {CHUNKNAME} {PLATFORM} - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options",meta=(EditCondition = "bCustomPakSaveDirRegular")) - FString PakSaveDirRegular = TEXT("{CHUNKNAME}/{PLATFORM}"); + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pak Options",meta=(EditCondition = "bCustomPakPathRegular")) + FString PakPathRegular = TEXT("{CHUNKNAME}/{PLATFORM}"); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SaveTo") bool bStorageNewRelease = true; @@ -258,5 +278,17 @@ struct HOTPATCHERRUNTIME_API FExportPatchSettings:public FHotPatcherSettingBase FString StorageCookedDir = TEXT("[PROJECTDIR]/Saved/Cooked"); FString GetStorageCookedDir()const; + FString GetChunkSavedDir(const FString& InVersionId,const FString& InBaseVersionId,const FString& InChunkName,const FString& InPlatformName)const; +}; + +struct HOTPATCHERRUNTIME_API FReplacePakRegular +{ + FReplacePakRegular()=default; + FReplacePakRegular(const FString& InVersionId,const FString& InBaseVersionId,const FString& InChunkName,const FString& InPlatformName): + VersionId(InVersionId),BaseVersionId(InBaseVersionId),ChunkName(InChunkName),PlatformName(InPlatformName){} + FString VersionId; + FString BaseVersionId; + FString ChunkName; + FString PlatformName; }; \ No newline at end of file diff --git a/HotPatcher/Source/HotPatcherRuntime/Public/FlibPatchParserHelper.h b/HotPatcher/Source/HotPatcherRuntime/Public/FlibPatchParserHelper.h index 942cd3cf..e65fbe2c 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Public/FlibPatchParserHelper.h +++ b/HotPatcher/Source/HotPatcherRuntime/Public/FlibPatchParserHelper.h @@ -241,9 +241,12 @@ class HOTPATCHERRUNTIME_API UFlibPatchParserHelper : public UBlueprintFunctionLi static bool IsValidPatchSettings(const FExportPatchSettings* PatchSettings,bool bExternalFilesCheck); static void SetPropertyTransient(UStruct* Struct,const FString& PropertyName,bool bTransient); static FString GetTargetPlatformsCmdLine(const TArray& Platforms); + static FString GetTargetPlatformsStr(const TArray& Platforms); static FString MergeOptionsAsCmdline(const TArray& InOptions); static FString GetPlatformsStr(TArray Platforms); static bool GetCmdletBoolValue(const FString& Token,bool& OutValue); + + static FString ReplacePakRegular(const FReplacePakRegular& RegularConf, const FString& InRegular); }; diff --git a/HotPatcher/Source/HotPatcherRuntime/Public/Templates/HotPatcherTemplateHelper.hpp b/HotPatcher/Source/HotPatcherRuntime/Public/Templates/HotPatcherTemplateHelper.hpp index c845eded..cf865b6d 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Public/Templates/HotPatcherTemplateHelper.hpp +++ b/HotPatcher/Source/HotPatcherRuntime/Public/Templates/HotPatcherTemplateHelper.hpp @@ -311,6 +311,7 @@ namespace THotPatcherTemplateHelper template TArray GetArrayBySrcWithCondition(TArray& SrcArray, TFunction Matcher, bool RemoveFromSrc) { + SCOPED_NAMED_EVENT_TEXT("GetArrayBySrcWithCondition",FColor::Red); TArray result; for(int32 Index = SrcArray.Num() - 1 ;Index >= 0;--Index) { diff --git a/Mods/HotChunker b/Mods/HotChunker index 5a220924..e5689db5 160000 --- a/Mods/HotChunker +++ b/Mods/HotChunker @@ -1 +1 @@ -Subproject commit 5a2209249c5c714f96a1d5cf15d37edb79120fa4 +Subproject commit e5689db545c5dbe5e285e013277e5440687c2d7f diff --git a/Mods/HotMultiCooker b/Mods/HotMultiCooker index e19902cd..db87b2ba 160000 --- a/Mods/HotMultiCooker +++ b/Mods/HotMultiCooker @@ -1 +1 @@ -Subproject commit e19902cd1d9e36481e9d9afc748b1cee68df82b7 +Subproject commit db87b2ba57241ed99d46c53741f17b5165d9ab8b