Skip to content

Instantly share code, notes, and snippets.

@koara-local
Last active October 17, 2016 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koara-local/6387a4e2a827286ea4691bd073516c89 to your computer and use it in GitHub Desktop.
Save koara-local/6387a4e2a827286ea4691bd073516c89 to your computer and use it in GitHub Desktop.
wayland-scanner genarate script
#!/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