]> git.xonotic.org Git - xonotic/xonotic.git/blob - all
use the customgame DP feature for branding as Xonotic
[xonotic/xonotic.git] / all
1 #!/bin/sh
2
3 set -e
4
5 verbose()
6 {
7         echo "\e[1m+ $@\e[m"
8         "$@"
9 }
10
11 repos_urls="
12         .
13         data/xonotic-data.pk3dir
14         data/xonotic-maps.pk3dir
15         data/xonotic-music.pk3dir
16         data/xonotic-nexcompat.pk3dir
17         darkplaces
18         fteqcc@git://github.com/Blub/qclib.git
19 "
20
21 repos=`for X in $repos_urls; do echo "${X%%@*}"; done`
22
23 if [ "$#" = 0 ]; then
24         set -- help
25 fi
26 cmd=$1
27 shift
28
29 d0=`pwd`
30 case "$cmd" in
31         update|pull)
32                 base=`git config remote.origin.url`
33                 base=${base%xonotic.git}
34                 for dcomplete in $repos_urls; do
35                         case "$dcomplete" in
36                                 *@*)
37                                         d=${dcomplete%%@*}
38                                         url=${dcomplete#*@}
39                                         switch=false
40                                         ;;
41                                 *)
42                                         d=${dcomplete%%@*}
43                                         url=$base${d##*/}.git
44                                         switch=true
45                                         ;;
46                         esac
47                         if [ -d "$d0/$d" ]; then
48                                 verbose cd "$d0/$d"
49                                 case "$d" in
50                                         .)
51                                                 ;;
52                                         *)
53                                                 if $switch; then
54                                                         verbose git config remote.origin.url "$url"
55                                                 fi
56                                                 ;;
57                                 esac
58                                 verbose git pull
59                                 cd "$d0"
60                         else
61                                 verbose git clone "$url" "$d0/$d"
62                         fi
63                 done
64                 ;;
65         checkout|switch)
66                 remote=$1
67                 branch=$2
68                 if [ -z "$branch" ]; then
69                         branch=$remote
70                         remote=origin
71                 fi
72                 exists=false
73                 for d in $repos; do
74                         verbose cd "$d0/$d"
75                         if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
76                                 exists=true
77                                 verbose git checkout "$branch"
78                         elif git rev-parse "refs/remotes/$remote/$branch" >/dev/null 2>&1; then
79                                 exists=true
80                                 verbose git checkout --track -b "$branch" "$remote/$branch"
81                         else
82                                 verbose git checkout master
83                         fi
84                         cd "$d0"
85                 done
86                 if ! $exists; then
87                         echo "The requested branch was not found in any repository."
88                 fi
89                 "$0" branch
90                 ;;
91         branch)
92                 remote=$1
93                 branch=$2
94                 if [ -z "$branch" ]; then
95                         branch=$remote
96                         remote=origin
97                 fi
98                 if [ -z "$branch" ]; then
99                         for d in $repos; do
100                                 cd "$d0/$d"
101                                 r=`git symbolic-ref HEAD`
102                                 r=${r#refs/heads/}
103                                 echo "$d is at $r"
104                                 cd "$d0"
105                         done
106                 else
107                         for d in $repos; do
108                                 cd "$d0/$d"
109                                 a=
110                                 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
111                                         echo "Branch in $d?"
112                                         read -r a
113                                 done
114                                 if [ x"$a" = x"y" ]; then
115                                         verbose git push "$remote" HEAD:"$branch"
116                                         verbose git checkout --track -b "$branch" "$remote/$branch"
117                                 fi
118                                 cd "$d0"
119                         done
120                         "$0" branch
121                 fi
122                 ;;
123         branches)
124                 for d in $repos; do
125                         cd "$d0/$d"
126                         echo "In $d:"
127                         git branch -a | sed 's/^/  /; /->/d'
128                         cd "$d0"
129                 done
130                 ;;
131         push)
132                 for d in $repos; do
133                         cd "$d0/$d"
134                         r=`git symbolic-ref HEAD`
135                         r=${r#refs/heads/}
136                         a=
137                         if git log "origin/$r".."$r" | grep .; then
138                                 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
139                                         echo "Push $r in $d?"
140                                         read -r a
141                                 done
142                                 if [ x"$a" = x"y" ]; then
143                                         verbose git push `git config "branch.$r.remote" || echo origin` HEAD
144                                 fi
145                         fi
146                         cd "$d0"
147                 done
148                 ;;
149         compile)
150                 if [ -z "$MAKEFLAGS" ]; then
151                         if [ -f /proc/cpuinfo ]; then
152                                 ncpus=$((`grep -c '^processor   :' /proc/cpuinfo`+0))
153                                 if [ $ncpus -gt 1 ]; then
154                                         MAKEFLAGS=-j$ncpus
155                                 fi
156                         fi
157                 fi
158                 verbose cd "$d0/fteqcc"
159                 verbose make $MAKEFLAGS
160                 verbose cd "$d0/data/xonotic-data.pk3dir"
161                 verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" $MAKEFLAGS
162                 verbose cd "$d0/darkplaces"
163                 verbose make $MAKEFLAGS sv-debug
164                 verbose make $MAKEFLAGS cl-debug
165                 verbose make $MAKEFLAGS sdl-debug
166                 ;;
167         run)
168                 client=-sdl
169                 case "$1" in
170                         sdl|glx|agl|dedicated)
171                                 client=-$1
172                                 shift
173                                 ;;
174                         wgl)
175                                 client=
176                                 shift
177                                 ;;
178                 esac
179                 if ! [ -x "darkplaces/darkplaces$client" ]; then
180                         if [ -x "darkplaces/darkplaces$client.exe" ]; then
181                                 client=$client.exe
182                         else
183                                 echo "Client darkplaces/darkplaces$client not found, aborting"
184                                 exit 1
185                         fi
186                 fi
187                 #verbose "darkplaces/darkplaces$client" -xonotic "$@"
188                 verbose "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
189                 ;;
190         each|foreach)
191                 for d in $repos; do
192                         verbose cd "$d0/$d"
193                         verbose "$@"
194                         cd "$d0"
195                 done
196                 ;;
197         *)
198                 echo "Usage:"
199                 echo "  $0 pull"
200                 echo "  $0 push"
201                 echo "  $0 branches"
202                 echo "  $0 branch <remote> <branchname>"
203                 echo "  $0 checkout"
204                 echo "  $0 compile"
205                 echo "  $0 run <client> <options>"
206                 echo "  $0 each <command>"
207                 ;;
208 esac