2021-12-02 06:21:36 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "IVirtualizationBackend.h"
|
|
|
|
|
|
|
|
|
|
#include "Containers/StringView.h"
|
|
|
|
|
|
2022-03-08 11:22:45 -05:00
|
|
|
class ISourceControlProvider;
|
|
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
namespace UE::Virtualization
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This backend can be used to access payloads stored in source control.
|
|
|
|
|
* The backend doesn't 'check out' a payload file but instead will just download the payload as
|
|
|
|
|
* a binary blob.
|
|
|
|
|
* It is assumed that the files are stored with the same path convention as the file system
|
|
|
|
|
* backend, found in Utils::PayloadIdToPath.
|
|
|
|
|
*
|
|
|
|
|
* Ini file setup:
|
2022-03-01 09:05:41 -05:00
|
|
|
* 'Name'=(Type=SourceControl, DepotRoot="//XXX/", UsePartitionedClient=X, SubmitFromTempDir=X)
|
2021-12-02 06:21:36 -05:00
|
|
|
* Where 'Name' is the backend name in the hierarchy and 'XXX' is the path in the source control
|
|
|
|
|
* depot where the payload files are being stored.
|
2021-12-07 03:21:51 -05:00
|
|
|
*
|
|
|
|
|
* Optional Values:
|
2022-03-01 09:05:41 -05:00
|
|
|
* UsePartitionedClient [bool]: When true the temporary workspace client created to submit payloads
|
|
|
|
|
* from will be created as a partitioned workspace which is less overhead
|
|
|
|
|
* on the source control server. If your server does not support this then
|
|
|
|
|
* use false. [Default=True]
|
|
|
|
|
* SubmitFromTempDir [bool]: When set to true, payloads will be submitted from the temp directory of
|
|
|
|
|
* the current machine and when false the files will be submitted from the
|
|
|
|
|
* Save directory of the current project. [Default=false]
|
|
|
|
|
*
|
|
|
|
|
* Environment Variables:
|
|
|
|
|
* UE-VirtualizationWorkingDir [string]: This can be set to a valid directory path that the backend
|
|
|
|
|
* should use as the root location to submit payloads from.
|
|
|
|
|
* If the users machine has this set then 'SubmitFromTempDir'
|
|
|
|
|
* will be ignored.
|
2021-12-02 06:21:36 -05:00
|
|
|
*/
|
|
|
|
|
class FSourceControlBackend final : public IVirtualizationBackend
|
|
|
|
|
{
|
|
|
|
|
public:
|
2022-03-08 11:22:45 -05:00
|
|
|
explicit FSourceControlBackend(FStringView ProjectName, FStringView ConfigName, FStringView InDebugName);
|
2021-12-02 06:21:36 -05:00
|
|
|
virtual ~FSourceControlBackend() = default;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/* IVirtualizationBackend implementation */
|
|
|
|
|
|
|
|
|
|
virtual bool Initialize(const FString& ConfigEntry) override;
|
|
|
|
|
|
2022-02-02 02:21:24 -05:00
|
|
|
virtual EPushResult PushData(const FIoHash& Id, const FCompressedBuffer& Payload, const FString& Context) override;
|
2021-12-08 02:19:42 -05:00
|
|
|
virtual bool PushData(TArrayView<FPushRequest> Requests) override;
|
|
|
|
|
|
2022-02-02 02:21:24 -05:00
|
|
|
virtual FCompressedBuffer PullData(const FIoHash& Id) override;
|
2021-12-02 06:21:36 -05:00
|
|
|
|
2022-02-02 02:21:24 -05:00
|
|
|
virtual bool DoesPayloadExist(const FIoHash& Id) override;
|
2021-12-02 06:21:36 -05:00
|
|
|
|
2022-02-02 02:21:24 -05:00
|
|
|
virtual bool DoPayloadsExist(TArrayView<const FIoHash> PayloadIds, TArray<bool>& OutResults) override;
|
2021-12-02 06:21:36 -05:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2022-02-02 02:21:24 -05:00
|
|
|
void CreateDepotPath(const FIoHash& PayloadId, FStringBuilderBase& OutPath);
|
2021-12-02 06:21:36 -05:00
|
|
|
|
2022-03-01 09:05:41 -05:00
|
|
|
bool FindSubmissionWorkingDir(const FString& ConfigEntry);
|
|
|
|
|
|
2022-01-18 04:50:38 -05:00
|
|
|
/** Will display a FMessage notification to the user on the next valid engine tick to try and keep them aware of connection failures */
|
|
|
|
|
void OnConnectionError();
|
2022-03-08 11:22:45 -05:00
|
|
|
|
2022-03-09 07:43:59 -05:00
|
|
|
/** A source control connection owned by the backend*/
|
|
|
|
|
TUniquePtr<ISourceControlProvider> SCCProvider;
|
|
|
|
|
|
2022-03-08 11:22:45 -05:00
|
|
|
/** The name of the current project */
|
|
|
|
|
FString ProjectName;
|
|
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
/** The root where the virtualized payloads are stored in source control */
|
|
|
|
|
FString DepotRoot;
|
2021-12-07 03:21:51 -05:00
|
|
|
|
2022-03-01 09:05:41 -05:00
|
|
|
/** The root directory from which payloads are submitted. */
|
|
|
|
|
FString SubmissionRootDir;
|
|
|
|
|
|
2021-12-07 03:21:51 -05:00
|
|
|
/** Should we try to make the temp client partitioned or not? */
|
|
|
|
|
bool bUsePartitionedClient = true;
|
|
|
|
|
|
2021-12-02 06:21:36 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace UE::Virtualization
|