2024-11-04 15:46:54 -05:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
#
|
2024-11-04 17:38:10 -05:00
|
|
|
# This python script builds integration from scratch. That includes:
|
|
|
|
|
#
|
|
|
|
|
# - Generating BuildConfiguration.xml in integration repository
|
|
|
|
|
# - Generating BuildConfiguration.xml in UnrealEngine repository
|
|
|
|
|
# - Hardwiring paths into Source/Integration/lpx-paths.hpp
|
|
|
|
|
# - Generating Integration.uproject
|
|
|
|
|
# - Generating Integration.code-workspace
|
2024-11-05 20:26:39 -05:00
|
|
|
# - Applies patch to Unreal Engine source.
|
2024-11-04 17:38:10 -05:00
|
|
|
# - Running Setup.sh in the UnrealEngine repository
|
|
|
|
|
# - Building luprex
|
|
|
|
|
# - Building ShaderCompileWorker
|
|
|
|
|
# - Building integration
|
|
|
|
|
#
|
|
|
|
|
# Once this is all done, everything is ready to go. It is now possible to
|
|
|
|
|
# start up the IDE and run luprex in the debugger.
|
|
|
|
|
#
|
|
|
|
|
# This script is mainly intended for the *initial* build.
|
|
|
|
|
# If you want to edit the code and recompile, it is okay to use
|
|
|
|
|
# this script a second time, but it's unnecessarily slow.
|
|
|
|
|
# It's much faster to edit and recompile using the IDE.
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
|
2024-11-05 20:26:39 -05:00
|
|
|
import sys, os, json, shutil, subprocess
|
2024-11-04 15:46:54 -05:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
#
|
2024-11-07 19:33:22 -05:00
|
|
|
# These things are operating system specific.
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
|
2024-11-07 19:33:22 -05:00
|
|
|
if sys.platform == "windows":
|
|
|
|
|
OS = "Windows"
|
|
|
|
|
DLL = "dll"
|
|
|
|
|
BAT = "bat"
|
|
|
|
|
DOT_EXE = ".exe"
|
|
|
|
|
USER = "Unknown"
|
|
|
|
|
BUILD_BAT = "Build.bat"
|
|
|
|
|
else:
|
|
|
|
|
OS = "Linux"
|
|
|
|
|
DLL = "so"
|
|
|
|
|
BAT = "sh"
|
|
|
|
|
DOT_EXE = ""
|
|
|
|
|
USER = os.environ["USER"]
|
|
|
|
|
BUILD_BAT = "Linux/Build.sh"
|
|
|
|
|
|
|
|
|
|
#
|
2024-11-11 14:14:52 -05:00
|
|
|
# Some handy utility functions
|
2024-11-07 19:33:22 -05:00
|
|
|
#
|
|
|
|
|
|
2024-11-11 14:14:52 -05:00
|
|
|
def readfile(fn):
|
|
|
|
|
with open(fn) as f:
|
|
|
|
|
return f.read()
|
2024-11-07 19:33:22 -05:00
|
|
|
|
2024-11-11 14:14:52 -05:00
|
|
|
def writefile(fn, str):
|
|
|
|
|
with open(fn, "w") as f:
|
|
|
|
|
f.write(str)
|
2024-11-07 19:33:22 -05:00
|
|
|
|
2024-11-11 14:14:52 -05:00
|
|
|
def shell(dir, cmd):
|
|
|
|
|
print("Running:", cmd)
|
|
|
|
|
subprocess.run(cmd, shell=True, check=True, cwd=dir)
|
2024-11-07 19:33:22 -05:00
|
|
|
|
|
|
|
|
#
|
2024-11-11 14:14:52 -05:00
|
|
|
# Find the two repositories and verify them.
|
2024-11-07 19:33:22 -05:00
|
|
|
#
|
|
|
|
|
|
2024-11-11 14:14:52 -05:00
|
|
|
INTEGRATION=os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
|
|
|
UNREALENGINE=os.path.join(os.path.dirname(INTEGRATION), "UnrealEngine")
|
2024-11-07 19:33:22 -05:00
|
|
|
|
2024-11-11 14:14:52 -05:00
|
|
|
if not os.path.isdir(f"{INTEGRATION}/Source/Integration"):
|
|
|
|
|
sys.exit(f"Integration repository is not valid: {INTEGRATION}")
|
|
|
|
|
if not os.path.isdir(f"{UNREALENGINE}/Engine/Source/Editor"):
|
|
|
|
|
sys.exit(f"Integration repository is not valid: {UNREALENGINE}")
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Create the Saved/UnrealBuildTool directories. These will hold
|
|
|
|
|
# the file BuildConfiguration.xml
|
2024-11-07 19:33:22 -05:00
|
|
|
#
|
2024-11-11 14:14:52 -05:00
|
|
|
# Change directory to one of these in order to force ourselves
|
|
|
|
|
# to specify all paths explicitly.
|
2024-11-07 19:33:22 -05:00
|
|
|
#
|
|
|
|
|
|
2024-11-11 14:14:52 -05:00
|
|
|
Path(f"{INTEGRATION}/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
|
|
|
|
|
Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
|
|
|
|
|
os.chdir(f"{INTEGRATION}/Saved/UnrealBuildTool")
|
2024-11-04 15:46:54 -05:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Remove previously-generated files.
|
2024-11-07 19:33:22 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
|
|
Path(f"{INTEGRATION}/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True)
|
|
|
|
|
Path(f"{INTEGRATION}/Integration.uproject").unlink(missing_ok=True)
|
|
|
|
|
Path(f"{INTEGRATION}/Integration.code-workspace").unlink(missing_ok=True)
|
|
|
|
|
Path(f"{INTEGRATION}/Makefile").unlink(missing_ok=True)
|
|
|
|
|
Path(f"{INTEGRATION}/Source/Integration/lpx-paths.hpp").unlink(missing_ok=True)
|
2024-11-04 15:46:54 -05:00
|
|
|
Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True)
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Write BuildConfiguration.xml
|
|
|
|
|
#
|
|
|
|
|
|
2024-11-07 19:33:22 -05:00
|
|
|
BUILDCONFIG=readfile(f"{INTEGRATION}/EnginePatches/BuildConfiguration{OS}.xml")
|
|
|
|
|
writefile(f"{INTEGRATION}/Saved/UnrealBuildTool/BuildConfiguration.xml", BUILDCONFIG)
|
2024-11-04 15:46:54 -05:00
|
|
|
writefile(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml", BUILDCONFIG)
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Write lpx-paths.hpp.
|
|
|
|
|
#
|
|
|
|
|
|
2024-11-07 19:33:22 -05:00
|
|
|
writefile(f"{INTEGRATION}/Source/Integration/lpx-paths.hpp", f"""
|
|
|
|
|
#define LUPREX_DLL_PATH "{INTEGRATION}/luprex/build/{OS}/luprexlib.{DLL}"
|
2024-11-04 15:46:54 -05:00
|
|
|
#define LUPREX_ROOT_PATH "{INTEGRATION}/luprex"
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
#
|
2024-11-05 20:26:39 -05:00
|
|
|
# Apply patch to the unreal engine source.
|
|
|
|
|
# Restore any affected sourcefiles before applying patch.
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
|
2024-11-05 20:26:39 -05:00
|
|
|
print("Applying patch to Unreal Engine...")
|
2024-11-07 17:53:05 -05:00
|
|
|
for line in readfile(f"{INTEGRATION}/EnginePatches/EnginePatch").splitlines():
|
|
|
|
|
if line.startswith("--- a/"):
|
2024-11-07 19:33:22 -05:00
|
|
|
shell(UNREALENGINE, f"git checkout HEAD {line[6:]}")
|
|
|
|
|
shell(UNREALENGINE, f"git apply {INTEGRATION}/EnginePatches/EnginePatch")
|
2024-11-04 15:46:54 -05:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Write Integration.uproject.
|
|
|
|
|
#
|
|
|
|
|
|
2024-11-07 19:33:22 -05:00
|
|
|
UPROJECTTEMPLATE=readfile(f"{INTEGRATION}/EnginePatches/uproject")
|
2024-11-04 15:46:54 -05:00
|
|
|
UPROJECT=json.loads(UPROJECTTEMPLATE)
|
2024-11-07 19:33:22 -05:00
|
|
|
with open(f"{INTEGRATION}/Integration.uproject", "w") as rewritten:
|
2024-11-04 15:46:54 -05:00
|
|
|
json.dump(UPROJECT, rewritten, indent=4)
|
|
|
|
|
|
|
|
|
|
#
|
2024-11-04 17:26:38 -05:00
|
|
|
# Run Setup.sh in UNREALENGINE
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
|
2024-11-07 19:33:22 -05:00
|
|
|
shell(UNREALENGINE, f"{UNREALENGINE}/Setup.{BAT}")
|
2024-11-04 15:46:54 -05:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Use UnrealBuildTool to generate a rough draft of Integration.code-workspace.
|
2025-02-24 16:46:05 -05:00
|
|
|
# We're not going to use it, but we set it aside as a reference that you can
|
|
|
|
|
# study to make changes to this script.
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
Path(f"{INTEGRATION}/Integration.code-workspace").unlink(missing_ok=True)
|
|
|
|
|
Path(f"{INTEGRATION}/Integration.code-workspace.old").unlink(missing_ok=True)
|
2024-11-07 19:33:22 -05:00
|
|
|
shell(INTEGRATION, f'{UNREALENGINE}/GenerateProjectFiles.{BAT} -projectfiles -project="{INTEGRATION}/Integration.uproject" -game')
|
2025-02-24 16:46:05 -05:00
|
|
|
Path(f"{INTEGRATION}/Integration.code-workspace").rename(f"{INTEGRATION}/Integration.code-workspace.old")
|
2024-11-04 15:46:54 -05:00
|
|
|
|
|
|
|
|
#
|
2025-02-24 16:46:05 -05:00
|
|
|
# Create a trivial makefile that calls into the unreal build system.
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
writefile(f"{INTEGRATION}/Makefile", f"""
|
|
|
|
|
# This makefile just invokes the unreal build system, then the luprex build system.
|
2024-11-04 15:46:54 -05:00
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
all:
|
|
|
|
|
\t{UNREALENGINE}/Engine/Build/BatchFiles/Linux/Build.sh IntegrationEditor Linux DebugGame {INTEGRATION}/Integration.uproject -waitmutex
|
|
|
|
|
\t(cd luprex ; make all)
|
2024-11-04 15:46:54 -05:00
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
clean:
|
|
|
|
|
\t{UNREALENGINE}/Engine/Build/BatchFiles/Linux/Build.sh IntegrationEditor Linux DebugGame {INTEGRATION}/Integration.uproject -waitmutex -clean
|
|
|
|
|
\t(cd luprex ; make clean)
|
|
|
|
|
""")
|
2024-11-04 15:46:54 -05:00
|
|
|
|
|
|
|
|
#
|
2025-02-24 16:46:05 -05:00
|
|
|
# Build our own Integration.code-workspace from scratch.
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
WORKSPACE={}
|
2025-01-21 20:20:54 -05:00
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
WORKSPACE["folders"] = []
|
|
|
|
|
WORKSPACE["folders"].append({ "name": "Integration", "path": "." })
|
|
|
|
|
WORKSPACE["folders"].append({ "name": "UE5", "path": UNREALENGINE })
|
2025-01-21 20:20:54 -05:00
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
WORKSPACE["settings"] = {}
|
|
|
|
|
WORKSPACE["settings"]["typescript.tsc.autoDetect"] = "off"
|
|
|
|
|
WORKSPACE["settings"]["lldb.dereferencePointers"] = False
|
|
|
|
|
WORKSPACE["settings"]["npm.autoDetect"] = "off"
|
|
|
|
|
|
|
|
|
|
WORKSPACE["settings"]["files.watcherExclude"] = {}
|
|
|
|
|
WORKSPACE["settings"]["files.watcherExclude"]["/home/jyelon/UnrealEngine/Engine/**"] = True
|
|
|
|
|
WORKSPACE["settings"]["files.watcherExclude"]["/home/jyelon/UnrealEngine/Samples/**"] = True
|
|
|
|
|
WORKSPACE["settings"]["files.watcherExclude"]["/home/jyelon/UnrealEngine/Templates/**"] = True
|
|
|
|
|
WORKSPACE["settings"]["files.associations"] = {
|
|
|
|
|
"*.ipp": "cpp",
|
|
|
|
|
"locale": "cpp",
|
|
|
|
|
"random": "cpp",
|
|
|
|
|
"queue": "cpp",
|
|
|
|
|
"stack": "cpp",
|
|
|
|
|
"__locale": "cpp",
|
|
|
|
|
"functional": "cpp",
|
|
|
|
|
"sstream": "cpp",
|
|
|
|
|
"regex": "cpp",
|
|
|
|
|
"*.inc": "cpp",
|
|
|
|
|
"strstream": "cpp",
|
|
|
|
|
"string_view": "cpp",
|
|
|
|
|
"typeindex": "cpp",
|
|
|
|
|
"typeinfo": "cpp",
|
|
|
|
|
"scoped_allocator": "cpp",
|
|
|
|
|
"array": "cpp",
|
|
|
|
|
"hash_map": "cpp",
|
|
|
|
|
"hash_set": "cpp",
|
|
|
|
|
"bitset": "cpp",
|
|
|
|
|
"slist": "cpp",
|
|
|
|
|
"initializer_list": "cpp",
|
|
|
|
|
"valarray": "cpp",
|
|
|
|
|
"__hash_table": "cpp",
|
|
|
|
|
"__split_buffer": "cpp",
|
|
|
|
|
"__tree": "cpp",
|
|
|
|
|
"deque": "cpp",
|
|
|
|
|
"list": "cpp",
|
|
|
|
|
"map": "cpp",
|
|
|
|
|
"set": "cpp",
|
|
|
|
|
"span": "cpp",
|
|
|
|
|
"string": "cpp",
|
|
|
|
|
"unordered_map": "cpp",
|
|
|
|
|
"unordered_set": "cpp",
|
|
|
|
|
"vector": "cpp",
|
|
|
|
|
"ranges": "cpp",
|
|
|
|
|
"utility": "cpp",
|
|
|
|
|
"ratio": "cpp",
|
|
|
|
|
"system_error": "cpp",
|
|
|
|
|
"tuple": "cpp",
|
|
|
|
|
"type_traits": "cpp",
|
|
|
|
|
"__bit_reference": "cpp",
|
|
|
|
|
"__node_handle": "cpp",
|
|
|
|
|
"atomic": "cpp",
|
|
|
|
|
"__memory": "cpp",
|
|
|
|
|
"limits": "cpp",
|
|
|
|
|
"optional": "cpp",
|
|
|
|
|
"variant": "cpp"
|
|
|
|
|
}
|
2024-11-04 15:46:54 -05:00
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
WORKSPACE["extensions"] = {}
|
|
|
|
|
WORKSPACE["extensions"]["recommendations"] = [
|
|
|
|
|
"vadimcn.vscode-lldb",
|
|
|
|
|
"dfarley1.file-picker",
|
|
|
|
|
"ms-python.python",
|
|
|
|
|
"ms-vscode.cpptools",
|
|
|
|
|
"ms-dotnettools.csharp",
|
|
|
|
|
"ms-vscode.mono-debug"
|
2024-11-04 15:46:54 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
2025-02-24 16:46:05 -05:00
|
|
|
WORKSPACE["tasks"] = {}
|
|
|
|
|
WORKSPACE["tasks"]["version"] = "2.0.0"
|
|
|
|
|
WORKSPACE["tasks"]["tasks"] = []
|
|
|
|
|
WORKSPACE["tasks"]["tasks"].append({
|
|
|
|
|
"label": "Make All",
|
|
|
|
|
"group": { "kind": "build", "isDefault": True },
|
|
|
|
|
"command": "make all",
|
|
|
|
|
"presentation" : { "clear" : True },
|
|
|
|
|
"problemMatcher": "$msCompile",
|
|
|
|
|
"type": "shell",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
WORKSPACE["tasks"]["tasks"].append({
|
|
|
|
|
"label": "Make Clean",
|
|
|
|
|
"group": "build",
|
|
|
|
|
"command": "make clean",
|
|
|
|
|
"presentation" : { "clear" : True },
|
|
|
|
|
"problemMatcher": "$msCompile",
|
|
|
|
|
"type": "shell",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WORKSPACE["launch"] = {}
|
|
|
|
|
WORKSPACE["launch"]["version"] = "0.2.0"
|
|
|
|
|
WORKSPACE["launch"]["configurations"] = []
|
|
|
|
|
WORKSPACE["launch"]["configurations"].append({
|
|
|
|
|
"name": "Launch Editor with Luprex",
|
|
|
|
|
"request": "launch",
|
|
|
|
|
"program": f"{UNREALENGINE}/Engine/Binaries/Linux/UnrealEditor-Linux-DebugGame",
|
|
|
|
|
"preLaunchTask": "Make All",
|
|
|
|
|
"args": [
|
|
|
|
|
f"{INTEGRATION}/Integration.uproject",
|
|
|
|
|
"-userdir=User/jyelon"
|
|
|
|
|
],
|
|
|
|
|
"cwd": UNREALENGINE,
|
|
|
|
|
"type": "lldb",
|
|
|
|
|
"initCommands": [
|
|
|
|
|
f"command script import {UNREALENGINE}/Engine/Extras/LLDBDataFormatters/UEDataFormatters_2ByteChars.py",
|
|
|
|
|
"settings set target.inline-breakpoint-strategy always",
|
|
|
|
|
"target stop-hook add --one-liner \"p ::UngrabAllInputImpl()\""
|
|
|
|
|
]
|
|
|
|
|
})
|
2024-11-07 17:53:05 -05:00
|
|
|
|
2024-11-25 15:20:33 -05:00
|
|
|
|
2024-11-04 15:46:54 -05:00
|
|
|
#
|
|
|
|
|
# Write Integration.code-workspace.
|
|
|
|
|
#
|
|
|
|
|
|
2024-11-07 19:33:22 -05:00
|
|
|
with open(f"{INTEGRATION}/Integration.code-workspace", "w") as rewritten:
|
2024-11-04 15:46:54 -05:00
|
|
|
json.dump(WORKSPACE, rewritten, indent=4)
|
|
|
|
|
|
2024-11-04 17:26:38 -05:00
|
|
|
#
|
|
|
|
|
# Do an initial build of Luprex
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
print("Building luprex...")
|
2024-11-07 19:33:22 -05:00
|
|
|
shell(f"{INTEGRATION}/luprex", "make")
|
2024-11-04 17:26:38 -05:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Build ShaderCompileWorker
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
print("Building ShaderCompileWorker...")
|
2024-11-07 19:33:22 -05:00
|
|
|
shell(UNREALENGINE, f"{UNREALENGINE}/Engine/Build/BatchFiles/{BUILD_BAT} ShaderCompileWorker {OS} Shipping -waitmutex")
|
|
|
|
|
Path(f"Engine/Binaries/{OS}/ShaderCompileWorker{DOT_EXE}").unlink(missing_ok=True)
|
|
|
|
|
shutil.copyfile(f"{UNREALENGINE}/Engine/Binaries/{OS}/ShaderCompileWorker-{OS}-Shipping{DOT_EXE}", f"{UNREALENGINE}/Engine/Binaries/{OS}/ShaderCompileWorker{DOT_EXE}")
|
2024-11-04 17:26:38 -05:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Build Integration
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
print("Building integration...")
|
2024-11-07 19:33:22 -05:00
|
|
|
shell(INTEGRATION, f'{UNREALENGINE}/Engine/Build/BatchFiles/{BUILD_BAT} IntegrationEditor {OS} DebugGame -project="{INTEGRATION}/Integration.uproject" -waitmutex')
|
2024-11-04 17:26:38 -05:00
|
|
|
|