]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/tools/genmod.sh
Merge branch 'master' into Mario/showspecs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / tools / genmod.sh
1 #!/usr/bin/env bash
2 set -eu
3 cd ${0%/*}
4 cd ..
5 ROOT=$PWD/
6
7 MOD=_mod
8
9 function genmod() {
10     # use context to work around cmake issue #12619
11     CTX="${PWD#$ROOT}/"
12     echo '// generated file; do not modify' > ${MOD}.inc
13     echo '// generated file; do not modify' > ${MOD}.qh
14     for f in $(ls | sort -k 1,1 -t .); do
15         if [[ "$f" == cl_* ]]; then if [[ -f "${f#cl_}" ]]; then continue; fi; fi
16         if [[ "$f" == sv_* ]]; then if [[ -f "${f#sv_}" ]]; then continue; fi; fi
17         if [[ "$f" == ui_* ]]; then if [[ -f "${f#ui_}" ]]; then continue; fi; fi
18         if [[ "$f" == *.qc ]]; then
19             echo "#include <${CTX}$f>" >> ${MOD}.inc
20             echo "#include <${CTX}${f%.qc}.qh>" >> ${MOD}.qh
21             if [[ -f "cl_$f" ]]; then echo -e "#ifdef CSQC\n    #include <${CTX}cl_$f>\n#endif" >> ${MOD}.inc; fi
22             if [[ -f "sv_$f" ]]; then echo -e "#ifdef SVQC\n    #include <${CTX}sv_$f>\n#endif" >> ${MOD}.inc; fi
23             if [[ -f "ui_$f" ]]; then echo -e "#ifdef MENUQC\n    #include <${CTX}ui_$f>\n#endif" >> ${MOD}.inc; fi
24         fi
25     done
26     # echo >> ${MOD}
27     for f in *; do if [ -d "$f" ]; then
28         (cd -- "$f" && genmod)
29         # echo "#include \"$f/MOD\"" >> ${MOD}
30     fi; done
31 }
32
33 (cd lib; genmod)
34 (cd common; genmod)
35 (cd ecs; genmod)
36 (cd client; genmod)
37 (cd server; genmod)
38 (cd menu; genmod)