Merge pull request #443 from ascent12/meson-glapi

Change glapi.sh to generate both source and header simeltaneously
This commit is contained in:
Drew DeVault 2017-11-21 20:13:53 -05:00 committed by GitHub
commit e6bf92cf02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 49 deletions

View File

@ -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,10 +58,7 @@ while read -r COMMAND; do
fi
done < $SPEC
case $OUT in
*.h)
cat > $OUT << EOF
cat > $OUT_H << EOF
#ifndef $INCLUDE_GUARD
#define $INCLUDE_GUARD
@ -77,11 +75,10 @@ case $OUT in
#endif
EOF
;;
*.c)
cat > $OUT << EOF
cat > $OUT_C << EOF
#include <wlr/util/log.h>
#include "$BASE.h"
#include "$OUT_H"
$DEFN
bool load_$BASE(void) {
@ -95,8 +92,3 @@ EOF
return true;
}
EOF
;;
*)
exit 1
;;
esac

View File

@ -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],
)