aboutsummaryrefslogtreecommitdiff
path: root/glgen.sh
diff options
context:
space:
mode:
authorScott Anderson <ascent12@hotmail.com>2017-11-22 14:04:29 +1300
committerScott Anderson <ascent12@hotmail.com>2017-11-22 14:04:29 +1300
commit02374b945d26b094ba7cd771841f967c7b83c956 (patch)
treebd97f7f7ff9951349e2e3059a0f0e279fc2f6f4d /glgen.sh
parentb8a2bfbc73a7e21010469c95538cc39c559dbed8 (diff)
Change glapi.sh to generate both files
Diffstat (limited to 'glgen.sh')
-rwxr-xr-xglgen.sh72
1 files changed, 32 insertions, 40 deletions
diff --git a/glgen.sh b/glgen.sh
index 75d93c3b..5cb23225 100755
--- a/glgen.sh
+++ b/glgen.sh
@@ -7,15 +7,16 @@
# to fail if it can't load the function. You'll need to check if that function
# is NULL before using it.
-if [ $# -ne 2 ]; then
+if [ $# -ne 3 ]; then
exit 1
fi
SPEC=$1
-OUT=$2
+OUT_C=$2
+OUT_H=$3
BASE=$(basename "$SPEC" .txt)
-INCLUDE_GUARD=$(printf %s "$SPEC" | tr -c [:alnum:] _ | tr [:lower:] [:upper:])
+INCLUDE_GUARD=$(printf %s "$OUT_H" | tr -c [:alnum:] _ | tr [:lower:] [:upper:])
DECL=""
DEFN=""
@@ -57,46 +58,37 @@ while read -r COMMAND; do
fi
done < $SPEC
+cat > $OUT_H << EOF
+#ifndef $INCLUDE_GUARD
+#define $INCLUDE_GUARD
-case $OUT in
-*.h)
- cat > $OUT << EOF
- #ifndef $INCLUDE_GUARD
- #define $INCLUDE_GUARD
+#include <stdbool.h>
- #include <stdbool.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <EGL/eglmesaext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
- #include <EGL/egl.h>
- #include <EGL/eglext.h>
- #include <EGL/eglmesaext.h>
- #include <GLES2/gl2.h>
- #include <GLES2/gl2ext.h>
+bool load_$BASE(void);
+$DECL
- bool load_$BASE(void);
- $DECL
-
- #endif
+#endif
EOF
- ;;
-*.c)
- cat > $OUT << EOF
- #include <wlr/util/log.h>
- #include "$BASE.h"
- $DEFN
-
- bool load_$BASE(void) {
- static bool done = false;
- if (done) {
- return true;
- }
- $LOADER
-
- done = true;
- return true;
- }
+
+cat > $OUT_C << EOF
+#include <wlr/util/log.h>
+#include "$OUT_H"
+$DEFN
+
+bool load_$BASE(void) {
+ static bool done = false;
+ if (done) {
+ return true;
+ }
+$LOADER
+
+ done = true;
+ return true;
+}
EOF
- ;;
-*)
- exit 1
- ;;
-esac