-
Notifications
You must be signed in to change notification settings - Fork 13
/
set_env.sh
62 lines (54 loc) · 1.55 KB
/
set_env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# This file must be sourced with ". set_env.sh" or "source set_env.sh"
if ! [ -d ./gibbon-compiler ]; then
echo "Error: please source this handy set_env script from the directory that contains it.";
return 1
fi
export GIBBONDIR=`pwd`
export PLTADDONDIR=$GIBBONDIR/.racket_sandbox/
STK="stack"
BUILD_ARGS=" --install-ghc build "
# A shortcut to make things easier:
function gib() {
cur=`pwd`
cd $GIBBONDIR/gibbon-compiler/
$STK $BUILD_ARGS
if [ "$?" == "0" ]; then
# Version 1: find the executable, but execute natively:
# CMD=`$STK exec -- which gibbon`;
# cd $cur;
# $CMD $@;
# Version 2: execute inside the environment:
$STK exec -- bash -c "cd $cur && gibbon $*";
cd $cur
else
cd $cur;
echo "'stack build' failed";
return 1;
fi
}
# A debugging version that prints back-traces upon exceptions.
#
# WARNING: as of stack 1.2 you need to stack-clean between using
# tc/tcd. It is not smart enough to rebuild automatically and keep
# the build artifacts separate.
function gib_dbg() {
BUILD_ARGS="$BUILD_ARGS --trace" gib $@
}
# Nix version
function gibn() {
STK="stack --nix" gib $@
}
function gibd() {
# --docker-auto-pull isn't working:
(cd $GIBBONDIR/gibbon-compiler/ && stack docker pull 2> /dev/null) && \
STK="stack --docker " gib $@
}
# A quick verison that doesn't check for recompile.
function gibq() {
cur=`pwd`
cd $GIBBONDIR/gibbon-compiler/
CMD=`stack exec -- which gibbon`
cd $cur
$CMD $@
}