Skip to content

Commit

Permalink
Refactor compiledb implementation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adamscott committed Oct 19, 2023
1 parent 7a3cfe8 commit 68570d6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/godotcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,8 @@ 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)))
env.Tool("compilation_db")
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))

# Builders
env.Append(BUILDERS={"GodotCPPBindings": Builder(action=scons_generate_bindings, emitter=scons_emit_files)})
Expand Down Expand Up @@ -315,7 +314,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 += [env.CompilationDatabase(normalize_path(env["compiledb_file"], env))]

env.Default(*default_args)

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

0 comments on commit 68570d6

Please sign in to comment.