From: TimePath Date: Mon, 14 Mar 2016 10:26:01 +0000 (+1100) Subject: Fix compilation unit tester X-Git-Tag: xonotic-v0.8.2~1082 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=91396bb7a7d3f0707dd21abc251af615484d9cd9;p=xonotic%2Fxonotic-data.pk3dir.git Fix compilation unit tester --- diff --git a/qcsrc/Makefile b/qcsrc/Makefile index e149f001e..1290a32d9 100644 --- a/qcsrc/Makefile +++ b/qcsrc/Makefile @@ -92,6 +92,7 @@ $(QCCVERSIONFILE): | $(WORKDIR) @ $(RM) $(WORKDIR)/qccversion.* @ echo $(QCCVERSION) > $@ +export WORKDIR export CPP export QCC export QCCDEFS diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 1c7ed0386..2617634af 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -528,7 +528,7 @@ void m_tooltip(vector pos) { it = m_findtooltipitem(main, pos); - if (it.instanceOfListBox && it.isScrolling(it)) it = world; + if (it.instanceOfListBox && it.isScrolling(it)) it = NULL; if (it && prev_tooltip != it.tooltip) { diff --git a/qcsrc/tools/compilationunits.sh b/qcsrc/tools/compilationunits.sh index 98ea3c6f3..88bba83c0 100755 --- a/qcsrc/tools/compilationunits.sh +++ b/qcsrc/tools/compilationunits.sh @@ -1,16 +1,18 @@ #!/bin/bash set -eu cd "$(dirname "$0")" -cd .. -declare -a NOWARN=( - -Wno-field-redeclared - -Wno-unused-variable - -Wno-implicit-function-pointer +WORKDIR=../.tmp + +CPP="cc -xc -E" +QCC=../../../../gmqcc/gmqcc + +declare -a QCCDEFS=( + -DNDEBUG=1 ) -declare QCC=../../../gmqcc/gmqcc +QCCDEFS="${QCCDEFS[@]}" -declare -a QCC_FLAGS=( +declare -a QCCFLAGS=( -std=gmqcc -Wall -Werror -fftepp -fftepp-predefs -Wcpp @@ -19,13 +21,25 @@ declare -a QCC_FLAGS=( -frelaxed-switch -Ooverlap-locals ) +declare -a NOWARN=( + -Wno-field-redeclared + -Wno-unused-variable + -Wno-implicit-function-pointer + -Wno-missing-return-values +) +QCCFLAGS="${QCCFLAGS[@]} ${NOWARN[@]}" + +. qcc.sh +cd .. function check() { declare -l base="${1}" - declare -la predefs=("-D${2}" "lib/_all.inc" "${base}/_all.qh") - find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do - echo "$file" - ${QCC} "${QCC_FLAGS[@]}" "${NOWARN[@]}" "${predefs[@]}" "$file" >/dev/null + MODE=${2} + find ${base} -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do + 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 done } diff --git a/qcsrc/tools/qcc.sh b/qcsrc/tools/qcc.sh index b3ad199b8..6295828f4 100755 --- a/qcsrc/tools/qcc.sh +++ b/qcsrc/tools/qcc.sh @@ -1,26 +1,47 @@ #!/bin/sh set -eu -MODE=$1 -IN=$3 -OUT=$2 - +WORKDIR=${WORKDIR} +CPP=${CPP} QCC=${QCC} QCCIDENT="-DGMQCC" +QCCDEFS=${QCCDEFS} +QCCFLAGS=${QCCFLAGS} + +function qpp() { + IN=$1 + OUT=$2 + >&2 echo + ${CPP} ${@:3} ${IN} + # additional information + ${CPP} ${@:3} \ + -dM 1>${WORKDIR}/${MODE}_macros.txt \ + -H 2>${WORKDIR}/${MODE}_includes.txt \ + ${IN} + # main step + ${CPP} ${@:3} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror ${IN} -o ${WORKDIR}/${MODE}.txt + sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ${WORKDIR}/${MODE}.txt +} + +function qcc() { + >&2 echo + $(basename ${QCC}) $@ + # FIXME: relative compiler path is too deep + (cd tools && ${QCC} $@) +} + +$(return >/dev/null 2>&1) || { + MODE=$1 + OUT=$2 + IN=$3 -case ${MODE} in - client) PROG=CSQC - ;; - menu) PROG=MENUQC - ;; - server) PROG=SVQC - ;; -esac + case ${MODE} in + client) PROG=CSQC + ;; + menu) PROG=MENUQC + ;; + server) PROG=SVQC + ;; + esac -CPP="${CPP} -I. ${QCCIDENT} ${QCCDEFS} -D${PROG}" -${CPP} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror -o ../.tmp/${MODE}.txt ${IN} -${CPP} -dM 1>../.tmp/${MODE}_macros.txt -H 2>../.tmp/${MODE}_includes.txt ${IN} -sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ../.tmp/${MODE}.txt > ../.tmp/${MODE}.qc -cd ${MODE} -echo $(basename ${QCC}) ${QCCFLAGS} -o ${OUT} ${MODE}.qc -${QCC} ${QCCFLAGS} -o ${OUT} ../../.tmp/${MODE}.qc + qpp ${IN} ${OUT} -I. ${QCCIDENT} ${QCCDEFS} -D${PROG} > ${WORKDIR}/${MODE}.qc + qcc ${QCCFLAGS} -o ${OUT} ../${WORKDIR}/${MODE}.qc +}