]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix some more shell madness. ./all compile now works from a directory with spaces.
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 10 Apr 2017 15:20:06 +0000 (11:20 -0400)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 10 Apr 2017 15:20:06 +0000 (11:20 -0400)
qcsrc/Makefile
qcsrc/tools/qcc.sh

index 903d8537e695bf35b33fb78889c814a38536cf7b..c660a7e94e5269d40aeea9f433fc2de70ee00bca 100644 (file)
@@ -1,7 +1,7 @@
 CPP := cc -xc -E
 QCC ?= gmqcc
 
-PROGS_OUT ?= $(CURDIR)/..
+PROGS_OUT ?= ..
 WORKDIR ?= ../.tmp
 
 QCCFLAGS_WATERMARK ?= $(shell git describe --tags --dirty='~')
@@ -102,15 +102,15 @@ export QCCFLAGS
 
 $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
        @ echo make[1]: Entering directory \`$(CURDIR)/client\'
-       ./tools/qcc.sh client $@ $<
+       ./tools/qcc.sh client $@ $<
 -include $(WORKDIR)/client.d
 
 $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
        @ echo make[1]: Entering directory \`$(CURDIR)/server\'
-       ./tools/qcc.sh server $@ $<
+       ./tools/qcc.sh server $@ $<
 -include $(WORKDIR)/server.d
 
 $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
        @ echo make[1]: Entering directory \`$(CURDIR)/menu\'
-       ./tools/qcc.sh menu $@ $<
+       ./tools/qcc.sh menu $@ $<
 -include $(WORKDIR)/menu.d
index 9951ec2fd7837645d812c9bc56e449dde0a05cdb..38c5c86340a28e6087e31960578dc0c6a1e11740 100755 (executable)
@@ -20,31 +20,39 @@ function qpp() {
         server) DEFS="-DGAMEQC -DSVQC"
         ;;
     esac
-    >&2 echo + ${CPP} ${@:3} ${DEFS} ${IN}
+    >&2 echo + ${CPP} "${@:3}" ${DEFS} "${IN}"
     set +e
     # additional information
-    ${CPP} ${@:3} ${DEFS} \
-        -dM 1>${WORKDIR}/${MODE}_macros.txt \
-        -H 2>${WORKDIR}/${MODE}_includes.txt \
-        ${IN}
+    ${CPP} "${@:3}" ${DEFS} \
+        -dM 1>"${WORKDIR}/${MODE}_macros.txt" \
+        -H 2>"${WORKDIR}/${MODE}_includes.txt" \
+        "${IN}"
     # main step
-    ${CPP} ${@:3} ${DEFS} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror ${IN} -o ${WORKDIR}/${MODE}.txt
+    ${CPP} "${@:3}" ${DEFS} -MMD -MP -MT "${OUT}" -Wall -Wundef -Werror "${IN}" -o "${WORKDIR}/${MODE}.txt"
     err=$?
     set -e
     if [ ${err} -ne 0 ]; then return ${err}; fi
-    sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ${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} $@)
+    (cd tools && ${QCC} "$@")
 }
 
 $(return >/dev/null 2>&1) || {
     MODE=$1
     OUT=$2
     IN=$3
-    qpp ${IN} ${OUT} -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${MODE}.qc
-    qcc ${QCCFLAGS} -o ${OUT} ../${WORKDIR}/${MODE}.qc
+    case "${OUT}" in
+      /*)
+        ;;
+      *)
+        OUT=${PWD}/${OUT}
+        ;;
+    esac
+    set -x
+    qpp "${IN}" "${OUT}" -I. ${QCCIDENT} ${QCCDEFS} > "${WORKDIR}/${MODE}.qc"
+    qcc ${QCCFLAGS} -o "${OUT}" "../${WORKDIR}/${MODE}.qc"
 }