summaryrefslogtreecommitdiff
path: root/applets/wncklet/wayland-protocol/generate-code.sh
diff options
context:
space:
mode:
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