Commit Graph

32 Commits

Author SHA1 Message Date
paul chipchase
c9b660cc17 Add the json module to UnrealVirtualizationTool.
#rb trivial
#rnx
#preflight 640749b38c0039bbf7b538ee

- Allows UVT to compile in modular mode.

[CL 24539631 by paul chipchase in ue5-main branch]
2023-03-07 09:40:26 -05:00
christopher waters
6a4206d490 Removing bad Launch include paths from programs.
[CL 24328631 by christopher waters in ue5-main branch]
2023-02-20 17:39:13 -05:00
paul chipchase
e17610f1e1 [UVT] Replace the cmdline parameter -verbose with -minimallogging and invert the meaning.
#rb trivial
#jira UE-177413
#preflight 63ef542fe832ea950a6d936c

- This means by default all log messages with 'Display' verbosity will be shown, we will only demote them to 'Log' verbosity when -minimallogging is passed in.
- UVT was originally intended to be called as a custom tool in P4V, at which point it made sense to hide a lot of the logging from the user so that the output would be easier for them to follow and if they did encounter a problem they could send the full log file in the bug report.
- In the past few months there has been an increase in people trying to use UVT to verify that they have setup VA on their project correctly rather than using the editor. In many of these cases it was not obvious that they'd need to pass in -verbose to see full output.
- By inverting the cmdline meaning we can display all logging to people by default (i.e. calling from the command line) and then supress the logging when called via P4V by using the new cmdline.

[CL 24279361 by paul chipchase in ue5-main branch]
2023-02-17 06:33:41 -05:00
paul chipchase
7b6f99c298 Fix CIS issue in UnrealVirtualizationTool from CL 24257111
#rb none
#jira none
#preflight skip

- TCHAR* -> const TCHAR*

[CL 24258937 by paul chipchase in ue5-main branch]
2023-02-16 11:21:13 -05:00
paul chipchase
d4b2bffc6f [UVT] Improve the output when -help is passed in or the commandline provided is incorrect.
#rb trivial
#jira none
#rnx
#preflight 63ee4321bd6bb956b9174a6e

- Improve some formatting and make it clear that the virtualize and rehydrate modes should take the project path too.

[CL 24257706 by paul chipchase in ue5-main branch]
2023-02-16 10:21:04 -05:00
paul chipchase
479468c9ee [UVT] Improve the robustness of the tool wrt ensuring that the correct project config settings are loaded.
#rb Per.Larsson
#jira UE-151641
#preflight 63ea068cde74ffbae5dc3a7f

### Problem
- A lot of systems rely on the engine to know which project is being loaded on start up so that the correct config settings can be applied however so far the UVT has not required the user to provide the desired project. This is because in theory, the tool could be given a list of packages or a changelist to process that contain packages from more than one project and if that happens we need to handle it correctly.
- The tool currently groups the provided packages by project, then runs the requested command on each project one at a time, initializing the VA system with that projects config files, then shutting it done once the project packages are processed. This allows us to pick up the correct settings for VA but other systems that we rely on, such as the DDC do not allow this sort of dynamic initialization and so may not have the correct settings.

### Solution
- Before the projects packages are processed we check to see if the project applied to the process during initialization (if any) matches the project to be processed. If not we launch a new version of the tool with the correct project settings and have the child process perform the main processing. The output of each child process (or any projects we were able to run in process) are then provided to the command for a final "post projects" phase.
- This means we can support multiple packages from multiple processes AND not require the user type out the project name when using the tool from the cmdline.
- Although launching a child process only adds a few seconds of overhead (per project) any tool or process that make use of UVT should be updated to provide the project where possible.

### Changes

### FUnrealVirtualizationToolApp
- As explained in the problem section, we now need to support launching a new instance of the tool as a child process.
- We communicate with the child process by providing an input file via the cmdline, which is then parsed and used to recreate the original command and project settings. Once the command has run in the child process it will write its output to an output file which the calling process can then read back in.
- So our new logic is to check the project that the tool was started with (in case the user provided a project path in the cmdline) against each project that we need to process. If the paths match then we can just process the project, if they do not match we launch a child process with the correct path and retrieve the output once done.
-- If a child process detects an incorrect path we just error out to avoid endless recursive process launching.
- Output from the child process is clearly logged to the user as coming from a child process to make debugging easier.

### FCommand
- Added ToJson/FromJson methods to FCommand, which simulates the same interface as though it was using the json serialization macros, however we want more control over things so do the serialization manually via FCommand::Serialize
-- Serialization is only used if the command is sent to a child process (if the current project is wrong), in which case the command should serialize out all info that it derived during setup that it will need to process correctly. Usually this consists of the options that were parsed from the command line. Then when the child process is run we will recreate the command via the same serialize method.
- Added a new class FProcessPipes, which acts as a wrapper around the pipes we can create by calling FPlatformProcess::CreatePipe which are returned as raw pointers. This ensures that the pipes are cleaned up once the FProcessPipes object goes out of scope.
- The ::Run method has been split into two, ::ProcessProject and ::ProcessOutput
-- ::ProcessProject is called once per project and allows the command to return output via the Output parameter. This can be call in process or via a child process if the project needs to be set.
-- ::ProcessOutput is called once all projects have been processed and provides an array which is a collection of the output from each call to ::ProcessProject. This is always called in process.
-- The output is passed around by the base type FCommandOutput. It is expected that commands derive their own type and as we do not mix command types, they should know how to cast the output back to the correct type when ::ProcessOutput is called. This is a bit messy but to go further risks over engineering given it is unlikely that more commands will be added to the tool. If we do expand the tool in the future then this can be revisited.

### FCommandOutput
- A struct used to represent the output of a command.
- If the command is run as a child process then this struct will be serialized out to disk (via json) then loaded back in by the calling process so that the output of each child process can be combined.
- Commands are expected to derive their own output structure and deal with the json serialization. To make this easier we provide a JSON_SERIALIZE_PARENT macro to allow for serialization of inheritance chains.
- This system does require that commands know which type of output to cast FCommandOutput to. At the moment we do not provide any type safety.

- Add json serialization to FProject and it's child struct FPlugin.
- FProject::GetProjectFilePath now returns as a reference to a FString rather than a FStringView.

[CL 24257111 by paul chipchase in ue5-main branch]
2023-02-16 09:18:15 -05:00
paul chipchase
dad1eaf01d [UVT] Improve error handling when failing to establish a perforce connection.
#rb trivial
#jira UE-151641
#rnx
#preflight 63d94cd3ba4fadeef0930cca

- As ISourceControlProvide::Init does not return if a connection was established or not we need to also call ISourceControlProvide::IsAvailable afterwards to check if we actually have a connection.
- This lets us fail early with a more specific error message rather than waiting for the first command to fail especially as our commands rarely print useful errors if the connection failed.

[CL 23931768 by paul chipchase in ue5-main branch]
2023-01-31 13:16:46 -05:00
paul chipchase
71ca126806 [UVT] Improve error message to reflect the actual problem (we could not create a perforce source control provider object rather than the actual connection failing)
#rb trivial
#jira none
#rnx
#preflight 63d9307867116074a86b1d42

[CL 23927828 by paul chipchase in ue5-main branch]
2023-01-31 10:58:11 -05:00
paul chipchase
f1b333d0b7 Clean up FCommand::TryConnectToSourceControl by adding an overload with no parameters.
#rb trivial
#jira none
#rnx
#preflight none (accidently submitted instead of launching preflight)

- This makes calling it without a valid client spec alittle cleaner as we no longer need to pass in a dummy FStringView/String

[CL 23926635 by paul chipchase in ue5-main branch]
2023-01-31 09:51:49 -05:00
paul chipchase
f7dc043d70 Fix the UnrealVirtualizationTool to work with the new interactive login system for the cloud DDC
#rb Sebastian.Nordgren
#jira UE-175587
#rnx
#preflight 63d8ec967a39a18021c168bf

- The DDC module can now invoke the 'DesktopPlatform' module when trying to set up the interactive ddc login. At the moment the 'DerivedDataCache' module only links to the includes with no dependency on the module itself so as a short term fix I am adding a dependency from the tool itself.
- The interactive login process relies on our basic OS message dialogs. On windows this requires that the .rc file in the 'Launch' module be included otherwise the message dialog will not be shown. We don't want a dependency on that module directly as it is super heavy weight but we can add our own .rc file for the tool and inside that include the .rc file of the 'Launch' module.

[CL 23926364 by paul chipchase in ue5-main branch]
2023-01-31 09:18:11 -05:00
Tim Smith
b8ba7e3884 Change mention of "UnrealHeaderTool" to "This app" in comment.
#rb self
#rnx
#preflight 63c57ab02e714f64ade3bbab

[CL 23730156 by Tim Smith in ue5-main branch]
2023-01-16 11:43:11 -05:00
paul chipchase
7c4a834261 Change TryVirtualizePackages/TryRehydratePackages to return the corresponding results structure rather than an enum value.
#rb Per.Larsson
#jira UE-169626
#rnx
#preflight 63bd670a71079a8d1c0e837b

- Since the API was forcing the caller to pass in a results structure to be filled in, we might as well make it the return value.
- Added a ::WasSuccessful method to the results structures that can be used instead of checking if the result had errors or not.
- Remove the reset method from FVirtualizationResult/FRehydrationResult as they no longer need it.
- The older deprecated methods still use the results enum, so we cannot easily deprecate those enums yet.

[CL 23626072 by paul chipchase in ue5-main branch]
2023-01-10 09:15:11 -05:00
paul chipchase
66b32a743f Add a new overload to IVirtualizationSystem::TryRehydratePackages, which takes additional options (via a bitfield enum) and returns more info about the resulting process. The original version has been deprecated.
#rb Per.Larsson
#jira UE-169626
#rnx
#preflight 63bd0ebfd862fdd347bce1fe

### VA System
- This allows us to provide the user with more ways to customize the rehydration and return more detailed info about it if the calling code wishes to log additional info. In both cases we can extend the options and the data returned without changing the API.
- At the moment the only flag we support is 'Checkout', which requests that the rehydration process checkout any package that it needs to modify rather than giving an error. This means that the user does not need to check packages out from revision control before running the rehydration process.
-- We still check if packages can be modified and warn the user if they can't, as package files could be locked in other ways.
- The rehydration process will now long the time taken if verbose logging is set for the category 'LogVirtualization'

### UnrealVirtualizationTool
- The virtualize command now reports how many packages were checked out if the flag was set.
- The rehydration command now supports a '-Checkout' commandline flag, which when enabled will use the new api to checkout the packages that need to be checked out when rehydrated.

[CL 23625132 by paul chipchase in ue5-main branch]
2023-01-10 06:27:20 -05:00
paul chipchase
0881177c30 Improved a code comment to be less confusing based on licensee feedback.
#rb trivial
#rnx
#preflight 63bd30b3c927e34482c4d099

[CL 23624774 by paul chipchase in ue5-main branch]
2023-01-10 04:50:50 -05:00
devin doucette
cc99d6c295 Logging: Added structured logging support to non-platform feedback contexts
#jira UE-152840
#preflight 63b4824f717a593ee7f1e245
#rb Zousar.Shaker
#rnx

[CL 23570675 by devin doucette in ue5-main branch]
2023-01-03 17:15:30 -05:00
paul chipchase
80beaf7cc8 Add a new overload to IVirtualizationSystem::TryVirtualizePackages, which takes additional options (via a bitfield enum) and returns more info about the resulting process. The original version has been drepcated.
#rb Per.Larsson
#jira UE-169626
#rnx
#preflight 639c4112012902cb8db43e13

- This allows us to provide the user with more ways to customize the virtualization and return more detailed info about it if the calling code wishes to log additional info. In both cases we can extend the options and the data returned without changing the API.
- Previously if we virtualized a package that was not checked out in revision control we would warn the user and then skip updating the package file on disk. This means the payloads would be uploaded but the user would be left with no local changes. Since sometimes we know we don't need to check out any package (virtualizing the packages in a change list for example) we don't want to always incur the cost of polling reivision control to see which packages do need checking out. This is why we now allow the caller to request package files be checked out via the new options enum EVirtualizationOptions.
-- If the EVirtualizationOptions::Checkout flag is provided we will poll the revision control status of all package files and then check out those which need it.
-- We still check if packages can be modified and warn the user if they can't, as package files could be locked in other ways.
- Added a new utility function to SourceControlUtilties to make it easier to check out packages. There is similar functionality elsewhere in the code base but the virtualization module is too low level to make use of it.
- Updated existing code that calls ::TryVirtualizePackages and add cases of ''using namespace UE::Virtualization' where required to improve readability.
- The UnrealVirtualizationTool now supports a new cmdline option "-checkout" that can be used when virtualizing packages. This will checkout any package that was actually virtualized so the result can be saved back out to the workspace domain. This means we no longer require the caller to have checked out the packages before running the tool.

[CL 23536832 by paul chipchase in ue5-main branch]
2022-12-16 06:25:07 -05:00
paul chipchase
5ec168007f Fix a shutdown crash in UVT if the virtualization command returns an error
#rb trivial
#jira none
#rnx
#preflight 639877140a6715255053caad

- Moved the shutdown code to scope exit so that they will continue to trigger on any early out paths.

[CL 23490478 by paul chipchase in ue5-main branch]
2022-12-13 08:05:24 -05:00
paul chipchase
c9735099a8 UnrealVirtualizationTool can now be given the path of a package or the path of a directory of packages to virtualize in addition to previous functionality. NOTE that all existing functionality should continue to work but using -Mode=Changelist or -Mode=Packagelist will result in a warning prompting the future use of the new versions for those commands.
#rb Per.Larsson
#jira UE-170657, UE-160396
#rnx
#preflight 637c9232fa348e8480bdc7e2

- When the rehydration functionality was added it started to look like more functionality would be added to the tool than originally thought so I started to add the new functionality via a command system. This change now moves the older legacy functionality to the coommand system as well.
- Added a new FVirtualizeCommand which can accept package paths, directory paths, packagelist files or changelists as the input.
-- Unlike the legacy commands, virtualizing via changelist does not require the client spec to be provided on the commandline, although doing so will avoid several perforce commands and speed up the call. It is expected that people calling the tool on the commandline will probably opt to not supply a clientspec and let the tool workout which workspace a changelist is under, where as calls from other tools (such as P4VUtils) can provide it if already known to speed things up.
-- FVirtualizeLegacyChangeListCommand replicates the functionality of the old -Mode=Changelist command.
-- FVirtualizeLegacyPackageListCommand replicates the functionality of the old -Mode=Packagelist command.
-- The new command will only try to submit the results if a changelist was provided as the input and even then it will not do so by default. The tool now requires people to opt into submitting the changelist via the command line option -submit. NOTE: Other versions of the command maybe allow submission in the future but the virtualization process needs to be improved so that it can check out package files before this really makes sense.
- The rehydration command no longer requires a clientspec on the command line, it wasn't using the value anyway.
- Moved the source control code from the app code files to CommandBase. If we add more commands in the future we might want to factor this out to its own base class so commands can opt into source control functionality.
- In the future we should probably move the package -> project sorting code (FUnrealVirtualizationToolApp::TrySortFilesByProject) into the command base code as well.

[CL 23233456 by paul chipchase in ue5-main branch]
2022-11-22 07:23:08 -05:00
paul chipchase
c198ede895 Add missing include to UnrealVirtualizationTool
#rb trivial
#rnx
#preflight 636e4e7f9e3bea8079595cb5

[CL 23097190 by paul chipchase in ue5-main branch]
2022-11-11 08:41:58 -05:00
henrik karlsson
b985fbd1b1 Removed lots of includes in high traffic headers in order to reduce compile times. Headers are still included if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2 is set to 1
List of highlights
* PlayerController - Removed ForceFeedback and and OnlineReplStructs
* Class - Removed Package.h
* World - Pawn, Blueprint and GameInstance
* Actor - CoreNet, HitResult and ActorDatalayer
* EngineBaseTypes - TaskGraphInterface
* AssetManager - AssetData
* Scene/Child/ActorComponent - CoreNet
* AnimInstance - AttributesRuntime, Skeleton, AnimCurveTypes, AnimMontage, BonePose
* BulkData - IoDispatcher
* AssetData - IoDispatcher, LinkerLoad
* SecureHash - AsyncWork
* CanvasTypes - UnrealEngine, StaticMeshResources
* IpAddress - AsyncWork, Stats

#preflight 6363717ece676ae8688f5d8c
#rb none

[CL 22968258 by henrik karlsson in ue5-main branch]
2022-11-03 17:56:44 -04:00
paul chipchase
fc827406e2 Add a number of ways for the VA system to be changed to lazy initialize on first use.
#rb Per.Larsson
#jira UE-161296
#rnx
#preflight 62fe3ce73d3fb466b229bcc0

- There are some usecases that require the VA system to initialize the first time it is accessed (usually the first time we attempt to pull a virtualized payload) rather than be initialized in the program start up. This change provides three different methods to achieve this:
-- Setting the define 'UE_VIRTUALIZATION_SYSTEM_LAZY_INIT' to 1 in a programs .target.cs
-- Setting [Core.ContentVirtualization]LazyInit=true in the Engine ini file
-- Running with the commandline option -VA-LazyInit

- If we detect that the source control backend is being initialized on a background thread we do not try to run the FConnect operation. The backend will still work but this does reduce the potential error checking on initialization. This is done because the FConnect operation currently only works on the main thread and to change this would be a bigger work item than we can schedule at the moment.
- UE::Virtualization::Initialize functions now take a EInitializationFlags enum as a parameter. This enum allows the call to ignore all lazy init settings and force the initialization immediately. This is useful for programs like the Virtualization standalone tool which just needs to start the system when needed.
-- The call to ::Initialize in LaunchEngineLoop passes in None and does not ignore lazy initialization.
-- Calls to ::Initialize in the UnrealVirtualizationTool however all use EInitializationFlags::ForceInitialize and ignore lazy initialization settings.
- Fixed an odd bug in UE::Virtualization::Initialize where the error path (if the config file cannot be found) was using a different start up code path.
- Add asserts when assigning to GVirtualizationSystem to make sure that it is null. This is not 100% safe but should catch some potential threading issues, if any.
- Add an assert after lazy initialization (IVirtualizationSystem::Get) to make sure that GVirtualizationSystem was assigned a valid object.
- Improve how we check for legacy values in [Core.ContentVirtualization]. We now support multiple allowed values.
- Added a way to poll if a VA system has been initialize yet or not, this allows us to avoid initializing a VA system if one has not yet been created and we try to:
-- Dump VA profiling stats after cooking
-- Send VA stats to studio analytics
- Note that currently using lazy init loading will probably cause the VA statistics panel not to work, this will be fixed in future work where we will allow the panel to register for a callback when the system is initialized.

[CL 21467510 by paul chipchase in ue5-main branch]
2022-08-19 19:15:42 -04:00
paul chipchase
7fa61baff0 Move anon namespace out of the named namespace to avoid naming confusion.
#rb trivial
#rnx
#preflight 62d16c2baf68cd745b71b0c4

[CL 21109457 by paul chipchase in ue5-main branch]
2022-07-15 09:51:54 -04:00
paul chipchase
0fd3ca3da4 Add a rehydration command to the stand alone virtualization tool, making it easier to reverse the effects of asset virtualization. Unlike previous processes, this one does not require that we load the package and will just manipulate the data storaged in the package trailer.
#rb Sebastian.Nordgren
#rnx
#jira UE-156436
#preflight 62c287f9a3568e30664eb94f

### VA Standalone Tool
- We now plan to add much more functionality to the tool than just virtualizing and submitting changelists, so to make this easier I am moving the tool towards a design where it should be fairly easy to add new functionality.
- Added FCommand, which is a base class for adding new functionality, simple derive from FCommand and hook it up at the appropriate locations.
-- In the future it should be possible for new command types to automatically register themselves to be initiated from the command line. There should be no need to edit UnrealVirtualizationToolApp to add a new command but this will be done as an additional work item.
-- At the moment FCommand comes with a number of utility methods to call that cover some common source control commands.
-- The original functionality has not yet been moved to the command system and so the code is a little bit weird at the moment. Updating older code to the new system will be done as an additional work item.
- FProject/FPlugin have been moved to their own code files.

### Rehydrate Command
- The rehydrate command will take a number of packages, check them out of source control and then attempt to virtualize them.
- At the moment the chekout logic is fairly basic, we just check out every package supplied, we don't check if the package is virtualized or not yet. This can be improved in additional work items. Ideally by the end of command the only packages that we have checked out should also be rehydrated.
- At the moment the command can either take a path of a specific package, a path of a directory to find packages in, or a changelist containing packages that should be rehydrated.
- A cleint spec (workspace) can optionally be provided, but if not supplied we will attempt to find a client spec for which to check out the packages.
- Currently we will check out the packages to the default change list.

### Rehydrate process
- Added the rehydration process in it's own code files in the virtualization module. Like the virtualization process this is exposed in a public header file and no via the Core interface which means it is very specific to our module/implementation.
- The process expects that the caller will have checked out any required packages from source control. It will treat being unable to update a package file as an error.
- Added PackageUtils.h/.cpp and moved some of the generic code from the virtualization process code there so that it can be shared by the rehydration process.

### Misc
Moving away from the using things like FPackagePath as that requires that the correct mount points have been registered for a project and at the moment (with the flakiness of FConfig*) it seems that the best idea would be to prefer absolute file paths where possible.

[CL 20982284 by paul chipchase in ue5-main branch]
2022-07-07 06:54:33 -04:00
marc audy
b5340b7540 Fixup ANY_PACKAGE in UnrealVirtualizationTool
#rnx
[CODEREVIEW] Robert.Manuszewski, Paul.Chipchase

#ROBOMERGE-AUTHOR: marc.audy
#ROBOMERGE-SOURCE: CL 20453799 in //UE5/Release-Engine-Staging/...
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v952-20449836)

[CL 20460755 by marc audy in ue5-main branch]
2022-06-01 18:10:56 -04:00
paul chipchase
b61cc7f1d6 Fix the virtualization tool so that it will virtualize packages with more than one content directory in their path.
#rb trivial
#rnx
#preflight 628ccc455665463c21036888

- The main change is that if we do not find the project file relative to the first /content/ directory we will keep looking up the path to see if we can find additional /content/ directories.
- All log messages have been changed to warnings for consistency.

[CL 20346906 by paul chipchase in ue5-main branch]
2022-05-24 08:50:14 -04:00