Skip to content

Commit

Permalink
Add ros prefix in dependency 'graph'
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Mar 5, 2022
1 parent 546a06b commit 7c3f930
Showing 1 changed file with 53 additions and 33 deletions.
86 changes: 53 additions & 33 deletions installer/tue-install-impl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,27 @@ function tue-install-target-now
return $?
}

function _set_dependencies
{
local parent_target=$1
local target=$2

# If the target has a parent target, add target as a dependency to the parent target
if [ -n "$parent_target" ] && [ "$parent_target" != "main-loop" ]
then

if [ "$parent_target" != "$target" ]
then
tue-install-debug "echo $target >> $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target"
tue-install-debug "echo $parent_target >> $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target"
echo "$target" >> "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target"
echo "$parent_target" >> "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target"
sort "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" -u -o "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target"
sort "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" -u -o "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target"
fi
fi
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

function tue-install-rosdep
Expand All @@ -143,49 +164,51 @@ function tue-install-rosdep
then
tue-install-debug "Target '$target' has not yet been resolved by rosdep, going to installation procedure"

# Also make sure ros is installed
tue-install-target ros || tue-install-error "Failed to install target 'ROS'"

# Check if target can be resolved by rosdep
tue-install-debug "rosdep resolve $target"
rosdep_res=($(rosdep resolve $target 2>&1))
if [ $? -eq 0 ]
then
tue-install-debug "rosdep correctly resolved to: ${rosdep_res[@]}"

# If the target has a parent target, add target as a dependency to the parent target
if [ -n "$parent_target" ]
then
if [ "$parent_target" != "$target" ]
then
echo "$target" >> $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target
echo "$parent_target" >> $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target
sort $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target -u -o $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target
sort $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target -u -o $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target
fi
fi
tue-install-debug "rosdep correctly resolved to: ${rosdep_res[*]}"

case ${rosdep_res[0]} in
"#apt") tue-install-system ${rosdep_res[1]}
;;
"#pip") tue-install-pip ${rosdep_res[1]}
;;
*) tue-install-debug "Unsupported rosdep output: ${rosdep_res[@]}"; TUE_INSTALL_CURRENT_TARGET=$parent_target; return 1
*) tue-install-debug "Unsupported rosdep output: ${rosdep_res[*]}";
TUE_INSTALL_CURRENT_TARGET=$parent_target;
TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target;
return 1
;;
esac

if [[ ${rosdep[1]} == "ros-"* ]]
then
# Also make sure ros is installed
tue-install-target ros || tue-install-error "Failed to install target 'ROS'"
fi

_set_dependencies $parent_target $target

touch $TUE_INSTALL_STATE_DIR/$target

TUE_INSTALL_CURRENT_TARGET=$parent_target
TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target
return 0
else
tue-install-debug "Could not be resolved by rosdep. error: ${rosdep_res[@]}"
tue-install-debug "Could not be resolved by rosdep. error: ${rosdep_res[*]}"
TUE_INSTALL_CURRENT_TARGET=$parent_target
TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target
return 1
fi
else
tue-install-debug "Target '$target' already resolved correctly by rosdep, skipping it this time."

_set_dependencies $parent_target $target

TUE_INSTALL_CURRENT_TARGET=$parent_target
TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target
return 0
fi
}
Expand All @@ -204,11 +227,18 @@ function tue-install-target
# Check if valid target received as input
if [ ! -d $TUE_INSTALL_TARGETS_DIR/$target ]
then
# Check if can be resolved by rosdep
tue-install-rosdep $target
if [ $? -eq 0 ]
# Targets starting with 'ros-' will never be resolved by rosdep
if [[ "$target" != "ros-"* ]]
then
return 0
# Check if can be resolved by rosdep
tue-install-rosdep $target
if [ $? -eq 0 ]
then
return 0
else
tue-install-debug "Target '$target' does not exist."
return 1
fi
else
tue-install-debug "Target '$target' does not exist."
return 1
Expand All @@ -219,17 +249,7 @@ function tue-install-target
TUE_INSTALL_CURRENT_TARGET=$target
TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$target

# If the target has a parent target, add target as a dependency to the parent target
if [ -n "$parent_target" ] && [ "$parent_target" != "main-loop" ]
then
if [ "$parent_target" != "$target" ]
then
echo "$target" >> "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target"
echo "$parent_target" >> "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target"
sort "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" -u -o "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target"
sort "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" -u -o "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target"
fi
fi
_set_dependencies $parent_target $target

local state_file="$TUE_INSTALL_STATE_DIR"/"$target"
local state_file_now="${state_file}-now"
Expand Down

0 comments on commit 7c3f930

Please sign in to comment.