forked from annulen/premake-dev-rgeary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildPremake.sh
executable file
·79 lines (67 loc) · 1.73 KB
/
buildPremake.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
78
#!/bin/bash
which readlink 2>&1 > /dev/null
if [[ $? == 0 ]]; then
premakeDir=$(readlink -f $(dirname $0) )
else
premakeDir=$(dirname $0)
fi
premake="$premakeDir/bin/debug/premake4 --scripts=$premakeDir/src"
systemScript="--systemScript=$premakeDir/premake-system.lua"
hashFile=$premakeDir/hash.tmp
cd $premakeDir
forceBuild=0
threads="-j16"
verbose=
debug=""
while getopts ":vdfj:-" OPTION
do
case "$OPTION" in
v) verbose=1 ;;
f) forceBuild=1 ;;
j) threads="-j$OPTARG" ;;
d) debug=" --debug " ;;
-) break ;;
\?) ;;
esac
done
shift $(($OPTIND-1))
if [[ $verbose ]]; then
echo "Building Premake"
fi
if [[ $forceBuild == 1 ]]; then
(rm -rf $premakeDir/bin
rm -rf $premakeDir/obj
rm *.ninja
rm .ninja_log) 2> /dev/null
fi
if [[ ! -f "$premakeDir/build.ninja" ]]; then
cp $premakeDir/build.ninja.default $premakeDir/build.ninja
fi
if [[ ! -f "$premakeDir/buildedges.ninja" ]]; then
cp $premakeDir/buildedges.ninja.default $premakeDir/buildedges.ninja
fi
# Test if premake exists
if [[ ! -f "$premakeDir/bin/release/premake4" || ! -f "$premakeDir/bin/debug/premake4" ]]; then
# Assume that ninja files in the depot are valid
ninja $threads
result=$?
if [[ $result != 0 ]]; then
echo "Error building Premake : ninja bootstrap of premake failed"
exit $result
fi
fi
# Now rebuild to make sure it's the latest
$premake --file=$premakeDir/premake4.lua embed nobuild --quiet --reporoot=$premakeDir "$@"
result=$?
if [[ $result == 0 ]]; then
$premake --file=$premakeDir/premake4.lua $systemScript --reporoot=$premakeDir ninja $debug $threads "$@"
result=$?
fi
if [[ $result != 0 ]]; then
echo "Error : Failed to build Premake"
rm $hashFile 2> /dev/null
fi
if [[ $verbose ]]; then
echo "---------------------"
fi
exit $result