Closed MaxwellGengYF closed 7 months ago
Bot detected the issue body's language is not English, translate it automatically.
Title: plugin.compile_commands.autoupdate does not carry precompiled header information
Bot detected the issue body's language is not English, translate it automatically.
At present, it is found that the vscode plug-in behaves normally when it directly calls compile_commands.lua, but the independent startup process behaves abnormally.
经过逆向,看起来是 XMAKE_GENERATOR_COMPDB_LSP 这个环境变量的问题,模仿vscode插件内写法: os.setenv("XMAKE_GENERATOR_COMPDB_LSP", "clangd") config.load() _config_targets() compile_commands.make(compileCommandsDirectory or ".vscode") 就会正确输出pch结果
Bot detected the issue body's language is not English, translate it automatically.
After reverse engineering, it seems that the problem is the XMAKE_GENERATOR_COMPDB_LSP environment variable, which imitates the writing method in the vscode plug-in: os.setenv("XMAKE_GENERATOR_COMPDB_LSP", "clangd") config.load() _config_targets() compile_commands.make(compileCommandsDirectory or ".vscode") The pch result will be output correctly.
配置下 lsp 到 clangd 就行了,因为目前已知的,就 clangd 支持 pch,其他的暂时没测试验证过,所以暂时禁用了 pch
add_rules("plugin.compile_commands.autoupdate", { lsp = "clangd", outputdir = ".vscode" })
Bot detected the issue body's language is not English, translate it automatically.
Just configure lsp to clangd, because as far as is known, only clangd supports pch, and the others have not been tested and verified, so pch is temporarily disabled.
add_rules("plugin.compile_commands.autoupdate", { lsp = "clangd", outputdir = ".vscode" })
Xmake Version
2.8.7
Operating System Version and Architecture
Any OS
Describe Bug
项目中使用 add_rules("plugin.compile_commands.autoupdate", { outputdir = ".vscode" }) 编译后生成的compile_commands.json不会正确打印预编译header信息。
Expected Behavior
应在arguments中正确输出 "-Yupch.h", "-FIpch.h"等
Project Configuration
set_xmakever("2.8.7") add_rules("plugin.compile_commands.autoupdate", { outputdir = ".vscode" })
Additional Information and Error Logs
compile_commands.json updated!