How can I make a bash script in a package run after catkin_make has been used on workspace?
I have a bash script that installs some packages necessary to use a package I am building. Ideally I would want this bash script to be executed the first time someone uses catkin_make on the workspace after my package has been cloned on the src folder of the workspace. How can this be done? Is there another way to accomplish what I am trying to do?
I have tried to do this from launch file without much success.
Running this on ROS melodic, Ubuntu 18.04
Asked by katsostak on 2021-09-05 22:40:55 UTC
Answers
Hello @katsostak,
Let's say you have created a bash script including all package init. I am just providing an example instead of whoami and date command think it is your script.
Mini batch script: abc.sh
#!/bin/bash
whoami
date
You first need to chmod +x abc.sh
You can execute it in 2 ways:
1. bash abc.sh
2. ./abc.sh
Ideally I would want this bash script to be executed the first time someone uses catkin_make on the workspace after my package has been cloned on the src folder of the workspace.
CMake Solution
It is also possible to add a "post build" command for a target in CMake with add_custom_command using the "POST_BUILD COMMAND" option:
add_custom_command(TARGET doc
POST_BUILD COMMAND your_script.sh
)
(I am not sure if this will work as intended for the target, maybe you have to experiment a bit.)
Asked by Ranjit Kathiriya on 2021-09-06 04:11:01 UTC
Comments
To avoid an xy-problem, it might be good to take a look at what sort of dependencies you're referring to.
Asked by gvdhoorn on 2021-09-06 05:29:56 UTC