More work on patch-integration.py

This commit is contained in:
2024-10-28 19:03:54 -04:00
parent fb4df7b872
commit ab3832681a
3 changed files with 157 additions and 108 deletions

View File

@@ -39,13 +39,6 @@
# be checked into git because it contains many hardwired
# paths.
#
# The UnrealBuildTool which is included with the UnrealEngine can
# generate a rough draft of Integration.code-workspace. However, the
# file it generates is not well-configured for our luprex-related
# needs. This python script uses UnrealBuildTool to generate the rough
# draft, then it loads Integration.code-workspace into RAM, edits it
# in RAM, and writes a new, improved version back out.
#
# We don't really need a Makefile, since Unreal games are build using
# UnrealBuildTool, not make. But, having a one-liner makefile can at
# least make it obvious what command you're supposed to type to build
@@ -117,111 +110,21 @@ writefile("Source/Integration/lpx-paths.hpp", f"""
# Write Integration.uproject.
#
writefile("Integration.uproject", """
{
"FileVersion": 3,
"EngineAssociation": "5.3",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "Integration",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine",
"CoreUObject"
]
}
],
"Plugins": [
{
"Name": "ModelingToolsEditorMode",
"Enabled": true,
"TargetAllowList": [
"Editor"
]
}
]
}
""")
UPROJECTTEMPLATE=readfile("EnginePatches/uproject")
UPROJECT=json.loads(UPROJECTTEMPLATE)
with open("Integration.uproject", "w") as rewritten:
json.dump(UPROJECT, rewritten, indent=4)
#
# Use UnrealBuildTool to generate a rough draft of Integration.code-workspace.
#
BUILDPROJECTFILES = f'dotnet {UNREALBUILDTOOL} -projectfiles -project="{INTEGRATION}/Integration.uproject" -game'
print(BUILDPROJECTFILES)
os.system(BUILDPROJECTFILES)
#
# Load the rough Integration.code-workspace into RAM, then delete the rough draft.
#
with open("Integration.code-workspace") as original:
WORKSPACE=json.load(original)
os.remove("Integration.code-workspace")
#
# Configure the correct build task as the default task.
#
for task in WORKSPACE["tasks"]["tasks"]:
if task["label"] == "IntegrationEditor Linux DebugGame Build":
task["group"] = { "kind": "build", "isDefault": "true" }
#
# Delete all build tasks that aren't relevant.
#
def goodtask(task):
return task["label"].startswith("IntegrationEditor Linux DebugGame")
WORKSPACE["tasks"]["tasks"] = [x for x in WORKSPACE["tasks"]["tasks"] if goodtask(x)]
#
# Add a build task for Luprex
#
LUPREXBUILDTASK={}
WORKSPACE["tasks"]["tasks"].append(LUPREXBUILDTASK)
LUPREXBUILDTASK["label"] = "Build Luprex"
LUPREXBUILDTASK["group"] = "build"
LUPREXBUILDTASK["command"] = "make"
LUPREXBUILDTASK["problemMatcher"] = "$msCompile"
LUPREXBUILDTASK["type"] = "shell"
LUPREXBUILDTASK["options"] = {}
LUPREXBUILDTASK["options"]["cwd"] = f"{INTEGRATION}/luprex"
#
# Convert all launch configurations to lldb.
#
for config in WORKSPACE["launch"]["configurations"]:
config["type"] = "lldb"
config["initCommands"] = [
f"command script import {UNREALENGINE}/Engine/Extras/LLDBDataFormatters/UEDataFormatters_2ByteChars.py",
f'target stop-hook add --one-liner "p ::UngrabAllInputImpl()"'
]
config["args"] = [ f"{INTEGRATION}/Integration.uproject", f"-userdir=User/{USER}" ]
config.pop("visualizerFile", None)
config.pop("showDisplayString", None)
#
# Delete all but the relevant launch configuration.
#
def goodconf(config):
return config["name"] == "Launch IntegrationEditor (DebugGame)"
WORKSPACE["launch"]["configurations"] = [x for x in WORKSPACE["launch"]["configurations"] if goodconf(x)]
#
# Write Integration.code-workspace.
# Using the template in EnginePatches/code-workspace, generate a
# updated version of Integration.code-workspace
#
WORKSPACETEMPLATE=readfile("EnginePatches/code-workspace")
WORKSPACETEMPLATE=WORKSPACETEMPLATE.replace("ENGINEPATH", UNREALENGINE)
WORKSPACETEMPLATE=WORKSPACETEMPLATE.replace("INTEGRATIONPATH", INTEGRATION)
WORKSPACETEMPLATE=WORKSPACETEMPLATE.replace("USERNAME", USER)
WORKSPACE=json.loads(WORKSPACETEMPLATE)
with open("Integration.code-workspace", "w") as rewritten:
json.dump(WORKSPACE, rewritten, indent=4)