updated to use CMAKE_PREFIX_PATH instead of CATKIN_WORKSPACES

This commit is contained in:
Dirk Thomas 2012-09-16 20:28:27 +00:00
parent 145c117254
commit 16d66a277b
3 changed files with 17 additions and 11 deletions

View File

@ -12,16 +12,22 @@ fi
PYTHON_CODE_BUILD_ROS_PACKAGE_PATH=$(cat <<EOF
from __future__ import print_function
import os
env_name = 'CATKIN_WORKSPACES'
items = os.environ[env_name].split(';') if env_name in os.environ and os.environ[env_name] != '' else []
env_name = 'CMAKE_PREFIX_PATH'
paths = [path for path in os.environ[env_name].split(os.pathsep)] if env_name in os.environ and os.environ[env_name] != '' else []
workspaces = [path for path in paths if os.path.exists(os.path.join(path, '.CATKIN_WORKSPACE'))]
paths = []
for item in items:
if item.find(':') != -1:
paths.append(item.split(':')[1])
for workspace in workspaces:
filename = os.path.join(workspace, '.CATKIN_WORKSPACE')
data = ''
with open(filename) as f:
data = f.read()
if data == '':
paths.append(os.path.join(workspace, 'share'))
paths.append(os.path.join(workspace, 'stacks'))
else:
paths.append(os.path.join(item, 'share'))
paths.append(os.path.join(item, 'stacks'))
print(':'.join(paths))
for source_path in data.split(';'):
paths.append(source_path)
print(os.pathsep.join(paths))
EOF
)
export ROS_PACKAGE_PATH=`python -c "$PYTHON_CODE_BUILD_ROS_PACKAGE_PATH"`

View File

@ -220,7 +220,7 @@ function rosls {
# sets arg as return value
function _roscmd {
local pkgdir exepath opt catkin_project_libexec_dir opts
if [[ -n $CATKIN_WORKSPACES ]]; then
if [[ -n $CMAKE_PREFIX_PATH ]]; then
catkin_project_libexec_dir=`catkin_find --first-only --libexec $1 2> /dev/null`
fi
pkgdir=`_ros_package_find $1`
@ -417,7 +417,7 @@ function _roscomplete_search_dir {
COMPREPLY=($(compgen -W "${opts}" -- ${arg}))
unset IFS
elif [[ $COMP_CWORD == 2 ]]; then
if [[ -n $CATKIN_WORKSPACES ]]; then
if [[ -n $CMAKE_PREFIX_PATH ]]; then
catkin_project_libexec_dir=`catkin_find --first-only --libexec ${COMP_WORDS[1]} 2> /dev/null`
fi
pkgdir=`_ros_package_find ${COMP_WORDS[1]}`

View File

@ -21,7 +21,7 @@ case $2 in
esac
# basename also makes .//foo into foo
basename=`basename $2`
if [[ -n $CATKIN_WORKSPACES ]]; then
if [[ -n $CMAKE_PREFIX_PATH ]]; then
catkin_project_libexec_dir=`catkin_find --first-only --libexec $1 2> /dev/null`
fi
pkgdir=`rospack find $1`