Files
UnrealEngineUWP/Engine/Plugins/ScriptPlugin/Source/ScriptGeneratorPlugin/Private/ScriptGeneratorPlugin.cpp
Robert Manuszewski 97cc1e1be1 Copying //UE4/Dev-Core to //UE4/Main
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2799478 on 2015/12/11 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Added Dev Stream custom versions.

	- Each stream now has its own custom version
	- Developers working in a stream should only modify their respective version

Change 2789867 on 2015/12/04 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	UnrealHeaderTool plugins no longer need to be a separate plugin and don't require UnrealHeaderTool source code changes to work.

	- Merged ScriptGeneratorPlugin with ScriptPlugin
	- Introduced the concept of UHT plugin support for plugins so that UHT's source files don't need to be modified to make it work with external plugins
	- Added RuntimeNoProgram module type (module that can be used at runtime but not by program targets).
	- Fixed logic with project file path setting in the engine. It will no longer try to crate a full path from an already rooted path.

Change 2796114 on 2015/12/09 by Steve.Robb@Dev-Core

	TEnumRange - enabled ranged-based for iteration over enum values.

Change 2789843 on 2015/12/04 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2

	More thorough way of verifying GC cluster assumptions.

Change 2794221 on 2015/12/08 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2

	Don't merge GC clusters by default

Change 2797824 on 2015/12/10 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Added the option to load all symbols for stack walking in non-monolithic builds.

Change 2790539 on 2015/12/04 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec

	Stats/Profiler - Better handling for live connection, using the same path as file profiles, added FStatsLoadedState to separate runtime stats state from the loaded one

Change 2794183 on 2015/12/08 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Always reset events when returning them to pool.

Change 2794406 on 2015/12/08 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2

	Fixing -unversioned flag being completely ignored when cooking

Change 2794563 on 2015/12/08 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream2

	Making sure string referenced assets don't get cooked if referenced by editor-only properties.

Change 2795124 on 2015/12/08 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec

	Profiler - Fixed bad data in min/max/avg inclusive times, added min/max/avg num calls, fixed event graph tooltip not displaying correct values

Change 2796208 on 2015/12/09 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec

	Profiler - Remove support for multiple instances in the profiler (game thread is always visible, a few crash fixes, cleaned code a bit)

Change 2797658 on 2015/12/10 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Allocation verification helpers. Helps with tracking down memory stomps, freeing the same pointers multiple times.

Change 2797699 on 2015/12/10 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Fix incorrect asset loading in Cooked game data (by bozaro)

	PR #1844

Change 2798173 on 2015/12/10 by Steve.Robb@Dev-Core

	Migration of Fortnite to use engine's TEnumRange.

Change 2798217 on 2015/12/10 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec

	PR #1331
	[Core] Added a stomp allocator that allows finding memory overruns, underruns, and read/write after free. (Contributed by Pablo Zurita)

Change 2799605 on 2015/12/11 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Fixing a crash when cancelling async loading caused by detaching linker from objects that had RF_NeedLoad flag set.

Change 2799849 on 2015/12/11 by Steve.Robb@Dev-Core

	Migration of Ocean to use engine's TEnumRange.

Change 2803144 on 2015/12/15 by Robert.Manuszewski@Robert.Manuszewski_NCL_Stream1

	Changed export tagging archive to also serialize class default objects using the normal Serialize path so that it can collect all custom versions used by exports.

Change 2803206 on 2015/12/15 by Jaroslaw.Surowiec@Stream.1.JarekSurowiec

	#jira UE-24177
	Audit ôshippingö defines in engine

Change 2804868 on 2015/12/16 by Steve.Robb@Dev-Core

	Removal of stats from MallocBinned2, to be readded later.

#lockdown Nick.Penwarden

[CL 2805158 by Robert Manuszewski in Main branch]
2015-12-16 11:52:36 -05:00

120 lines
4.4 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "ScriptGeneratorPluginPrivatePCH.h"
#include "ScriptCodeGeneratorBase.h"
#include "GenericScriptCodeGenerator.h"
#include "LuaScriptCodeGenerator.h"
#include "IProjectManager.h"
#include "Runtime/Core/Public/Features/IModularFeatures.h"
DEFINE_LOG_CATEGORY(LogScriptGenerator);
class FScriptGeneratorPlugin : public IScriptGeneratorPlugin
{
/** Specialized script code generator */
TAutoPtr<FScriptCodeGeneratorBase> CodeGenerator;
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/** IScriptGeneratorPlugin interface */
virtual FString GetGeneratedCodeModuleName() const override { return TEXT("ScriptPlugin"); }
virtual bool ShouldExportClassesForModule(const FString& ModuleName, EBuildModuleType::Type ModuleType, const FString& ModuleGeneratedIncludeDirectory) const override;
virtual bool SupportsTarget(const FString& TargetName) const override;
virtual void Initialize(const FString& RootLocalPath, const FString& RootBuildPath, const FString& OutputDirectory, const FString& IncludeBase) override;
virtual void ExportClass(UClass* Class, const FString& SourceHeaderFilename, const FString& GeneratedHeaderFilename, bool bHasChanged) override;
virtual void FinishExport() override;
virtual FString GetGeneratorName() const override;
};
IMPLEMENT_MODULE( FScriptGeneratorPlugin, ScriptGeneratorPlugin )
void FScriptGeneratorPlugin::StartupModule()
{
// Register ourselves as an editor feature
IModularFeatures::Get().RegisterModularFeature(TEXT("ScriptGenerator"), this);
}
void FScriptGeneratorPlugin::ShutdownModule()
{
CodeGenerator.Reset();
// Unregister our feature
IModularFeatures::Get().UnregisterModularFeature(TEXT("ScriptGenerator"), this);
}
FString FScriptGeneratorPlugin::GetGeneratorName() const
{
#if WITH_LUA
return TEXT("Lua Example Code Generator Plugin");
#else
return TEXT("Example Code Generator Plugin");
#endif
}
void FScriptGeneratorPlugin::Initialize(const FString& RootLocalPath, const FString& RootBuildPath, const FString& OutputDirectory, const FString& IncludeBase)
{
#if WITH_LUA
UE_LOG(LogScriptGenerator, Log, TEXT("Using Lua Script Generator."));
CodeGenerator = new FLuaScriptCodeGenerator(RootLocalPath, RootBuildPath, OutputDirectory, IncludeBase);
#else
UE_LOG(LogScriptGenerator, Log, TEXT("Using Generic Script Generator."));
CodeGenerator = new FGenericScriptCodeGenerator(RootLocalPath, RootBuildPath, OutputDirectory, IncludeBase);
#endif
UE_LOG(LogScriptGenerator, Log, TEXT("Output directory: %s"), *OutputDirectory);
}
bool FScriptGeneratorPlugin::ShouldExportClassesForModule(const FString& ModuleName, EBuildModuleType::Type ModuleType, const FString& ModuleGeneratedIncludeDirectory) const
{
bool bCanExport = (ModuleType == EBuildModuleType::Runtime || ModuleType == EBuildModuleType::Game);
if (bCanExport)
{
// Only export functions from selected modules
static struct FSupportedModules
{
TArray<FString> SupportedScriptModules;
FSupportedModules()
{
GConfig->GetArray(TEXT("Plugins"), TEXT("ScriptSupportedModules"), SupportedScriptModules, GEngineIni);
}
} SupportedModules;
bCanExport = SupportedModules.SupportedScriptModules.Num() == 0 || SupportedModules.SupportedScriptModules.Contains(ModuleName);
}
return bCanExport;
}
void FScriptGeneratorPlugin::ExportClass(UClass* Class, const FString& SourceHeaderFilename, const FString& GeneratedHeaderFilename, bool bHasChanged)
{
CodeGenerator->ExportClass(Class, SourceHeaderFilename, GeneratedHeaderFilename, bHasChanged);
}
void FScriptGeneratorPlugin::FinishExport()
{
CodeGenerator->FinishExport();
}
bool FScriptGeneratorPlugin::SupportsTarget(const FString& TargetName) const
{
// We only support the target if it explicitly enables the required script plugin in its uproject file
bool bSupportsTarget = false;
if (FPaths::IsProjectFilePathSet())
{
FProjectDescriptor ProjectDescriptor;
FText OutError;
if (ProjectDescriptor.Load(FPaths::GetProjectFilePath(), OutError))
{
for (auto& PluginDescriptor : ProjectDescriptor.Plugins)
{
// For your own script plugin you might want to change the hardcoded name here to something else
if (PluginDescriptor.bEnabled && PluginDescriptor.Name == TEXT("ScriptPlugin"))
{
bSupportsTarget = true;
break;
}
}
}
}
return bSupportsTarget;
}