MetroRobots / ros_glint

Make your ROS code sparkle!
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

check_manifest_dependencies doesn't remove build_export_depend tags, causing compilation issue #24

Open Achllle opened 1 month ago

Achllle commented 1 month ago

When running glint_ros check_manifest_dependencies on a package that has build, build_export, and exec depends in package.xml, the linter check_manifest_dependencies tries to merge them into a single depend tag, however build_export_depend tags aren't removed in the process, causing building to fail with:

Traceback (most recent call last):
  File "/opt/ros/noetic/share/catkin/cmake/parse_package_xml.py", line 115, in <module>
    main()
  File "/opt/ros/noetic/share/catkin/cmake/parse_package_xml.py", line 101, in main
    package = parse_package(args.package_xml)
  File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 584, in parse_package
    return parse_package_string(xml, filename, warnings=warnings)
  File "/usr/lib/python3/dist-packages/catkin_pkg/package.py", line 786, in parse_package_string
    raise InvalidPackage('Error(s):%s' % (''.join(['\n- %s' % e for e in errors])), filename)
catkin_pkg.package.InvalidPackage: Error(s) in package '/xyz/package.xml':
Error(s):
- The generic dependency on 'roscpp' is redundant with: build_export_depend
- The generic dependency on 'rospy' is redundant with: build_export_depend
- The generic dependency on 'std_msgs' is redundant with: build_export_depend
- The generic dependency on 'std_srvs' is redundant with: build_export_depend

The suggested diff is as follows:

+   <depend>roscpp</depend>
+   <depend>rospy</depend>
+   <depend>std_msgs</depend>
+   <depend>std_srvs</depend>
+   <build_export_depend>message_runtime</build_export_depend>

...
    <!-- Use test_depend for packages you need only for testing: -->
    <!--   <test_depend>gtest</test_depend> -->
    <!-- Use doc_depend for packages you need only for building documentation: -->
    <!--   <doc_depend>doxygen</doc_depend> -->
    <buildtool_depend>catkin</buildtool_depend>
-   <build_depend>roscpp</build_depend>
-   <build_depend>rospy</build_depend>
-   <build_depend>std_msgs</build_depend>
-   <build_depend>std_srvs</build_depend>
    <build_export_depend>roscpp</build_export_depend>
    <build_export_depend>rospy</build_export_depend>
    <build_export_depend>std_msgs</build_export_depend>
    <build_export_depend>std_srvs</build_export_depend>
-   <exec_depend>roscpp</exec_depend>
-   <exec_depend>rospy</exec_depend>
-   <exec_depend>std_msgs</exec_depend>
-   <exec_depend>std_srvs</exec_depend>

Setting prefer_depend_tag in the config to True prevents the tags from being replaced by a single depend tag, causing things to build properly. I would expect the value to have to be False, but that's another issue. It seems like the issue is with package_xml, but posting here so others can find it (and since I haven't looked at where to find that repo)