From d888252af4e9c4726029f230b55d3df3dd068ea3 Mon Sep 17 00:00:00 2001 From: keks137 Date: Tue, 17 Jun 2025 19:45:09 +0200 Subject: [PATCH] Add compilation_db to scons build to create compile_commands.json for automatic LSP configuration --- SConstruct | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SConstruct b/SConstruct index 1d599d0d..50470408 100644 --- a/SConstruct +++ b/SConstruct @@ -10,6 +10,12 @@ projectdir = "demo" localEnv = Environment(tools=["default"], PLATFORM="") +# Add compilation_db tool early to capture all build commands +try: + localEnv.Tool("compilation_db") # <--- ADD THIS EARLY TOOL LOAD +except: + print("Note: compilation_db tool not available (SCons 4.0+ required)") + # Build profiles can be used to decrease compile times. # You can either specify "disabled_classes", OR # explicitly specify "enabled_classes" which disables all other classes. @@ -37,6 +43,11 @@ Run the following command to download godot-cpp: env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs}) +# Generate compile_commands.json after setting up build targets +if "compilation_db" in localEnv["TOOLS"]: # <--- ADD COMPILATION DB TARGET + db = env.CompilationDatabase("compile_commands.json") + Default(db) # Ensure it's built by default + env.Append(CPPPATH=["src/"]) sources = Glob("src/*.cpp")