Skip to content

Add compilation_db to scons build to create compile_commands.json for automatic LSP configuration #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")

Expand Down