Guest User

tools/qcc.sh

a guest
Apr 28th, 2017
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. IFS=$' \n\t'
  4.  
  5. WORKDIR=${WORKDIR}
  6. CPP=${CPP}
  7. QCC=${QCC}
  8. QCCIDENT="-DGMQCC"
  9. QCCDEFS=${QCCDEFS}
  10. QCCFLAGS=${QCCFLAGS}
  11.  
  12. function qpp() {
  13.     IN=$1
  14.     OUT=$2
  15.     case ${MODE} in
  16.         client) DEFS="-DGAMEQC -DCSQC"
  17.         ;;
  18.         menu) DEFS="-DMENUQC"
  19.         ;;
  20.         server) DEFS="-DGAMEQC -DSVQC"
  21.         ;;
  22.     esac
  23.     >&2 echo + ${CPP} ${@:3} ${DEFS} ${IN}
  24.     set +e
  25.     # additional information
  26.     ${CPP} ${@:3} ${DEFS} \
  27.         -dM 1>${WORKDIR}/${MODE}_macros.txt \
  28.         -H 2>${WORKDIR}/${MODE}_includes.txt \
  29.         ${IN}
  30.     # main step
  31.     ${CPP} ${@:3} ${DEFS} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror ${IN} -o ${WORKDIR}/${MODE}.txt
  32.     err=$?
  33.     set -e
  34.     if [ ${err} -ne 0 ]; then return ${err}; fi
  35.     sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ${WORKDIR}/${MODE}.txt
  36.     cp ${WORKDIR}/${MODE}.qc ${WORKDIR}/orig.${MODE}.qc
  37.     grep --invert-match "^# " ${WORKDIR}/orig.${MODE}.qc > ${WORKDIR}/${MODE}.qc
  38. }
  39.  
  40. function qcc() {
  41.     >&2 echo + $(basename ${QCC}) $@
  42.     # FIXME: relative compiler path is too deep
  43.     (cd tools && ${QCC} $@)
  44. }
  45.  
  46. $(return >/dev/null 2>&1) || {
  47.     MODE=$1
  48.     OUT=$2
  49.     IN=$3
  50.     qpp ${IN} ${OUT} -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${MODE}.qc
  51.     qcc ${QCCFLAGS} -o ${OUT} ../${WORKDIR}/${MODE}.qc
  52. }
RAW Paste Data