Just wanted to share a discovery I had trying to set up my favourite “IDE”: vim + bash:
It’s possible to invoke C++ script compilation from terminal and have it working with the editor’s hot reload function.
I made this script based on the information in the output log.
Add this function to your ~/.bashrc:
function unrealbuild {
UNR_PATH=/opt/UnrealEngine;
RANDNUM=$(( ( RANDOM % 1000 ) + 1000 ));
CURR_DIR=`pwd`;
PROJ_NAME=$(basename ${1%.uproject});
echo $RANDNUM
${UNR_PATH}/Engine/Build/BatchFiles/Linux/RunMono.sh ${UNR_PATH}/Engine/Binaries/DotNET/UnrealBuildTool.exe $PROJ_NAME -ModuleWithSuffix $PROJ_NAME $RANDNUM Linux Development -editorrecompile -canskiplink "${CURR_DIR}/${PROJ_NAME}.uproject" -progress
}
(Of course, replace the “/opt/UnrealEngine” bit with the path to your UnrealEngine folder.)
And then use it like this:
cd /path/to/ProjectName
unrealbuild ./ProjectName.uproject
Note:
The part I’m not so certain of is the purpose of the RANDNUM variable. I found that it only works if I create a new random number every time.
I don’t know if the numbers the built-in compiler tool uses are being tracked in the editor to be deleted later on, and if this script will generate a bunch of garbage binaries that way.
In any case, the binaries are going to the /path/to/ProjectName/Binaries/Linux folder, you can keep an eye on them there.
Improvements:
If anyone has anything to add, perhaps making it more flexible, it’d be highly appreciated.
:~/Documents/Unreal Projects/Time$ unrealbuild Time.uproject
1902
Running Mono...
Fixing inconsistent case in filenames.
Setting up Mono
~/programs/UnrealEngine/Engine ~/Documents/Unreal Projects/Time
ERROR: '-ModuleWithSuffix <Name> <Suffix>' syntax is no longer supported on the command line. Use '-Module=<Name>,<Suffix>' instead.
(see ../Programs/UnrealBuildTool/Log.txt for full exception trace)
I’ve tried changing it to this:
${UNR_PATH}/Engine/Build/BatchFiles/Linux/RunMono.sh ${UNR_PATH}/Engine/Binaries/DotNET/UnrealBuildTool.exe $PROJ_NAME -Module=$PROJ_NAME,$RANDNUM Linux Development -editorrecompile -canskiplink "${CURR_DIR}/${PROJ_NAME}.uproject" -progress
But this also doesn’t work and throws error like it doesn’t know what ‘module’ means.
ERROR: One or more of the modules specified using the '-module' argument could not be found.
(see ../Programs/UnrealBuildTool/Log.txt for full exception trace)
Anyone has this issue or know the solution to this?
Not sure if it is okay to post in a dead thread like this, but I didn’t see anything about it in the forum rules. I will gladly make a new thread about compiling code on the Linux platform if asked by the moderators.
From my understanding reading through the code, you need to use the following command line argument.
-ModuleWithSuffix=$PROJ_NAME,$RANDNUM
That is, include the comma in the command line argument and it should work. I was reading through the code in an attempt to respond to OP’s question about the suffix number that is needed for a hot reload. Here’s what I found in the source.
// Patch action history for hot reload when running in assembler mode. In assembler mode, the suffix on the output file will be
// the same for every invocation on that makefile, but we need a new suffix each time.
// For all the hot-reloadable modules that may need a unique suffix appended, build a mapping from output item to all the output items in that module. We can't
// apply a suffix to one without applying a suffix to all of them.
It seems to me like the purpose of this is for appending a build number, but it is a little weird that it only accepts ints, so you can’t have a proper build number like 1.13.0 for example.