summaryrefslogtreecommitdiff
path: root/applets/wncklet/wayland-protocol/generate-code.sh
diff options
context:
space:
mode:
authorWilliam Wold <[email protected]>2019-08-01 04:54:28 +0000
committerraveit65 <[email protected]>2020-10-21 20:35:15 +0200
commit2f5ab12d358be4ab3e8e8ba42dcd0a7a6a84de64 (patch)
tree31d3907b2a05f96c47e94d75f2d70a9701044387 /applets/wncklet/wayland-protocol/generate-code.sh
parenteda5735ce6b52e8cf738077027581bfe2257c3cb (diff)
downloadmate-panel-2f5ab12d358be4ab3e8e8ba42dcd0a7a6a84de64.tar.bz2
mate-panel-2f5ab12d358be4ab3e8e8ba42dcd0a7a6a84de64.tar.xz
Add foreign toplevel management protocol and generated code
Diffstat (limited to 'applets/wncklet/wayland-protocol/generate-code.sh')
-rwxr-xr-xapplets/wncklet/wayland-protocol/generate-code.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/applets/wncklet/wayland-protocol/generate-code.sh b/applets/wncklet/wayland-protocol/generate-code.sh
new file mode 100755
index 00000000..90b248b2
--- /dev/null
+++ b/applets/wncklet/wayland-protocol/generate-code.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# This script uses wayland-scanner to generate C bindings from Wayland protocol XML definitions
+# It only needs to be called with the XML files change, and is not called as part of the build system
+
+# Fail the script if anything goes wrong
+set -euo pipefail
+
+# Get the directory this script is in
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+echo "Looking for Wayland protocols in $SCRIPT_DIR"
+
+# Loop through all XML files in the same directory as this script
+for PROTO_FILE_PATH in $(ls "$SCRIPT_DIR"/*.xml); do
+ # Strip the path and the .xml extension
+ PROTO_NAME=$(basename "$PROTO_FILE_PATH" .xml)
+ echo "Generating C bindings for $PROTO_NAME"
+ wayland-scanner -c client-header "$PROTO_FILE_PATH" "$SCRIPT_DIR/$PROTO_NAME-client.h"
+ wayland-scanner -c private-code "$PROTO_FILE_PATH" "$SCRIPT_DIR/$PROTO_NAME-code.c"
+done