Can now launch two versions of the client, for standalone and client
This commit is contained in:
@@ -60,6 +60,69 @@ def shell(dir, cmd):
|
||||
print("Running:", cmd)
|
||||
subprocess.run(cmd, shell=True, check=True, cwd=dir)
|
||||
|
||||
#
|
||||
# This is the code for a simple json macro preprocessor.
|
||||
# It is used to write json files containing macros, which can
|
||||
# then be macroexpanded later in the json file. The json
|
||||
# file should have a 'macros' section at the top level.
|
||||
#
|
||||
|
||||
def replace_strings_recursively(template, variables):
|
||||
if isinstance(template, str):
|
||||
# Then apply macro-local substitutions
|
||||
for key, value in variables.items():
|
||||
template = template.replace(key, str(value))
|
||||
return template
|
||||
elif isinstance(template, list):
|
||||
return [replace_strings_recursively(item, variables) for item in template]
|
||||
elif isinstance(template, dict):
|
||||
return {k: replace_strings_recursively(v, variables) for k, v in template.items()}
|
||||
else:
|
||||
return template
|
||||
|
||||
|
||||
def macroexpand_json_recursively(data, macros):
|
||||
if isinstance(data, dict):
|
||||
if "macro" in data and "vars" in data:
|
||||
macro_name = data["macro"]
|
||||
variables = data["vars"]
|
||||
base_macro = macros[macro_name]
|
||||
expanded = replace_strings_recursively(base_macro, variables)
|
||||
return macroexpand_json_recursively(expanded, macros)
|
||||
else:
|
||||
return {
|
||||
key: macroexpand_json_recursively(value, macros)
|
||||
for key, value in data.items()
|
||||
}
|
||||
elif isinstance(data, list):
|
||||
return [macroexpand_json_recursively(item, macros) for item in data]
|
||||
else:
|
||||
return data
|
||||
|
||||
|
||||
def macroexpand_json(source_filename, output_filename, globals):
|
||||
"""
|
||||
Load JSON from `source_filename`, perform macro expansion using any
|
||||
macros defined in the "macros" block, and write the expanded JSON to
|
||||
`output_filename`. Global variables are passed as a Python dict.
|
||||
"""
|
||||
# Load the input template
|
||||
with open(source_filename, "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Extract and remove macros
|
||||
macros = data.pop("macros", {})
|
||||
|
||||
# Expand macros
|
||||
expanded = macroexpand_json_recursively(data, macros)
|
||||
|
||||
# Expand global variables
|
||||
expanded2 = replace_strings_recursively(expanded, globals)
|
||||
|
||||
# Write output
|
||||
with open(output_filename, "w") as f:
|
||||
json.dump(expanded2, f, indent=4)
|
||||
|
||||
#
|
||||
# Find the two repositories and verify them.
|
||||
#
|
||||
@@ -72,6 +135,12 @@ if not os.path.isdir(f"{INTEGRATION}/Source/Integration"):
|
||||
if not os.path.isdir(f"{UNREALENGINE}/Engine/Source/Editor"):
|
||||
sys.exit(f"Integration repository is not valid: {UNREALENGINE}")
|
||||
|
||||
JSONGLOBALS= {
|
||||
"INTEGRATION": INTEGRATION,
|
||||
"UNREALENGINE": UNREALENGINE,
|
||||
"USERNAME": USER,
|
||||
}
|
||||
|
||||
#
|
||||
# Create the Saved/UnrealBuildTool directories. These will hold
|
||||
# the file BuildConfiguration.xml
|
||||
@@ -118,19 +187,21 @@ writefile(f"{INTEGRATION}/Source/Integration/lpx-paths.hpp", f"""
|
||||
#
|
||||
|
||||
print("Applying patch to Unreal Engine...")
|
||||
PATCHED_FILES = []
|
||||
for line in readfile(f"{INTEGRATION}/EnginePatches/EnginePatch").splitlines():
|
||||
if line.startswith("--- a/"):
|
||||
shell(UNREALENGINE, f"git checkout HEAD {line[6:]}")
|
||||
PATCHED_FILES.append(line[6:])
|
||||
if PATCHED_FILES:
|
||||
shell(UNREALENGINE, "git checkout HEAD -- " + " ".join(PATCHED_FILES))
|
||||
shell(UNREALENGINE, f"git apply {INTEGRATION}/EnginePatches/EnginePatch")
|
||||
|
||||
#
|
||||
# Write Integration.uproject.
|
||||
#
|
||||
|
||||
UPROJECTTEMPLATE=readfile(f"{INTEGRATION}/EnginePatches/uproject")
|
||||
UPROJECT=json.loads(UPROJECTTEMPLATE)
|
||||
with open(f"{INTEGRATION}/Integration.uproject", "w") as rewritten:
|
||||
json.dump(UPROJECT, rewritten, indent=4)
|
||||
macroexpand_json(f"{INTEGRATION}/Integration.uproject.tpl.json",
|
||||
f"{INTEGRATION}/Integration.uproject",
|
||||
JSONGLOBALS)
|
||||
|
||||
#
|
||||
# Run Setup.sh in UNREALENGINE
|
||||
@@ -138,17 +209,6 @@ with open(f"{INTEGRATION}/Integration.uproject", "w") as rewritten:
|
||||
|
||||
shell(UNREALENGINE, f"{UNREALENGINE}/Setup.{BAT}")
|
||||
|
||||
#
|
||||
# Use UnrealBuildTool to generate a rough draft of Integration.code-workspace.
|
||||
# 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.
|
||||
#
|
||||
|
||||
Path(f"{INTEGRATION}/Integration.code-workspace").unlink(missing_ok=True)
|
||||
Path(f"{INTEGRATION}/Integration.code-workspace.old").unlink(missing_ok=True)
|
||||
shell(INTEGRATION, f'{UNREALENGINE}/GenerateProjectFiles.{BAT} -projectfiles -project="{INTEGRATION}/Integration.uproject" -game')
|
||||
Path(f"{INTEGRATION}/Integration.code-workspace").rename(f"{INTEGRATION}/Integration.code-workspace.old")
|
||||
|
||||
#
|
||||
# Create a trivial makefile that calls into the unreal build system.
|
||||
#
|
||||
@@ -166,135 +226,24 @@ clean:
|
||||
""")
|
||||
|
||||
#
|
||||
# Build our own Integration.code-workspace from scratch.
|
||||
# Use UnrealBuildTool to generate Integration.code-workspace.ubt
|
||||
#
|
||||
# We're not going to use it, but we keep it as a reference that you can
|
||||
# use when editing Integration.workspace-template.
|
||||
#
|
||||
|
||||
WORKSPACE={}
|
||||
|
||||
WORKSPACE["folders"] = []
|
||||
WORKSPACE["folders"].append({ "name": "Integration", "path": "." })
|
||||
WORKSPACE["folders"].append({ "name": "UE5", "path": UNREALENGINE })
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
WORKSPACE["extensions"] = {}
|
||||
WORKSPACE["extensions"]["recommendations"] = [
|
||||
"vadimcn.vscode-lldb",
|
||||
"dfarley1.file-picker",
|
||||
"ms-python.python",
|
||||
"ms-vscode.cpptools",
|
||||
"ms-dotnettools.csharp",
|
||||
"ms-vscode.mono-debug"
|
||||
]
|
||||
|
||||
|
||||
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()\""
|
||||
]
|
||||
})
|
||||
|
||||
Path(f"{INTEGRATION}/Integration.code-workspace").unlink(missing_ok=True)
|
||||
Path(f"{INTEGRATION}/Integration.code-workspace.ubt").unlink(missing_ok=True)
|
||||
shell(INTEGRATION, f'{UNREALENGINE}/GenerateProjectFiles.{BAT} -projectfiles -project="{INTEGRATION}/Integration.uproject" -game')
|
||||
Path(f"{INTEGRATION}/Integration.code-workspace").rename(f"{INTEGRATION}/Integration.code-workspace.ubt")
|
||||
|
||||
#
|
||||
# Write Integration.code-workspace.
|
||||
# Build Integration.code-workspace from Integration.workspace-template.
|
||||
#
|
||||
|
||||
with open(f"{INTEGRATION}/Integration.code-workspace", "w") as rewritten:
|
||||
json.dump(WORKSPACE, rewritten, indent=4)
|
||||
macroexpand_json(f"{INTEGRATION}/Integration.code-workspace.tpl.json",
|
||||
f"{INTEGRATION}/Integration.code-workspace",
|
||||
JSONGLOBALS)
|
||||
|
||||
#
|
||||
# Do an initial build of Luprex
|
||||
|
||||
Reference in New Issue
Block a user