This repository has been archived by the owner on Feb 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
/
new-platform.sh
executable file
·72 lines (65 loc) · 1.73 KB
/
new-platform.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
63
64
65
66
67
68
69
70
71
#!/bin/sh
#
# There are two ways to invoke this script:
#
# 1) ./platform.sh GHC_BINDIST CABAL STACK build-all
#
# 2) Create the file config.platform with the contents:
#
# GHC_BINDIST=...
# CABAL=...
# STACK=...
#
# and then run this script as:
#
# ./platform.sh build-all
#
set -e
HPTOOL=hptool/dist/build/hptool/hptool
HPTOOL_ALT=hptool/.cabal-sandbox/bin/hptool
if ( cabal sandbox --help >/dev/null 2>&1 ) ; then
if [ \! -d hptool/.cabal-sandbox ]
then
echo '***'
echo '*** Setting up sandbox for hptool'
echo '***'
cabal update
(cd hptool; cabal sandbox init; cabal install --only-dependencies)
fi
else
if ( cabal install --dry-run --only-dependencies | grep -q 'would be installed' ) ; then
echo '=== pre-requisite packages for hptool are not installed'
echo ' run the following:'
echo ' cd hptool ; cabal install --only-dependencies'
exit 1
fi
fi
echo '***'
echo '*** Building hptool'
echo '***'
(cd hptool; cabal build)
if [ "$HPTOOL_ALT" -nt "$HPTOOL" ] ; then
HPTOOL="$HPTOOL_ALT"
fi
SCRIPT=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT")
CONFIG_PATH="$SCRIPT_DIR/config.platform"
echo '***'
echo '*** Running hptool'
echo '***'
if [ -e "$CONFIG_PATH" ]; then
echo "=== sourcing $CONFIG_PATH"
. "$CONFIG_PATH"
ok="1"
if [ -z "$STACK" ]; then echo "STACK is not set"; ok=""; fi
if [ -z "$CABAL" ]; then echo "CABAL is not set"; ok=""; fi
if [ -z "$GHC_BINDIST" ]; then echo "GHC_BINDIST is not set"; ok=""; fi
if [ -z "$ok" ]; then
echo "config not complete: " $CONFIG_PATH
else
echo "*** Using parameters from $CONFIG_PATH"
exec $HPTOOL "$GHC_BINDIST" "$CABAL" "$STACK" "$@"
fi
else
exec $HPTOOL "$@"
fi