0
$\begingroup$

Rosanswers logo

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.


Originally posted by tom on ROS Answers with karma: 1079 on 2011-09-07

Post score: 2

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Ugo with karma: 1620 on 2011-09-07

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by tom on 2011-09-08:
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.

Comment by Brian Gerkey on 2011-09-08:
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().

Comment by tom on 2011-09-07:
Yes, it surely will - thank you.

$\endgroup$
0
$\begingroup$

Rosanswers logo

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)

Originally posted by Brian Gerkey with karma: 2916 on 2011-09-08

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.