Created
March 13, 2017 17:38
-
-
Save ihnorton/9da6dedb895fd0eb3addbec35b7c08d5 to your computer and use it in GitHub Desktop.
slicer-script.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DESIGNER=/usr/local/Cellar/qt/4.8.7_3/Designer.app/Contents/MacOS/Designer | |
SLICER_REAL=~/git/slcr/s4nj/Slicer-build/bin/Slicer.app/Contents/MacOS/Slicer | |
SLICER_LAUNCH=~/git/slcr/s4nj/Slicer-build/Slicer | |
LLDB=/usr/bin/lldb | |
SLICER_MODULE_PATHS="/Users/inorton/git/dmri/TestExt-build/SlicerDMRI-build/inner-build/lib/Slicer-4.7/cli-modules/. \ | |
/Users/inorton/git/dmri/TestExt-build/SlicerDMRI-build/inner-build/lib/Slicer-4.7/qt-loadable-modules/. \ | |
/Users/inorton/work/git/ukftractography-build/inner-build/lib/Slicer-4.7/qt-scripted-modules \ | |
/Users/inorton/work/git/ukftractography-build/inner-build/lib/Slicer-4.7/qt-loadable-modules" | |
SLICER_PYTHON_PATHS="/Users/inorton/git/dmri/TestExt-build/SlicerDMRI-build/inner-build/lib/Slicer-4.7/qt-scripted-modules \ | |
/Users/inorton/git/dmri/TestExt-build/SlicerDMRI-build/inner-build/lib/Slicer-4.7/qt-loadable-modules/. \ | |
/Users/inorton/git/dmri/TestExt-build/SlicerDMRI-build/inner-build/lib/Slicer-4.7/qt-loadable-modules/Python \ | |
/Users/inorton/work/git/ukftractography-build/inner-build/lib/Slicer-4.7/qt-loadable-modules/Python" | |
SLICER_ENV=`$SLICER_LAUNCH --launcher-show-set-environment-commands` | |
#### Do the things | |
# script is being sourced | |
if [[ $0 != "$BASH_SOURCE" ]]; then | |
# set paths into the sourcing environment | |
eval $SLICER_ENV | |
# called as "s4 db" | |
elif [ "$1" == "db" ]; then | |
# start debugger with paths | |
# we have to do extra work here because putting | |
# DYLD and PYTHONPATH in the environment breaks | |
# lldb when it tries to use Slicer's python. | |
# so we make a temp file with commands to set | |
# subprocess environment. | |
# note: piping the commands to lldb does | |
# not work because it sees stdin and exits | |
( | |
vars=$($SLICER_LAUNCH --launcher-dump-environment) | |
vars="settings set target.env-vars $vars" | |
fout=$(mktemp) | |
echo $vars > $fout | |
$LLDB -s $fout -- $SLICER_REAL ${@:2} --additional-module-paths $SLICER_MODULE_PATHS | |
); | |
# called as "s4 ds" | |
elif [ "$1" == "ds" ]; then | |
# start Qt Designer with paths | |
( | |
eval $SLICER_ENV | |
# add any extra paths in case there are plugins elsewhere | |
export QT_PLUGIN_PATH="$QT_PLUGIN_PATH;$SLICER_MODULE_PATHS" | |
$DESIGNER | |
) | |
# otherwise, just start Slicer with paths | |
else | |
( | |
eval $SLICER_ENV | |
$SLICER_REAL $@ --additional-module-paths $SLICER_MODULE_PATHS | |
); | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment