summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/ector/CMakeLists.txt7
-rwxr-xr-xsrc/lib/ector/gl/shader/gen_shaders.sh35
2 files changed, 28 insertions, 14 deletions
diff --git a/src/lib/ector/CMakeLists.txt b/src/lib/ector/CMakeLists.txt
index 71daae7705..fa6263408d 100644
--- a/src/lib/ector/CMakeLists.txt
+++ b/src/lib/ector/CMakeLists.txt
@@ -105,8 +105,7 @@ set(SOURCES
105 software/ector_software_surface.c 105 software/ector_software_surface.c
106) 106)
107 107
108add_custom_command( 108add_custom_target(ector-update-shaders
109 OUTPUT ${EFL_LIB_SOURCE_DIR}/gl/shader/ector_gl_shaders.x
110 COMMAND /bin/sh ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh 109 COMMAND /bin/sh ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh
111 DEPENDS 110 DEPENDS
112 ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh 111 ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh
@@ -114,5 +113,7 @@ add_custom_command(
114 ${EFL_LIB_SOURCE_DIR}/gl/shader/vertex.glsl 113 ${EFL_LIB_SOURCE_DIR}/gl/shader/vertex.glsl
115 ${EFL_LIB_SOURCE_DIR}/gl/shader/include.glsl 114 ${EFL_LIB_SOURCE_DIR}/gl/shader/include.glsl
116 WORKING_DIRECTORY "${EFL_LIB_SOURCE_DIR}" 115 WORKING_DIRECTORY "${EFL_LIB_SOURCE_DIR}"
117 COMMENT "SHADERS ${EFL_LIB_SOURCE_DIR}/gl/shader/ector_gl_shaders.x" 116 COMMENT "SHADERS src/lib/ector/gl/shader/ector_gl_shaders.x (if needed)"
118) 117)
118
119set(DEPENDENCIES ector-update-shaders)
diff --git a/src/lib/ector/gl/shader/gen_shaders.sh b/src/lib/ector/gl/shader/gen_shaders.sh
index c0192c3a01..9656e67ad9 100755
--- a/src/lib/ector/gl/shader/gen_shaders.sh
+++ b/src/lib/ector/gl/shader/gen_shaders.sh
@@ -10,30 +10,43 @@ OUTPUT="$DIR/ector_gl_shaders.x"
10if ! git rev-parse 2>> /dev/null >> /dev/null ; then exit 0 ; fi 10if ! git rev-parse 2>> /dev/null >> /dev/null ; then exit 0 ; fi
11if git diff --quiet --exit-code -- "$DIR" 11if git diff --quiet --exit-code -- "$DIR"
12then 12then
13 touch "$OUTPUT" 13 for f in gen_shaders.sh fragment.glsl vertex.glsl include.glsl; do
14 if [ "$DIR/$f" -nt "$OUTPUT" ]; then
15 touch "$OUTPUT"
16 break
17 fi
18 done
14 exit 0 19 exit 0
15fi 20fi
16 21
17exec 1<&-
18exec 1>"$OUTPUT"
19
20# Write header 22# Write header
21printf "/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */\n" 23rm -f "$OUTPUT.tmp"
22printf "/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */\n\n" 24cat <<EOF >> $OUTPUT.tmp
25/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */
26/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */
27
28EOF
23 29
24for SHD in fragment vertex ; do 30for SHD in fragment vertex ; do
25 m4 "$DIR/include.glsl" "$DIR/$SHD.glsl" > "$SHD.tmp" 31 m4 "$DIR/include.glsl" "$DIR/$SHD.glsl" > "$SHD.tmp"
26 32
27 OIFS="$IFS" 33 OIFS="$IFS"
28 IFS=`printf '\n+'` 34 IFS=$'\n'
29 IFS=${IFS%+} 35 echo -n "static const char ${SHD}_glsl[] =" >> "$OUTPUT.tmp"
30 printf "static const char "$SHD"_glsl[] ="
31 for LINE in `cat "$SHD.tmp"` ; do 36 for LINE in `cat "$SHD.tmp"` ; do
32 printf "\n \"$LINE\\\n\"" 37 printf "\n \"$LINE\\\n\"" >> "$OUTPUT.tmp"
33 done 38 done
34 printf ";\n\n" 39 printf ";\n\n" >> "$OUTPUT.tmp"
35 IFS="$OIFS" 40 IFS="$OIFS"
36 41
37 rm "$SHD.tmp" 42 rm "$SHD.tmp"
38done 43done
39 44
45if ! cmp "$OUTPUT" "$OUTPUT.tmp" >/dev/null 2>/dev/null; then
46 echo "$OUTPUT updated, please 'git commit' it."
47 rm -f "$OUTPUT"
48 mv "$OUTPUT.tmp" "$OUTPUT"
49else
50 rm -f "$OUTPUT.tmp"
51fi
52