From: Rudolf Polzer Date: Thu, 15 Jul 2010 15:45:00 +0000 (+0200) Subject: shader audit script improved (parses shaders now) X-Git-Tag: xonotic-v0.1.0preview~154^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=920b8fd74c20014d3aaeca656118c80f4f229bdc;p=xonotic%2Fxonotic-maps.pk3dir.git shader audit script improved (parses shaders now) --- diff --git a/scripts/shader-audit.sh b/scripts/shader-audit.sh index d5710c70..388f3944 100644 --- a/scripts/shader-audit.sh +++ b/scripts/shader-audit.sh @@ -1,5 +1,86 @@ #!/bin/sh +use_texture() +{ + echo "$1 uses texture $2" +} + +parsing_shader= + +parse_shaderstage() +{ + while read L A1 A2 Aother; do + case "$L" in + map) + case "$A1" in + '$lightmap') + ;; + *) + use_texture "$parsing_shader" "$A1" + ;; + esac + ;; + animmap) + for X in $A2 $Aother; do + use_texture "$parsing_shader" "$X" + done + ;; + '}') + break + ;; + *) + ;; + esac + done +} + +parse_shader() +{ + while read L A1; do + case "$L" in + qer_editorimage\ *) + use_texture "$parsing_shader" "$A1" + ;; + '{') + parse_shaderstage + ;; + '}') + break + ;; + *) + ;; + esac + done +} + +parse_shaderfile() +{ + while read L; do + case "$L" in + textures/*) + parsing_shader="$L" + ;; + '{') + parse_shader + ;; + *) + ;; + esac + done +} + +strip_comments() +{ + sed 's,//.*,,g; s,\r, ,g; s,\t, ,g; s, *, ,g; s, $,,; s,^ ,,; /^$/ d' +} + +t=`mktemp` +for X in *.shader; do + strip_comments < "$X" > "$t" + parse_shaderfile < "$t" +done +rm -f "$t" + ( cd ../textures; find */ -type f -not -name '*_norm.*' -not -name '*_glow.*' -not -name '*_gloss.*' -print ) | while IFS= read -r TEX; do TEX=${TEX%.*} # does it have a shader?