Skip to content

Commit 129b494

Browse files
Ivorforcemaiself
authored andcommitted
Add a way to create compile_commands.json, lifted from godot-cpp.
1 parent 00c1088 commit 129b494

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
gdextension_interface.h
99
extension_api.json
1010

11+
# Build tools
1112
/docs/*build/
12-
13-
13+
compile_commands.json

SConstruct

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,23 @@ opts.Add(
121121
)
122122

123123

124+
opts.Add(
125+
BoolVariable(
126+
key="compiledb",
127+
help="Generate compilation DB (`compile_commands.json`) for external tools",
128+
default=env.get("compiledb", False),
129+
)
130+
)
131+
132+
opts.Add(
133+
PathVariable(
134+
key="compiledb_file",
135+
help="Path to a custom `compile_commands.json` file",
136+
default=env.get("compiledb_file", "compile_commands.json"),
137+
validator=build_utils.validate_parent_dir,
138+
)
139+
)
140+
124141
# for now there's no distinction between build targets, so always use template_release
125142
env['target'] = 'template_release'
126143

@@ -267,6 +284,9 @@ env.Alias("archive_importer_r_string", [
267284
)
268285
])
269286

287+
env.Tool("compilation_db")
288+
env.Alias("compiledb", env.CompilationDatabase(build_utils.normalize_path(env["compiledb_file"], env)))
289+
270290
if not env.get('skip_module_embed', False):
271291
# pkg_files = Install('src', files)
272292
godot_zip = Zip(

0 commit comments

Comments
 (0)