]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/tools/compilationunits.sh
better explain -O3 in compilation units test
[xonotic/xonotic-data.pk3dir.git] / qcsrc / tools / compilationunits.sh
index 55799ff7c4db70fe3d470284b1c8bc6b4548b69d..7a7ff17b6d554cbe6451ae2dda773ec81b017088 100755 (executable)
@@ -38,6 +38,11 @@ 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
@@ -59,8 +64,10 @@ function check1() {
     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 ${prog}/_all.qh \
+            ${includes} \
             -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${prog}.qc
     qcc ${QCCFLAGS} -o ../${WORKDIR}/test.dat ../${WORKDIR}/${prog}.qc >/dev/null
 }
@@ -72,6 +79,12 @@ function check() {
     done
 }
 
-check client
-check server
-check menu
+if [ ${#@} -eq 0 ]; then
+    check client
+    check server
+    check menu
+else
+    for var in ${@}; do
+        check ${var}
+    done
+fi