69 lines
1.9 KiB
Python
Executable File
69 lines
1.9 KiB
Python
Executable File
#!/usr/bin/python3
|
|
#
|
|
# This script applies patches to the UnrealEngine repository.
|
|
#
|
|
# We don't keep our own unreal engine repository because that
|
|
# would be overkill. Instead, you must check out the standard
|
|
# copy of Unreal engine, then we apply a few simple patches.
|
|
# The files patched are:
|
|
#
|
|
# UnrealEngine/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml
|
|
# UnrealEngine/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp
|
|
#
|
|
# This python program will generate these files as necessary.
|
|
#
|
|
# It is safe to run this patch program a second time to repair
|
|
# any of these files, if necessary. Doing so will not corrupt
|
|
# anything.
|
|
#
|
|
#--------------------------------------------------------------
|
|
|
|
import sys, os, json, glob
|
|
from pathlib import Path
|
|
|
|
#
|
|
# Some handy utility functions
|
|
#
|
|
|
|
def readfile(fn):
|
|
with open(fn) as f:
|
|
return f.read()
|
|
|
|
def writefile(fn, str):
|
|
with open(fn, "w") as f:
|
|
f.write(str)
|
|
|
|
#
|
|
# These are some directory paths that we will need.
|
|
#
|
|
|
|
INTEGRATION = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
UNREALENGINE = os.environ["HOME"] + "/UnrealEngine"
|
|
if not os.path.isdir(UNREALENGINE): error("No unreal installed in $HOME/UnrealEngine")
|
|
|
|
#
|
|
# Change to the target directory.
|
|
# Remove any existing project files.
|
|
#
|
|
|
|
os.chdir(UNREALENGINE)
|
|
Path("Engine/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
|
|
Path("Engine/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True)
|
|
Path("Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp").unlink(missing_ok=True)
|
|
|
|
#
|
|
# Write BuildConfiguration.xml
|
|
#
|
|
|
|
BUILDCONFIG=readfile(f"{INTEGRATION}/EnginePatches/BuildConfigurationLinux.xml")
|
|
writefile("Engine/Saved/UnrealBuildTool/BuildConfiguration.xml", BUILDCONFIG)
|
|
|
|
#
|
|
# Write LogMacros.cpp
|
|
#
|
|
|
|
LOGMACROS=readfile(f"{INTEGRATION}/EnginePatches/LogMacros.cpp")
|
|
writefile(f"{UNREALENGINE}/Engine/Source/Runtime/Core/Private/Logging/LogMacros.cpp", LOGMACROS)
|
|
|
|
|