Skip to content

return prefix path in ament_index_has_resource - #155

Merged
dirk-thomas merged 1 commit into
masterfrom
ament_index_get_prefix_path
Feb 6, 2019
Merged

dirk-thomas merged 1 commit into
masterfrom
ament_index_get_prefix_path

Conversation

@dirk-thomas

Copy link
Copy Markdown
Contributor

Replaces #154.

@dirk-thomas dirk-thomas added enhancement New feature or request in review Waiting for review (Kanban column) labels Feb 5, 2019
@dirk-thomas dirk-thomas self-assigned this Feb 5, 2019
@pbaughman

Copy link
Copy Markdown
Contributor

@dirk-thomas I tried this in our build and it trashed things pretty badly. I think someone somewhere is comparing the return value directly to TRUE, but I didn't dig in too deeply

@pbaughman

pbaughman commented Feb 6, 2019 •

Copy link
Copy Markdown
Contributor

A little more info as I dig into this. . . Our build fails with:

--- stderr: builtin_interfaces
CMake Error at cmake_install.cmake:212 (file):
  file INSTALL cannot find
 
 "/home/workspace/build/builtin_interfaces/rosidl_generator_py/builtin_interfaces/msg/_duration.py"

When I make this change

@dirk-thomas dirk-thomas added in progress Actively being worked on (Kanban column) and removed in review Waiting for review (Kanban column) labels Feb 6, 2019
@pbaughman

Copy link
Copy Markdown
Contributor

Digging a little more - it looks like once I make this change, rmw get_rmw_typesupport no longer recognizes the path as being 'TRUE'

Digging into the cmake docs a little, I think the rule that applies is

if(<variable|string>)
True if given a variable that is defined to a value that is not a false constant. False otherwise. (Note macro arguments are not variables.)

Since the path to the resource is a value that is not a false constant, I'd expect it to evaluate to TRUE, but that's not how it's behaving. Maybe I'm mis-reading the docs

@pbaughman

Copy link
Copy Markdown
Contributor

I put some print statements into get_rmw_typesupport:

function(get_rmw_typesupport var rmw_implementation)                                                                                                           
  cmake_parse_arguments(ARG "" "LANGUAGE" "" ${ARGN})                                                                                                          
  if(ARG_UNPARSED_ARGUMENTS)                                                                                                                                   
    message(FATAL_ERROR "get_rmw_typesupport() called with unused "
      "arguments: ${ARG_UNPARSED_ARGUMENTS}")
  endif()
  set(resource_type "rmw_typesupport")
  if(ARG_LANGUAGE)
    string(TOLOWER "${ARG_LANGUAGE}" ARG_LANGUAGE)                                                                                                             
    set(resource_type "${resource_type}_${ARG_LANGUAGE}")                                                                                                      
  endif()
  ament_index_has_resource(has_resource "${resource_type}" "${rmw_implementation}")                                                                            
  if(${has_resource})
    message("Found resource and has_resource was ${has_resource}")  # <----- Added this for debugging
    ament_index_get_resource(resource "${resource_type}" "${rmw_implementation}")                                                                              
  else()
    message("Did not find resource and has_resource was ${has_resource}")  # <----- Added this for debugging
    set(resource "")
  endif()
  set(${var} "${resource}" PARENT_SCOPE)                                                                                                                       
endfunction()    

With the proposed change:

colcon build --packages-up-to rosidl_generator_py
. . .
Starting >>> rosidl_generator_py
--- stderr: rosidl_generator_py
Did not find resource and has_resource was /path/to/workspace/install
Did not find resource and has_resource was /path/to/workspace/install
---
Finished <<< rosidl_generator_py [10.8s]

Without the proposed change:

Starting >>> rosidl_generator_py
--- stderr: rosidl_generator_py         
Found resource and has_resource was TRUE
Found resource and has_resource was TRUE
---
Finished <<< rosidl_generator_py [13.9s]

@pbaughman

Copy link
Copy Markdown
Contributor

If get_rmw_typesupport.cmake did

if(has_resource)

instead of

if(${has_resource})

Then this change works on my machine. I'd be a little worried about similar issues in other people's builds, though.

@dirk-thomas

dirk-thomas commented Feb 6, 2019 •

Copy link
Copy Markdown
Contributor Author

If get_rmw_typesupport.cmake did

if(has_resource)

Indeed, see ros2/rmw#165.

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@dirk-thomas dirk-thomas added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Feb 6, 2019
@dirk-thomas

Copy link
Copy Markdown
Contributor Author

Ready for review.

@dirk-thomas
dirk-thomas merged commit 06f842e into master Feb 6, 2019
@dirk-thomas
dirk-thomas deleted the ament_index_get_prefix_path branch February 6, 2019 23:32
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants