forked from OpenACD/OpenACD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.sh
executable file
·77 lines (67 loc) · 1.58 KB
/
hooks.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
72
73
74
75
76
77
#!/usr/bin/env bash
BASEDIR="$( cd "$( dirname "$0" )" && pwd)"
REBAR="$BASEDIR/rebar"
function pre_compile {
ebinDir="$BASEDIR/ebin"
if [ ! -d "$ebinDir" ]; then
mkdir "$ebinDir"
fi
# record what commit/version openacd is at
OPENACD_COMMIT=""
if [ -d "$BASEDIR/.git" ]
then
OPENACD_COMMIT=`git log -1 --pretty=format:%H`
fi
if [ -e "$BASEDIR/include/commit_ver.hrl" ] && [ ! $OPENACD_COMMIT ]
then
exit 0
else
if [ ! $OPENACD_COMMIT ]
then
OPENACD_COMMIT="undefined"
else
OPENACD_COMMIT="\"$OPENACD_COMMIT\""
fi
fi
echo "%% automatically generated by OpenACD precompile script. Editing means
%% it will just get overwritten again.
-define(OPENACD_COMMIT, $OPENACD_COMMIT)." > "$BASEDIR"/include/commit_ver.hrl
}
function pre_get-deps {
if [ "${GIT_UPDATE_DISABLED}" != "1" ]; then
echo "Updating submodules..."
cd "$BASEDIR"
git submodule init && git submodule update
cd -
fi
}
function post_get-deps {
# needed by rebar to be added to lib path
mkdir -p "$BASEDIR/ebin"
# create temp apps directory
appsDir="$BASEDIR/apps"
if [ ! -d "$appsDir" ]; then
mkdir -p "$appsDir"
includeApps=./include_apps/*
for app in $includeApps; do
ln -sf ../"$app" "$appsDir"
done
oaDir="$appsDir"/OpenACD
mkdir "$oaDir"
ln -sf ../../ebin "$oaDir"/ebin
ln -sf ../../src "$oaDir"/src
ln -sf ../../include "$oaDir"/include
ln -sf ../../priv "$oaDir"/priv
ln -sf ../../deps "$oaDir"/deps
fi
}
case "$1" in
"pre_get-deps")
pre_get-deps;;
"post_get-deps")
post_get-deps;;
"pre_compile")
pre_compile;;
"post_compile")
post_compile;;
esac