delete: .vscode/
远程库不需要这个本地可以生成的文件夹
This commit is contained in:
1 parent
29699728ff
commit
884cd5a290
3 files changed
-166
No files matched your search
Vendored
-93
@@ -1,93 +0,0 @@
|
||||
# .vscode/
|
||||
|
||||
VS Code 的工作区配置(只影响编辑器体验,**删掉不影响仿真运行**)。
|
||||
|
||||
| 文件 | 说明 |
|
||||
|---|---|
|
||||
| `settings.json` | clangd 设成唯一的 C++ 智能感知引擎;`xacro/urdf/sdf` 关联成 XML |
|
||||
| `c_cpp_properties.json` | cpptools 的兜底配置(当前被禁用,留着备用) |
|
||||
|
||||
> 注意:这里**没有** `cmake.sourceDirectory`。本工程不使用 CMake / colcon,
|
||||
> 那行配置已随迁移删除;如果 CMake Tools 插件又把它写回来,可以忽略。
|
||||
|
||||
## C++ 智能感知怎么工作
|
||||
|
||||
用 **clangd**,它读工作区根的 `compile_commands.json`(真实编译命令),
|
||||
所以 include 路径、宏定义、C++ 标准全部**自动**跟构建保持一致,不用手写。
|
||||
|
||||
```
|
||||
xmake(仓库根)
|
||||
↓ plugin.compile_commands.autoupdate 规则自动触发
|
||||
compile_commands.json(工作区根,每次构建后重写)
|
||||
↓
|
||||
clangd 读取
|
||||
```
|
||||
|
||||
**没有手工生成步骤** —— 以前那个 `tools/gen_compdb.sh`(合并 colcon 的分包产物)
|
||||
已经随去 colcon 一起删掉了。
|
||||
|
||||
## ⚠️ 最常踩的坑:报「xxx.hpp file not found」
|
||||
|
||||
**现象**:
|
||||
|
||||
```
|
||||
'sentry_nav/waypoint_sequencer.hpp' file not found
|
||||
Too many errors emitted, stopping now [-ferror-limit=]
|
||||
```
|
||||
|
||||
**原因**:`compile_commands.json` 是**旧的**。clangd 只读它,不会自己去看 `xmake.lua`。
|
||||
只要做过下面任何一件事,这个文件就过期了:
|
||||
|
||||
- 新增 / 重命名 / 删除 `.cpp`
|
||||
- 改 `xmake.lua` 的 `add_files` / `add_includedirs` / `set_languages`
|
||||
- 新增 `#include` 指向一个新的目录
|
||||
- 换 C++ 标准
|
||||
|
||||
**修复**(两步,缺一不可):
|
||||
|
||||
```bash
|
||||
cd ~/Gazebo_projects/sentry_nav_dev
|
||||
xmake # 构建 + 自动重写根 compile_commands.json
|
||||
```
|
||||
|
||||
然后在 VS Code 里:
|
||||
|
||||
```
|
||||
Ctrl+Shift+P → clangd: Restart language server
|
||||
```
|
||||
|
||||
> 只 `clangd: Restart` 不跑 `xmake` 是**不够的** —— 文件本身没变,clangd 读到的还是旧路径。
|
||||
|
||||
## 验证 compdb 是否正确
|
||||
|
||||
```bash
|
||||
# 看根 compdb 里有哪些编译单元(应该是 6 个:2 节点 + 2 核心 + 2 测试)
|
||||
python3 -c "
|
||||
import json
|
||||
for e in json.load(open('compile_commands.json')):
|
||||
print(e['file'].split('sentry_nav_dev/')[-1])
|
||||
"
|
||||
|
||||
# 更彻底:直接用 clangd 解析一遍(应该输出 All checks completed, 0 errors)
|
||||
clangd --check=src/sentry_nav/src/patrol.cpp --compile-commands-dir=.
|
||||
```
|
||||
|
||||
## 兜底配置(`clangd.fallbackFlags`)
|
||||
|
||||
只在你**单独打开一个头文件**、而它不在任何编译单元里时才生效:
|
||||
|
||||
```json
|
||||
"-std=c++23",
|
||||
"-I/opt/ros/lyrical/include",
|
||||
"-I${workspaceFolder}/src/sentry_nav/include"
|
||||
```
|
||||
|
||||
## 真正的构建仍然用命令行
|
||||
|
||||
```bash
|
||||
cd ~/Gazebo_projects/sentry_nav_dev
|
||||
xmake # 编译
|
||||
xmake test # 单元测试
|
||||
```
|
||||
|
||||
> `sentry_sim` 里没有 C/C++ 源码,编辑器对它只剩 SDF/XML 高亮,不涉及编译。
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"version": 4,
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ROS 2 Lyrical",
|
||||
"compileCommands": "${workspaceFolder}/compile_commands.json",
|
||||
// 首选 compileCommands(真实编译命令),下面 includePath 是它缺失时的兜底。
|
||||
"includePath": [
|
||||
// 本包头文件(sentry_nav/xxx.hpp)——含纯算法核心
|
||||
"${workspaceFolder}/src/sentry_nav/include",
|
||||
"${workspaceFolder}/src/**",
|
||||
"/opt/ros/lyrical/include/**",
|
||||
"/usr/include/pcl-1.15/**",
|
||||
"/usr/include/eigen3/**",
|
||||
"/usr/include/**"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++23",
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
-51
@@ -1,51 +0,0 @@
|
||||
{
|
||||
// ---- C++ 智能感知 ----
|
||||
// 用 clangd 当唯一引擎:它直接读工作区根的 compile_commands.json,
|
||||
// include 路径/宏定义全部来自真实编译命令,不会再漏 ROS 头文件或本工程的头文件。
|
||||
//
|
||||
// 这份 compile_commands.json 由 xmake 在**每次构建后自动重写**
|
||||
// (根 xmake.lua 里的 plugin.compile_commands.autoupdate 规则),
|
||||
// 不需要任何手工生成步骤。
|
||||
//
|
||||
// 改了源码结构、但编辑器还在报 "xxx.hpp file not found" 时,
|
||||
// 跑一次 `xmake` 让它刷新,然后在 VS Code 里
|
||||
// Ctrl+Shift+P → "clangd: Restart language server"。
|
||||
"C_Cpp.intelliSenseEngine": "disabled",
|
||||
// 不丢 --clang-tidy,避免 ROS 头文件里一堆代码风格告警糊满屏幕。
|
||||
"clangd.arguments": [
|
||||
"--background-index",
|
||||
"--completion-style=detailed",
|
||||
"--header-insertion=never"
|
||||
],
|
||||
// 单独打开头文件、又不在编译数据库里时的兜底参数。
|
||||
// 标准跟着工程走(C++23),并加上本工程的纯算法库头文件目录。
|
||||
"clangd.fallbackFlags": [
|
||||
"-std=c++23",
|
||||
"-I/opt/ros/lyrical/include",
|
||||
"-I${workspaceFolder}/src/sentry_nav/include"
|
||||
],
|
||||
|
||||
"files.associations": {
|
||||
"*.xacro": "xml",
|
||||
"*.urdf": "xml",
|
||||
"*.sdf": "xml"
|
||||
},
|
||||
|
||||
// 编辑 SDF 时别被 XML 校验器报错(Gazebo 的 SDF 有自己的 schema,VS Code 不认识)
|
||||
"xml.validation.enabled": false,
|
||||
"ROS2.distro": "jazzy",
|
||||
"python.autoComplete.extraPaths": [
|
||||
"/opt/ros/jazzy/opt/gz_sim_vendor/lib/python",
|
||||
"/opt/ros/jazzy/opt/sdformat_vendor/lib/python",
|
||||
"/opt/ros/jazzy/opt/gz_transport_vendor/lib/python",
|
||||
"/opt/ros/jazzy/opt/gz_msgs_vendor/lib/python",
|
||||
"/opt/ros/jazzy/lib/python3.12/site-packages"
|
||||
],
|
||||
"python.analysis.extraPaths": [
|
||||
"/opt/ros/jazzy/opt/gz_sim_vendor/lib/python",
|
||||
"/opt/ros/jazzy/opt/sdformat_vendor/lib/python",
|
||||
"/opt/ros/jazzy/opt/gz_transport_vendor/lib/python",
|
||||
"/opt/ros/jazzy/opt/gz_msgs_vendor/lib/python",
|
||||
"/opt/ros/jazzy/lib/python3.12/site-packages"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user