From ae7b09afae75e02324bf29575c9a0b1863023e8a Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 25 Jan 2019 07:13:54 -0800 Subject: [PATCH] gfx: Update generate_wayland_protos.sh. --- gfx/common/wayland/generate_wayland_protos.sh | 68 +++++++++++++------ qb/config.libs.sh | 3 +- 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/gfx/common/wayland/generate_wayland_protos.sh b/gfx/common/wayland/generate_wayland_protos.sh index 2732bb47b1..1921f1086f 100755 --- a/gfx/common/wayland/generate_wayland_protos.sh +++ b/gfx/common/wayland/generate_wayland_protos.sh @@ -1,35 +1,65 @@ #!/bin/sh -WAYSCAN=/usr/bin/wayland-scanner -WAYLAND_PROTOS=/usr/share/wayland-protocols -OUTPUT=gfx/common/wayland -if [ ! -d $WAYLAND_PROTOS ]; then - WAYSCAN=/usr/local/bin/wayland-scanner - WAYLAND_PROTOS=/usr/local/share/wayland-protocols -fi +set -eu -if [ ! -d $OUTPUT ]; then - mkdir $OUTPUT -fi +cd -- "$(cd -- "${0%/*}/" && pwd -P)" -if [ "${1:-}" = '1.12' ]; then +. ../../../qb/qb.init.sh + +SCANNER_VERSION='' +SHARE_DIR='' + +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. + -s, --share path Sets the path of the wayland protocols directory." + +while [ $# -gt 0 ]; do + option="$1" + shift + case "$option" in + -- ) break ;; + -c|--codegen ) SCANNER_VERSION="$1"; shift ;; + -h|--help ) die 0 "$usage" ;; + -s|--share ) SHARE_DIR="$1/wayland-protocols"; shift ;; + * ) die 1 "Unrecognized option '$option', use -h for help." ;; + esac +done + +WAYSCAN="$(exists wayland-scanner || :)" + +[ "${WAYSCAN}" ] || die 1 "Error: No wayscan in ($PATH)" + +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 + +[ "${WAYLAND_PROTOS}" ] || die 1 'Error: No wayland-protocols directory found.' + +if [ "$SCANNER_VERSION" = '1.12' ]; then CODEGEN=code else CODEGEN=private-code fi #Generate xdg-shell_v6 header and .c files -$WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.h -$WAYSCAN $CODEGEN $WAYLAND_PROTOS/unstable/xdg-shell/xdg-shell-unstable-v6.xml $OUTPUT/xdg-shell-unstable-v6.c +"$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 #Generate xdg-shell header and .c files -$WAYSCAN client-header $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.h -$WAYSCAN $CODEGEN $WAYLAND_PROTOS/stable/xdg-shell/xdg-shell.xml $OUTPUT/xdg-shell.c +"$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 #Generate idle-inhibit header and .c files -$WAYSCAN client-header $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.h -$WAYSCAN $CODEGEN $WAYLAND_PROTOS/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml $OUTPUT/idle-inhibit-unstable-v1.c +"$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 #Generate xdg-decoration header and .c files -$WAYSCAN client-header $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.h -$WAYSCAN $CODEGEN $WAYLAND_PROTOS/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml $OUTPUT/xdg-decoration-unstable-v1.c +"$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 diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 501b52daae..7454e2d3da 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -466,7 +466,8 @@ check_val '' XF86VM -lXxf86vm '' xxf86vm '' '' if [ "$HAVE_WAYLAND_PROTOS" = yes ] && [ "$HAVE_WAYLAND_SCANNER" = yes ] && [ "$HAVE_WAYLAND" = yes ]; then - ./gfx/common/wayland/generate_wayland_protos.sh "$WAYLAND_SCANNER_VERSION" + ./gfx/common/wayland/generate_wayland_protos.sh -c "$WAYLAND_SCANNER_VERSION" -s "$SHARE_DIR" || + die 1 'Error: Failed generating wayland protocols.' else die : 'Notice: wayland libraries not found, disabling wayland support.' HAVE_WAYLAND='no'