-
Notifications
You must be signed in to change notification settings - Fork 786
/
Copy path10.ros.sh.em
55 lines (50 loc) · 2.29 KB
/
10.ros.sh.em
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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