Skip to content

Commit

Permalink
update shell scripts to define or allow override CATKIN_SETUP_DIR (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Jul 26, 2013
1 parent a0d699a commit 644daf7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
15 changes: 8 additions & 7 deletions cmake/templates/_setup_util.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ import os
import platform
import sys

# environment at generation time
CMAKE_PREFIX_PATH = '@CMAKE_PREFIX_PATH_AS_IS@'.split(';')
setup_dir = '@SETUP_DIR@'
if setup_dir and setup_dir not in CMAKE_PREFIX_PATH:
CMAKE_PREFIX_PATH.insert(0, setup_dir)
CMAKE_PREFIX_PATH = os.pathsep.join(CMAKE_PREFIX_PATH)

CATKIN_MARKER_FILE = '.catkin'

system = platform.system()
Expand Down Expand Up @@ -256,6 +249,14 @@ if __name__ == '__main__':
print(e, file=sys.stderr)
exit(1)

# environment at generation time
CMAKE_PREFIX_PATH = '@CMAKE_PREFIX_PATH_AS_IS@'.split(';')
# prepend current workspace if not already part of CPP
base_path = os.path.dirname(__file__)
if base_path not in CMAKE_PREFIX_PATH:
CMAKE_PREFIX_PATH.insert(0, base_path)
CMAKE_PREFIX_PATH = os.pathsep.join(CMAKE_PREFIX_PATH)

environ = dict(os.environ)
lines = []
if not args.extend:
Expand Down
8 changes: 5 additions & 3 deletions cmake/templates/env.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ if [ $# -eq 0 ] ; then
/bin/echo "Usage: env.sh COMMANDS"
/bin/echo "Calling env.sh without arguments is not supported anymore. Instead spawn a subshell and source a setup file manually."
exit 1
else
. "@SETUP_DIR@/@[email protected]"
exec "$@"
fi

# source @[email protected] from same directory as this file
CATKIN_SETUP_DIR=$(cd `dirname $0`;pwd)
. "$CATKIN_SETUP_DIR/@[email protected]"
exec "$@"
5 changes: 4 additions & 1 deletion cmake/templates/setup.bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
# generated from catkin/cmake/templates/setup.bash.in

CATKIN_SHELL=bash
. "@SETUP_DIR@/setup.sh"

# source setup.sh from same directory as this file
CATKIN_SETUP_DIR=$(cd `dirname ${BASH_SOURCE[0]}`;pwd)
. "$CATKIN_SETUP_DIR/setup.sh"
5 changes: 4 additions & 1 deletion cmake/templates/setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
# Supported command line options:
# --extend: skips the undoing of changes from a previously sourced setup file

_SETUP_UTIL="@SETUP_DIR@/_setup_util.py"
# since this file is sourced either use the provided CATKIN_SETUP_DIR
# or fall back to the destination set at configure time
: ${CATKIN_SETUP_DIR:=@SETUP_DIR@}
_SETUP_UTIL="$CATKIN_SETUP_DIR/_setup_util.py"

if [ ! -f "$_SETUP_UTIL" ]; then
echo "Missing Python script: $_SETUP_UTIL"
Expand Down
3 changes: 2 additions & 1 deletion cmake/templates/setup.zsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# generated from catkin/cmake/templates/setup.zsh.in

CATKIN_SHELL=zsh
CATKIN_SETUP_DIR=$(cd `dirname $0`;pwd)
emulate sh # emulate POSIX
. "@SETUP_DIR@/setup.sh"
. "$CATKIN_SETUP_DIR/setup.sh"
emulate zsh # back to zsh mode

0 comments on commit 644daf7

Please sign in to comment.