]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/tools/compilationunits.sh
Merge branch 'TimePath/modules'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / tools / compilationunits.sh
1 #!/usr/bin/env bash
2 set -eu
3 cd ${0%/*}
4
5 WORKDIR=../.tmp
6
7 CPP="cc -xc -E"
8 : ${QCC:=$PWD/../../../../gmqcc/gmqcc}
9
10 declare -a QCCDEFS=(
11     -DNDEBUG=1
12     -DXONOTIC=1
13     -DWATERMARK="\"$(git describe --tags --dirty='~')\""
14 )
15 QCCDEFS="${QCCDEFS[@]}"
16
17 declare -a QCCFLAGS=(
18     -std=gmqcc
19     -Wall -Werror
20     -futf8
21     -freturn-assignments
22     -frelaxed-switch
23     -Ooverlap-locals
24 )
25 declare -a NOWARN=(
26     -Wno-field-redeclared
27     -Wno-unused-variable
28     -Wno-implicit-function-pointer
29     -Wno-missing-return-values
30 )
31 QCCFLAGS="${QCCFLAGS[@]} ${NOWARN[@]}"
32
33 . qcc.sh
34 cd ..
35
36 function check1() {
37     declare -l prog="${1}"
38     declare -l file="${2}"
39     MODE=${prog}
40     qpp ${file} test.dat \
41             -include lib/_all.inc -include ${prog}/_all.qh \
42             -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${prog}.qc
43     qcc ${QCCFLAGS} -o ../${WORKDIR}/test.dat ../${WORKDIR}/${prog}.qc >/dev/null
44 }
45
46 function check() {
47     declare -l prog="${1}"
48     find ${prog} -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
49         check1 ${prog} ${file}
50     done
51 }
52
53 check client
54 check server
55 check menu