Skip to content

Commit 6c5b6af

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 0db95a9 commit 6c5b6af

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
@@ -262,9 +262,8 @@ def generate(env):
262262
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
263263

264264
# compile_commands.json
265-
if env.get("compiledb", False):
266-
env.Tool("compilation_db")
267-
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
265+
env.Tool("compilation_db")
266+
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
268267

269268
# Builders
270269
env.Append(BUILDERS={"GodotCPPBindings": Builder(action=scons_generate_bindings, emitter=scons_emit_files)})
@@ -303,7 +302,13 @@ def _godot_cpp(env):
303302

304303
if env["build_library"]:
305304
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
306-
env.Default(library)
305+
default_args = [library]
306+
307+
# Add compiledb if the option is set
308+
if env.get("compiledb", False):
309+
default_args += [env.CompilationDatabase(normalize_path(env["compiledb_file"], env))]
310+
311+
env.Default(*default_args)
307312

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

0 commit comments

Comments
 (0)