From 67dba0b353dd0352c9272017ef42f1cbbe18be51 Mon Sep 17 00:00:00 2001 From: jyelon Date: Thu, 3 Oct 2024 14:11:25 -0400 Subject: [PATCH] More work on generating the project config files --- .gitignore | 1 + .../Blueprints/Blueprint_CeilingLight.uasset | 4 +- .../Shapes/Shape_Pipe_90.uasset | 4 +- Integration.uproject | 26 --- make-vscode.py | 149 ++++++++++++++++++ 5 files changed, 154 insertions(+), 30 deletions(-) delete mode 100644 Integration.uproject create mode 100755 make-vscode.py diff --git a/.gitignore b/.gitignore index 4ec87264..056d96b8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ a.out gprof.out gmon.out .vsconfig +Integration.uproject Integration.code-workspace *~ diff --git a/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset b/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset index 3ae9ade6..c5c3b84e 100644 --- a/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset +++ b/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:320caa41eca0ad84fb7b6ec4cc8775a80716f97e231aab1bb86c0308fc757430 -size 45023 +oid sha256:4a60a29ad596546d481e43dfb8698842a78cc07f4a4b1000fa397cfba4e72331 +size 158206 diff --git a/Content/StarterContent/Shapes/Shape_Pipe_90.uasset b/Content/StarterContent/Shapes/Shape_Pipe_90.uasset index 511b0378..5456d861 100644 --- a/Content/StarterContent/Shapes/Shape_Pipe_90.uasset +++ b/Content/StarterContent/Shapes/Shape_Pipe_90.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:36a4e17228e6f85fe4600a88ea6bb2939737671a8cba62e45c0a285e8b60a185 -size 59989 +oid sha256:9f59adc6f7d0c2ae5c5802b26230be22d01c0eb457ebeefafcc1db1cbde9ad0b +size 59590 diff --git a/Integration.uproject b/Integration.uproject deleted file mode 100644 index db8e5ff9..00000000 --- a/Integration.uproject +++ /dev/null @@ -1,26 +0,0 @@ -{ - "FileVersion": 3, - "EngineAssociation": "5.3", - "Category": "", - "Description": "", - "Modules": [ - { - "Name": "Integration", - "Type": "Runtime", - "LoadingPhase": "Default", - "AdditionalDependencies": [ - "Engine", - "CoreUObject" - ] - } - ], - "Plugins": [ - { - "Name": "ModelingToolsEditorMode", - "Enabled": true, - "TargetAllowList": [ - "Editor" - ] - } - ] -} \ No newline at end of file diff --git a/make-vscode.py b/make-vscode.py new file mode 100755 index 00000000..52f21795 --- /dev/null +++ b/make-vscode.py @@ -0,0 +1,149 @@ +#!/usr/bin/python3 +# +# This script generates these config files: +# +# Integration.uproject +# Integration.code-workspace +# +# Unreal needs "Integration.uproject". This config file tells +# UnrealBuildTool what version of the unreal engine to link this game +# with. It also specifies a couple of other game-specific configuration +# settings. It can't easily be checked into git because it contains +# a GUID which is specific to your local machine. +# +# VSCode needs "Integration.code-workspace," it tells vscode how to +# compile this game and how to run it under the debugger. It can't +# be checked into git because it contains many hardwired +# paths. +# +# We generate Integration.uproject from scratch. Later, the unreal +# editor will inject the engine GUID into the file. +# +# 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 a rough draft, +# then it loads Integration.code-workspace into RAM, edits it in RAM, +# and writes a new, improved version back out. +# + +import sys, os, json + +# +# These are some directory paths that we will need. +# + +INTEGRATION = os.path.dirname(os.path.abspath(sys.argv[0])) +UNREALENGINE = os.environ["HOME"] + "/UnrealEngine" + +# +# This is the template from which Integration.uproject is generated. +# + +UPROJECT_TEMPLATE=""" +{ + "FileVersion": 3, + "EngineAssociation": "5.3", + "Category": "", + "Description": "", + "Modules": [ + { + "Name": "Integration", + "Type": "Runtime", + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine", + "CoreUObject" + ] + } + ], + "Plugins": [ + { + "Name": "ModelingToolsEditorMode", + "Enabled": true, + "TargetAllowList": [ + "Editor" + ] + } + ] +} +""" + +# +# Convert the UPROJECT template into json in RAM. +# + +UPROJECT = json.loads(UPROJECT_TEMPLATE) + +# +# Write Integration.uproject +# + +with open("Integration.uproject", "w") as uproj: + json.dump(UPROJECT, uproj, indent=4) + +# +# Use UnrealBuildTool to generate a rough draft of Integration.code-workspace. +# + +BUILDPROJECTFILES = f'dotnet Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.dll -projectfiles -project="{INTEGRATION}/Integration.uproject" -game -vscode' +os.chdir(UNREALENGINE) +print(BUILDPROJECTFILES) +os.system(BUILDPROJECTFILES) + +# +# Load the rough draft into RAM, then delete the rough draft. +# + +os.chdir(INTEGRATION) +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)] + +# +# Convert all launch configurations to lldb. +# + +LLDBINIT=f"command script import {UNREALENGINE}/Engine/Extras/LLDBDataFormatters/UEDataFormatters_2ByteChars.py" + +for config in WORKSPACE["launch"]["configurations"]: + config["type"] = "lldb" + config["initCommands"] = [ LLDBINIT ] + 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 it all back out. +# + +with open("Integration.code-workspace", "w") as rewritten: + json.dump(WORKSPACE, rewritten, indent=4) +