You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #jira UE-174785 #rnx #preflight 63ff0ceeae54ee4ce912c17c - Recently how we discover packages for the VA commandlets was changed to be much faster but it was also changed to automatically filter out all engine content as we removed the optional (opt in) feature of virtualizing engine content. - This meant that 'CheckForVirtualizedContent' would not be able to check engine packages if '-CheckEngine' was set as we were not providing the commandlet with them. - ::FindAllPackages has been renamed ::FindPackages and both it and ::DiscoverPackages now accept a flags parameter that allows the caller to request that engine content be excluded. - Although most commandlets do not want engine content, having the engine content filter as opt in closer matches existing apis and will probably lead to less mistakes. [CL 24459148 by paul chipchase in ue5-main branch]
77 lines
2.6 KiB
C++
77 lines
2.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "GeneratePayloadManifestCommandlet.h"
|
|
|
|
#include "CommandletUtils.h"
|
|
#include "HAL/FileManager.h"
|
|
#include "Misc/PackageName.h"
|
|
#include "Misc/PackagePath.h"
|
|
#include "Misc/Paths.h"
|
|
#include "UObject/PackageTrailer.h"
|
|
|
|
UGeneratePayloadManifestCommandlet::UGeneratePayloadManifestCommandlet(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
}
|
|
|
|
int32 UGeneratePayloadManifestCommandlet::Main(const FString& Params)
|
|
{
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(UGeneratePayloadManifestCommandlet);
|
|
|
|
TArray<FString> PackageNames = UE::Virtualization::DiscoverPackages(Params, UE::Virtualization::EFindPackageFlags::ExcludeEngineContent);
|
|
|
|
UE_LOG(LogVirtualization, Display, TEXT("Found %d files to look in"), PackageNames.Num());
|
|
|
|
int32 PackageTrailerCount = 0;
|
|
|
|
const FString CSVPath = FPaths::ProjectSavedDir() / TEXT("payload_manifest.csv");
|
|
TUniquePtr<FArchive> ManifestFile(IFileManager::Get().CreateFileWriter(*CSVPath));
|
|
if (!ManifestFile.IsValid())
|
|
{
|
|
UE_LOG(LogVirtualization, Error, TEXT("Failed to open '%s' for write"), *CSVPath);
|
|
return 1;
|
|
}
|
|
|
|
const ANSICHAR* Headings = "Path,PayloadId,SizeOnDisk,UncompressedSize,StorageType, FilterReason\n";
|
|
ManifestFile->Serialize((void*)Headings, FPlatformString::Strlen(Headings));
|
|
|
|
{
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(ParsePackageTrailers);
|
|
|
|
UE_LOG(LogVirtualization, Display, TEXT("Parsing files..."));
|
|
|
|
uint32 FilesParsed = 0;
|
|
for (const FString& PackagePath : PackageNames)
|
|
{
|
|
if (FPackageName::IsPackageFilename(PackagePath))
|
|
{
|
|
UE::FPackageTrailer Trailer;
|
|
if (UE::FPackageTrailer::TryLoadFromFile(PackagePath, Trailer))
|
|
{
|
|
PackageTrailerCount++;
|
|
|
|
Trailer.ForEachPayload([&ManifestFile,&PackagePath](const FIoHash& Id, uint64 SizeOnDisk, uint64 RawSize, UE::EPayloadAccessMode Mode, UE::Virtualization::EPayloadFilterReason Filter)->void
|
|
{
|
|
TAnsiStringBuilder<256> LineBuilder;
|
|
LineBuilder << PackagePath << "," << Id << "," << SizeOnDisk << "," << RawSize << "," << Mode << "," << *LexToString(Filter) <<"\n";
|
|
ManifestFile->Serialize((void*)LineBuilder.ToString(), LineBuilder.Len());
|
|
});
|
|
}
|
|
}
|
|
|
|
if (++FilesParsed % 10000 == 0)
|
|
{
|
|
float PercentCompleted = ((float)FilesParsed / (float)PackageNames.Num()) * 100.0f;
|
|
UE_LOG(LogVirtualization, Display, TEXT("Parsed %d/%d (%.0f%%)"), FilesParsed, PackageNames.Num(), PercentCompleted);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
ManifestFile.Reset(); // Flush file to disk
|
|
|
|
UE_LOG(LogVirtualization, Display, TEXT("Found %d package trailers"), PackageTrailerCount);
|
|
UE_LOG(LogVirtualization, Display, TEXT("Manifest written to '%s'"), *CSVPath);
|
|
|
|
return 0;
|
|
} |