Skip to content

Commit

Permalink
add verilator support for compdb
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 22, 2025
1 parent 07b15c3 commit 1d3dfbf
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions xmake/plugins/project/clang/compile_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

-- imports
import("core.base.option")
import("core.base.hashset")
import("core.tool.compiler")
import("core.project.rule")
import("core.project.project")
Expand All @@ -41,8 +42,7 @@ function _sourcebatch_is_built(sourcebatch)
local rulename = sourcebatch.rulename
if rulename == "c.build" or rulename == "c++.build"
or rulename == "asm.build" or rulename == "cuda.build"
or rulename == "objc.build" or rulename == "objc++.build"
or rulename:startswith("verilator.") then
or rulename == "objc.build" or rulename == "objc++.build" then
return true
end
end
Expand Down Expand Up @@ -144,6 +144,16 @@ function _translate_arguments(arguments)
return args
end

-- Are there other supported source files, which come from custom rules?
function _is_other_sourcefile(sourcefile)
local extensions = _g._other_supported_exts
if extensions == nil then
extensions = hashset.from({".v", ".sv"})
_g._other_supported_exts = extensions
end
return extensions:has(path.extension(sourcefile))
end

-- make command
function _make_arguments(jsonfile, arguments, opt)

Expand All @@ -155,6 +165,10 @@ function _make_arguments(jsonfile, arguments, opt)
local sourcekind = try {function () return language.sourcekind_of(path.filename(arg)) end}
if sourcekind and os.isfile(arg) then
sourcefile = tostring(arg)
elseif _is_other_sourcefile(arg) and os.isfile(arg) then
sourcefile = tostring(arg)
end
if sourcefile then
break
end
end
Expand Down

0 comments on commit 1d3dfbf

Please sign in to comment.