Skip to content

Commit 68570d6

Browse files
committed
Refactor compiledb implementation
This comment enables the possibility to build the "compile_commands.json" file by only using `scons -Q compiledb`. No need to use the argument `compiledb=yes`. And when using the `compiledb=yes`, it will create a "compiled_commands.json" automatically.
1 parent 7a3cfe8 commit 68570d6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/godotcpp.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,8 @@ def generate(env):
274274
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
275275

276276
# compile_commands.json
277-
if env.get("compiledb", False):
278-
env.Tool("compilation_db")
279-
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
277+
env.Tool("compilation_db")
278+
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
280279

281280
# Builders
282281
env.Append(BUILDERS={"GodotCPPBindings": Builder(action=scons_generate_bindings, emitter=scons_emit_files)})
@@ -315,7 +314,13 @@ def _godot_cpp(env):
315314

316315
if env["build_library"]:
317316
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
318-
env.Default(library)
317+
default_args = [library]
318+
319+
# Add compiledb if the option is set
320+
if env.get("compiledb", False):
321+
default_args += [env.CompilationDatabase(normalize_path(env["compiledb_file"], env))]
322+
323+
env.Default(*default_args)
319324

320325
env.AppendUnique(LIBS=[env.File("bin/%s" % library_name)])
321326
return library

0 commit comments

Comments
 (0)