2018-12-14 13:41:00 -05:00
|
|
|
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
|
2014-11-07 09:55:57 -05:00
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "ContentSourceProviders/FeaturePack/FeaturePackContentSourceProvider.h"
|
|
|
|
|
#include "GenericPlatform/GenericPlatformFile.h"
|
|
|
|
|
#include "HAL/PlatformFilemanager.h"
|
|
|
|
|
#include "HAL/FileManager.h"
|
|
|
|
|
#include "Modules/ModuleManager.h"
|
2014-11-07 09:55:57 -05:00
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "DirectoryWatcherModule.h"
|
2014-11-07 09:55:57 -05:00
|
|
|
#include "FeaturePackContentSource.h"
|
|
|
|
|
|
2014-12-11 09:08:57 -05:00
|
|
|
|
2014-11-07 09:55:57 -05:00
|
|
|
class FFillArrayDirectoryVisitor : public IPlatformFile::FDirectoryVisitor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) override
|
|
|
|
|
{
|
|
|
|
|
if (bIsDirectory)
|
|
|
|
|
{
|
|
|
|
|
Directories.Add(FilenameOrDirectory);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Files.Add(FilenameOrDirectory);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<FString> Directories;
|
|
|
|
|
TArray<FString> Files;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FFeaturePackContentSourceProvider::FFeaturePackContentSourceProvider()
|
|
|
|
|
{
|
2015-05-31 12:48:56 -04:00
|
|
|
FeaturePackPath = FPaths::FeaturePackDir();
|
2017-11-21 16:14:55 -05:00
|
|
|
EnterpriseFeaturePackPath = FPaths::EnterpriseFeaturePackDir();
|
2015-07-13 05:47:36 -04:00
|
|
|
TemplatePath = FPaths::RootDir() + TEXT("Templates/");
|
2017-11-21 16:14:55 -05:00
|
|
|
EnterpriseTemplatePath = FPaths::EnterpriseDir() + TEXT("Templates/");
|
2014-12-11 09:08:57 -05:00
|
|
|
StartUpDirectoryWatcher();
|
|
|
|
|
RefreshFeaturePacks();
|
2014-11-07 09:55:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TArray<TSharedRef<IContentSource>> FFeaturePackContentSourceProvider::GetContentSources()
|
|
|
|
|
{
|
|
|
|
|
return ContentSources;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FFeaturePackContentSourceProvider::SetContentSourcesChanged(FOnContentSourcesChanged OnContentSourcesChangedIn)
|
|
|
|
|
{
|
|
|
|
|
OnContentSourcesChanged = OnContentSourcesChangedIn;
|
2014-11-07 13:16:53 -05:00
|
|
|
}
|
|
|
|
|
|
2014-12-11 09:08:57 -05:00
|
|
|
void FFeaturePackContentSourceProvider::StartUpDirectoryWatcher()
|
|
|
|
|
{
|
|
|
|
|
FDirectoryWatcherModule& DirectoryWatcherModule = FModuleManager::LoadModuleChecked<FDirectoryWatcherModule>(TEXT("DirectoryWatcher"));
|
|
|
|
|
IDirectoryWatcher* DirectoryWatcher = DirectoryWatcherModule.Get();
|
|
|
|
|
if (DirectoryWatcher)
|
|
|
|
|
{
|
|
|
|
|
// If the path doesn't exist on disk, make it so the watcher will work.
|
|
|
|
|
IFileManager::Get().MakeDirectory(*FeaturePackPath);
|
|
|
|
|
DirectoryChangedDelegate = IDirectoryWatcher::FDirectoryChanged::CreateRaw(this, &FFeaturePackContentSourceProvider::OnFeaturePackDirectoryChanged);
|
2015-01-08 09:29:27 -05:00
|
|
|
DirectoryWatcher->RegisterDirectoryChangedCallback_Handle(FeaturePackPath, DirectoryChangedDelegate, DirectoryChangedDelegateHandle);
|
2017-11-21 16:14:55 -05:00
|
|
|
|
|
|
|
|
if (IFileManager::Get().DirectoryExists(*FPaths::EnterpriseDir()))
|
|
|
|
|
{
|
|
|
|
|
// If the path doesn't exist on disk, make it so the watcher will work.
|
|
|
|
|
IFileManager::Get().MakeDirectory(*EnterpriseFeaturePackPath);
|
|
|
|
|
DirectoryWatcher->RegisterDirectoryChangedCallback_Handle(EnterpriseFeaturePackPath, DirectoryChangedDelegate, DirectoryChangedDelegateHandle);
|
|
|
|
|
}
|
2014-12-11 09:08:57 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FFeaturePackContentSourceProvider::ShutDownDirectoryWatcher()
|
|
|
|
|
{
|
|
|
|
|
FDirectoryWatcherModule& DirectoryWatcherModule = FModuleManager::LoadModuleChecked<FDirectoryWatcherModule>( TEXT( "DirectoryWatcher" ) );
|
|
|
|
|
IDirectoryWatcher* DirectoryWatcher = DirectoryWatcherModule.Get();
|
|
|
|
|
if ( DirectoryWatcher )
|
|
|
|
|
{
|
2015-01-08 09:29:27 -05:00
|
|
|
DirectoryWatcher->UnregisterDirectoryChangedCallback_Handle(FeaturePackPath, DirectoryChangedDelegateHandle);
|
2017-11-21 16:14:55 -05:00
|
|
|
DirectoryWatcher->UnregisterDirectoryChangedCallback_Handle(EnterpriseFeaturePackPath, DirectoryChangedDelegateHandle);
|
2014-12-11 09:08:57 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FFeaturePackContentSourceProvider::OnFeaturePackDirectoryChanged( const TArray<FFileChangeData>& FileChanges )
|
|
|
|
|
{
|
|
|
|
|
RefreshFeaturePacks();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 07:47:41 -04:00
|
|
|
/** Sorting function sort keys. */
|
|
|
|
|
struct FFeaturePackCompareSortKey
|
|
|
|
|
{
|
|
|
|
|
FORCEINLINE bool operator()( TSharedRef<IContentSource> const& A, TSharedRef<IContentSource> const& B) const { return A->GetSortKey() < B->GetSortKey(); }
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-11 09:08:57 -05:00
|
|
|
void FFeaturePackContentSourceProvider::RefreshFeaturePacks()
|
|
|
|
|
{
|
|
|
|
|
ContentSources.Empty();
|
2015-07-13 05:47:36 -04:00
|
|
|
// TODO improve this and seperate handling of .upack and manifest (loose) parsing
|
|
|
|
|
// first the .upack files
|
2014-12-11 09:08:57 -05:00
|
|
|
IPlatformFile &PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
|
|
|
|
|
FFillArrayDirectoryVisitor DirectoryVisitor;
|
2017-11-21 16:14:55 -05:00
|
|
|
PlatformFile.IterateDirectory(*FeaturePackPath, DirectoryVisitor);
|
|
|
|
|
PlatformFile.IterateDirectory(*EnterpriseFeaturePackPath, DirectoryVisitor);
|
2014-12-11 09:08:57 -05:00
|
|
|
for ( auto FeaturePackFile : DirectoryVisitor.Files )
|
|
|
|
|
{
|
2015-01-07 03:33:48 -05:00
|
|
|
if( FeaturePackFile.EndsWith(TEXT(".upack")) == true)
|
2014-12-11 09:08:57 -05:00
|
|
|
{
|
2015-01-07 03:33:48 -05:00
|
|
|
TUniquePtr<FFeaturePackContentSource> NewContentSource = MakeUnique<FFeaturePackContentSource>(FeaturePackFile);
|
|
|
|
|
if (NewContentSource->IsDataValid())
|
|
|
|
|
{
|
|
|
|
|
ContentSources.Add(MakeShareable(NewContentSource.Release()));
|
|
|
|
|
}
|
2014-12-11 09:08:57 -05:00
|
|
|
}
|
|
|
|
|
}
|
2015-07-13 05:47:36 -04:00
|
|
|
|
|
|
|
|
// Now the 'loose' feature packs
|
|
|
|
|
FFillArrayDirectoryVisitor TemplateDirectoryVisitor;
|
|
|
|
|
PlatformFile.IterateDirectoryRecursively(*TemplatePath, TemplateDirectoryVisitor);
|
2017-11-21 16:14:55 -05:00
|
|
|
PlatformFile.IterateDirectoryRecursively(*EnterpriseTemplatePath, TemplateDirectoryVisitor);
|
2015-07-13 05:47:36 -04:00
|
|
|
for (auto TemplatePackFile: TemplateDirectoryVisitor.Files)
|
|
|
|
|
{
|
|
|
|
|
FString ThisPackRoot = FPaths::GetPath(TemplatePackFile);
|
|
|
|
|
if (ThisPackRoot.EndsWith(TEXT("FeaturePack")) == true)
|
|
|
|
|
{
|
|
|
|
|
if(TemplatePackFile.EndsWith(TEXT("manifest.json")) == true)
|
|
|
|
|
{
|
|
|
|
|
TUniquePtr<FFeaturePackContentSource> NewContentSource = MakeUnique<FFeaturePackContentSource>(TemplatePackFile);
|
|
|
|
|
if (NewContentSource->IsDataValid())
|
|
|
|
|
{
|
|
|
|
|
ContentSources.Add(MakeShareable(NewContentSource.Release()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-03-19 07:47:41 -04:00
|
|
|
ContentSources.Sort(FFeaturePackCompareSortKey());
|
2014-12-11 09:08:57 -05:00
|
|
|
OnContentSourcesChanged.ExecuteIfBound();
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-07 13:16:53 -05:00
|
|
|
FFeaturePackContentSourceProvider::~FFeaturePackContentSourceProvider()
|
|
|
|
|
{
|
2014-12-11 09:08:57 -05:00
|
|
|
ShutDownDirectoryWatcher();
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
}
|