From 02374b945d26b094ba7cd771841f967c7b83c956 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Nov 2017 14:04:29 +1300 Subject: [PATCH] Change glapi.sh to generate both files --- glgen.sh | 68 ++++++++++++++++++++-------------------------- render/meson.build | 17 ++++-------- 2 files changed, 36 insertions(+), 49 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 - #include +#include +#include +#include +#include +#include - #include - #include - #include - #include - #include +bool load_$BASE(void); +$DECL - bool load_$BASE(void); - $DECL - - #endif +#endif EOF - ;; -*.c) - cat > $OUT << EOF - #include - #include "$BASE.h" - $DEFN - bool load_$BASE(void) { - static bool done = false; - if (done) { - return true; - } - $LOADER +cat > $OUT_C << EOF +#include +#include "$OUT_H" +$DEFN - done = true; - return true; - } +bool load_$BASE(void) { + static bool done = false; + if (done) { + return true; + } +$LOADER + + done = true; + return true; +} EOF - ;; -*) - exit 1 - ;; -esac diff --git a/render/meson.build b/render/meson.build index 749d1393..1eea9a83 100644 --- a/render/meson.build +++ b/render/meson.build @@ -1,14 +1,9 @@ glgen = find_program('../glgen.sh') -glapi_c = custom_target('glapi.c', +glapi = custom_target('glapi', input: 'glapi.txt', - output: '@BASENAME@.c', - command: [glgen, '@INPUT@', '@OUTPUT@'], -) -glapi_h = custom_target('glapi.h', - input: 'glapi.txt', - output: '@BASENAME@.h', - command: [glgen, '@INPUT@', '@OUTPUT@'], + output: ['@BASENAME@.c', '@BASENAME@.h'], + command: [glgen, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@'], ) lib_wlr_render = static_library( @@ -24,13 +19,13 @@ lib_wlr_render = static_library( 'wlr_renderer.c', 'wlr_texture.c', ), - glapi_c, - glapi_h, + glapi[0], + glapi[1], include_directories: wlr_inc, dependencies: [glesv2, egl], ) wlr_render = declare_dependency( link_with: lib_wlr_render, - sources: glapi_h, + sources: glapi[1], )