diff options
| author | ruki <[email protected]> | 2025-01-23 00:40:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-23 00:40:39 +0800 |
| commit | 4cdbc3d94ddbb3f0bb7d7633a8b5f1d5b3c37a2a (patch) | |
| tree | 220b120d045708211ff2d71c2d06e34acb780853 | |
| parent | 07b15c3f88552dbf268ed3dbc5de6100aa40544f (diff) | |
add verilator support for compdb
| -rw-r--r-- | xmake/plugins/project/clang/compile_commands.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index b0f888fdd..e0e92f17e 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -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") @@ -41,12 +42,21 @@ 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 +-- Is there other supported source file, 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 + -- get LSP, clangd, ccls, ... function _get_lsp() local lsp = option.get("lsp") @@ -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 |
