Notes
Development Environment Hacks
In the vein of
BryanStearnsDevEnvNotes and
MorgenSagenDevEnvNotes, I sat down and hacked some
Z-Shell scripts for doing some of the things they describe.
Some of the code depends on this function from my
.zshrc, which removes elements from the path array and PATH environment variable
# remove $2 from the path (w/o $) indicated by $1
# i.e 'remove-from-path path /usr/local/bin'
# based on rationalize-path in http://zsh.sunsite.dk/Contrib/startup/users/debbiep/dot.zshenv
remove-from-path () {
# Note that this works only on arrays, not colon-delimited strings.
# Not that this is a problem now that there is typeset -T.
local element
local build
build=()
# Evil quoting to survive an eval and to make sure that
# this works even with variables containing IFS characters, if I'm
# crazy enough to setopt shwordsplit.
eval '
foreach element in "$'"$1"'[@]"
do
if [[ -d "$element" && "$element" != $2 ]]
then
build=("$build[@]" "$element")
fi
done
'"$1"'=( "$build[@]" )
'
}
I normally setup my OSAF environment by running this script. It assumes that Chandler source trees are under
$OSAF_TREE_ROOT. I'm also using Morgen's patch to move the download archives.
You can use the
chandler-tree function to switch your environment between Chandler source trees. You should be able to use tab completion to complete the names of various trees under $OSAF_TREE_ROOT. You can also use
chandler-mode to switch between release and debug modes. Again, you should be able to tab complete the modes. These scripts do not switch between different versions of the binaries, internal, or external.
#!/usr/bin/env zsh
# set basic Chandler variables
export OSAF_HOME=$HOME/work/osaf
export CHANDLERBIN=$OSAF_HOME/binaries
export CHANDLERARCHIVES=$OSAF_HOME/downloads
export BUILD_ROOT=$OSAF_HOME/src/external
export CHANDLERHOME=$OSAF_HOME/src/trees/head
export PATH=$CHANDLERBIN/release:$OSAF_HOME/src/hardhat:$PATH
# the next line is commmented out because ~/Library/lib/python/dateutil conflicts w/ Chandler's dateutil
#export PYTHONPATH=$HOME/work/osaf/lib:$PYTHONPATH
unset PYTHONPATH
unset PYTHONSTARTUP
alias osaf-pycrust="RunPython $CHANDLERBIN/release/Library/Frameworks/Python.framework/Versions/Current/lib/python2.4/site-packages/wx/py/PyCrust.py "
#alias osaf-python="$CHANDLERHOME/release/RunPython"
alias osaf-ipython="LESS=-ceMqsr $TWL_BIN/osaf-ipython.sh -profile osaf"
#alias osaf-chandler='(cd $CHANDLERHOME/Chandler; $CHANDLERHOME/release/RunRelease)'
alias fix-chandler-readline='cp /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload/readline.so $CHANDLERBIN/release/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload/readline.so'
export OSAF_TREE_ROOT=$OSAF_HOME/src
export OSAF_TREE_SERVER=<redacted>.sauria.com
export OSAF_TREE_SERVER_ROOT=work/osaf/src
# sync local source tree to server
upsync-trees() {
rsync $* -avz --delete $OSAF_TREE_ROOT/trees $OSAF_TREE_SERVER:$OSAF_TREE_SERVER_ROOT
}
# sync local source tree from server
downsync-trees() {
rsync $* -avz --delete $OSAF_TREE_SERVER:$OSAF_TREE_SERVER_ROOT/trees $OSAF_TREE_ROOT
}
# switch to a new chandler tree
chandler-tree() {
# autocompleting list of trees/branches
# cdable variables named after trees/branches
echo "Switching to tree $1"
export CHANDLERHOME=$OSAF_HOME/src/trees/$1
export CHANDLER_REP=$CHANDLERHOME/repository
cd $CHANDLERHOME
}
# use old style completion
function osaf_trees { reply=(`echo $OSAF_TREE_ROOT/trees/*(/:t)`) }
compctl -K osaf_trees chandler-tree
# switch between debug and release
chandler-mode() {
if [[ $1 == "debug" ]] then
remove-from-path path $CHANDLERBIN/release
else
remove-from-path path $CHANDLERBIN/debug
fi
# release vs debug
echo "switching to $1"
export PATH=$CHANDLERBIN/$1:$PATH
}
compctl -k "(release debug)" chandler-mode
# for long running jobs
hh() {
time $OSAF_HOME/src/hardhat/hardhat.py $*;
say 'Hardhat is done'
}
# display set messes up chandler build?
#unset DISPLAY
cdable_vars=($cdable_vars OSAF_HOME CHANDLERHOME CHANDLER_REP)
chandler-tree head