Files
UnrealEngineUWP/Engine/Source/Developer/Windows/LiveCoding/Private/External/LC_EntryPoint.cpp
ben marsh cf183af67c Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.

Changes vs standalone Live++ version:

* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.

Known issues:

* Does not currently support class layout changes / object reinstancing

#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira

#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)

[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00

201 lines
4.4 KiB
C++

// Copyright 2011-2019 Molecular Matters GmbH, all rights reserved.
#include "LC_EntryPoint.h"
#include "LC_ClientStartupThread.h"
#include "LC_CriticalSection.h"
#include "LC_RunMode.h"
#include "LPP_API.h"
namespace
{
// startup thread. initialized when LppRegisterProcessGroup is called
static ClientStartupThread* g_startupThread = nullptr;
// critical section to ensure that startup thread is initialized only once
static CriticalSection g_ensureOneTimeStartup;
static RunMode::Enum g_runMode = RunMode::DEFAULT;
}
// BEGIN EPIC MOD - Manually trigger startup/shutdown code
void Startup(HINSTANCE instance)
{
g_startupThread = new ClientStartupThread(instance);
}
void Shutdown(void)
{
// wait for the startup thread to finish its work and clean up
g_startupThread->Join();
delete g_startupThread;
}
#if 0
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD dwReason, _In_ LPVOID /* lpvReserved */)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
Startup(hinstDLL);
break;
case DLL_PROCESS_DETACH:
Shutdown();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
return Windows::TRUE;
}
#endif
// END EPIC MOD
// exported Live++ API
// BEGIN EPIC MOD - Internalizing API
#define LPP_DLL_API
//#define LPP_DLL_API extern "C" __declspec(dllexport)
// END EPIC MOD - Internalizing API
LPP_DLL_API void __cdecl LppRegisterProcessGroup(const char* const groupName)
{
// now that we have the process group name, start Live++.
// ensure that initialization can happen only once, even if the user calls this more than once.
{
CriticalSection::ScopedLock lock(&g_ensureOneTimeStartup);
static bool firstTime = true;
if (!firstTime)
{
// this was already called once, bail out
return;
}
firstTime = false;
}
g_startupThread->Start(groupName, g_runMode);
}
LPP_DLL_API void* __cdecl LppEnableModule(const wchar_t* const nameOfExeOrDll)
{
// hand command creation to the user command thread
return g_startupThread->EnableModule(nameOfExeOrDll);
}
LPP_DLL_API void* __cdecl LppEnableAllModules(const wchar_t* const nameOfExeOrDll)
{
// hand command creation to the user command thread
return g_startupThread->EnableAllModules(nameOfExeOrDll);
}
LPP_DLL_API void* __cdecl LppDisableModule(const wchar_t* const nameOfExeOrDll)
{
// hand command creation to the user command thread
return g_startupThread->DisableModule(nameOfExeOrDll);
}
LPP_DLL_API void* __cdecl LppDisableAllModules(const wchar_t* const nameOfExeOrDll)
{
// hand command creation to the user command thread
return g_startupThread->DisableAllModules(nameOfExeOrDll);
}
LPP_DLL_API void __cdecl LppWaitForToken(void* token)
{
g_startupThread->WaitForToken(token);
}
LPP_DLL_API void __cdecl LppTriggerRecompile(void)
{
g_startupThread->TriggerRecompile();
}
LPP_DLL_API void __cdecl LppBuildPatch(const wchar_t* moduleNames[], const wchar_t* objPaths[], unsigned int count)
{
g_startupThread->BuildPatch(moduleNames, objPaths, count);
}
LPP_DLL_API void __cdecl LppInstallExceptionHandler(void)
{
g_startupThread->InstallExceptionHandler();
}
LPP_DLL_API void __cdecl LppUseExternalBuildSystem(void)
{
g_runMode = RunMode::EXTERNAL_BUILD_SYSTEM;
}
// BEGIN EPIC MOD - Adding ShowConsole command
LPP_DLL_API void __cdecl LppShowConsole()
{
g_startupThread->ShowConsole();
}
// END EPIC MOD
// BEGIN EPIC MOD - Adding SetVisible command
LPP_DLL_API void __cdecl LppSetVisible(bool visible)
{
g_startupThread->SetVisible(visible);
}
// END EPIC MOD
// BEGIN EPIC MOD - Adding SetActive command
LPP_DLL_API void __cdecl LppSetActive(bool active)
{
g_startupThread->SetActive(active);
}
// END EPIC MOD
// BEGIN EPIC MOD - Adding SetBuildArguments command
LPP_DLL_API void __cdecl LppSetBuildArguments(const wchar_t* arguments)
{
g_startupThread->SetBuildArguments(arguments);
}
// END EPIC MOD
LPP_DLL_API void __cdecl LppApplySettingBool(const char* const settingName, int value)
{
// hand command creation to the user command thread
g_startupThread->ApplySettingBool(settingName, value);
}
LPP_DLL_API void __cdecl LppApplySettingInt(const char* const settingName, int value)
{
// hand command creation to the user command thread
g_startupThread->ApplySettingInt(settingName, value);
}
LPP_DLL_API void __cdecl LppApplySettingString(const char* const settingName, const wchar_t* const value)
{
// hand command creation to the user command thread
g_startupThread->ApplySettingString(settingName, value);
}
#undef LPP_DLL_API