mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[build] Update compile_commands.json when building
The compile_commands.json database is used by clangd to understand the compilation settings of the project. Keep this up to date by making ninja update it as part of the build, and have it depend on all build and module files.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ sysroot
|
||||
.peru
|
||||
__pycache__
|
||||
/venv
|
||||
compile_commands.json
|
||||
|
||||
@@ -76,3 +76,6 @@ rule strip
|
||||
|
||||
rule touch
|
||||
command = touch $out
|
||||
|
||||
rule compdb
|
||||
command = ninja -t compdb > $out
|
||||
|
||||
@@ -141,7 +141,7 @@ class Module:
|
||||
|
||||
inputs = []
|
||||
parse_deps = []
|
||||
parse_dep = "${module_dir}/.parse_dep.phony"
|
||||
parse_depfile = "${module_dir}/.parse_dep.phony"
|
||||
|
||||
for start in self.sources:
|
||||
source = start
|
||||
@@ -150,7 +150,7 @@ class Module:
|
||||
output = source.output
|
||||
|
||||
if source.action.parse_deps:
|
||||
oodeps = [parse_dep]
|
||||
oodeps = [parse_depfile]
|
||||
else:
|
||||
oodeps = []
|
||||
|
||||
@@ -177,7 +177,7 @@ class Module:
|
||||
build.newline()
|
||||
build.build(
|
||||
rule = "touch",
|
||||
outputs = [parse_dep],
|
||||
outputs = [parse_depfile],
|
||||
implicit = child_deps,
|
||||
order_only = parse_deps,
|
||||
)
|
||||
|
||||
@@ -142,6 +142,8 @@ class Project:
|
||||
build.default([out])
|
||||
build.newline()
|
||||
|
||||
compdb = "${source_root}/compile_commands.json"
|
||||
|
||||
build.rule("regen",
|
||||
command = " ".join([str(root / 'configure')] + sys.argv[1:]),
|
||||
description = "Regenerate build files",
|
||||
@@ -156,6 +158,14 @@ class Project:
|
||||
for target in targets:
|
||||
regen_implicits += target.depfiles
|
||||
|
||||
build.build(
|
||||
rule = "compdb",
|
||||
outputs = [compdb],
|
||||
implicit = regen_implicits,
|
||||
)
|
||||
build.default([compdb])
|
||||
build.newline()
|
||||
|
||||
build.build(
|
||||
rule = "regen",
|
||||
outputs = ['build.ninja'],
|
||||
|
||||
Reference in New Issue
Block a user