replace env hooks with a dependency on ros_environment (#166)
This commit is contained in:
parent
4edd0f8337
commit
6f699fbfc1
|
@ -24,13 +24,6 @@ if(NOT (APPLE OR WIN32 OR MINGW OR ANDROID))
|
||||||
target_link_libraries(roslib rt)
|
target_link_libraries(roslib rt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_HOST_UNIX)
|
|
||||||
catkin_add_env_hooks(10.ros SHELLS sh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks)
|
|
||||||
else()
|
|
||||||
catkin_add_env_hooks(10.ros SHELLS bat DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
catkin_python_setup()
|
catkin_python_setup()
|
||||||
|
|
||||||
install(TARGETS roslib
|
install(TARGETS roslib
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
REM generated from ros/env-hooks/10.ros.bat.em
|
|
||||||
|
|
||||||
REM scrub old ROS bin dirs, to avoid accidentally finding the wrong executables
|
|
||||||
set _COMMAND=@(PYTHON_EXECUTABLE) -c "import os; print(os.pathsep.join([x for x in r'%PATH%'.split(os.pathsep) if not any([d for d in ['cturtle', 'diamondback', 'electric', 'fuerte'] if d in x])]))"
|
|
||||||
rem Need the delims= line here to ensure that it reads with eol delimiters, not space.
|
|
||||||
for /f "delims=" %%i in ('%COMMAND%') do set PATH=%%i
|
|
||||||
|
|
||||||
set ROS_DISTRO=lunar
|
|
||||||
|
|
||||||
REM python function to generate ROS package path based on all parent workspaces (prepends the separator if necessary)
|
|
||||||
REM do not use EnableDelayedExpansion here, it messes with the != symbols
|
|
||||||
setlocal disabledelayedexpansion
|
|
||||||
echo from __future__ import print_function > _parent_package_path.py
|
|
||||||
echo import os >> _parent_package_path.py
|
|
||||||
echo env_name = 'CATKIN_WORKSPACES' >> _parent_package_path.py
|
|
||||||
echo items = os.environ[env_name].split(';') if env_name in os.environ and os.environ[env_name] != '' else [] >> _parent_package_path.py
|
|
||||||
echo path = '' >> _parent_package_path.py
|
|
||||||
echo for item in items: >> _parent_package_path.py
|
|
||||||
echo path += ':' + (os.path.join(item, 'share') if item.find(':') == -1 else item.split(':')[1]) >> _parent_package_path.py
|
|
||||||
echo print(path) >> _parent_package_path.py
|
|
||||||
endlocal
|
|
||||||
|
|
||||||
setlocal EnableDelayedExpansion
|
|
||||||
|
|
||||||
set ROS_PACKAGE_PATH_PARENTS=
|
|
||||||
for /f %%a in ('@(PYTHON_EXECUTABLE) _parent_package_path.py') do set ROS_PACKAGE_PATH_PARENTS=!ROS_PACKAGE_PATH_PARENTS!%%a
|
|
||||||
|
|
||||||
@[if DEVELSPACE]@
|
|
||||||
REM env variables in develspace
|
|
||||||
set ROS_PACKAGE_PATH=@(CMAKE_SOURCE_DIR)!ROS_PACKAGE_PATH_PARENTS!
|
|
||||||
set ROS_ETC_DIR=@(CATKIN_DEVEL_PREFIX)/@(CATKIN_GLOBAL_ETC_DESTINATION)/ros
|
|
||||||
@[else]@
|
|
||||||
REM env variables in installspace
|
|
||||||
set ROS_PACKAGE_PATH=@(CMAKE_INSTALL_PREFIX)/share;@(CMAKE_INSTALL_PREFIX)/stacks;%ROS_PACKAGE_PATH_PARENTS%
|
|
||||||
set ROS_ETC_DIR=@(CMAKE_INSTALL_PREFIX)/@(CATKIN_GLOBAL_ETC_DESTINATION)/ros
|
|
||||||
@[end if]@
|
|
||||||
|
|
||||||
del _parent_package_path.py
|
|
||||||
|
|
||||||
REM Make sure these two variables survive local scope
|
|
||||||
endlocal && set ROS_PACKAGE_PATH=%ROS_PACKAGE_PATH% && set ROS_ETC_DIR=%ROS_ETC_DIR%
|
|
||||||
|
|
||||||
REM unset ROS workspace
|
|
||||||
set ROS_WORKSPACE=
|
|
||||||
set _COMMAND=
|
|
|
@ -1,55 +0,0 @@
|
||||||
# generated from ros/env-hooks/10.ros.sh.em
|
|
||||||
|
|
||||||
# scrub old ROS bin dirs, to avoid accidentally finding the wrong executables
|
|
||||||
export PATH="`@(PYTHON_EXECUTABLE) -c \"import os; print(os.pathsep.join([x for x in \\\"$PATH\\\".split(os.pathsep) if not any([d for d in ['cturtle', 'diamondback', 'electric', 'fuerte'] if d in x])]))\"`"
|
|
||||||
|
|
||||||
@{
|
|
||||||
# This is a build-time environment variable which allows a build engineer to override the expected
|
|
||||||
# ROS_DISTRO value for a workspace, for example to deliberately use a newer version of roslib with
|
|
||||||
# an older release or vice-versa, or to define a custom distro (eg, "ROS Banana").
|
|
||||||
from os import environ
|
|
||||||
ROS_DISTRO = environ.get("ROS_DISTRO_OVERRIDE", "lunar")
|
|
||||||
}@
|
|
||||||
if [ -n "$ROS_DISTRO" -a "$ROS_DISTRO" != "@(ROS_DISTRO)" ]; then
|
|
||||||
echo "ROS_DISTRO was set to '$ROS_DISTRO' before. Please make sure that the environment does not mix paths from different distributions."
|
|
||||||
fi
|
|
||||||
export ROS_DISTRO=@(ROS_DISTRO)
|
|
||||||
|
|
||||||
# python function to generate ROS package path based on all workspaces
|
|
||||||
PYTHON_CODE_BUILD_ROS_PACKAGE_PATH=$(cat <<EOF
|
|
||||||
from __future__ import print_function
|
|
||||||
import os
|
|
||||||
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'))]
|
|
||||||
paths = []
|
|
||||||
for workspace in workspaces:
|
|
||||||
filename = os.path.join(workspace, '.catkin')
|
|
||||||
data = ''
|
|
||||||
with open(filename) as f:
|
|
||||||
data = f.read()
|
|
||||||
if data == '':
|
|
||||||
paths.append(os.path.join(workspace, 'share'))
|
|
||||||
if os.path.isdir(os.path.join(workspace, 'stacks')):
|
|
||||||
paths.append(os.path.join(workspace, 'stacks'))
|
|
||||||
else:
|
|
||||||
for source_path in data.split(';'):
|
|
||||||
paths.append(source_path)
|
|
||||||
print(os.pathsep.join(paths))
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
export ROS_PACKAGE_PATH="`@(PYTHON_EXECUTABLE) -c \"$PYTHON_CODE_BUILD_ROS_PACKAGE_PATH\"`"
|
|
||||||
|
|
||||||
@[if DEVELSPACE]@
|
|
||||||
# env variables in develspace
|
|
||||||
export ROS_ETC_DIR="@(CATKIN_DEVEL_PREFIX)/@(CATKIN_GLOBAL_ETC_DESTINATION)/ros"
|
|
||||||
@[else]@
|
|
||||||
# env variables in installspace
|
|
||||||
if [ -z "$CATKIN_ENV_HOOK_WORKSPACE" ]; then
|
|
||||||
CATKIN_ENV_HOOK_WORKSPACE="@(CMAKE_INSTALL_PREFIX)"
|
|
||||||
fi
|
|
||||||
export ROS_ETC_DIR="$CATKIN_ENV_HOOK_WORKSPACE/@(CATKIN_GLOBAL_ETC_DESTINATION)/ros"
|
|
||||||
@[end if]@
|
|
||||||
|
|
||||||
# unset ROS workspace
|
|
||||||
unset ROS_WORKSPACE
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<run_depend>catkin</run_depend>
|
<run_depend>catkin</run_depend>
|
||||||
<run_depend version_gte="1.0.37">python-rospkg</run_depend>
|
<run_depend version_gte="1.0.37">python-rospkg</run_depend>
|
||||||
|
<run_depend>ros_environment</run_depend>
|
||||||
<run_depend>rospack</run_depend>
|
<run_depend>rospack</run_depend>
|
||||||
|
|
||||||
<export>
|
<export>
|
||||||
|
|
Loading…
Reference in New Issue