- #!/bin/sh
- set -e
-
- # delete old dub.d if another run left it in /tmp
- rm -f /tmp/dub.d
-
- # find the executable location (note: must stay mac compatible here)
- VIBEBINARY=$(readlink "$0" || true)
- if [ ! -n "$VIBEBINARY" ]; then VIBEBINARY="$0"; fi
- VIBEPATH=$(dirname "$VIBEBINARY")
-
- # use pkg-config if possible or fallback to default flags
- LIBS=$(pkg-config --libs libevent libevent_pthreads libssl 2>/dev/null || echo "-levent_pthreads -levent -lssl -lcrypto")
- LIBS=$(echo "$LIBS" | sed 's/^-L/-L-L/; s/ -L/ -L-L/g; s/^-l/-L-l/; s/ -l/ -L-l/g')
- export LIBS
-
- # generate a file name for the temporary compile/run script
- START_SCRIPT=`mktemp -t dub.start.XXXXXXXX`
-
- # copy dub.d to /tmp and make it deletable by anyone
- cp -p "$VIBEPATH"/dub.d /tmp/dub.d
- chmod 666 /tmp/dub.d
-
- # run VPM and delete the dub.d file again, VPM will output the compile/run script
- 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
- rm /tmp/dub.d
-
- # compile/run the application
- chmod +x "$START_SCRIPT"
- "$START_SCRIPT"
- rm "$START_SCRIPT"