You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Deprecated some global functions now in ConfigUtilities - Deleted a couple of old deprecated stuff from 3.24 #rb chris.waters #preflight 628415e1ba3597a030b3b900 [CL 20259749 by Josh Adams in ue5-main branch]
108 lines
3.4 KiB
C++
108 lines
3.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Commandlets/MakeBinaryConfigCommandlet.h"
|
|
#include "Interfaces/ITargetPlatformManagerModule.h"
|
|
#include "Interfaces/ITargetPlatform.h"
|
|
#include "Interfaces/IPluginManager.h"
|
|
#include "Misc/CoreDelegates.h"
|
|
#include "Misc/CommandLine.h"
|
|
#include "Misc/ConfigCacheIni.h"
|
|
#include "Misc/ConfigContext.h"
|
|
#include "Misc/FileHelper.h"
|
|
|
|
UMakeBinaryConfigCommandlet::UMakeBinaryConfigCommandlet(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
}
|
|
|
|
int32 UMakeBinaryConfigCommandlet::Main(const FString& Params)
|
|
{
|
|
FString OutputFile;
|
|
if (!FParse::Value(FCommandLine::Get(), TEXT("OutputFile="), OutputFile))
|
|
{
|
|
UE_LOG(LogTemp, Fatal, TEXT("OutputFile= parameter required"));
|
|
return -1;
|
|
}
|
|
|
|
FString StagedPluginsFile;
|
|
if (!FParse::Value(FCommandLine::Get(), TEXT("StagedPluginsFile="), StagedPluginsFile))
|
|
{
|
|
UE_LOG(LogTemp, Fatal, TEXT("StagedPluginsFile= parameter required"));
|
|
return -1;
|
|
}
|
|
|
|
// only expecting one targetplatform
|
|
const TArray<ITargetPlatform*>& Platforms = GetTargetPlatformManagerRef().GetActiveTargetPlatforms();
|
|
check(Platforms.Num() == 1);
|
|
FString PlatformName = Platforms[0]->IniPlatformName();
|
|
|
|
FConfigCacheIni Config(EConfigCacheType::Temporary);
|
|
FConfigContext Context = FConfigContext::ReadIntoConfigSystem(&Config, PlatformName);
|
|
Config.InitializeKnownConfigFiles(Context);
|
|
|
|
// removing for now, because this causes issues with some plugins not getting ini files merged in
|
|
// IPluginManager::Get().IntegratePluginsIntoConfig(Config, *FinalConfigFilenames.EngineIni, *PlatformName, *StagedPluginsFile);
|
|
|
|
// pull out deny list entries
|
|
|
|
TArray<FString> KeyDenyListStrings;
|
|
TArray<FString> SectionsDenyList;
|
|
GConfig->GetArray(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("IniKeyBlacklist"), KeyDenyListStrings, GGameIni);
|
|
GConfig->GetArray(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("IniSectionBlacklist"), SectionsDenyList, GGameIni);
|
|
TArray<FName> KeysDenyList;
|
|
for (FString Key : KeyDenyListStrings)
|
|
{
|
|
KeysDenyList.Add(FName(*Key));
|
|
}
|
|
|
|
for (const FString& Filename : Config.GetFilenames())
|
|
{
|
|
FConfigFile* File = Config.FindConfigFile(Filename);
|
|
|
|
delete File->SourceConfigFile;
|
|
File->SourceConfigFile = nullptr;
|
|
|
|
for (FString Section : SectionsDenyList)
|
|
{
|
|
File->Remove(Section);
|
|
}
|
|
|
|
// now go over any remaining sections and remove keys
|
|
for (TPair<FString, FConfigSection>& SectionPair : *File)
|
|
{
|
|
FConfigSection& Section = SectionPair.Value;
|
|
for (FName Key : KeysDenyList)
|
|
{
|
|
Section.Remove(Key);
|
|
}
|
|
}
|
|
}
|
|
|
|
// check the deny list removed itself
|
|
KeyDenyListStrings.Empty();
|
|
Config.GetArray(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("IniKeyBlacklist"), KeyDenyListStrings, GGameIni);
|
|
check(KeyDenyListStrings.Num() == 0);
|
|
|
|
// allow delegates to modify the config data with some tagged binary data
|
|
FCoreDelegates::FExtraBinaryConfigData ExtraData(Config, true);
|
|
FCoreDelegates::AccessExtraBinaryConfigData.Broadcast(ExtraData);
|
|
|
|
// write it all out!
|
|
TArray<uint8> FileContent;
|
|
{
|
|
// Use FMemoryWriter because FileManager::CreateFileWriter doesn't serialize FName as string and is not overridable
|
|
FMemoryWriter MemoryWriter(FileContent, true);
|
|
|
|
Config.Serialize(MemoryWriter);
|
|
MemoryWriter << ExtraData.Data;
|
|
}
|
|
|
|
if (!FFileHelper::SaveArrayToFile(FileContent, *OutputFile))
|
|
{
|
|
UE_LOG(LogTemp, Fatal, TEXT("Failed to create Config.bin file"));
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|