Last active
October 17, 2016 09:42
-
-
Save koara-local/6387a4e2a827286ea4691bd073516c89 to your computer and use it in GitHub Desktop.
wayland-scanner genarate script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
# The MIT License (MIT) | |
# Copyright (c) 2016 Kohei Arao | |
# https://opensource.org/licenses/MIT | |
FILEPATH=$1 | |
# validate | |
FILENAME=$(basename ${FILEPATH}) | |
EXTENSION=${FILENAME##*.} | |
PROTOCOLNAME=${FILENAME%.*} | |
echo "FILENAME=${FILENAME}" | |
echo "EXTENSION=${EXTENSION}" | |
echo "PROTOCOLNAME=${PROTOCOLNAME}" | |
if [[ EXTENSION == "xml" ]] || [[ 0 == $(cat ${FILEPATH} | grep "<protocol name=\"${PROTOCOLNAME//-/_}\">" | wc -l) ]]; | |
then | |
echo "validate error!" | |
exit 1 | |
fi | |
wayland-scanner code < ${FILEPATH} > ${PROTOCOLNAME}-protocol.c | |
wayland-scanner server-header < ${FILEPATH} > ${PROTOCOLNAME}-server-protocol.h | |
wayland-scanner client-header < ${FILEPATH} > ${PROTOCOLNAME}-client-protocol.h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment