Shell脚本更新CMakelists.txt, 注释/反注释 #ros2相关的内容

 1.背景:

Qt Creator ROS2 没有提供官方集成(2024-10-12),用 Github 开源插件 ros_qtc_plugin(参见我的另一篇博客 Ubuntu22 Qt6.6 ROS 插件, 使 Qt Creator 可编译ROS工程)。由于Qt 版本变化,插件突然失效,Qt 无法打开我的 ROS2 工程。没时间调研,暂时采取注释掉 CMakeLists 文件中ROS2 相关内容,Qt Creator 仅用来编辑 Qt UI 页面,命令行编译方式workaround。

Shell 脚本功能:修改CMakelists.txt,注释/取消注释 #ros2 start#ros2 end 之间的内容(不包括这两行,以及其他注释)

2. sed 命令解释

# 使用sed取消注释ROS相关内容
sed -i '/#ros2 start/,/#ros2 end/{/^#ros2 start/!{/^#ros2 end/!s/^/#/}}' "$file" && \
echo "ROS content uncommented in $file"

这里的sed命令使用了以下参数:

  • -i:直接对文件进行编辑(in-place),不输出到标准输出。
  • /#ros2 start/,/#ros2 end/:指定了一个范围,从包含#ros2 start的行开始,到包含#ros2 end的行结束。
  • {...}:对范围内的行执行多个命令。</
/bin/bash: /home/amov/anaconda3/lib/libtinfo.so.6: no version information available (required by /bin/bash) Working Path: /home/amov/ws_livox/src/livox_ros_driver2 ROS version is: ROS1 Base path: /home/amov/ws_livox Source space: /home/amov/ws_livox/src Build space: /home/amov/ws_livox/build Devel space: /home/amov/ws_livox/devel Install space: /home/amov/ws_livox/install Creating symlink "/home/amov/ws_livox/src/CMakeLists.txt" pointing to "/opt/ros/noetic/share/catkin/cmake/toplevel.cmake" #### #### Running command: "cmake /home/amov/ws_livox/src -DROS_EDITION=ROS1 -DCATKIN_DEVEL_PREFIX=/home/amov/ws_livox/devel -DCMAKE_INSTALL_PREFIX=/home/amov/ws_livox/install -G Unix Makefiles" in "/home/amov/ws_livox/build" #### cmake: /home/amov/anaconda3/lib/libcurl.so.4: no version information available (required by cmake) -- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using CATKIN_DEVEL_PREFIX: /home/amov/ws_livox/devel -- Using CMAKE_PREFIX_PATH: /home/amov/anaconda3;/home/amov/sjtu_ws/devel;/home/amov/tst/devel;/home/amov/p230_experiment/devel;/home/amov/prometheus_mavros/devel;/opt/ros/noetic;/home/amov/anaconda3 -- This workspace overlays: /home/amov/sjtu_ws/devel;/home/amov/tst/devel;/home/amov/p230_experiment/devel;/home/amov/prometheus_mavros/devel;/opt/ros/noetic -- Found PythonInterp: /home/amov/anaconda3/bin/python3 (found suitable version "3.9.13", minimum required is "3") -- Using PYTHON_EXECUTABLE: /home/amov/anaconda3/
05-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值