From e75d7157143a33913f5d53a6842ea0a560dca9fa Mon Sep 17 00:00:00 2001 From: itycodes Date: Tue, 1 Oct 2024 09:08:26 +0200 Subject: [PATCH] Clean up protocol building Move protocols to a subdirectory, /protocols, and DRY the Makefile. --- Makefile | 39 +++++-------------- main.c | 4 +- .../ext-foreign-toplevel-list-v1.xml | 0 .../ext-image-capture-source-v1.xml | 0 .../ext-image-copy-capture-v1.xml | 0 5 files changed, 12 insertions(+), 31 deletions(-) rename ext-foreign-toplevel-list-v1.xml => protocols/ext-foreign-toplevel-list-v1.xml (100%) rename ext-image-capture-source-v1.xml => protocols/ext-image-capture-source-v1.xml (100%) rename ext-image-copy-capture-v1.xml => protocols/ext-image-copy-capture-v1.xml (100%) diff --git a/Makefile b/Makefile index b575c85..b02a1a4 100644 --- a/Makefile +++ b/Makefile @@ -4,22 +4,21 @@ CC = gcc CLIBS = -lwayland-client CFLAGS = $(CLIBS) -EXT_SOURCE_PROTOCOL_IMPL = ext-image-capture-source-v1-protocol.c -EXT_SOURCE_PROTOCOL_HEADER = ext-image-capture-source-v1-protocol.h - -EXT_CAPTURE_PROTOCOL_IMPL = ext-image-copy-capture-v1-protocol.c -EXT_CAPTURE_PROTOCOL_HEADER = ext-image-copy-capture-v1-protocol.h - -EXT_TOPLEVEL_PROTOCOL_IMPL = ext-foreign-toplevel-list-v1-protocol.c -EXT_TOPLEVEL_PROTOCOL_HEADER = ext-foreign-toplevel-list-v1-protocol.h - SRC = main.c OUT = screencap -PROTOCOL_IMPLS = $(EXT_TOPLEVEL_PROTOCOL_IMPL) $(EXT_SOURCE_PROTOCOL_IMPL) $(EXT_CAPTURE_PROTOCOL_IMPL) -PROTOCOL_HEADERS = $(EXT_TOPLEVEL_PROTOCOL_HEADER) $(EXT_SOURCE_PROTOCOL_HEADER) $(EXT_CAPTURE_PROTOCOL_HEADER) + +PROTOCOL_NAMES = $(foreach proto, $(wildcard protocols/*), $(notdir $(basename $(proto)))) +PROTOCOL_IMPLS = $(foreach proto, $(PROTOCOL_NAMES), $(addsuffix .prot.c,$(proto))) +PROTOCOL_HEADERS = $(foreach proto, $(PROTOCOL_NAMES), $(addsuffix .prot.h,$(proto))) PROTOCOLS = $(PROTOCOL_IMPLS) $(PROTOCOL_HEADERS) +%.prot.c: protocols/%.xml + wayland-scanner private-code $< $@ + +%.prot.h: protocols/%.xml + wayland-scanner client-header $< $@ + all: $(OUT) clean: @@ -29,21 +28,3 @@ clean: $(OUT): $(PROTOCOLS) $(SRC) $(CC) $(PROTOCOL_IMPLS) $(SRC) $(CFLAGS) -o $(OUT) -$(EXT_SOURCE_PROTOCOL_IMPL): - wayland-scanner private-code ./ext-image-capture-source-v1.xml $(EXT_SOURCE_PROTOCOL_IMPL) - -$(EXT_SOURCE_PROTOCOL_HEADER): - wayland-scanner client-header ./ext-image-capture-source-v1.xml $(EXT_SOURCE_PROTOCOL_HEADER) - -$(EXT_CAPTURE_PROTOCOL_IMPL): - wayland-scanner private-code ./ext-image-copy-capture-v1.xml $(EXT_CAPTURE_PROTOCOL_IMPL) - -$(EXT_CAPTURE_PROTOCOL_HEADER): - wayland-scanner client-header ./ext-image-copy-capture-v1.xml $(EXT_CAPTURE_PROTOCOL_HEADER) - -$(EXT_TOPLEVEL_PROTOCOL_IMPL): - wayland-scanner private-code ./ext-foreign-toplevel-list-v1.xml $(EXT_TOPLEVEL_PROTOCOL_IMPL) - -$(EXT_TOPLEVEL_PROTOCOL_HEADER): - wayland-scanner client-header ./ext-foreign-toplevel-list-v1.xml $(EXT_TOPLEVEL_PROTOCOL_HEADER) - diff --git a/main.c b/main.c index 85debe7..8a67935 100644 --- a/main.c +++ b/main.c @@ -7,8 +7,8 @@ #include -#include "ext-image-capture-source-v1-protocol.h" -#include "ext-image-copy-capture-v1-protocol.h" +#include "ext-image-capture-source-v1.prot.h" +#include "ext-image-copy-capture-v1.prot.h" #include "rif.h" diff --git a/ext-foreign-toplevel-list-v1.xml b/protocols/ext-foreign-toplevel-list-v1.xml similarity index 100% rename from ext-foreign-toplevel-list-v1.xml rename to protocols/ext-foreign-toplevel-list-v1.xml diff --git a/ext-image-capture-source-v1.xml b/protocols/ext-image-capture-source-v1.xml similarity index 100% rename from ext-image-capture-source-v1.xml rename to protocols/ext-image-capture-source-v1.xml diff --git a/ext-image-copy-capture-v1.xml b/protocols/ext-image-copy-capture-v1.xml similarity index 100% rename from ext-image-copy-capture-v1.xml rename to protocols/ext-image-copy-capture-v1.xml