Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catkin_generate_environment: don't overwrite existing .catkin file #676

Merged

Conversation

jbohren
Copy link
Member

@jbohren jbohren commented Jul 9, 2014

The Orocos RTT package, a pure CMake package, currently doesn't use catkin for building, but it does call find_package(catkin) in order to determine if catkin is installed on the system, and if so, it calls catkin_add_env_hooks() to add an env hook. This works fine if you're installing it to an isolated workspace or somewhere else, but when installing to a develspace (like with catkin_tools), it causes the .catkin file to be overwritten and you lose the list of all previously-built packages.

This patch replaces the normal CMake install(FILES ...) command with an install(CODE ...) command which just checks if the file already exists or not.

@dirk-thomas
Copy link
Member

Can you please update the PR to only write an empty file within the install(CODE ...) block? It shouldn't do an install in there and it doesn't require the temporary in build space anymore.

@jbohren
Copy link
Member Author

jbohren commented Jul 9, 2014

Can you please update the PR to only write an empty file within the install(CODE ...) block? It shouldn't do an install in there and it doesn't require the temporary in build space anymore.

Yeah that makes more sense. Done.

install(FILES
${CMAKE_BINARY_DIR}/catkin_generated/installspace/.catkin
DESTINATION ${CMAKE_INSTALL_PREFIX})
set(_catkin_marker_file_installed "${CMAKE_INSTALL_PREFIX}/.catkin")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that it works but have you tried to move the variable into the install(CODE ..) block and actually keep CMAKE_INSTALL_PREFIX as a variable (escaping the $) to expand it at install time?

@jbohren
Copy link
Member Author

jbohren commented Jul 9, 2014

Putting the escaped ${CMAKE_INSTALL_PREFIX} to be evaluated at install time works.

I also modified the develspace marker file generation in the case that an empty .catkin file has been created in the develspace. As described in the log message, this should have a negligible impact on race condition sensitivity.

install(FILES
${CMAKE_BINARY_DIR}/catkin_generated/installspace/.catkin
DESTINATION ${CMAKE_INSTALL_PREFIX})
set(_catkin_marker_file_installed "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable seems to be not used anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, thought I got that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2f23fd8

- During install step of a catkin package, don't overwrite an existing
  .catkin file
- During a devel build, don't append a semicolon-prefixed source path to
  the .catkin file if the .catkin file is empty. This is related to the
  previous race condition fix which prevented overwriting the .catkin
  file. This should introduce negligible sensitivity to parallel
  invocations of catkin-based CMake builds only if the .catkin file is
  empty. For all other cases, it is still an atomic <4k APPEND write.
@dirk-thomas
Copy link
Member

Thanks for keeping up with all my nitpicking.

dirk-thomas added a commit that referenced this pull request Jul 10, 2014
…nstall

catkin_generate_environment: don't overwrite existing .catkin file
@dirk-thomas dirk-thomas merged commit b01a0e6 into ros:indigo-devel Jul 10, 2014
@jbohren
Copy link
Member Author

jbohren commented Jul 10, 2014

Thanks for keeping up with all my nitpicking.

Thank you for responding so quickly to these PRs!

# install empty workspace marker if it doesn't already exist
install(CODE "
if (NOT EXISTS \"\${CMAKE_INSTALL_PREFIX}/.catkin\")
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/.catkin\" \"\")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code fails when the folder CMAKE_INSTALL_PREFIX does not exist: http://jenkins.ros.org/job/ros-indigo-catkin_binarydeb_trusty_amd64/11/console

I hope the fix in f2efd9e works...

Actually that won't be sufficient since it also needs to handle DESTDIR correctly: 149a241

dirk-thomas added a commit that referenced this pull request Jul 11, 2014
dirk-thomas added a commit that referenced this pull request Jul 11, 2014
dirk-thomas added a commit that referenced this pull request Aug 18, 2014
cwecht pushed a commit to cwecht/catkin that referenced this pull request Mar 20, 2018
cwecht pushed a commit to cwecht/catkin that referenced this pull request Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants