qb: Allow falling back to a bundled wayland-protocols when not found.

This commit is contained in:
orbea 2019-02-10 13:37:08 -08:00
parent 57ec26f269
commit d3dcc548b2
2 changed files with 33 additions and 18 deletions

View File

@ -6,6 +6,7 @@ cd -- "$(cd -- "${0%/*}/" && pwd -P)"
. ../../../qb/qb.init.sh
PROTOS=''
SCANNER_VERSION=''
SHARE_DIR=''
@ -14,6 +15,7 @@ usage="generate_wayland_protos.sh - Generates wayland protocols.
Usage: generate_wayland_protos.sh [OPTIONS]
-c, --codegen version Sets the wayland scanner compatibility version.
-h, --help Shows this message.
-p, --protos yes|no Set to 'no' to use the bundled wayland-protocols.
-s, --share path Sets the path of the wayland protocols directory."
while [ $# -gt 0 ]; do
@ -23,6 +25,7 @@ while [ $# -gt 0 ]; do
-- ) break ;;
-c|--codegen ) SCANNER_VERSION="$1"; shift ;;
-h|--help ) die 0 "$usage" ;;
-p|--protos ) PROTOS="$1"; shift ;;
-s|--share ) SHARE_DIR="$1/wayland-protocols"; shift ;;
* ) die 1 "Unrecognized option '$option', use -h for help." ;;
esac
@ -34,13 +37,18 @@ WAYSCAN="$(exists wayland-scanner || :)"
WAYLAND_PROTOS=''
for protos in "$SHARE_DIR" /usr/local/share/wayland-protocols /usr/share/wayland-protocols; do
[ -d "$protos" ] || continue
WAYLAND_PROTOS="$protos"
break
done
if [ "$PROTOS" != 'no' ]; then
for protos in "$SHARE_DIR" /usr/local/share/wayland-protocols /usr/share/wayland-protocols; do
[ -d "$protos" ] || continue
WAYLAND_PROTOS="$protos"
break
done
fi
[ "${WAYLAND_PROTOS}" ] || die 1 'Error: No wayland-protocols directory found.'
if [ -z "${WAYLAND_PROTOS}" ]; then
WAYLAND_PROTOS='../../../deps/wayland-protocols'
die : 'Notice: Using the bundled wayland-protocols.'
fi
if [ "$SCANNER_VERSION" = '1.12' ]; then
CODEGEN=code
@ -48,18 +56,23 @@ else
CODEGEN=private-code
fi
XDG_SHELL_UNSTABLE='unstable/xdg-shell/xdg-shell-unstable-v6.xml'
XDG_SHELL='stable/xdg-shell/xdg-shell.xml'
XDG_DECORATION_UNSTABLE='unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'
IDLE_INHIBIT_UNSTABLE='unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'
#Generate xdg-shell_v6 header and .c files
"$WAYSCAN" client-header "$WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml" ./xdg-shell-unstable-v6.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml" ./xdg-shell-unstable-v6.c
"$WAYSCAN" client-header "$WAYLAND_PROTOS/$XDG_SHELL_UNSTABLE" ./xdg-shell-unstable-v6.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/$XDG_SHELL_UNSTABLE" ./xdg-shell-unstable-v6.c
#Generate xdg-shell header and .c files
"$WAYSCAN" client-header "$WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml" ./xdg-shell.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml" ./xdg-shell.c
"$WAYSCAN" client-header "$WAYLAND_PROTOS/$XDG_SHELL" ./xdg-shell.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/$XDG_SHELL" ./xdg-shell.c
#Generate idle-inhibit header and .c files
"$WAYSCAN" client-header "$WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" ./idle-inhibit-unstable-v1.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" ./idle-inhibit-unstable-v1.c
"$WAYSCAN" client-header "$WAYLAND_PROTOS/$IDLE_INHIBIT_UNSTABLE" ./idle-inhibit-unstable-v1.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/$IDLE_INHIBIT_UNSTABLE" ./idle-inhibit-unstable-v1.c
#Generate xdg-decoration header and .c files
"$WAYSCAN" client-header "$WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml" ./xdg-decoration-unstable-v1.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml" ./xdg-decoration-unstable-v1.c
"$WAYSCAN" client-header "$WAYLAND_PROTOS/$XDG_DECORATION_UNSTABLE" ./xdg-decoration-unstable-v1.h
"$WAYSCAN" $CODEGEN "$WAYLAND_PROTOS/$XDG_DECORATION_UNSTABLE" ./xdg-decoration-unstable-v1.c

View File

@ -435,12 +435,14 @@ check_pkgconf DBUS dbus-1
check_val '' XEXT -lXext '' xext '' '' false
check_val '' XF86VM -lXxf86vm '' xxf86vm '' '' false
if [ "$HAVE_WAYLAND_PROTOS" = yes ] &&
[ "$HAVE_WAYLAND_SCANNER" = yes ] &&
if [ "$HAVE_WAYLAND_SCANNER" = yes ] &&
[ "$HAVE_WAYLAND_CURSOR" = yes ] &&
[ "$HAVE_WAYLAND" = yes ]; then
./gfx/common/wayland/generate_wayland_protos.sh -c "$WAYLAND_SCANNER_VERSION" -s "$SHARE_DIR" ||
die 1 'Error: Failed generating wayland protocols.'
./gfx/common/wayland/generate_wayland_protos.sh \
-c "$WAYLAND_SCANNER_VERSION" \
-p "$HAVE_WAYLAND_PROTOS" \
-s "$SHARE_DIR" ||
die 1 'Error: Failed generating wayland protocols.'
else
die : 'Notice: wayland libraries not found, disabling wayland support.'
HAVE_WAYLAND='no'