2019-12-26 15:32:37 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
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
# include "LiveCodingModule.h"
# include "Modules/ModuleManager.h"
# include "Features/IModularFeatures.h"
# include "HAL/IConsoleManager.h"
# include "Misc/CoreDelegates.h"
# include "LiveCodingLog.h"
2021-06-11 14:48:40 -04:00
# include "External/LC_Commands.h"
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
# include "External/LC_EntryPoint.h"
2019-07-16 08:46:52 -04:00
# include "External/LC_API.h"
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
# include "Misc/App.h"
# include "Misc/Paths.h"
# include "Misc/ConfigCacheIni.h"
2020-12-11 14:21:20 -04:00
# include "Misc/MessageDialog.h"
2021-12-08 11:50:54 -05:00
# include "Misc/ScopedSlowTask.h"
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
# include "ISettingsModule.h"
2019-03-12 10:09:23 -04:00
# include "ISettingsSection.h"
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
# include "Windows/WindowsHWrapper.h"
2021-05-14 07:45:59 -04:00
# include "Algo/Sort.h"
# include "Algo/BinarySearch.h"
2022-08-15 12:06:33 -04:00
# include "HAL/LowLevelMemTracker.h"
2022-10-20 09:21:20 -04:00
# include "Async/TaskGraphInterfaces.h"
2021-03-18 08:13:59 -04:00
# if WITH_EDITOR
2021-06-13 23:49:22 -04:00
# include "Editor.h"
2021-03-18 08:13:59 -04:00
# include "Kismet2/ReloadUtilities.h"
2021-06-11 14:48:40 -04:00
# include "Widgets/Notifications/SNotificationList.h"
# include "Framework/Notifications/NotificationManager.h"
2021-03-18 08:13:59 -04:00
# else
# include "UObject/Reload.h"
# endif
# if WITH_ENGINE
# include "Engine/Engine.h"
2021-04-27 06:40:20 -04:00
# include "UObject/UObjectIterator.h"
2021-05-14 07:45:59 -04:00
# include "UObject/StrongObjectPtr.h"
2021-03-18 08:13:59 -04:00
# endif
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
2022-07-18 11:46:10 -04:00
# include "Windows/AllowWindowsPlatformTypes.h"
# include <psapi.h> // for GetModuleFileNameEx
# ifdef NT_SUCCESS
# undef NT_SUCCESS
# endif
# include <subauth.h> // for UNICODE_STRING
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
IMPLEMENT_MODULE ( FLiveCodingModule , LiveCoding )
# define LOCTEXT_NAMESPACE "LiveCodingModule"
2022-08-15 12:06:33 -04:00
LLM_DEFINE_TAG ( LiveCoding ) ;
2019-03-07 17:30:35 -05:00
bool GIsCompileActive = false ;
2021-04-26 12:49:25 -04:00
bool GTriggerReload = false ;
2019-08-28 12:34:28 -04:00
bool GHasLoadedPatch = false ;
2021-06-11 14:48:40 -04:00
commands : : PostCompileResult GPostCompileResult = commands : : PostCompileResult : : Success ;
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
FString GLiveCodingConsolePath ;
2019-03-06 12:44:16 -05:00
FString GLiveCodingConsoleArguments ;
2021-03-18 08:13:59 -04:00
FLiveCodingModule * GLiveCodingModule = nullptr ;
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
2019-05-24 11:51:54 -04:00
# if IS_MONOLITHIC
extern const TCHAR * GLiveCodingEngineDir ;
extern const TCHAR * GLiveCodingProject ;
# endif
2021-03-18 08:13:59 -04:00
# if !WITH_EDITOR
class FNullReload : public IReload
{
public :
FNullReload ( FLiveCodingModule & InLiveCodingModule )
: LiveCodingModule ( InLiveCodingModule )
{
BeginReload ( EActiveReloadType : : LiveCoding , * this ) ;
}
~ FNullReload ( )
{
EndReload ( ) ;
}
virtual EActiveReloadType GetType ( ) const
{
return EActiveReloadType : : LiveCoding ;
}
virtual const TCHAR * GetPrefix ( ) const
{
return TEXT ( " LIVECODING " ) ;
}
virtual void NotifyFunctionRemap ( FNativeFuncPtr NewFunctionPointer , FNativeFuncPtr OldFunctionPointer )
{
}
virtual void NotifyChange ( UClass * New , UClass * Old ) override
{
}
virtual void NotifyChange ( UEnum * New , UEnum * Old ) override
{
}
virtual void NotifyChange ( UScriptStruct * New , UScriptStruct * Old ) override
{
}
2021-06-09 11:43:12 -04:00
virtual void NotifyChange ( UPackage * New , UPackage * Old ) override
{
}
2021-03-29 10:54:06 -04:00
virtual bool GetEnableReinstancing ( bool bHasChanged ) const
2021-03-18 08:13:59 -04:00
{
2021-03-29 10:54:06 -04:00
if ( bHasChanged & & ! bEnabledMessage )
2021-03-18 08:13:59 -04:00
{
2021-03-29 10:54:06 -04:00
bEnabledMessage = true ;
2021-06-11 14:48:40 -04:00
bHasReinstancingOccurred = true ;
2021-03-18 08:13:59 -04:00
static const TCHAR * Message = TEXT ( " Object structure changes detected. LiveCoding re-instancing isn't supported in builds without the editor " ) ;
UE_LOG ( LogLiveCoding , Error , TEXT ( " %s " ) , Message ) ;
# if WITH_ENGINE
if ( GEngine )
{
GEngine - > AddOnScreenDebugMessage ( uint64 ( uintptr_t ( & LiveCodingModule ) ) , 5.f , FColor : : Red , Message ) ;
}
# endif
}
2021-03-29 10:54:06 -04:00
return false ;
}
virtual void Reinstance ( )
{
2021-03-18 08:13:59 -04:00
}
2022-11-15 13:39:47 -05:00
virtual UObject * GetReinstancedCDO ( UObject * CDO ) override
{
return CDO ;
}
virtual const UObject * GetReinstancedCDO ( const UObject * CDO ) override
{
return CDO ;
}
2021-06-11 14:48:40 -04:00
bool HasReinstancingOccurred ( ) const
{
return bHasReinstancingOccurred ;
}
void Reset ( )
{
bHasReinstancingOccurred = false ;
}
2021-03-18 08:13:59 -04:00
private :
FLiveCodingModule & LiveCodingModule ;
2021-03-29 10:54:06 -04:00
mutable bool bEnabledMessage = false ;
2021-06-11 14:48:40 -04:00
mutable bool bHasReinstancingOccurred = false ;
2021-03-18 08:13:59 -04:00
} ;
# endif
2023-01-31 14:46:34 -05:00
namespace LivePP
{
// Based on liveProcess::GetLowerBoundIn4GBRange
uintptr_t GetLowerBound ( uintptr_t ModuleBase , uint64 Padding )
{
constexpr uintptr_t LowestPossibleAddress = 64ull * 1024ull ;
return ModuleBase > = LowestPossibleAddress + Padding ? ModuleBase - Padding : LowestPossibleAddress ;
}
// Based on liveProcess::GetUpperBoundIn4GBRange
uintptr_t GetUpperBound ( uintptr_t ModuleBase , uint64 Padding )
{
constexpr uintptr_t HighestPossibleAddress = 0x00007FFFFFFF0000ull ;
return ModuleBase < = HighestPossibleAddress - Padding ? ModuleBase + Padding : HighestPossibleAddress ;
}
// Based on VirtualMemoryRange::ReservePages
void ReservePages ( TArray < uintptr_t > & ReservedPages , uintptr_t AddressStart , uintptr_t AddressEnd , uint64 PageAlignment )
{
HANDLE ProcessHandle = GetCurrentProcess ( ) ;
// reserve all free pages in the virtual memory range.
// pages must be aligned to the given alignment.
for ( uintptr_t Address = AddressStart ; Address < AddressEnd ; /* nothing */ )
{
// align address to be scanned
Address = Align ( Address , PageAlignment ) ;
if ( Address < AddressStart )
{
// overflow happened because we scanned too far
break ;
}
: : MEMORY_BASIC_INFORMATION MemoryInfo = { } ;
const size_t BytesReturned = : : VirtualQueryEx ( ProcessHandle , ( const void * ) Address , & MemoryInfo , sizeof ( : : MEMORY_BASIC_INFORMATION ) ) ;
if ( BytesReturned = = 0 )
{
break ;
}
// we are only interested in free pages
if ( MemoryInfo . State = = MEM_FREE )
{
// work out the maximum size of the page allocation.
// we should not allocate past the end of the range.
const uint64 BytesLeft = AddressEnd - ( uintptr_t ) MemoryInfo . BaseAddress ;
const uint64 Size = std : : min < uint64 > ( MemoryInfo . RegionSize , BytesLeft ) ;
// try to reserve this page.
// if we are really unlucky, the process might have allocated this region in the meantime.
void * BaseAddress = : : VirtualAllocEx ( ProcessHandle , MemoryInfo . BaseAddress , Size , MEM_RESERVE , PAGE_NOACCESS ) ;
if ( BaseAddress )
{
ReservedPages . Add ( ( uintptr_t ) BaseAddress ) ;
}
}
// keep on searching
Address = ( uintptr_t ) MemoryInfo . BaseAddress + MemoryInfo . RegionSize ;
}
}
}
namespace
{
constexpr uint64 DefaultPadding = 128ull * 1024ull * 1024ull ; // LivePP used 2ull * 1024ull * 1024ull * 1024ull;
constexpr uint64 DefaultPageAlignment = 64ull * 1024ull ;
constexpr uint32 NewModuleCountThreshhold = 128 ;
void ReservePagesBefore ( TArray < uintptr_t > & ReservedPages , uintptr_t ModuleBase , uint64 Padding , uint32 PageAlignment )
{
LivePP : : ReservePages ( ReservedPages , LivePP : : GetLowerBound ( ModuleBase , Padding ) , ModuleBase , PageAlignment ) ;
}
void ReservePagesBetween ( TArray < uintptr_t > & ReservedPages , uintptr_t StartModuleBase , uintptr_t EndModuleBase , uint64 Padding , uint32 PageAlignment )
{
LivePP : : ReservePages ( ReservedPages , LivePP : : GetLowerBound ( StartModuleBase , Padding ) , LivePP : : GetUpperBound ( EndModuleBase , Padding ) , PageAlignment ) ;
}
void ReservePagesAfter ( TArray < uintptr_t > & ReservedPages , uintptr_t ModuleBase , uint64 Padding , uint32 PageAlignment )
{
LivePP : : ReservePages ( ReservedPages , ModuleBase , LivePP : : GetUpperBound ( ModuleBase , Padding ) , PageAlignment ) ;
}
void ReservePages ( TArray < uintptr_t > & ReservedPages , const TArray < uintptr_t > & ModuleBases , uint64 Padding , uint64 PageAlignment )
{
if ( ModuleBases . IsEmpty ( ) )
{
return ;
}
// We use an ordered list to avoid rescanning the same ranges over and over again
TArray < uintptr_t > SortedModuleBases ( ModuleBases ) ;
SortedModuleBases . Sort ( ) ;
// Reserve prior to the first module
ReservePagesBefore ( ReservedPages , SortedModuleBases [ 0 ] , Padding , PageAlignment ) ;
// Loop through the pairs of modules
for ( int i = 0 ; i < SortedModuleBases . Num ( ) - 1 ; + + i )
{
uintptr_t StartModuleBase = SortedModuleBases [ i ] ;
uintptr_t EndModuleBase = SortedModuleBases [ i + 1 ] ;
if ( EndModuleBase - StartModuleBase < Padding * 2 )
{
ReservePagesBetween ( ReservedPages , StartModuleBase , EndModuleBase , Padding , PageAlignment ) ;
}
else
{
ReservePagesAfter ( ReservedPages , StartModuleBase , Padding , PageAlignment ) ;
ReservePagesBefore ( ReservedPages , EndModuleBase , Padding , PageAlignment ) ;
}
}
// Reserve after the last module
ReservePagesAfter ( ReservedPages , SortedModuleBases . Last ( ) , Padding , PageAlignment ) ;
}
}
2022-07-18 11:46:10 -04:00
// Helper structure to load the NTDLL library and work with an API
struct FNtDllFunction
{
FARPROC Addr ;
FNtDllFunction ( const char * Name )
{
HMODULE NtDll = LoadLibraryW ( L " ntdll.dll " ) ;
check ( NtDll ) ;
Addr = GetProcAddress ( NtDll , Name ) ;
}
template < typename . . . ArgTypes >
unsigned int operator ( ) ( ArgTypes . . . Args )
{
typedef unsigned int ( NTAPI * Prototype ) ( ArgTypes . . . ) ;
return ( Prototype ( ( void * ) Addr ) ) ( Args . . . ) ;
}
} ;
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
FLiveCodingModule : : FLiveCodingModule ( )
2022-07-18 11:46:10 -04:00
: FullEngineDir ( FPaths : : ConvertRelativePathToFull ( FPaths : : EngineDir ( ) ) )
, FullEnginePluginsDir ( FPaths : : ConvertRelativePathToFull ( FPaths : : EnginePluginsDir ( ) ) )
2019-03-12 10:10:07 -04:00
, FullProjectDir ( FPaths : : ConvertRelativePathToFull ( FPaths : : ProjectDir ( ) ) )
, FullProjectPluginsDir ( FPaths : : ConvertRelativePathToFull ( FPaths : : ProjectPluginsDir ( ) ) )
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
{
2021-03-18 08:13:59 -04:00
GLiveCodingModule = this ;
}
FLiveCodingModule : : ~ FLiveCodingModule ( )
{
GLiveCodingModule = nullptr ;
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
}
void FLiveCodingModule : : StartupModule ( )
{
2022-08-15 12:06:33 -04:00
LLM_SCOPE_BYTAG ( LiveCoding ) ;
2022-07-18 11:46:10 -04:00
// Register with NT to get dll nitrifications
FNtDllFunction RegisterFunc ( " LdrRegisterDllNotification " ) ;
RegisterFunc ( 0 , OnDllNotification , this , & CallbackCookie ) ;
// Get the creating process main executable name. We want to skip this file when iterating through the dll list
FString MainModuleName ;
{
TCHAR Scratch [ MAX_PATH ] ;
int Length = GetModuleFileNameEx ( : : GetCurrentProcess ( ) , NULL , Scratch , MAX_PATH ) ;
MainModuleName = FString ( Length , Scratch ) ;
}
// https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-peb_ldr_data
typedef struct _PEB_LDR_DATA {
BYTE Reserved1 [ 8 ] ;
PVOID Reserved2 [ 3 ] ;
LIST_ENTRY InMemoryOrderModuleList ;
} PEB_LDR_DATA , * PPEB_LDR_DATA ;
// https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-peb
typedef struct _PEB {
BYTE Reserved1 [ 2 ] ;
BYTE BeingDebugged ;
BYTE Reserved2 [ 1 ] ;
PVOID Reserved3 [ 2 ] ;
PPEB_LDR_DATA Ldr ;
//...
} PEB , * PPEB ;
// https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-teb
typedef struct _TEB {
PVOID Reserved1 [ 12 ] ;
PPEB ProcessEnvironmentBlock ;
//...
} TEB , * PTEB ;
// https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-peb_ldr_data
typedef struct _LDR_DATA_TABLE_ENTRY {
PVOID Reserved1 [ 2 ] ;
LIST_ENTRY InMemoryOrderLinks ;
PVOID Reserved2 [ 2 ] ;
PVOID DllBase ;
PVOID EntryPoint ;
PVOID Reserved3 ;
UNICODE_STRING FullDllName ;
//...
} LDR_DATA_TABLE_ENTRY , * PLDR_DATA_TABLE_ENTRY ;
// Enumerate already loaded modules.
const TEB * ThreadEnvBlock = reinterpret_cast < TEB * > ( NtCurrentTeb ( ) ) ;
const PEB * ProcessEnvBlock = ThreadEnvBlock - > ProcessEnvironmentBlock ;
const LIST_ENTRY * ModuleIter = ProcessEnvBlock - > Ldr - > InMemoryOrderModuleList . Flink ;
const LIST_ENTRY * ModuleIterEnd = ModuleIter - > Blink ;
do
{
const auto & ModuleData = * ( LDR_DATA_TABLE_ENTRY * ) ( ModuleIter - 1 ) ;
if ( ModuleData . DllBase = = 0 )
{
break ;
}
FString FullPath ( ModuleData . FullDllName . Length / sizeof ( ModuleData . FullDllName . Buffer [ 0 ] ) , ModuleData . FullDllName . Buffer ) ;
if ( ! FullPath . Equals ( MainModuleName , ESearchCase : : IgnoreCase ) )
{
FPaths : : NormalizeFilename ( FullPath ) ;
OnDllLoaded ( FullPath ) ;
}
ModuleIter = ModuleIter - > Flink ;
} while ( ModuleIter ! = ModuleIterEnd ) ;
2019-03-11 18:57:53 -04:00
Settings = GetMutableDefault < ULiveCodingSettings > ( ) ;
2019-03-07 15:21:21 -05:00
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
IConsoleManager & ConsoleManager = IConsoleManager : : Get ( ) ;
EnableCommand = ConsoleManager . RegisterConsoleCommand (
TEXT ( " LiveCoding " ) ,
TEXT ( " Enables live coding support " ) ,
2022-08-15 15:08:39 -04:00
FConsoleCommandWithOutputDeviceDelegate : : CreateRaw ( this , & FLiveCodingModule : : EnableConsoleCommand ) ,
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
ECVF_Cheat
) ;
2019-05-24 11:51:54 -04:00
CompileCommand = ConsoleManager . RegisterConsoleCommand (
TEXT ( " LiveCoding.Compile " ) ,
TEXT ( " Initiates a live coding compile " ) ,
2021-12-08 11:50:54 -05:00
FConsoleCommandDelegate : : CreateLambda ( [ this ] { Compile ( ELiveCodingCompileFlags : : None , nullptr ) ; } ) ,
2019-05-24 11:51:54 -04:00
ECVF_Cheat
) ;
# if IS_MONOLITHIC
FString DefaultEngineDir = GLiveCodingEngineDir ;
# else
FString DefaultEngineDir = FPaths : : EngineDir ( ) ;
# endif
# if USE_DEBUG_LIVE_CODING_CONSOLE
static const TCHAR * DefaultConsolePath = TEXT ( " Binaries/Win64/LiveCodingConsole-Win64-Debug.exe " ) ;
# else
static const TCHAR * DefaultConsolePath = TEXT ( " Binaries/Win64/LiveCodingConsole.exe " ) ;
# endif
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
ConsolePathVariable = ConsoleManager . RegisterConsoleVariable (
TEXT ( " LiveCoding.ConsolePath " ) ,
2019-05-24 11:51:54 -04:00
FPaths : : ConvertRelativePathToFull ( DefaultEngineDir / DefaultConsolePath ) ,
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
TEXT ( " Path to the live coding console application " ) ,
ECVF_Cheat
) ;
2019-05-24 11:51:54 -04:00
# if IS_MONOLITHIC
FString SourceProject = ( GLiveCodingProject ! = nullptr ) ? GLiveCodingProject : TEXT ( " " ) ;
# else
FString SourceProject = FPaths : : IsProjectFilePathSet ( ) ? FPaths : : GetProjectFilePath ( ) : TEXT ( " " ) ;
# endif
2022-08-16 08:49:21 -04:00
if ( SourceProject . Len ( ) > 0 )
{
SourceProject = FPaths : : ConvertRelativePathToFull ( SourceProject ) ;
}
2019-05-24 11:51:54 -04:00
SourceProjectVariable = ConsoleManager . RegisterConsoleVariable (
TEXT ( " LiveCoding.SourceProject " ) ,
2022-08-16 08:49:21 -04:00
SourceProject ,
2019-05-24 11:51:54 -04:00
TEXT ( " Path to the project that this target was built from " ) ,
ECVF_Cheat
) ;
2019-03-07 15:21:21 -05:00
EndFrameDelegateHandle = FCoreDelegates : : OnEndFrame . AddRaw ( this , & FLiveCodingModule : : Tick ) ;
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
ISettingsModule * SettingsModule = FModuleManager : : GetModulePtr < ISettingsModule > ( " Settings " ) ;
if ( SettingsModule ! = nullptr )
{
2019-03-12 10:09:23 -04:00
SettingsSection = SettingsModule - > RegisterSettings ( " Editor " , " General " , " Live Coding " ,
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
LOCTEXT ( " LiveCodingSettingsName " , " Live Coding " ) ,
LOCTEXT ( " LiveCodintSettingsDescription " , " Settings for recompiling C++ code while the engine is running. " ) ,
GetMutableDefault < ULiveCodingSettings > ( )
) ;
}
2020-12-15 09:27:44 -04:00
LppStartup ( ) ;
2019-03-11 18:57:53 -04:00
2022-11-04 14:48:13 -04:00
bSettingsEnabledLastTick = Settings - > bEnabled ;
2022-10-20 09:21:20 -04:00
if ( Settings - > bEnabled & & Settings - > Startup ! = ELiveCodingStartupMode : : Manual & & ! FApp : : IsUnattended ( ) )
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
{
2022-10-20 09:21:20 -04:00
StartLiveCodingAsync ( Settings - > Startup ) ;
}
else if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " LiveCoding " ) ) )
{
StartLiveCodingAsync ( ELiveCodingStartupMode : : Manual ) ;
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
}
2021-06-17 08:47:50 -04:00
bEnableReinstancingLastTick = IsReinstancingEnabled ( ) ;
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
}
void FLiveCodingModule : : ShutdownModule ( )
{
2020-01-29 14:48:18 -05:00
LppShutdown ( ) ;
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
FCoreDelegates : : OnEndFrame . Remove ( EndFrameDelegateHandle ) ;
IConsoleManager & ConsoleManager = IConsoleManager : : Get ( ) ;
2019-05-24 11:51:54 -04:00
ConsoleManager . UnregisterConsoleObject ( SourceProjectVariable ) ;
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
ConsoleManager . UnregisterConsoleObject ( ConsolePathVariable ) ;
2019-05-24 11:51:54 -04:00
ConsoleManager . UnregisterConsoleObject ( CompileCommand ) ;
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
ConsoleManager . UnregisterConsoleObject ( EnableCommand ) ;
2022-07-18 11:46:10 -04:00
// Unregister from the dll notifications
if ( CallbackCookie )
{
FNtDllFunction UnregisterFunc ( " LdrUnregisterDllNotification " ) ;
UnregisterFunc ( CallbackCookie ) ;
}
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
}
2019-03-11 18:57:53 -04:00
void FLiveCodingModule : : EnableByDefault ( bool bEnable )
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
{
2022-10-20 09:21:20 -04:00
if ( Settings - > bEnabled ! = bEnable )
2019-03-12 10:09:23 -04:00
{
Settings - > bEnabled = bEnable ;
2022-10-20 09:21:20 -04:00
if ( SettingsSection . IsValid ( ) )
2019-03-12 10:09:23 -04:00
{
SettingsSection - > Save ( ) ;
}
}
2019-03-11 18:57:53 -04:00
EnableForSession ( bEnable ) ;
}
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
2019-03-11 18:57:53 -04:00
bool FLiveCodingModule : : IsEnabledByDefault ( ) const
{
return Settings - > bEnabled ;
}
2022-08-15 15:08:39 -04:00
void FLiveCodingModule : : EnableConsoleCommand ( FOutputDevice & out )
{
EnableForSession ( true ) ;
// For packaged builds, by default it is unlikely that UE_LOG messages will be seen in the console.
// So log any error directly.
if ( ! EnableErrorText . IsEmpty ( ) )
{
out . Log ( EnableErrorText ) ;
}
}
2019-03-11 18:57:53 -04:00
void FLiveCodingModule : : EnableForSession ( bool bEnable )
{
if ( bEnable )
{
2021-10-13 12:19:13 -04:00
EnableErrorText = FText : : GetEmpty ( ) ;
2022-10-20 09:21:20 -04:00
switch ( State )
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
{
2022-10-20 09:21:20 -04:00
case EState : : NotRunning :
StartLiveCoding ( ELiveCodingStartupMode : : Manual ) ; // State set in this method
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
ShowConsole ( ) ;
2022-10-20 09:21:20 -04:00
break ;
case EState : : Starting :
WaitForStartup ( ) ;
break ;
case EState : : Running :
case EState : : RunningAndEnabled :
State = EState : : RunningAndEnabled ;
2019-08-28 10:30:23 -04:00
ShowConsole ( ) ;
2022-10-20 09:21:20 -04:00
break ;
2019-08-28 10:30:23 -04:00
}
2019-03-11 18:57:53 -04:00
}
else
{
2022-10-20 09:21:20 -04:00
switch ( State )
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
{
2022-10-20 09:21:20 -04:00
case EState : : NotRunning :
case EState : : Starting :
break ;
case EState : : Running :
case EState : : RunningAndEnabled :
HideConsole ( ) ;
State = EState : : Running ;
break ;
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
}
}
}
2022-10-20 09:21:20 -04:00
void FLiveCodingModule : : WaitForStartup ( )
{
if ( State = = EState : : Starting )
{
UE_LOG ( LogLiveCoding , Display , TEXT ( " Waiting for console to start. " ) ) ;
FPlatformProcess : : ConditionalSleep ( [ this ] ( ) { return State ! = EState : : Starting ; } ) ;
}
}
2019-03-11 18:57:53 -04:00
bool FLiveCodingModule : : IsEnabledForSession ( ) const
2019-03-12 10:09:26 -04:00
{
2022-10-20 09:21:20 -04:00
switch ( State )
{
case EState : : NotRunning :
case EState : : Starting :
case EState : : Running :
return false ;
case EState : : RunningAndEnabled :
return true ;
default :
return false ;
}
2019-03-12 10:09:26 -04:00
}
2021-10-13 13:18:44 -04:00
const FText & FLiveCodingModule : : GetEnableErrorText ( ) const
2021-10-13 12:19:13 -04:00
{
return EnableErrorText ;
}
2019-03-14 17:52:18 -04:00
bool FLiveCodingModule : : CanEnableForSession ( ) const
{
# if !IS_MONOLITHIC
FModuleManager & ModuleManager = FModuleManager : : Get ( ) ;
if ( ModuleManager . HasAnyOverridenModuleFilename ( ) )
{
return false ;
}
# endif
return true ;
}
2019-03-12 10:09:26 -04:00
bool FLiveCodingModule : : HasStarted ( ) const
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
{
2022-10-20 09:21:20 -04:00
return HasStarted ( false ) ;
}
bool FLiveCodingModule : : HasStarted ( bool bAllowStarting ) const
{
switch ( State )
{
case EState : : NotRunning :
return false ;
case EState : : Starting :
return bAllowStarting ;
case EState : : Running :
case EState : : RunningAndEnabled :
return true ;
default :
return false ;
}
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
}
void FLiveCodingModule : : ShowConsole ( )
{
2022-10-20 09:21:20 -04:00
ShowConsole ( false ) ;
}
void FLiveCodingModule : : ShowConsole ( bool bAllowStarting )
{
if ( HasStarted ( bAllowStarting ) )
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
{
2019-03-11 18:57:53 -04:00
LppSetVisible ( true ) ;
LppSetActive ( true ) ;
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
LppShowConsole ( ) ;
}
}
2022-10-20 09:21:20 -04:00
void FLiveCodingModule : : HideConsole ( )
{
if ( HasStarted ( ) )
{
UE_LOG ( LogLiveCoding , Display , TEXT ( " Console will be hidden but remain running in the background. Restart to disable completely. " ) ) ;
LppSetActive ( false ) ;
LppSetVisible ( false ) ;
}
}
2019-03-11 18:57:53 -04:00
void FLiveCodingModule : : Compile ( )
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
{
2021-12-08 11:50:54 -05:00
Compile ( ELiveCodingCompileFlags : : None , nullptr ) ;
}
inline bool ReturnResults ( ELiveCodingCompileResult InResult , ELiveCodingCompileResult * OutResult )
{
if ( OutResult ! = nullptr )
2019-03-07 15:21:21 -05:00
{
2021-12-08 11:50:54 -05:00
* OutResult = InResult ;
2019-03-07 15:21:21 -05:00
}
2021-12-08 11:50:54 -05:00
return InResult = = ELiveCodingCompileResult : : Success | | InResult = = ELiveCodingCompileResult : : NoChanges | | InResult = = ELiveCodingCompileResult : : InProgress ;
}
bool FLiveCodingModule : : Compile ( ELiveCodingCompileFlags CompileFlags , ELiveCodingCompileResult * Result )
{
if ( GIsCompileActive )
{
return ReturnResults ( ELiveCodingCompileResult : : CompileStillActive , Result ) ;
}
EnableForSession ( true ) ;
2022-10-20 09:21:20 -04:00
if ( ! HasStarted ( ) )
2021-12-08 11:50:54 -05:00
{
return ReturnResults ( ELiveCodingCompileResult : : NotStarted , Result ) ;
}
// Need to do this immediately rather than waiting until next tick
2022-10-20 09:21:20 -04:00
UpdateModules ( false ) ;
2021-12-08 11:50:54 -05:00
// Trigger the recompile
GIsCompileActive = true ;
LastResults = ELiveCodingCompileResult : : Failure ;
LppTriggerRecompile ( ) ;
// If we aren't waiting, just return now
if ( ! EnumHasAnyFlags ( CompileFlags , ELiveCodingCompileFlags : : WaitForCompletion ) )
{
return ReturnResults ( ELiveCodingCompileResult : : InProgress , Result ) ;
}
// Wait until we are no longer compiling. Cancellation is handled via other mechanisms and
// need not be detected in this loop. GIsCompileActive will be cleared.
FText StatusUpdate = LOCTEXT ( " CompileStatusMessage " , " Compiling... " ) ;
FScopedSlowTask SlowTask ( 0 , StatusUpdate , GIsSlowTask ) ;
SlowTask . MakeDialog ( ) ;
// Wait until the compile completes
while ( GIsCompileActive )
{
SlowTask . EnterProgressFrame ( 0.0f ) ;
AttemptSyncLivePatching ( ) ;
FPlatformProcess : : Sleep ( 0.01f ) ;
}
// A final sync to get the result and complete the process
AttemptSyncLivePatching ( ) ;
return ReturnResults ( LastResults , Result ) ;
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
}
2019-03-07 17:30:35 -05:00
bool FLiveCodingModule : : IsCompiling ( ) const
{
return GIsCompileActive ;
}
2019-03-07 15:21:21 -05:00
void FLiveCodingModule : : Tick ( )
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
{
2019-07-16 08:46:52 -04:00
2022-10-20 09:21:20 -04:00
// Check for a change in the last requested enable state if we are in automatic mode
2022-11-04 14:48:13 -04:00
if ( Settings - > bEnabled ! = bSettingsEnabledLastTick & & Settings - > Startup ! = ELiveCodingStartupMode : : Manual )
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
{
2022-10-20 09:21:20 -04:00
switch ( State )
2020-12-11 14:21:20 -04:00
{
2022-10-20 09:21:20 -04:00
case EState : : NotRunning :
2022-11-04 14:48:13 -04:00
bSettingsEnabledLastTick = Settings - > bEnabled ;
2022-10-20 09:21:20 -04:00
if ( Settings - > bEnabled )
{
EnableForSession ( true ) ;
if ( ! IsEnabledForSession ( ) )
{
FMessageDialog : : Open ( EAppMsgType : : Ok , EnableErrorText ) ;
}
}
break ;
case EState : : Starting :
case EState : : Running :
break ;
case EState : : RunningAndEnabled :
2022-11-04 14:48:13 -04:00
bSettingsEnabledLastTick = Settings - > bEnabled ;
2022-10-20 09:21:20 -04:00
if ( ! Settings - > bEnabled )
{
EnableForSession ( false ) ;
}
break ;
2020-12-11 14:21:20 -04:00
}
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
}
2019-05-24 11:51:54 -04:00
2022-10-20 09:21:20 -04:00
if ( HasStarted ( ) )
2019-05-24 11:51:54 -04:00
{
2022-10-20 09:21:20 -04:00
if ( LppWantsRestart ( ) )
{
LppRestart ( lpp : : LPP_RESTART_BEHAVIOR_REQUEST_EXIT , 0 ) ;
}
2019-09-09 14:18:24 -04:00
2022-10-20 09:21:20 -04:00
if ( HasStarted ( ) & & IsReinstancingEnabled ( ) ! = bEnableReinstancingLastTick )
{
bEnableReinstancingLastTick = IsReinstancingEnabled ( ) ;
LppSetReinstancingFlow ( bEnableReinstancingLastTick ) ;
}
if ( bUpdateModulesInTick )
{
UpdateModules ( false ) ;
bUpdateModulesInTick = false ;
}
AttemptSyncLivePatching ( ) ;
}
2021-04-08 14:32:07 -04:00
}
void FLiveCodingModule : : AttemptSyncLivePatching ( )
{
2021-07-26 17:08:28 -04:00
// We use to wait for all commands to finish, but that causes a lock up if starting PIE after a compilation
// request caused another command to be sent to the live coding console. For example, the registering of
// another lazy load module at PIE start would cause this problem.
for ( int Index = LppPendingTokens . Num ( ) ; Index - - > 0 ; )
2021-04-08 14:32:07 -04:00
{
2021-07-26 17:08:28 -04:00
if ( LppTryWaitForToken ( LppPendingTokens [ Index ] ) )
2021-04-08 14:32:07 -04:00
{
2021-07-26 17:08:28 -04:00
LppPendingTokens . RemoveAt ( Index ) ;
2021-04-08 14:32:07 -04:00
}
}
2019-09-09 14:18:24 -04:00
// Needs to happen after updating modules, since "Quick Restart" functionality may try to install patch immediately
extern void LppSyncPoint ( ) ;
LppSyncPoint ( ) ;
2021-04-26 12:49:25 -04:00
if ( ( ! GIsCompileActive | | GTriggerReload ) & & Reload . IsValid ( ) )
2019-09-09 14:18:24 -04:00
{
2021-03-18 08:13:59 -04:00
if ( GHasLoadedPatch )
{
2021-04-26 12:49:25 -04:00
# if WITH_COREUOBJECT && WITH_ENGINE
2021-05-14 07:45:59 -04:00
// Collect the existing objects
TArray < UObject * > StartingObjects ;
if ( Reload - > GetEnableReinstancing ( false ) )
{
StartingObjects . Reserve ( 1024 ) ; // Arbitrary
for ( TObjectIterator < UObject > It ( EObjectFlags : : RF_NoFlags ) ; It ; + + It )
{
StartingObjects . Add ( * It ) ;
}
Algo : : Sort ( StartingObjects ) ;
}
2021-04-26 12:49:25 -04:00
// During the module loading process, the list of changed classes will be recorded. Invoking this method will
// result in the RegisterForReinstancing method being invoked which in turn records the classes in the ClassesToReinstance
// member variable being populated.
ProcessNewlyLoadedUObjects ( ) ;
// Complete the process of re-instancing without doing a GC
# if WITH_EDITOR
Reload - > Finalize ( false ) ;
# endif
2021-05-14 07:45:59 -04:00
TArray < TStrongObjectPtr < UObject > > NewObjects ;
2021-04-26 12:49:25 -04:00
if ( Reload - > GetEnableReinstancing ( false ) )
{
2021-05-14 07:45:59 -04:00
// Loop through the objects again looking for anything new that isn't associated with a
// reinstanced class.
for ( TObjectIterator < UObject > It ( EObjectFlags : : RF_NoFlags ) ; It ; + + It )
{
if ( Algo : : BinarySearch ( StartingObjects , * It ) = = INDEX_NONE )
{
if ( ! It - > GetClass ( ) - > HasAnyClassFlags ( CLASS_NewerVersionExists ) )
{
NewObjects . Add ( TStrongObjectPtr < UObject > ( * It ) ) ;
}
}
}
// Loop through all of the classes looking for classes that have been re-instanced. Reset the CDO
// to something that will never change. Since these classes have been replaced, they should NEVER
// have their CDos accessed again. In the future we should try to figure out a better solution the issue
// where the reinstanced crashes recreating the default object probably due to a mismatch between then
// new constructor being invoked and the blueprint data associated with the old class. With LC, the
// old constructor has been replaced.
static UObject * DummyDefaultObject = UObject : : StaticClass ( ) - > ClassDefaultObject ;
2021-04-26 12:49:25 -04:00
for ( TObjectIterator < UClass > It ; It ; + + It )
{
UClass * Class = * It ;
2021-05-14 07:45:59 -04:00
if ( Class - > GetName ( ) . StartsWith ( TEXT ( " LIVECODING_ " ) ) | |
Class - > GetName ( ) . StartsWith ( TEXT ( " REINST_ " ) ) )
2021-04-26 12:49:25 -04:00
{
2021-05-14 07:45:59 -04:00
Class - > ClassDefaultObject = DummyDefaultObject ;
2021-04-26 12:49:25 -04:00
}
}
}
2021-05-14 07:45:59 -04:00
// Broadcast event prior to GC. Otherwise some things are holding onto references
FCoreUObjectDelegates : : ReloadCompleteDelegate . Broadcast ( EReloadCompleteReason : : None ) ;
2021-04-26 12:49:25 -04:00
// Perform the GC to try and destruct all the objects which will be invoking the old destructors.
CollectGarbage ( GARBAGE_COLLECTION_KEEPFLAGS , true ) ;
# endif
// Second sync point to finish off the patching
if ( GTriggerReload )
{
LppSyncPoint ( ) ;
}
# if WITH_COREUOBJECT && WITH_ENGINE
2021-05-14 07:45:59 -04:00
// Remove the reference to any new objects
NewObjects . Empty ( ) ;
2021-04-26 12:49:25 -04:00
# endif
2021-03-18 08:13:59 -04:00
OnPatchCompleteDelegate . Broadcast ( ) ;
GHasLoadedPatch = false ;
2021-06-11 14:48:40 -04:00
bHasReinstancingOccurred | = Reload - > HasReinstancingOccurred ( ) ;
2021-03-18 08:13:59 -04:00
}
2021-04-26 12:49:25 -04:00
else if ( GTriggerReload )
{
LppSyncPoint ( ) ;
}
2021-12-08 11:50:54 -05:00
2021-06-11 14:48:40 -04:00
if ( ! GIsCompileActive )
{
static const FString Success ( " Live coding succeeded " ) ;
// Reset this first so it does its logging first
Reload . Reset ( ) ;
switch ( GPostCompileResult )
{
case commands : : PostCompileResult : : Success :
2021-12-08 11:50:54 -05:00
LastResults = ELiveCodingCompileResult : : Success ;
2021-06-11 14:48:40 -04:00
if ( bHasReinstancingOccurred )
{
2021-09-20 08:03:38 -04:00
if ( ! IsReinstancingEnabled ( ) )
{
UE_LOG ( LogLiveCoding , Warning , TEXT ( " %s, %s " ) , * Success , TEXT ( " data type changes with re-instancing disabled is not supported and will likely lead to a crash " ) ) ;
}
else
{
2021-06-11 14:48:40 -04:00
# if WITH_EDITOR
2021-09-20 08:03:38 -04:00
UE_LOG ( LogLiveCoding , Warning , TEXT ( " %s, %s " ) , * Success , TEXT ( " data type changes may cause packaging to fail if assets reference the new or updated data types " ) ) ;
2021-06-11 14:48:40 -04:00
# else
2021-09-20 08:03:38 -04:00
UE_LOG ( LogLiveCoding , Warning , TEXT ( " %s, %s " ) , * Success , TEXT ( " data type changes may cause unexpected failures " ) ) ;
2021-06-11 14:48:40 -04:00
# endif
2021-09-20 08:03:38 -04:00
}
2021-06-11 14:48:40 -04:00
}
else
{
UE_LOG ( LogLiveCoding , Display , TEXT ( " %s " ) , * Success ) ;
}
break ;
case commands : : PostCompileResult : : NoChanges :
2021-12-08 11:50:54 -05:00
LastResults = ELiveCodingCompileResult : : NoChanges ;
2021-06-11 14:48:40 -04:00
UE_LOG ( LogLiveCoding , Display , TEXT ( " %s, %s " ) , * Success , TEXT ( " no code changes detected " ) ) ;
break ;
case commands : : PostCompileResult : : Cancelled :
2021-12-08 11:50:54 -05:00
LastResults = ELiveCodingCompileResult : : Cancelled ;
UE_LOG ( LogLiveCoding , Error , TEXT ( " Live coding canceled " ) ) ;
2021-06-11 14:48:40 -04:00
break ;
case commands : : PostCompileResult : : Failure :
2021-12-08 11:50:54 -05:00
LastResults = ELiveCodingCompileResult : : Failure ;
2021-06-11 14:48:40 -04:00
UE_LOG ( LogLiveCoding , Error , TEXT ( " Live coding failed, please see Live console for more information " ) ) ;
break ;
default :
2021-12-08 11:50:54 -05:00
LastResults = ELiveCodingCompileResult : : Failure ;
2021-06-11 14:48:40 -04:00
check ( false ) ;
}
# if WITH_EDITOR
static const FText SuccessText = LOCTEXT ( " Success " , " Live coding succeeded " ) ;
static const FText NoChangesText = LOCTEXT ( " NoChanges " , " No code changes were detected. " ) ;
static const FText FailureText = LOCTEXT ( " Failed " , " Live coding failed " ) ;
static const FText FailureDetailText = LOCTEXT ( " FailureDetail " , " Please see Live Coding console for more information. " ) ;
static const FText CancelledText = LOCTEXT ( " Cancelled " , " Live coding cancelled " ) ;
static const FText ReinstancingText = LOCTEXT ( " Reinstancing " , " Data type changes may cause packaging to fail if assets reference the new or updated data types. " ) ;
2021-09-20 08:03:38 -04:00
static const FText DisabledText = LOCTEXT ( " ReinstancingDisabled " , " Data type changes with re-instancing disabled is not supported and will likely lead to a crash. " ) ;
2021-06-11 14:48:40 -04:00
switch ( GPostCompileResult )
{
case commands : : PostCompileResult : : Success :
if ( bHasReinstancingOccurred )
{
2021-09-20 08:03:38 -04:00
if ( ! IsReinstancingEnabled ( ) )
{
ShowNotification ( true , SuccessText , & DisabledText ) ;
}
else
{
ShowNotification ( true , SuccessText , & ReinstancingText ) ;
}
2021-06-11 14:48:40 -04:00
}
else
{
ShowNotification ( true , SuccessText , nullptr ) ;
}
break ;
case commands : : PostCompileResult : : NoChanges :
ShowNotification ( true , SuccessText , & NoChangesText ) ;
break ;
case commands : : PostCompileResult : : Cancelled :
ShowNotification ( false , CancelledText , nullptr ) ;
break ;
case commands : : PostCompileResult : : Failure :
ShowNotification ( false , FailureText , & FailureDetailText ) ;
break ;
default :
check ( false ) ;
}
# endif
}
else
{
Reload - > Reset ( ) ;
}
2019-09-09 14:18:24 -04:00
}
2021-04-26 12:49:25 -04:00
GTriggerReload = false ;
2021-03-18 08:13:59 -04:00
}
2021-06-11 14:48:40 -04:00
# if WITH_EDITOR
void FLiveCodingModule : : ShowNotification ( bool Success , const FText & Title , const FText * SubText )
{
FNotificationInfo Info ( Title ) ;
Info . ExpireDuration = 5.0f ;
Info . bUseSuccessFailIcons = true ;
if ( SubText )
{
Info . SubText = * SubText ;
}
TSharedPtr < SNotificationItem > CompileNotification = FSlateNotificationManager : : Get ( ) . AddNotification ( Info ) ;
CompileNotification - > SetCompletionState ( Success ? SNotificationItem : : CS_Success : SNotificationItem : : CS_Fail ) ;
}
# endif
2019-08-28 12:34:28 -04:00
ILiveCodingModule : : FOnPatchCompleteDelegate & FLiveCodingModule : : GetOnPatchCompleteDelegate ( )
{
return OnPatchCompleteDelegate ;
}
2022-10-20 09:21:20 -04:00
void FLiveCodingModule : : StartLiveCodingAsync ( ELiveCodingStartupMode StartupMode )
{
if ( IsRunningCommandlet ( ) )
{
StartLiveCoding ( StartupMode ) ;
}
else
{
auto Task = [ this , StartupMode ] ( )
{
StartLiveCoding ( StartupMode ) ;
} ;
FFunctionGraphTask : : CreateAndDispatchWhenReady ( MoveTemp ( Task ) , TStatId ( ) ) ;
}
}
bool FLiveCodingModule : : StartLiveCoding ( ELiveCodingStartupMode StartupMode )
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
{
2021-10-13 12:19:13 -04:00
EnableErrorText = FText : : GetEmpty ( ) ;
2022-10-20 09:21:20 -04:00
if ( ! HasStarted ( ) )
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
{
2022-10-20 09:21:20 -04:00
State = EState : : Starting ;
if ( StartupMode = = ELiveCodingStartupMode : : AutomaticButHidden )
{
GLiveCodingConsoleArguments = L " -Hidden " ;
}
else
{
GLiveCodingConsoleArguments = L " " ;
}
2019-03-14 17:52:18 -04:00
// Make sure there aren't any hot reload modules already active
if ( ! CanEnableForSession ( ) )
{
2021-10-13 12:19:13 -04:00
EnableErrorText = LOCTEXT ( " NoLiveCodingCompileAfterHotReload " , " Live Coding cannot be enabled while hot-reloaded modules are active. Please close the editor and build from your IDE before restarting. " ) ;
2019-03-14 17:52:18 -04:00
UE_LOG ( LogLiveCoding , Error , TEXT ( " Unable to start live coding session. Some modules have already been hot reloaded. " ) ) ;
2022-10-20 09:21:20 -04:00
State = EState : : NotRunning ;
2019-03-14 17:52:18 -04:00
return false ;
}
2019-03-11 18:57:53 -04:00
// Setup the console path
GLiveCodingConsolePath = ConsolePathVariable - > GetString ( ) ;
if ( ! FPaths : : FileExists ( GLiveCodingConsolePath ) )
{
2021-10-13 12:19:13 -04:00
FFormatNamedArguments Args ;
Args . Add ( TEXT ( " Executable " ) , FText : : FromString ( GLiveCodingConsolePath ) ) ;
const static FText FormatString = LOCTEXT ( " LiveCodingMissingExecutable " , " Unable to start live coding session. Missing executable '{Executable}'. Use the LiveCoding.ConsolePath console variable to modify. " ) ;
EnableErrorText = FText : : Format ( FormatString , Args ) ;
2019-03-11 18:57:53 -04:00
UE_LOG ( LogLiveCoding , Error , TEXT ( " Unable to start live coding session. Missing executable '%s'. Use the LiveCoding.ConsolePath console variable to modify. " ) , * GLiveCodingConsolePath ) ;
2022-10-20 09:21:20 -04:00
State = EState : : NotRunning ;
2019-03-11 18:57:53 -04:00
return false ;
}
2019-05-24 11:51:54 -04:00
// Get the source project filename
FString SourceProject = SourceProjectVariable - > GetString ( ) ;
if ( SourceProject . Len ( ) > 0 & & ! FPaths : : FileExists ( SourceProject ) )
{
2021-10-13 12:19:13 -04:00
FFormatNamedArguments Args ;
Args . Add ( TEXT ( " ProjectFile " ) , FText : : FromString ( SourceProject ) ) ;
const static FText FormatString = LOCTEXT ( " LiveCodingMissingProjectFile " , " Unable to start live coding session. Unable to find source project file '{ProjectFile}'. " ) ;
EnableErrorText = FText : : Format ( FormatString , Args ) ;
2019-05-24 11:51:54 -04:00
UE_LOG ( LogLiveCoding , Error , TEXT ( " Unable to start live coding session. Unable to find source project file '%s'. " ) , * SourceProject ) ;
2022-10-20 09:21:20 -04:00
State = EState : : NotRunning ;
2019-05-24 11:51:54 -04:00
return false ;
}
2019-03-11 18:57:53 -04:00
UE_LOG ( LogLiveCoding , Display , TEXT ( " Starting LiveCoding " ) ) ;
// Enable external build system
LppUseExternalBuildSystem ( ) ;
// Enable the server
2019-12-07 19:03:02 -05:00
FString ProjectPath = FPaths : : ConvertRelativePathToFull ( FPaths : : ProjectDir ( ) ) . ToLower ( ) ;
2021-03-29 13:42:53 -04:00
FString ProcessGroup = FString : : Printf ( TEXT ( " UE_%s_0x%08x " ) , FApp : : GetProjectName ( ) , GetTypeHash ( ProjectPath ) ) ;
2019-03-11 18:57:53 -04:00
LppRegisterProcessGroup ( TCHAR_TO_ANSI ( * ProcessGroup ) ) ;
2023-01-31 14:46:34 -05:00
SetBuildArguments ( ) ;
2019-03-11 18:57:53 -04:00
2021-04-26 12:49:25 -04:00
# if WITH_EDITOR
2021-06-17 08:47:50 -04:00
if ( IsReinstancingEnabled ( ) )
2021-04-26 12:49:25 -04:00
{
2021-06-11 14:48:40 -04:00
LppSetReinstancingFlow ( true ) ;
}
if ( GEditor ! = nullptr )
{
LppDisableCompileFinishNotification ( ) ;
2021-04-26 12:49:25 -04:00
}
# endif
2019-06-12 23:22:12 -04:00
// Create a mutex that allows UBT to detect that we shouldn't hot-reload into this executable. The handle to it will be released automatically when the process exits.
FString ExecutablePath = FPaths : : ConvertRelativePathToFull ( FPlatformProcess : : ExecutablePath ( ) ) ;
FString MutexName = TEXT ( " Global \\ LiveCoding_ " ) ;
for ( int Idx = 0 ; Idx < ExecutablePath . Len ( ) ; Idx + + )
{
TCHAR Character = ExecutablePath [ Idx ] ;
if ( Character = = ' / ' | | Character = = ' \\ ' | | Character = = ' : ' )
{
MutexName + = ' + ' ;
}
else
{
MutexName + = Character ;
}
}
2022-07-18 11:46:10 -04:00
ensure ( CreateMutex ( NULL , FALSE , * MutexName ) ) ;
2019-06-12 23:22:12 -04:00
2019-05-24 11:51:54 -04:00
// Configure all the current modules. For non-commandlets, schedule it to be done in the first Tick() so we can batch everything together.
if ( IsRunningCommandlet ( ) )
{
2022-10-20 09:21:20 -04:00
UpdateModules ( true ) ;
2019-05-24 11:51:54 -04:00
}
else
{
bUpdateModulesInTick = true ;
}
2019-03-11 18:57:53 -04:00
2022-10-20 09:21:20 -04:00
if ( StartupMode = = ELiveCodingStartupMode : : Automatic )
{
ShowConsole ( true ) ;
}
2023-01-31 14:46:34 -05:00
// Register a delegate to listen for new modules loaded from this point onwards
ModulesChangedDelegateHandle = FModuleManager : : Get ( ) . OnModulesChanged ( ) . AddRaw ( this , & FLiveCodingModule : : OnModulesChanged ) ;
2019-03-11 18:57:53 -04:00
// Mark it as started
2022-10-20 09:21:20 -04:00
State = EState : : RunningAndEnabled ;
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
}
return true ;
}
2023-01-31 14:46:34 -05:00
void FLiveCodingModule : : SetBuildArguments ( )
{
FScopeLock lock ( & SetBuildArgumentsCs ) ;
// Build the command line
FString KnownTargetName = FPlatformMisc : : GetUBTTargetName ( ) ;
if ( KnownTargetName ! = LastKnownTargetName )
{
LastKnownTargetName = KnownTargetName ;
FString Arguments = FString : : Printf ( TEXT ( " %s %s %s " ) ,
* KnownTargetName ,
FPlatformMisc : : GetUBTPlatform ( ) ,
LexToString ( FApp : : GetBuildConfiguration ( ) ) ) ;
UE_LOG ( LogLiveCoding , Display , TEXT ( " LiveCodingConsole Arguments: %s " ) , * Arguments ) ;
FString SourceProject = SourceProjectVariable - > GetString ( ) ;
if ( SourceProject . Len ( ) > 0 )
{
Arguments + = FString : : Printf ( TEXT ( " -Project= \" %s \" " ) , * FPaths : : ConvertRelativePathToFull ( SourceProject ) ) ;
}
LppSetBuildArguments ( * Arguments ) ;
}
}
2022-10-20 09:21:20 -04:00
void FLiveCodingModule : : UpdateModules ( bool bAllowStarting )
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
{
2022-10-20 09:21:20 -04:00
if ( HasStarted ( bAllowStarting ) )
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
{
2023-01-31 14:46:34 -05:00
// The target name might have changed now that we are loading early
SetBuildArguments ( ) ;
TArray < ModuleChange > Changes ;
TArray < uintptr_t > Pages ;
FGraphEventRef Task ;
{
FScopeLock lock ( & ModuleChangeCs ) ;
Swap ( Changes , ModuleChanges ) ;
Swap ( Pages , ReservedPages ) ;
Task = ReservePagesTaskRef ;
LastReservePagesModuleCount = 0 ;
}
if ( Task . IsValid ( ) )
{
FTaskGraphInterface : : Get ( ) . WaitUntilTaskCompletes ( Task ) ;
}
2019-05-24 11:51:54 -04:00
# if IS_MONOLITHIC
wchar_t FullFilePath [ WINDOWS_MAX_PATH ] ;
2019-09-28 08:19:35 -04:00
verify ( GetModuleFileName ( hInstance , FullFilePath , UE_ARRAY_COUNT ( FullFilePath ) ) ) ;
2019-05-24 11:51:54 -04:00
LppEnableModule ( FullFilePath ) ;
# else
2022-08-11 08:59:35 -04:00
// Collect the list of preloaded modules
TSet < FName > PreloadedFileNames ;
{
FModuleManager & Manager = FModuleManager : : Get ( ) ;
2023-01-16 09:26:35 -05:00
for ( FName ModuleName : Settings - > PreloadNamedModules )
2022-08-11 08:59:35 -04:00
{
2023-01-16 09:26:35 -05:00
TArray < FName > OutModules ;
Manager . FindModules ( * ModuleName . ToString ( ) , OutModules ) ;
for ( FName OutModule : OutModules )
2022-08-11 08:59:35 -04:00
{
2023-01-16 09:26:35 -05:00
FString FileName = Manager . GetModuleFilename ( OutModule ) ;
if ( ! FileName . IsEmpty ( ) )
{
PreloadedFileNames . Add ( FName ( FPaths : : GetBaseFilename ( FileName , true ) ) ) ;
}
2022-08-11 08:59:35 -04:00
}
}
}
2019-05-24 11:51:54 -04:00
TArray < FString > EnableModules ;
2023-01-31 14:46:34 -05:00
TArray < FString > LazyLoadModules ;
2022-07-18 11:46:10 -04:00
for ( const ModuleChange & Change : Changes )
2019-05-24 11:51:54 -04:00
{
2022-07-18 11:46:10 -04:00
if ( Change . bLoaded )
2019-05-24 11:51:54 -04:00
{
2022-07-18 11:46:10 -04:00
ConfiguredModules . Add ( Change . FullName ) ;
FString FullFilePath ( Change . FullName . ToString ( ) ) ;
2022-08-11 08:59:35 -04:00
if ( ShouldPreloadModule ( PreloadedFileNames , FullFilePath ) )
2019-05-24 11:51:54 -04:00
{
2022-07-18 11:46:10 -04:00
EnableModules . Add ( FullFilePath ) ;
2019-05-24 11:51:54 -04:00
}
2022-07-18 11:46:10 -04:00
else
{
2023-01-31 14:46:34 -05:00
LazyLoadModules . Add ( FullFilePath ) ;
2022-07-18 11:46:10 -04:00
}
}
else
{
ConfiguredModules . Remove ( Change . FullName ) ;
2019-05-24 11:51:54 -04:00
}
}
if ( EnableModules . Num ( ) > 0 )
{
TArray < const TCHAR * > EnableModuleFileNames ;
for ( const FString & EnableModule : EnableModules )
{
EnableModuleFileNames . Add ( * EnableModule ) ;
}
2021-04-08 14:32:07 -04:00
2023-01-31 14:46:34 -05:00
TArray < const TCHAR * > LazyLoadModuleFileNames ;
for ( const FString & LazyLoadModule : LazyLoadModules )
2021-04-08 14:32:07 -04:00
{
2023-01-31 14:46:34 -05:00
LazyLoadModuleFileNames . Add ( * LazyLoadModule ) ;
}
{
TRACE_CPUPROFILER_EVENT_SCOPE ( LppEnableModulesEx ) ;
void * LppEnableModulesExToken = LppEnableModulesEx (
EnableModuleFileNames . GetData ( ) , EnableModuleFileNames . Num ( ) ,
LazyLoadModuleFileNames . GetData ( ) , LazyLoadModuleFileNames . Num ( ) ,
Pages . GetData ( ) , Pages . Num ( ) ) ;
LppPendingTokens . Add ( LppEnableModulesExToken ) ;
2021-04-08 14:32:07 -04:00
}
2019-05-24 11:51:54 -04:00
}
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
# endif
2019-05-24 11:51:54 -04:00
}
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
}
2023-01-31 14:46:34 -05:00
void FLiveCodingModule : : ReservePagesTask ( )
{
for ( ; ; )
{
TArray < ModuleChange > Changes ;
{
FScopeLock lock ( & ModuleChangeCs ) ;
uint32 NewModules = ModuleChanges . Num ( ) - LastReservePagesModuleCount ;
if ( NewModules < NewModuleCountThreshhold )
{
ReservePagesTaskRef = FGraphEventRef ( ) ;
return ;
}
Changes . Append ( ModuleChanges . GetData ( ) + LastReservePagesModuleCount , NewModules ) ;
LastReservePagesModuleCount = ModuleChanges . Num ( ) ;
}
TRACE_CPUPROFILER_EVENT_SCOPE ( LiveCodingReservePages ) ;
TArray < uintptr_t > ModuleBases ;
ModuleBases . Reserve ( Changes . Num ( ) ) ;
for ( const ModuleChange & Change : Changes )
{
if ( Change . bLoaded )
{
HMODULE Handle = : : GetModuleHandle ( * Change . FullName . ToString ( ) ) ;
ModuleBases . Add ( reinterpret_cast < uintptr_t > ( Handle ) ) ;
}
}
TArray < uintptr_t > Pages ;
ReservePages ( Pages , ModuleBases , DefaultPadding , DefaultPageAlignment ) ;
{
FScopeLock lock ( & ModuleChangeCs ) ;
ReservedPages . Append ( Pages ) ;
}
}
}
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
void FLiveCodingModule : : OnModulesChanged ( FName ModuleName , EModuleChangeReason Reason )
{
# if !IS_MONOLITHIC
if ( Reason = = EModuleChangeReason : : ModuleLoaded )
{
2019-05-24 11:51:54 -04:00
// Assume that Tick() won't be called if we're running a commandlet
if ( IsRunningCommandlet ( ) )
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
{
2022-10-20 09:21:20 -04:00
UpdateModules ( false ) ;
2019-03-18 18:07:05 -04:00
}
else
{
2019-05-24 11:51:54 -04:00
bUpdateModulesInTick = true ;
2019-03-18 18:07:05 -04:00
}
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
}
# endif
}
2022-08-11 08:59:35 -04:00
bool FLiveCodingModule : : ShouldPreloadModule ( const TSet < FName > & PreloadedFileNames , const FString & FullFilePath ) const
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
{
2022-07-18 11:46:10 -04:00
// Perform some name based checks
2020-12-11 14:21:20 -04:00
{
2022-08-11 08:59:35 -04:00
FString FileName = FPaths : : GetBaseFilename ( FullFilePath , true ) ;
FName Name ( FileName , FNAME_Find ) ;
if ( Name ! = NAME_None & & PreloadedFileNames . Contains ( Name ) )
2022-07-18 11:46:10 -04:00
{
return true ;
}
2020-12-11 14:21:20 -04:00
}
2022-07-18 11:46:10 -04:00
if ( FullFilePath . StartsWith ( FullProjectDir , ESearchCase : : IgnoreCase ) )
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
{
2019-03-18 18:07:05 -04:00
if ( Settings - > bPreloadProjectModules = = Settings - > bPreloadProjectPluginModules )
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
{
2019-03-18 18:07:05 -04:00
return Settings - > bPreloadProjectModules ;
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
}
2022-07-18 11:46:10 -04:00
if ( FullFilePath . StartsWith ( FullProjectPluginsDir , ESearchCase : : IgnoreCase ) )
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
{
2019-03-18 18:07:05 -04:00
return Settings - > bPreloadProjectPluginModules ;
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
}
else
{
2019-03-18 18:07:05 -04:00
return Settings - > bPreloadProjectModules ;
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
}
}
else
{
if ( FApp : : IsEngineInstalled ( ) )
{
return false ;
}
2019-03-18 18:07:05 -04:00
if ( Settings - > bPreloadEngineModules = = Settings - > bPreloadEnginePluginModules )
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
{
2019-03-18 18:07:05 -04:00
return Settings - > bPreloadEngineModules ;
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
}
2022-07-18 11:46:10 -04:00
if ( FullFilePath . StartsWith ( FullEnginePluginsDir , ESearchCase : : IgnoreCase ) )
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
{
2019-03-18 18:07:05 -04:00
return Settings - > bPreloadEnginePluginModules ;
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
}
else
{
2019-03-18 18:07:05 -04:00
return Settings - > bPreloadEngineModules ;
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
}
}
}
2021-03-18 08:13:59 -04:00
void FLiveCodingModule : : BeginReload ( )
{
if ( GLiveCodingModule ! = nullptr )
{
if ( ! GLiveCodingModule - > Reload . IsValid ( ) )
{
2021-06-11 14:48:40 -04:00
GLiveCodingModule - > bHasReinstancingOccurred = false ;
GLiveCodingModule - > bHasPatchBeenLoaded = false ;
GPostCompileResult = commands : : PostCompileResult : : Success ;
2021-03-18 08:13:59 -04:00
# if WITH_EDITOR
GLiveCodingModule - > Reload . Reset ( new FReload ( EActiveReloadType : : LiveCoding , TEXT ( " LIVECODING " ) , * GLog ) ) ;
2021-06-17 08:47:50 -04:00
GLiveCodingModule - > Reload - > SetEnableReinstancing ( GLiveCodingModule - > IsReinstancingEnabled ( ) ) ;
2021-05-14 07:45:59 -04:00
GLiveCodingModule - > Reload - > SetSendReloadCompleteNotification ( false ) ;
2021-03-18 08:13:59 -04:00
# else
GLiveCodingModule - > Reload . Reset ( new FNullReload ( * GLiveCodingModule ) ) ;
# endif
}
}
}
2021-06-17 08:47:50 -04:00
bool FLiveCodingModule : : IsReinstancingEnabled ( ) const
{
# if WITH_EDITOR
2021-08-02 10:26:32 -04:00
return Settings - > bEnableReinstancing ;
2021-06-17 08:47:50 -04:00
# else
return false ;
# endif
}
bool FLiveCodingModule : : AutomaticallyCompileNewClasses ( ) const
{
return Settings - > bAutomaticallyCompileNewClasses ;
}
2022-07-18 11:46:10 -04:00
void FLiveCodingModule : : OnDllNotification ( unsigned int Reason , const void * DataPtr , void * Context )
{
FLiveCodingModule * This = reinterpret_cast < FLiveCodingModule * > ( Context ) ;
enum
{
LDR_DLL_NOTIFICATION_REASON_LOADED = 1 ,
LDR_DLL_NOTIFICATION_REASON_UNLOADED = 2 ,
} ;
struct FNotificationData
{
uint32 Flags ;
const UNICODE_STRING & FullPath ;
const UNICODE_STRING & BaseName ;
UPTRINT Base ;
} ;
const auto & Data = * ( FNotificationData * ) DataPtr ;
FString FullPath ( Data . FullPath . Length / sizeof ( Data . FullPath . Buffer [ 0 ] ) , Data . FullPath . Buffer ) ;
FPaths : : NormalizeFilename ( FullPath ) ;
switch ( Reason )
{
case LDR_DLL_NOTIFICATION_REASON_LOADED :
This - > OnDllLoaded ( FullPath ) ;
break ;
case LDR_DLL_NOTIFICATION_REASON_UNLOADED :
This - > OnDllUnloaded ( FullPath ) ;
break ;
}
}
void FLiveCodingModule : : OnDllLoaded ( const FString & FullPath )
{
if ( IsUEDll ( FullPath ) )
{
FScopeLock lock ( & ModuleChangeCs ) ;
ModuleChanges . Emplace ( ModuleChange { FName ( FullPath ) , true } ) ;
2023-01-31 14:46:34 -05:00
if ( ! ReservePagesTaskRef . IsValid ( ) & & ModuleChanges . Num ( ) - LastReservePagesModuleCount > = NewModuleCountThreshhold )
{
ReservePagesTaskRef = FFunctionGraphTask : : CreateAndDispatchWhenReady ( [ this ] ( ) { ReservePagesTask ( ) ; } ) ;
}
2022-07-18 11:46:10 -04:00
}
}
void FLiveCodingModule : : OnDllUnloaded ( const FString & FullPath )
{
if ( IsUEDll ( FullPath ) )
{
FScopeLock lock ( & ModuleChangeCs ) ;
ModuleChanges . Emplace ( ModuleChange { FName ( FullPath ) , false } ) ;
}
}
bool FLiveCodingModule : : IsUEDll ( const FString & FullPath )
{
// Ignore patches.
if ( IsPatchDll ( FullPath ) )
{
return false ;
}
// Dll must be in the engine or project dir
if ( ! FullPath . StartsWith ( FullEngineDir , ESearchCase : : IgnoreCase ) & &
! FullPath . StartsWith ( FullEnginePluginsDir , ESearchCase : : IgnoreCase ) & &
! FullPath . StartsWith ( FullProjectDir , ESearchCase : : IgnoreCase ) & &
! FullPath . StartsWith ( FullProjectPluginsDir , ESearchCase : : IgnoreCase ) )
{
return false ;
}
return true ;
}
bool FLiveCodingModule : : IsPatchDll ( const FString & FullPath )
{
// If the Dll ends with ".patch_#.dll", then ignore it
FString Name = FPaths : : GetBaseFilename ( FullPath , true ) ;
FString Extension = FPaths : : GetExtension ( Name ) ;
if ( ! Extension . StartsWith ( " patch_ " , ESearchCase : : IgnoreCase ) )
{
return false ;
}
for ( int Index = 6 ; Index < Extension . Len ( ) ; + + Index )
{
if ( ! FChar : : IsDigit ( Extension [ Index ] ) )
{
return false ;
}
}
return true ;
}
2021-03-18 08:13:59 -04:00
// Invoked from LC_ClientCommandActions
void LiveCodingBeginPatch ( )
{
GHasLoadedPatch = true ;
// If we are beginning a patch from a restart from the console, we need to create the reload object
FLiveCodingModule : : BeginReload ( ) ;
}
// Invoked from LC_ClientCommandActions
void LiveCodingEndCompile ( )
{
GIsCompileActive = false ;
}
2021-04-26 12:49:25 -04:00
// Invoked from LC_ClientCommandActions
void LiveCodingPreCompile ( )
{
UE_LOG ( LogLiveCoding , Display , TEXT ( " Starting Live Coding compile. " ) ) ;
GIsCompileActive = true ;
if ( GLiveCodingModule ! = nullptr )
{
GLiveCodingModule - > BeginReload ( ) ;
}
}
// Invoked from LC_ClientCommandActions
2021-06-11 14:48:40 -04:00
void LiveCodingPostCompile ( commands : : PostCompileResult PostCompileResult )
2021-04-26 12:49:25 -04:00
{
2021-06-11 14:48:40 -04:00
GPostCompileResult = PostCompileResult ;
2021-04-26 12:49:25 -04:00
GIsCompileActive = false ;
}
// Invoked from LC_ClientCommandActions
void LiveCodingTriggerReload ( )
{
GTriggerReload = true ;
}
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
# undef LOCTEXT_NAMESPACE