colcon / colcon-ros

Extension for colcon to support ROS packages
http://colcon.readthedocs.io
Apache License 2.0
13 stars 26 forks source link

Tries to get targets list after cmake invocation has failed #116

Closed mikepurvis closed 3 years ago

mikepurvis commented 3 years ago

I haven't got a MWE for this, but we're seeing an issue sometimes where the CMake invocation fails, but the error message is unhelpful because it pertains to make help having failed. I believe this logic here should check the value of rc before calling has_target, or else the inner get_makefile_targets function should catch the exception and return an empty list in that case:

https://github.com/colcon/colcon-ros/blob/d77a37bcf0dbd6de92f5ce9cdb21efcb50dfd054/colcon_ros/task/catkin/build.py#L75-L82

Example:

-- Configuring incomplete, errors occurred!
See also "[...]/ws/build/python_orocos_kdl/CMakeFiles/CMakeOutput.log".
See also "[...]/ws/build/python_orocos_kdl/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "[...]/colcon-env/lib/python3.8/site-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "[...]/colcon-env/lib/python3.8/site-packages/colcon_core/task/__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "[...]/colcon-env/lib/python3.8/site-packages/colcon_ros/task/catkin/build.py", line 82, in build
    if await has_target(args.build_base, 'install'):
  File "[...]/colcon-env/lib/python3.8/site-packages/colcon_cmake/task/cmake/__init__.py", line 57, in has_target
    return target in await get_makefile_targets(path)
  File "[...]/colcon-env/lib/python3.8/site-packages/colcon_cmake/task/cmake/__init__.py", line 77, in get_makefile_targets
    output = await check_output([
  File "[...]/colcon-env/lib/python3.8/site-packages/colcon_core/subprocess.py", line 109, in check_output
    assert not rc, \
AssertionError: Expected ['/usr/bin/cmake', '--build', '[...]/ws/build/python_orocos_kdl', '--target', 'help'] to pass: make: *** No rule to make target 'help'.  Stop.

FYI @iwanders

dirk-thomas commented 3 years ago

Thanks for the report. Please try the proposed patch from #117 and comment if it resolves the problem for you.