]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/tools/compilationunits.sh
ok, the files are only present when ./all compile was used before running this test
[xonotic/xonotic-data.pk3dir.git] / qcsrc / tools / compilationunits.sh
1 #!/usr/bin/env bash
2 set -eu
3 cd ${0%/*}
4
5 # if these files exist from previous compilation, `./all compile` will stop
6 # detecting changes after running this script so delete them to trigger
7 # a recompile next time
8 if [ -f ../../csprogs.dat ]; then
9     rm ../../csprogs.dat
10 fi
11
12 if [ -f ../../menu.dat ]; then
13     rm ../../menu.dat
14 fi
15
16 if [ -f ../../progs.dat ]; then
17     rm ../../progs.dat
18 fi
19
20 WORKDIR=../.tmp
21
22 CPP="cc -xc -E"
23 : ${QCC:=$PWD/../../../../gmqcc/gmqcc}
24
25 declare -a QCCDEFS=(
26     -DNDEBUG=1
27     -DXONOTIC=1
28     -DWATERMARK="\"$(git describe --tags --dirty='~')\""
29 )
30 QCCDEFS="${QCCDEFS[@]}"
31
32 declare -a QCCFLAGS=(
33     -std=gmqcc
34     -Wall -Werror
35     -futf8
36     -freturn-assignments
37     -frelaxed-switch
38     -Ooverlap-locals
39 )
40 declare -a NOWARN=(
41     -Wno-field-redeclared
42     -Wno-unused-variable
43     -Wno-implicit-function-pointer
44     -Wno-missing-return-values
45 )
46 QCCFLAGS="${QCCFLAGS[@]} ${NOWARN[@]}"
47
48 . qcc.sh
49 cd ..
50
51 function check1() {
52     declare -l prog="${1}"
53     declare -l file="${2}"
54     MODE=${prog}
55     qpp ${file} test.dat \
56             -include lib/_all.inc -include ${prog}/_all.qh \
57             -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${prog}.qc
58     qcc ${QCCFLAGS} -o ../${WORKDIR}/test.dat ../${WORKDIR}/${prog}.qc >/dev/null
59 }
60
61 function check() {
62     declare -l prog="${1}"
63     find ${prog} -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
64         check1 ${prog} ${file}
65     done
66 }
67
68 check client
69 check server
70 check menu