Skip to content

Commit 802c9bb

Browse files
authored
Merge pull request #5635 from xmake-io/compdb
support verilator for compdb
2 parents d60da40 + 4cdbc3d commit 802c9bb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

xmake/plugins/project/clang/compile_commands.lua

+15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
-- imports
2222
import("core.base.option")
23+
import("core.base.hashset")
2324
import("core.tool.compiler")
2425
import("core.project.rule")
2526
import("core.project.project")
@@ -46,6 +47,16 @@ function _sourcebatch_is_built(sourcebatch)
4647
end
4748
end
4849

50+
-- Is there other supported source file, which come from custom rules?
51+
function _is_other_sourcefile(sourcefile)
52+
local extensions = _g._other_supported_exts
53+
if extensions == nil then
54+
extensions = hashset.from({".v", ".sv"})
55+
_g._other_supported_exts = extensions
56+
end
57+
return extensions:has(path.extension(sourcefile))
58+
end
59+
4960
-- get LSP, clangd, ccls, ...
5061
function _get_lsp()
5162
local lsp = option.get("lsp")
@@ -154,6 +165,10 @@ function _make_arguments(jsonfile, arguments, opt)
154165
local sourcekind = try {function () return language.sourcekind_of(path.filename(arg)) end}
155166
if sourcekind and os.isfile(arg) then
156167
sourcefile = tostring(arg)
168+
elseif _is_other_sourcefile(arg) and os.isfile(arg) then
169+
sourcefile = tostring(arg)
170+
end
171+
if sourcefile then
157172
break
158173
end
159174
end

0 commit comments

Comments
 (0)