ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Adding custom actions to rosbuild

asked 2011-09-07 21:39:39 -0500

tom gravatar image

I've got a package defining messages for rosserial. After changing a message, I need to deploy (copy) the changes to a folder containing generated messages for an Arduino board. Is there a (clean) way to add custom actions to the rosbuild system? For now I'm assuming I could modify Makefile in my message-defining-package adding the actions I need after the call:

include $(shell rospack find mk)/cmake.mk

but won't it get overwritten in some case and is it the right way to do it? I've got a deploy script and would like to call it from somewhere.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2011-09-07 21:59:31 -0500

Ugo gravatar image

I'm not sure that it's the correct answer, but I think you should rather edit the CMakeLists.txt than the Makefile.

You can add a custom command to your CMakeLists.txt using this line:

EXECUTE_PROCESS(COMMAND "${PROJECT_SOURCE_DIR}/your_script.sh")

Hope this helps.

edit flag offensive delete link more

Comments

Yes, it surely will - thank you.
tom gravatar image tom  ( 2011-09-07 22:00:56 -0500 )edit
Note that `execute_process()` will run in-place when the CMakeLists.txt file is parsed, before the build happens. If you would rather arrange for the command to run later, during/after the build, see my answer on using `add_custom_target()`.
Brian Gerkey gravatar image Brian Gerkey  ( 2011-09-08 09:29:07 -0500 )edit
Actually I just tested it again to make sure and executing make on my message-package causes correct behaviour, ie. all generated messages get copied after being built. I added my deploy script at the end of CMakeLists.txt.
tom gravatar image tom  ( 2011-09-08 20:14:30 -0500 )edit
2

answered 2011-09-08 09:27:48 -0500

Brian Gerkey gravatar image

You can use add_custom_target(), e.g.:

# Declare a custom target that will do the copy when the 'all' target fires
add_custom_target(deploy ALL
                  COMMAND cp $(CMAKE_SOURCE_DIR)/undeployed /tmp/deployed)
# Declare a dependency on the 'rosbuild_precompile' target, to ensure 
# that message generation happens before we copy.
add_dependencies(deploy rosbuild_precompile)
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-09-07 21:39:39 -0500

Seen: 406 times

Last updated: Sep 08 '11