-
Notifications
You must be signed in to change notification settings - Fork 14
/
build_game.sh
executable file
·106 lines (90 loc) · 2.14 KB
/
build_game.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
. ./build.cfg
safe_copy()
{
if [ -f "$1" ]
then
cp -v "$1" "$2"
fi
}
radiant_build()
{
if [ "$SKIP_RADIANT" = "1" ]; then
exit 0
fi
./make_mapdef.sh "$1"
# copy files over to RADIANT
if [ ! -z "$RADIANT_PATH" ]
then
if [ -d "$RADIANT_PATH/gamepacks/games" ];
then
mkdir -p "$RADIANT_PATH/gamepacks/$1.game/$1/"
safe_copy "./$1/radiant.game" "$RADIANT_PATH/gamepacks/games/$1.game"
safe_copy "./$1/entities.def" "$RADIANT_PATH/gamepacks/$1.game/$1/entities.def"
safe_copy "./$1/radiant.xml" "$RADIANT_PATH/gamepacks/$1.game/default_build_menu.xml"
fi
fi
}
if [ "$SKIP_UPDATE" = "1" ]; then
BUILD_UPDATE=0
fi
# if we're attempting to update the projects, check for git
if [ "$BUILD_UPDATE" -eq 1 ]; then
if ! [ -x "$(command -v git)" ]; then
printf "'git' is not installed.\n"
exit 1
fi
fi
set -e
SCRPATH="$( cd "$( dirname $(readlink -nf $0) )" && pwd )"
PATH="$SCRPATH/bin:$PATH"
if [ -x "$(command -v fteqcc)" ]; then
# We want to compile a specific game
if [ $# -gt 0 ]; then
if [ "$BUILD_UPDATE" -eq 1 ]; then
# git pull on the main repo
git pull
fi
cd "$SCRPATH/$1"/src
if [ "$BUILD_UPDATE" -eq 1 ]; then
# git pull on the main repo
git pull
fi
make
cd "$SCRPATH"
radiant_build "$1"
exit 0
fi
export OLDDIR=$(pwd)
cd ./src
if [ "$BUILD_UPDATE" -eq 1 ]; then
# git pull on the main repo
git pull
fi
make
cd "$OLDDIR"
# update repos first in case there's dependencies
find "$SCRPATH" -name Makefile | grep 'src\/Makefile' | grep -v engine | grep -v worldspawn | while read MFILE_N; do
NEWDIR=$(dirname "$MFILE_N")
cd "$NEWDIR"
if [ -f "$NEWDIR/../.git/config" ]; then
printf "Updating git repo inside $NEWDIR\n"
if [ "$BUILD_UPDATE" -eq 1 ]; then
git pull
fi
fi
cd $OLDDIR
done;
# now loop through _again_ to build
find "$SCRPATH" -name Makefile | grep 'src\/Makefile' | grep -v engine | grep -v worldspawn | while read MFILE_N; do
NEWDIR=$(dirname "$MFILE_N")
cd "$NEWDIR"
make
cd ..
export GAMEDIR=$(basename $PWD)
cd $OLDDIR
radiant_build "$GAMEDIR"
done;
else
printf "FTEQCC compiler is not present, please run build_engine.sh\n"
fi