Files
Ben Marsh e1fe0cc030 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

[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00

125 lines
3.8 KiB
C++

// Copyright 2011-2019 Molecular Matters GmbH, all rights reserved.
#include "LC_CommandMap.h"
#include "LC_DuplexPipe.h"
namespace
{
template <class T>
static bool DefaultAction(const DuplexPipe* pipe, void*)
{
// receive command and continue execution
T command = {};
const bool success = pipe->ReceiveCommand(&command);
pipe->SendAck();
if (!success)
{
return false;
}
return true;
}
template <typename T>
static void RegisterDefaultAction(CommandMap::Action* actions)
{
actions[T::ID] = &DefaultAction<T>;
}
}
CommandMap::CommandMap(void)
: m_actions()
{
// register default handlers that receive command data and continue execution
RegisterDefaultAction<commands::Acknowledge>(m_actions);
RegisterDefaultAction<commands::RegisterProcess>(m_actions);
RegisterDefaultAction<commands::RegisterProcessFinished>(m_actions);
RegisterDefaultAction<commands::EnableModuleBatchBegin>(m_actions);
RegisterDefaultAction<commands::EnableModuleBatchEnd>(m_actions);
RegisterDefaultAction<commands::DisableModuleBatchBegin>(m_actions);
RegisterDefaultAction<commands::DisableModuleBatchEnd>(m_actions);
RegisterDefaultAction<commands::EnableModule>(m_actions);
RegisterDefaultAction<commands::EnableModuleFinished>(m_actions);
RegisterDefaultAction<commands::DisableModule>(m_actions);
RegisterDefaultAction<commands::DisableModuleFinished>(m_actions);
RegisterDefaultAction<commands::EnableAllModules>(m_actions);
RegisterDefaultAction<commands::EnableAllModulesFinished>(m_actions);
RegisterDefaultAction<commands::DisableAllModules>(m_actions);
RegisterDefaultAction<commands::DisableAllModulesFinished>(m_actions);
RegisterDefaultAction<commands::EnterSyncPoint>(m_actions);
RegisterDefaultAction<commands::LeaveSyncPoint>(m_actions);
RegisterDefaultAction<commands::CallHooks>(m_actions);
RegisterDefaultAction<commands::GetModule>(m_actions);
RegisterDefaultAction<commands::GetModuleInfo>(m_actions);
RegisterDefaultAction<commands::LoadPatch>(m_actions);
RegisterDefaultAction<commands::LoadPatchInfo>(m_actions);
RegisterDefaultAction<commands::UnloadPatch>(m_actions);
RegisterDefaultAction<commands::CallEntryPoint>(m_actions);
RegisterDefaultAction<commands::LogOutput>(m_actions);
RegisterDefaultAction<commands::ReadyForCompilation>(m_actions);
RegisterDefaultAction<commands::CompilationFinished>(m_actions);
RegisterDefaultAction<commands::DisconnectClient>(m_actions);
RegisterDefaultAction<commands::TriggerRecompile>(m_actions);
RegisterDefaultAction<commands::BuildPatch>(m_actions);
RegisterDefaultAction<commands::HandleException>(m_actions);
RegisterDefaultAction<commands::HandleExceptionFinished>(m_actions);
// BEGIN EPIC MOD - Adding ShowConsole command
RegisterDefaultAction<commands::ShowConsole>(m_actions);
// END EPIC MOD
// BEGIN EPIC MOD - Adding SetVisible command
RegisterDefaultAction<commands::SetVisible>(m_actions);
// END EPIC MOD
// BEGIN EPIC MOD - Adding SetActive command
RegisterDefaultAction<commands::SetActive>(m_actions);
// END EPIC MOD
// BEGIN EPIC MOD - Adding SetBuildArguments command
RegisterDefaultAction<commands::SetBuildArguments>(m_actions);
// END EPIC MOD
RegisterDefaultAction<commands::ApplySettingBool>(m_actions);
RegisterDefaultAction<commands::ApplySettingInt>(m_actions);
RegisterDefaultAction<commands::ApplySettingString>(m_actions);
}
CommandMap::~CommandMap(void)
{
}
bool CommandMap::HandleCommands(const DuplexPipe* pipe, void* context)
{
for (;;)
{
// fetch incoming command id
uint32_t commandId = 0u;
{
const bool success = pipe->ReceiveCommandId(&commandId);
if (!success)
{
return false;
}
}
// call handler for this command
const Action action = m_actions[commandId];
const bool continueExecution = action(pipe, context);
if (!continueExecution)
{
return true;
}
}
}