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.

(cherry picked from commit 2d5024ac8e)
pull/1281/head
Adam Scott 2023-09-04 15:00:42 -04:00 committed by David Snopek
parent 7704a9d054
commit 8295486fdb
1 changed files with 9 additions and 4 deletions

View File

@ -263,7 +263,6 @@ def generate(env):
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
# compile_commands.json
if env.get("compiledb", False):
env.Tool("compilation_db")
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
@ -304,7 +303,13 @@ def _godot_cpp(env):
if env["build_library"]:
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
env.Default(library)
default_args = [library]
# Add compiledb if the option is set
if env.get("compiledb", False):
default_args += ["compiledb"]
env.Default(*default_args)
env.AppendUnique(LIBS=[env.File("bin/%s" % library_name)])
return library