[cogl] %.c: %.glsl codegen: use BUILT_SOURCES var + fix stringify.sh

Don't let stringify.sh write to the $srcdir + use the BUILT_SOURCES var in
Makefile.am so as to ensure all .c.  and .h files get generated from their
corresponding .glsl files before building other targets.
This commit is contained in:
Robert Bragg 2009-08-19 15:38:25 +01:00
parent 0aa31b4ebc
commit 391477e67b
2 changed files with 28 additions and 26 deletions

View File

@ -74,10 +74,14 @@ EXTRA_DIST = cogl-defines.h.in \
cogl-fixed-vertex-shader.glsl \ cogl-fixed-vertex-shader.glsl \
cogl-fixed-fragment-shader.glsl cogl-fixed-fragment-shader.glsl
.glsl.h : BUILT_SOURCES = \
/bin/sh $(top_srcdir)/clutter/cogl/gles/stringify.sh -h $< cogl-fixed-vertex-shader.h \
cogl-fixed-vertex-shader.c \
cogl-fixed-fragment-shader.h \
cogl-fixed-fragment-shader.c
.glsl.c : %.h: $(srcdir)/%.glsl
/bin/sh $(top_srcdir)/clutter/cogl/gles/stringify.sh $< /bin/sh $(srcdir)/stringify.sh -h $< > $@
%.c: $(srcdir)/%.glsl
/bin/sh $(srcdir)/stringify.sh $< > $@
cogl-gles2-wrapper.lo : cogl-fixed-vertex-shader.h cogl-fixed-fragment-shader.h

View File

@ -24,7 +24,7 @@
output_copyright () output_copyright ()
{ {
cat <<EOF > "$1"; cat <<EOF
/* /*
* Cogl * Cogl
* *
@ -52,35 +52,33 @@ EOF
# If two arguments are given then generate the header file instead # If two arguments are given then generate the header file instead
if test "$#" = 2; then if test "$#" = 2; then
bfname="${2%.glsl}"; bfname="${2%.glsl}"
bname=`basename "$bfname"`; bname=`basename "$bfname"`
varname=`echo -n "${bname}" | tr -c a-z _`; varname=`echo -n "${bname}" | tr -c a-z _`
guardname=`echo -n "${varname}" | tr a-z A-Z`; guardname=`echo -n "${varname}" | tr a-z A-Z`
guardname="__${guardname}_H"; guardname="__${guardname}_H"
headername="${bfname}.h";
output_copyright "${headername}"; output_copyright
echo >> "${headername}"; echo
echo "#ifndef ${guardname}" >> "${headername}"; echo "#ifndef ${guardname}"
echo "#define ${guardname}" >> "${headername}"; echo "#define ${guardname}"
echo >> "${headername}"; echo
sed -n \ sed -n \
-e 's/^ *\/\*\*\* \([a-zA-Z0-9_]*\) \*\*\*\//extern const char \1[];/p' \ -e 's/^ *\/\*\*\* \([a-zA-Z0-9_]*\) \*\*\*\//extern const char \1[];/p' \
< "$2" >> "${headername}"; < "$2"
echo >> "${headername}"; echo
echo "#endif /* ${guardname} */" >> "${headername}"; echo "#endif /* ${guardname} */"
else else
bfname="${1%.glsl}"; bfname="${1%.glsl}";
bname=`basename "${bfname}"`; bname=`basename "${bfname}"`;
cname="${bfname}.c";
varname=`echo -n "${bname}" | tr -c a-z _`; varname=`echo -n "${bname}" | tr -c a-z _`;
output_copyright "${cname}"; output_copyright
echo >> "${cname}"; echo
sed -n \ sed -n \
-e h \ -e h \
-e 's/^ *\/\*\*\* \([a-zA-Z0-9_]*\) \*\*\*\// ;\nconst char \1[] =/' \ -e 's/^ *\/\*\*\* \([a-zA-Z0-9_]*\) \*\*\*\// ;\nconst char \1[] =/' \
@ -91,6 +89,6 @@ else
-e 's/$/\\n"/' \ -e 's/$/\\n"/' \
-e ': got' \ -e ': got' \
-e p \ -e p \
< "$1" >> "${cname}"; < "$1"
echo " ;" >> "${cname}"; echo " ;"
fi; fi