X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Ftools%2Fcompilationunits.sh;h=d13cb6e091e8f2dd9e350f78e25fc30f7de33d35;hp=ebb232105f51a66d03770486c0afe3950c44f7fb;hb=af2f0cb624aaf967708b22e1303d113668af5114;hpb=f34fd47ee0a7f283ab60592a17399ec5a500416c diff --git a/qcsrc/tools/compilationunits.sh b/qcsrc/tools/compilationunits.sh index ebb232105..d13cb6e09 100755 --- a/qcsrc/tools/compilationunits.sh +++ b/qcsrc/tools/compilationunits.sh @@ -1,7 +1,27 @@ #!/usr/bin/env bash +[ -z "$QCCFLAGS_WATERMARK" ] && export QCCFLAGS_WATERMARK=$(git describe --tags --dirty='~') set -eu 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 CPP="cc -xc -E" @@ -10,12 +30,20 @@ CPP="cc -xc -E" declare -a QCCDEFS=( -DNDEBUG=1 -DXONOTIC=1 - -DWATERMARK="\"$(git describe --tags --dirty='~')\"" + -DWATERMARK="\"$QCCFLAGS_WATERMARK\"" + -DENABLE_EFFECTINFO=0 + -DENABLE_DEBUGDRAW=0 + -DENABLE_DEBUGTRACE=0 ) QCCDEFS="${QCCDEFS[@]}" declare -a QCCFLAGS=( -std=gmqcc + # Without -O3, GMQCC thinks some variables are used uninitialized if the initialization is done inside an `if (1)` block + # (which is created by e.g. BEGIN_MACRO) which would cause the compilation units test to fail. + # There doesn't appear to be any measurable increase in compile time + # and it allows us to get rid of some explicit initializations which are just useless noise. + -O3 -Wall -Werror -futf8 -freturn-assignments @@ -37,10 +65,12 @@ function check1() { declare -l prog="${1}" declare -l file="${2}" MODE=${prog} - qpp ${file} test.dat \ - -include lib/_all.inc -include ${prog}/_all.qh \ + includes="-include lib/_all.inc" + [ -f ${prog}/_all.qh ] && includes="${includes} -include ${prog}/_all.qh" + qpp ${file} test-${prog}.dat \ + ${includes} \ -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${prog}.qc - qcc ${QCCFLAGS} -o ../${WORKDIR}/test.dat ../${WORKDIR}/${prog}.qc >/dev/null + qcc ${QCCFLAGS} -o ../${WORKDIR}/test-${prog}.dat ../${WORKDIR}/${prog}.qc >/dev/null } function check() { @@ -50,6 +80,13 @@ function check() { done } -check client -check server -check menu +if [ ${#@} -eq 0 ]; then + check client + check server + check menu +else + for var in ${@}; do + var=${var#test-} + check ${var} + done +fi