Change glapi.sh to generate both files

master
Scott Anderson 7 years ago
parent b8a2bfbc73
commit 02374b945d

@ -7,15 +7,16 @@
# to fail if it can't load the function. You'll need to check if that function # to fail if it can't load the function. You'll need to check if that function
# is NULL before using it. # is NULL before using it.
if [ $# -ne 2 ]; then if [ $# -ne 3 ]; then
exit 1 exit 1
fi fi
SPEC=$1 SPEC=$1
OUT=$2 OUT_C=$2
OUT_H=$3
BASE=$(basename "$SPEC" .txt) 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="" DECL=""
DEFN="" DEFN=""
@ -57,46 +58,37 @@ while read -r COMMAND; do
fi fi
done < $SPEC done < $SPEC
cat > $OUT_H << EOF
#ifndef $INCLUDE_GUARD
#define $INCLUDE_GUARD
case $OUT in #include <stdbool.h>
*.h)
cat > $OUT << EOF
#ifndef $INCLUDE_GUARD
#define $INCLUDE_GUARD
#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> bool load_$BASE(void);
#include <EGL/eglext.h> $DECL
#include <EGL/eglmesaext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
bool load_$BASE(void); #endif
$DECL
#endif
EOF EOF
;;
*.c) cat > $OUT_C << EOF
cat > $OUT << EOF #include <wlr/util/log.h>
#include <wlr/util/log.h> #include "$OUT_H"
#include "$BASE.h" $DEFN
$DEFN
bool load_$BASE(void) {
bool load_$BASE(void) { static bool done = false;
static bool done = false; if (done) {
if (done) { return true;
return true; }
} $LOADER
$LOADER
done = true;
done = true; return true;
return true; }
}
EOF EOF
;;
*)
exit 1
;;
esac

@ -1,14 +1,9 @@
glgen = find_program('../glgen.sh') glgen = find_program('../glgen.sh')
glapi_c = custom_target('glapi.c', glapi = custom_target('glapi',
input: 'glapi.txt', input: 'glapi.txt',
output: '@BASENAME@.c', output: ['@BASENAME@.c', '@BASENAME@.h'],
command: [glgen, '@INPUT@', '@OUTPUT@'], command: [glgen, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@'],
)
glapi_h = custom_target('glapi.h',
input: 'glapi.txt',
output: '@BASENAME@.h',
command: [glgen, '@INPUT@', '@OUTPUT@'],
) )
lib_wlr_render = static_library( lib_wlr_render = static_library(
@ -24,13 +19,13 @@ lib_wlr_render = static_library(
'wlr_renderer.c', 'wlr_renderer.c',
'wlr_texture.c', 'wlr_texture.c',
), ),
glapi_c, glapi[0],
glapi_h, glapi[1],
include_directories: wlr_inc, include_directories: wlr_inc,
dependencies: [glesv2, egl], dependencies: [glesv2, egl],
) )
wlr_render = declare_dependency( wlr_render = declare_dependency(
link_with: lib_wlr_render, link_with: lib_wlr_render,
sources: glapi_h, sources: glapi[1],
) )

Loading…
Cancel
Save