-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape whitespace and special characters in generated compile_commands.json #1726
Comments
我这里 mac下测试 ok,没啥问题 commands 是完整string ,所以有转义要求也是合理的,为了便于拆分解析,通常的命令执行都是如此 而 args 都拆分了,每一项都已经分开了,还要求空格转义,这本身就有点另类。。
|
目前看c/c++的flag vscode会处理,只有cuda的flag有问题, microsoft/vscode-cpptools#8091 |
vscode解析cuda时需要把这些参数传给nvcc,而nvcc不会处理这个问题;解析c++的时候内部就完成了,不需要传给外部程序,所以没问题。vscode对空格的处理还要等他们完成不同shell的不同escaping行为处理工作才行。在这之前xmake能否提供一个兼容模式,生成类似cmake的"command": ... 描述,而不是arguments?或者针对nvcc的flag特殊处理一下空格问题? |
按理来讲 arguments 应该比 commands 兼容性更好才对,避免了 xmake层额外的转义拼string,也省去了 vscode 那边的转义解析 这边改成 commands 改动量不少,短期内也可能引入其他问题 等搞稳定发版 说不定vscode那边都支持上nvcc空格了 这边可以对nvcc flag特殊处理,不过加了即使当前临时兼容了,后面vscode那边改进完了,那这边现有版本不是反而又不兼容了?还得同步改回来?如果这样的话 还不如直接等那边改进完就好 |
不会不兼容,现在cpp的-I flag也是同时兼容
改成
这样写无论LLVM和vscode那边怎么变化都不会影响的。这个问题主要影响的就是windows上cuda intellisense(因为cuda sdk默认安装位置含空格),做这样一个改动就没问题了 |
改了下,再试试 |
现在可以了 |
描述讨论详情
microsoft/vscode-cpptools#4781
https://clang.llvm.org/docs/JSONCompilationDatabase.html
LLVM对compile_commands.json的
"command": ...
作出了明确规定,也就是需要显示处理空格和特殊字符。但"arguments": [...]
没作特别说明,vscode认为要求和command是一样的,也就是需要escape这些特殊字符。现在xmake生成的compile_commands如果含有空格等,则不会进行转义,从而无法被vscode正确处理。例如xmake会生成这样的compile_commands但vscode要求这样(cmake采用这种形式)
或者这样
The text was updated successfully, but these errors were encountered: