summaryrefslogtreecommitdiff
path: root/src/lib/ector/gl/shader/gen_shaders.sh
blob: 139d5ea10998071f189642bfeee1394e83fca668 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash

# This script will generate a C file containing all the shaders used by Evas

DIR=`dirname $0`

OUTPUT=${DIR}/ector_gl_shaders.x

# Skip generation if there is no diff (or no git)
if ! git rev-parse 2>> /dev/null >> /dev/null ; then exit 0 ; fi
if git diff --quiet --exit-code -- "$DIR"
then
  touch "${OUTPUT}"
  exit 0
fi

exec 1<&-
exec 1>${OUTPUT}

# Write header
printf "/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */\n"
printf "/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */\n\n"

for shd in fragment vertex ; do
  m4 ${DIR}/include.glsl ${DIR}/${shd}.glsl > ${shd}.tmp

  OIFS=$IFS
  IFS=$'\n'
  printf "static const char ${shd}_glsl[] ="
  for line in `cat ${shd}.tmp` ; do
      printf "\n   \"${line}\\\n\""
  done
  printf ";\n\n"
  IFS=${OIFS}

  rm ${shd}.tmp
done