Newer
Older
dub_jkp / bin / dub
@Sönke Ludwig Sönke Ludwig on 2 Nov 2012 1 KB Renamed the files in the bin directory.
  1. #!/bin/sh
  2. set -e
  3.  
  4. # delete old dub.d if another run left it in /tmp
  5. rm -f /tmp/dub.d
  6.  
  7. # find the executable location (note: must stay mac compatible here)
  8. VIBEBINARY=$(readlink "$0" || true)
  9. if [ ! -n "$VIBEBINARY" ]; then VIBEBINARY="$0"; fi
  10. VIBEPATH=$(dirname "$VIBEBINARY")
  11.  
  12. # use pkg-config if possible or fallback to default flags
  13. LIBS=$(pkg-config --libs libevent libevent_pthreads libssl 2>/dev/null || echo "-levent_pthreads -levent -lssl -lcrypto")
  14. LIBS=$(echo "$LIBS" | sed 's/^-L/-L-L/; s/ -L/ -L-L/g; s/^-l/-L-l/; s/ -l/ -L-l/g')
  15. export LIBS
  16.  
  17. # generate a file name for the temporary compile/run script
  18. START_SCRIPT=`mktemp -t dub.start.XXXXXXXX`
  19.  
  20. # copy dub.d to /tmp and make it deletable by anyone
  21. cp -p "$VIBEPATH"/dub.d /tmp/dub.d
  22. chmod 666 /tmp/dub.d
  23.  
  24. # run VPM and delete the dub.d file again, VPM will output the compile/run script
  25. rdmd -g -w -property -I"$VIBEPATH"/../source $LIBS -Jviews -Isource /tmp/dub.d "$VIBEPATH" "$START_SCRIPT" $1 $2 $3 $4 $5 $6 $7 $8 $9
  26. rm /tmp/dub.d
  27.  
  28. # compile/run the application
  29. chmod +x "$START_SCRIPT"
  30. "$START_SCRIPT"
  31. rm "$START_SCRIPT"