X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Ftools%2Fcompilationunits.sh;h=e3d1eb01368df1c714c55d7264eda99e89ff8bbd;hp=3c794e93fbba747b9eb43b6954a86a3c4a0856cf;hb=3ac61b98c83be079c61cf525491d2028b2a889dc;hpb=edf01df130d0d1877461561178b8833a9ab6051c diff --git a/qcsrc/tools/compilationunits.sh b/qcsrc/tools/compilationunits.sh index 3c794e93fb..e3d1eb0136 100755 --- a/qcsrc/tools/compilationunits.sh +++ b/qcsrc/tools/compilationunits.sh @@ -1,6 +1,25 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu -cd "$(dirname "$0")" +cd ${0%/*} + +# This script attempts to build the codebase in every possible header configuration, +# to check that all files #include what they need, so that we can eventually move away +# from a unity build and into incremental compilation. + +# If these files exist from previous compilation, `./all compile` will stop +# detecting changes after running this script so delete them to trigger +# a recompile next time. +if [ -f ../../csprogs.dat ]; then + rm ../../csprogs.dat +fi + +if [ -f ../../menu.dat ]; then + rm ../../menu.dat +fi + +if [ -f ../../progs.dat ]; then + rm ../../progs.dat +fi WORKDIR=../.tmp @@ -9,8 +28,11 @@ CPP="cc -xc -E" declare -a QCCDEFS=( -DNDEBUG=1 + -DXONOTIC=1 -DWATERMARK="\"$(git describe --tags --dirty='~')\"" - -DDEBUGPATHING=0 + -DENABLE_EFFECTINFO=0 + -DENABLE_DEBUGDRAW=0 + -DENABLE_DEBUGTRACE=0 ) QCCDEFS="${QCCDEFS[@]}" @@ -34,23 +56,30 @@ QCCFLAGS="${QCCFLAGS[@]} ${NOWARN[@]}" cd .. function check1() { - declare -l base="${1}" - MODE=${2} - declare -l file="${3}" + declare -l prog="${1}" + declare -l file="${2}" + MODE=${prog} + includes="-include lib/_all.inc" + [ -f ${prog}/_all.qh ] && includes="${includes} -include ${prog}/_all.qh" qpp ${file} test.dat \ - -include lib/_all.inc -include ${base}/_all.qh \ - -I. ${QCCIDENT} ${QCCDEFS} -D${MODE} > ${WORKDIR}/${MODE}.qc - qcc ${QCCFLAGS} -o ../${WORKDIR}/test.dat ../${WORKDIR}/${MODE}.qc >/dev/null + ${includes} \ + -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${prog}.qc + qcc ${QCCFLAGS} -o ../${WORKDIR}/test.dat ../${WORKDIR}/${prog}.qc >/dev/null } function check() { - declare -l base="${1}" - MODE=${2} - find ${base} -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do - check1 ${base} ${MODE} ${file} + declare -l prog="${1}" + find ${prog} -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do + check1 ${prog} ${file} done } -check client CSQC -check server SVQC -check menu MENUQC +if [ ${#@} -eq 0 ]; then + check client + check server + check menu +else + for var in ${@}; do + check ${var} + done +fi