From 920b8fd74c20014d3aaeca656118c80f4f229bdc Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 15 Jul 2010 17:45:00 +0200 Subject: [PATCH] shader audit script improved (parses shaders now) --- scripts/shader-audit.sh | 81 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) 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? -- 2.39.2