Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
#fyi Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00
|
|
|
// Copyright 2011-2019 Molecular Matters GmbH, all rights reserved.
|
|
|
|
|
|
|
|
|
|
#include "LC_Environment.h"
|
|
|
|
|
#include "LC_FileUtil.h"
|
|
|
|
|
#include "LC_MemoryFile.h"
|
|
|
|
|
#include "LC_StringUtil.h"
|
|
|
|
|
#include "LC_AppSettings.h"
|
|
|
|
|
#include "LC_Logging.h"
|
|
|
|
|
|
2019-04-04 11:55:49 -04:00
|
|
|
// BEGIN EPIC MOD - Allow passing environment block for linker
|
|
|
|
|
#include "Containers/StringConv.h"
|
|
|
|
|
// END EPIC MOD
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
#fyi Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00
|
|
|
|
|
|
|
|
namespace environment
|
|
|
|
|
{
|
|
|
|
|
struct Block
|
|
|
|
|
{
|
|
|
|
|
size_t size;
|
|
|
|
|
char* data;
|
|
|
|
|
};
|
|
|
|
|
|
2019-04-04 11:55:49 -04:00
|
|
|
// BEGIN EPIC MOD - Allow passing environment block for linker
|
|
|
|
|
Block* CreateBlockFromMap(const TMap<FString, FString>& Pairs)
|
|
|
|
|
{
|
|
|
|
|
std::vector<char> blockData;
|
|
|
|
|
for (const TPair<FString, FString>& Pair : Pairs)
|
|
|
|
|
{
|
|
|
|
|
auto AnsiString = StringCast<ANSICHAR>(*FString::Printf(TEXT("%s=%s"), *Pair.Key, *Pair.Value));
|
|
|
|
|
const char* AnsiStringData = AnsiString.Get();
|
|
|
|
|
blockData.insert(blockData.end(), AnsiStringData, strchr(AnsiStringData, 0) + 1);
|
|
|
|
|
}
|
|
|
|
|
blockData.push_back('\0');
|
|
|
|
|
|
|
|
|
|
Block* block = new Block;
|
|
|
|
|
block->size = blockData.size();
|
|
|
|
|
block->data = new char[blockData.size()];
|
|
|
|
|
memcpy(block->data, blockData.data(), blockData.size());
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
// END EPIC MOD
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
#fyi Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00
|
|
|
|
|
|
|
|
Block* CreateBlockFromFile(const wchar_t* path)
|
|
|
|
|
{
|
|
|
|
|
const file::Attributes& attributes = file::GetAttributes(path);
|
|
|
|
|
const uint64_t fileSize = file::GetSize(attributes);
|
|
|
|
|
|
|
|
|
|
file::MemoryFile* file = file::Open(path, file::OpenMode::READ_ONLY);
|
|
|
|
|
if (!file)
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
types::vector<char> blockData;
|
|
|
|
|
blockData.reserve(static_cast<size_t>(fileSize));
|
|
|
|
|
|
|
|
|
|
// walk through the file and gather individual environment variables line by line
|
|
|
|
|
const char* memory = static_cast<const char*>(file::GetData(file));
|
|
|
|
|
const char* memoryEnd = memory + fileSize;
|
|
|
|
|
for (/*nothing*/; memory < memoryEnd; /*nothing*/)
|
|
|
|
|
{
|
|
|
|
|
const char* start = memory;
|
|
|
|
|
|
|
|
|
|
// search for carriage return
|
2019-05-14 18:08:06 -04:00
|
|
|
while ((memory < memoryEnd) && (memory[0] != '\r'))
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
#fyi Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00
|
|
|
{
|
|
|
|
|
++memory;
|
|
|
|
|
}
|
2019-05-14 18:08:06 -04:00
|
|
|
|
|
|
|
|
if (memory >= memoryEnd)
|
|
|
|
|
{
|
|
|
|
|
// reached the end
|
|
|
|
|
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
[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00
|
|
|
const char* end = memory;
|
|
|
|
|
|
|
|
|
|
std::string line(start, end);
|
|
|
|
|
|
|
|
|
|
// values can contain '=', '\r' and '\n', so parsing key=value pairs cannot be done
|
|
|
|
|
// unambiguously given a block of text. to avoid passing an invalid environment block
|
|
|
|
|
// to CreateProcess() when invoking the compiler/linker, we simply remove all lines
|
|
|
|
|
// that do not contain an '=' - these are the ones that would lead to error 87
|
|
|
|
|
// (invalid parameter) when calling CreateProcess().
|
|
|
|
|
if (string::Contains(line.c_str(), "="))
|
|
|
|
|
{
|
|
|
|
|
// valid key=value pair.
|
|
|
|
|
// insert line into block data, and add null terminator to signal the end of this variable.
|
|
|
|
|
blockData.insert(blockData.end(), line.begin(), line.end());
|
|
|
|
|
blockData.push_back('\0');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// skip carriage return and new line
|
2019-05-14 18:08:06 -04:00
|
|
|
while ((memory < memoryEnd) && ((memory[0] == '\r') || (memory[0] == '\n')))
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
#fyi Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00
|
|
|
{
|
|
|
|
|
++memory;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// add null terminator that signals the end of the whole block
|
|
|
|
|
blockData.push_back('\0');
|
|
|
|
|
|
|
|
|
|
file::Close(file);
|
|
|
|
|
|
|
|
|
|
Block* block = new Block;
|
|
|
|
|
block->size = blockData.size();
|
|
|
|
|
block->data = new char[block->size];
|
|
|
|
|
memcpy(block->data, blockData.data(), block->size);
|
|
|
|
|
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DestroyBlock(Block*& block)
|
|
|
|
|
{
|
|
|
|
|
if (block)
|
|
|
|
|
{
|
|
|
|
|
delete[] block->data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete block;
|
|
|
|
|
block = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DumpBlockData(const wchar_t* name, const Block* block)
|
|
|
|
|
{
|
|
|
|
|
// don't do any parsing when dev output is turned off
|
|
|
|
|
if (!appSettings::g_enableDevLog->GetValue())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LC_LOG_DEV("Environment block %S:", name);
|
|
|
|
|
LC_LOG_INDENT_DEV;
|
|
|
|
|
|
|
|
|
|
const char* start = block->data;
|
|
|
|
|
const char* end = start;
|
|
|
|
|
while (end < block->data + block->size)
|
|
|
|
|
{
|
|
|
|
|
// search for null terminator
|
|
|
|
|
while (*end != '\0')
|
|
|
|
|
{
|
|
|
|
|
++end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LC_LOG_DEV("%s", start);
|
|
|
|
|
|
|
|
|
|
++end;
|
|
|
|
|
start = end;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const void* GetBlockData(const Block* block)
|
|
|
|
|
{
|
|
|
|
|
return block->data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const size_t GetBlockSize(const Block* block)
|
|
|
|
|
{
|
|
|
|
|
return block->size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::wstring GetVariable(const wchar_t* variable)
|
|
|
|
|
{
|
|
|
|
|
std::wstring value;
|
|
|
|
|
value.resize(MAX_PATH);
|
|
|
|
|
|
|
|
|
|
size_t bytes = 0u;
|
2019-05-14 18:08:06 -04:00
|
|
|
const errno_t error = _wgetenv_s(&bytes, &value[0], value.size(), variable);
|
|
|
|
|
if (error != 0)
|
|
|
|
|
{
|
|
|
|
|
LC_LOG_DEV("Could not retrieve environment variable %S (Error: %d)", variable, error);
|
|
|
|
|
}
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
#fyi Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
[CL 5304722 by Ben Marsh in 4.22 branch]
2019-03-05 15:54:02 -05:00
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|