diff options
author | Adam Scott <ascott.ca@gmail.com> | 2023-09-04 15:00:42 -0400 |
---|---|---|
committer | Adam Scott <ascott.ca@gmail.com> | 2023-10-19 10:51:31 -0400 |
commit | 2d5024ac8ec623b91308df6225028de30a9cf2d0 (patch) | |
tree | 1fb99df1cfd2a53e3706e4b68f7efbd0306442a6 | |
parent | 7a3cfe80896be657ed4e92d76234235291c9263d (diff) | |
download | redot-cpp-2d5024ac8ec623b91308df6225028de30a9cf2d0.tar.gz |
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.
-rw-r--r-- | tools/godotcpp.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/godotcpp.py b/tools/godotcpp.py index 6b44272..329fffc 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -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)}) @@ -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 += ["compiledb"] + + env.Default(*default_args) env.AppendUnique(LIBS=[env.File("bin/%s" % library_name)]) return library |