Skip to content

Commit 4cdbc3d

Browse files
committed
add verilator support for compdb
1 parent 07b15c3 commit 4cdbc3d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

xmake/plugins/project/clang/compile_commands.lua

+16-2
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")
@@ -41,12 +42,21 @@ function _sourcebatch_is_built(sourcebatch)
4142
local rulename = sourcebatch.rulename
4243
if rulename == "c.build" or rulename == "c++.build"
4344
or rulename == "asm.build" or rulename == "cuda.build"
44-
or rulename == "objc.build" or rulename == "objc++.build"
45-
or rulename:startswith("verilator.") then
45+
or rulename == "objc.build" or rulename == "objc++.build" then
4646
return true
4747
end
4848
end
4949

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+
5060
-- get LSP, clangd, ccls, ...
5161
function _get_lsp()
5262
local lsp = option.get("lsp")
@@ -155,6 +165,10 @@ function _make_arguments(jsonfile, arguments, opt)
155165
local sourcekind = try {function () return language.sourcekind_of(path.filename(arg)) end}
156166
if sourcekind and os.isfile(arg) then
157167
sourcefile = tostring(arg)
168+
elseif _is_other_sourcefile(arg) and os.isfile(arg) then
169+
sourcefile = tostring(arg)
170+
end
171+
if sourcefile then
158172
break
159173
end
160174
end

0 commit comments

Comments
 (0)