diff options
| author | star9029 <[email protected]> | 2023-07-29 23:51:27 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2023-07-29 23:51:27 +0800 |
| commit | 7070b3b0ad4b8cbc48acb014540d119eea774647 (patch) | |
| tree | 5c15fae9c78f453ed1eb363f8bdb94086b0c02c2 | |
| parent | 495ae60c63e442805f38b5c80e70e586d97600e5 (diff) | |
improve compile_commands
| -rw-r--r-- | xmake/plugins/project/clang/compile_commands.lua | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index e3521db5c..a5f298458 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -61,19 +61,20 @@ function _get_windows_sdk_arguments(target) if msvc then local envs = msvc:runenvs() local WindowsSdkDir = envs.WindowsSdkDir - - local includedirs = os.dirs(path.join(WindowsSdkDir, "Include", envs.WindowsSDKVersion, "*")) - - for _, tool in ipairs({"atlmfc", "diasdk"}) do - local tool_dir = path.join(WindowsSdkDir, tool, "include") - if os.isdir(tool_dir) then - table.insert(includedirs, tool_dir) + local WindowsSDKVersion = envs.WindowsSDKVersion + if WindowsSdkDir and WindowsSDKVersion then + local includedirs = os.dirs(path.join(WindowsSdkDir, "Include", envs.WindowsSDKVersion, "*")) + for _, tool in ipairs({"atlmfc", "diasdk"}) do + local tool_dir = path.join(WindowsSdkDir, tool, "include") + if os.isdir(tool_dir) then + table.insert(includedirs, tool_dir) + end end - end - for _, dir in ipairs(includedirs) do - table.insert(args, "-imsvc") - table.insert(args, dir) + for _, dir in ipairs(includedirs) do + table.insert(args, "-imsvc") + table.insert(args, dir) + end end end return args @@ -165,7 +166,7 @@ function _make_arguments(jsonfile, arguments, sourcefile, target) arguments = _translate_arguments(arguments) local lsp = _get_lsp() - if lsp and lsp == "clangd" and is_plat("windows") then + if lsp and lsp == "clangd" and target:is_plat("windows") then table.join2(arguments, _get_windows_sdk_arguments(target)) end |
