Set up clangd for intellisense. Whoof, that was difficult.

This commit is contained in:
2025-06-09 15:38:14 -04:00
parent 61209d4c2f
commit 4a2574ddab
5 changed files with 58 additions and 15 deletions

8
.clangd Normal file
View File

@@ -0,0 +1,8 @@
InlayHints:
Enabled: Yes
DeducedTypes: Yes
ParameterNames: Yes
Designators: Yes

View File

@@ -36,10 +36,18 @@
"**/x86_64-linux-gnu/**": "cpp",
"*.ipp": "cpp",
"*.inc": "cpp"
}
},
"C_Cpp.intelliSenseEngine": "disabled",
"clangd.path": "/usr/bin/clangd-15",
"clangd.arguments": [
"--compile-commands-dir=[INTEGRATION]/.vscode",
"--header-insertion=never"
],
"C_Cpp.autocomplete": "Disabled"
},
"extensions": {
"recommendations": [
"llvm-vs-code-extensions.vscode-clangd",
"vadimcn.vscode-lldb",
"dfarley1.file-picker",
"ms-python.python",
@@ -73,6 +81,16 @@
},
"problemMatcher": "$msCompile",
"type": "shell"
},
{
"label": "Make Intellisense",
"group": "build",
"command": "make intellisense",
"presentation": {
"clear": true
},
"problemMatcher": "$msCompile",
"type": "shell"
}
]
},
@@ -103,4 +121,4 @@
}
}
}
}
}

View File

@@ -2,11 +2,26 @@
#
# Do not edit Makefile, instead, edit Makefile.tpl.txt
#
# It is not usually necessary to rebuild the intellisense database
# unless you've added a source file.
#
all:
(cd luprex ; make all)
[UNREALENGINE]/Engine/Build/BatchFiles/[BUILD_BAT] IntegrationEditor [OS] DebugGame [INTEGRATION]/Integration.uproject -waitmutex
[UNREALENGINE]/Engine/Build/BatchFiles/[BUILD_BAT] -waitmutex IntegrationEditor [OS] DebugGame [INTEGRATION]/Integration.uproject
clean:
(cd luprex ; make clean)
[UNREALENGINE]/Engine/Build/BatchFiles/[BUILD_BAT] IntegrationEditor [OS] DebugGame [INTEGRATION]/Integration.uproject -waitmutex -clean
[UNREALENGINE]/Engine/Build/BatchFiles/[BUILD_BAT] -waitmutex IntegrationEditor [OS] DebugGame [INTEGRATION]/Integration.uproject -clean
rm -f .vscode/compile_commands.json
intellisense: all
(cd [INTEGRATION] ; find Intermediate -type f -name '*.rsp' -print0 | tar --null -czf rsp_files.tgz --files-from=-)
(cd [UNREALENGINE] ; find Engine -type f -name '*.rsp' -print0 | tar --null -czf rsp_files.tgz --files-from=-)
[UNREALENGINE]/Engine/Build/BatchFiles/[BUILD_BAT] -waitmutex UnrealEditor [OS] DebugGame -mode=GenerateClangDatabase -OutputDir=[UNREALENGINE]/.vscode
[UNREALENGINE]/Engine/Build/BatchFiles/[BUILD_BAT] -waitmutex IntegrationEditor [OS] DebugGame [INTEGRATION]/Integration.uproject -mode=GenerateClangDatabase -OutputDir=[UNREALENGINE]/.vscode
cat [UNREALENGINE]/.vscode/compile_commands.json >> [INTEGRATION]/.vscode/compile_commands.json
(cd [INTEGRATION] ; tar xfz rsp_files.tgz)
(cd [UNREALENGINE] ; tar xfz rsp_files.tgz)
rm -f [INTEGRATION]/rsp_files.tgz [UNREALENGINE]/rsp_files.tgz

View File

@@ -9,6 +9,8 @@ Install important Software
- install git-lfs support. Usually: apt-get install git-lfs
- install visual studio code. Usually: apt-get install code
- install dotnet6. Usually: apt-get install dotnet6
- install clangd-15. Usually: apt-get install clangd-15
- install jq. On Linux, this is usually already installed.
- install python3. On Linux, this is usually already installed.
Git Clone the UnrealEngine repository:
@@ -25,11 +27,6 @@ Git Clone the integration Repository
Apply patches and build everything:
- Change directory to $HOME/integration
- python3 build-everything.py
-
- Note: build-everything is mainly intended for the *initial* build.
- If you want to edit the code and recompile, it is okay to use
- build-everything.py a second time, but it's unnecessarily slow.
- It's much faster to edit and recompile using visual studio code.
Launch Integration in the Debugger
- Change directory to $HOME/integration

View File

@@ -58,6 +58,7 @@ else:
CONFIG["INTEGRATION"] = os.path.dirname(os.path.abspath(sys.argv[0]))
CONFIG["UNREALENGINE"] = os.path.join(os.path.dirname(CONFIG["INTEGRATION"]), "UnrealEngine")
CONFIG["UE_BUILD_BAT"] = CONFIG["UNREALENGINE"] + "/Engine/Build/BatchFiles/" + CONFIG["BUILD_BAT"] + " -waitmutex"
globals().update(CONFIG)
@@ -72,9 +73,7 @@ if not os.path.isdir(f"{UNREALENGINE}/Engine/Source/Editor"):
#
# This is the code for a simple json preprocessor that can
# expand "for-each" loops and substitute variables. Because
# a single string is valid json, you can also use this to
# substitute variables in a string or a text file.
# expand "for-each" loops and substitute variables.
#
JSON_VAR_REGEX = re.compile(r'\[([A-Z0-9_]+)\]')
@@ -105,6 +104,11 @@ def expand_json_file(sourcefile, outputfile):
expanded = expand_json(data, CONFIG)
Path(outputfile).write_text(json.dumps(expanded, indent=4))
#
# Because a single string is valid json, we can also use the json
# expander to substitute variables in plain old text files.
#
def expand_text_file(sourcefile, outputfile):
Path(outputfile).unlink(missing_ok=True)
data = Path(sourcefile).read_text()
@@ -207,13 +211,14 @@ expand_json_file(f"{INTEGRATION}/Integration.code-workspace.tpl.json",
expand_text_file(f"{INTEGRATION}/Makefile.tpl.txt",
f"{INTEGRATION}/Makefile")
#
# Build ShaderCompileWorker
#
print("Building ShaderCompileWorker...")
shell(UNREALENGINE, f"{UNREALENGINE}/Engine/Build/BatchFiles/{BUILD_BAT} ShaderCompileWorker {OS} Shipping -waitmutex")
shell(UNREALENGINE, f"{UNREALENGINE}/Engine/Build/BatchFiles/{BUILD_BAT} -waitmutex ShaderCompileWorker {OS} Shipping")
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}")
@@ -221,5 +226,5 @@ shutil.copyfile(f"{UNREALENGINE}/Engine/Binaries/{OS}/ShaderCompileWorker-{OS}-S
# Run Make
#
shell(INTEGRATION, 'make')
shell(INTEGRATION, 'make intellisense')