xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
229 stars 54 forks source link

UpdateIntellisense 命令生成的 compile_commands 没有包含 rule:on_config add includedirs 信息 #125

Closed OuYangPaste closed 2 years ago

OuYangPaste commented 2 years ago

Xmake 版本

v2.6.9+HEAD.22ecc01

操作系统版本和架构

Linux: 5.15.24-amd64-desktop

描述问题

如题 而使用 xmake project -k compile_commands 命令则没有这个问题

期待的结果

UpdateIntellisense 也能正常处理 rule:on_config add includedirs 依赖

工程配置

No response

附加信息和错误日志

No response

waruqi commented 2 years ago

UpdateIntellisense 直接加载的 configs,按理你只要 build 过一遍工程,configs 已经被执行过了就行。。你试下先 build 下再 update

OuYangPaste commented 2 years ago

build 过了,补充一下这个问题的发现缘由,最开始我是直接描述域调用的 add_includedirs, 两种用法用了好久没出问题,直到今天我把其中一些常用操作重新封装了成 rule 之后,一用 UpdateIntellisense vscode 头文件就报错,用 xmake project -k compile_commands 又好了,然后来回粗略对比了下最后生成的 compile_commands,UpdateIntellisense 生成的确实缺少了 rule:on_config 里的 add includedirs 信息

OuYangPaste commented 2 years ago

稍微对比了两边的源码,发现 xmake-vscode/assets/update_intellisense.lua 加上 task.run("config") 就好了,如下图 image

waruqi commented 2 years ago

稍微对比了两边的源码,发现 xmake-vscode/assets/update_intellisense.lua 加上 task.run("config") 就好了,如下图

之前特定没加,想着项目本身就是要编译一遍的,编译的时候,config 原本就会执行一遍,没必要再去走一遍的,不应该没有。。

OuYangPaste commented 2 years ago

emmm 以我粗浅的理解来说,rule:on_config 似乎是比较灵活的不需要配置文件去另外进行记录? 所以即便编译一遍之后再 update intellisense,不重跑 configure 阶段的话也是无法获取到这一部分的信息?

waruqi commented 2 years ago

目前没加 task config 的另外一个原因是因为,现在 watch 了 .xmake 下的 xmake.conf 配置变动,然后执行的 update ,但是执行 task config 又会导致 xmake.conf 继续变动,会无限死循环,不停的 update 。。。

代码里也有相关说明,所以现在只能 load config

https://github.com/xmake-io/xmake-vscode/blob/ad72fc457f386803300ea37d9b0d02534232c0b0/assets/update_intellisense.lua#L9

OuYangPaste commented 2 years ago

目前没加 task config 的另外一个原因是因为,现在 watch 了 .xmake 下的 xmake.conf 配置变动,然后执行的 update ,但是执行 task config 又会导致 xmake.conf 继续变动,会无限死循环,不停的 update 。。。

哈,话说目前 vscode 插件会 自动 update 么,貌似我这边一直都是手动的... 按道理来说自动 update 的话,我执行 xmake project -k compile_commands 里面执行了 task config 然后更新了 xmake.conf 再然后就会去执行 update ...

waruqi commented 2 years ago

https://github.com/xmake-io/xmake-vscode/issues/40

一直都是自动更新的,xmake.lua 有改动就会 update

OuYangPaste commented 2 years ago

一直都是自动更新的,xmake.lua 有改动就会 update

我研究下我这边不自动 update 的问题

OuYangPaste commented 2 years ago

现在我改为使用 rule:on_load,测试过 update 生成的 compile_commands 没有问题了 自动 update 的功能我测试了下,vscode 里改动 xmake.lua 是会自动 update 的, 但是改动源文件和打开项目是不会自动 update 的,再加上平时我习惯了直接vscode 终端 vim 改 xmake.lua, 所以存在感有点弱

waruqi commented 2 years ago

vim 改 xmake.lua 只要文件有变动,还是会自动 update 的

OuYangPaste commented 2 years ago

vim 改 xmake.lua 只要文件有变动,还是会自动 update 的

噫,试了几遍 vim 改的没变,vscode 改有变

waruqi commented 2 years ago

那就怪了,监听的是文件改动,跟用哪个 editor 编辑应该无关的,除非没保存。

OuYangPaste commented 2 years ago

...不知道为什么 vscode 改完之后,vim 改的也会变了...

OuYangPaste commented 2 years ago

可能我 保存完之后 ls 得太快了还没更新过来有延迟