diff options
| author | ruki <[email protected]> | 2021-03-12 23:12:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-03-12 23:12:41 +0800 |
| commit | 364eec542b0b115f5631eb462de02af399ad0041 (patch) | |
| tree | fb52893caf561291ef907a0934c3630e2f77df81 | |
| parent | 2490f934e09fa3e7b5cee51a91ba8de20f957b76 (diff) | |
improve compile_commands generator
| -rw-r--r-- | xmake/plugins/project/clang/compile_commands.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index 9c25789d5..e4391a507 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -34,6 +34,7 @@ end -- https://github.com/xmake-io/xmake/issues/1050 function _translate_arguments(arguments) local args = {} + local is_msvc = path.basename(arguments[1]):lower() == "cl" for _, arg in ipairs(arguments) do if arg:find("-isystem", 1, true) then arg = arg:replace("-isystem", "-I") @@ -42,6 +43,11 @@ function _translate_arguments(arguments) elseif arg:find("[%-/]external:W") or arg:find("[%-/]experimental:external") then arg = nil end + -- @see use msvc-style flags for msvc to support language-server better + -- https://github.com/xmake-io/xmake/issues/1284 + if is_msvc and arg and arg:startswith("-") then + arg = arg:gsub("^%-", "/") + end if arg then table.insert(args, arg) end |
