From 6218a99a3a66073e771e1204e1e30ec95ef8b149 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 6 Jun 2023 23:37:45 +0200 Subject: [PATCH] Move to pkg-config Hyprland has recently changed the way plugins recognize the hyprland headers, moving from directly including the paths with -I option to automatically generating the cflags with `pkg-config --cflags hyprland`. This change means that compilation attempts using the direct include option will start to fail with newer versions of hyprland, which now uses /usr/local/include for it's headers after `make pluginenv`. This commit migrates the original system to respect this change, modifying Makefile, and with it, the include paths for hyprland headers, which are now prefixed with hyprland/. --- Makefile | 11 ++++++----- include/globals.hpp | 2 +- src/main.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 13f5215..6d2a077 100644 --- a/Makefile +++ b/Makefile @@ -14,15 +14,16 @@ install: all cp $(PLUGIN_NAME).so ${HOME}/.local/share/hyprload/plugins/bin check_env: -ifndef HYPRLAND_HEADERS - $(error HYPRLAND_HEADERS is undefined! Please set it to the path to the root of the configured Hyprland repo) -endif + @if ! pkg-config --exists hyprland; then \ + echo 'Hyprland headers not available. Run `make pluginenv` in the root Hyprland directory.'; \ + exit 1; \ + fi $(PLUGIN_NAME).so: $(SOURCE_FILES) $(INCLUDE_FILES) - g++ -shared -fPIC --no-gnu-unique $(SOURCE_FILES) -o $(PLUGIN_NAME).so -g -I "/usr/include/pixman-1" -I "/usr/include/libdrm" -I "${HYPRLAND_HEADERS}" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/include" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/build/include" -Iinclude -std=c++23 + g++ -shared -fPIC --no-gnu-unique $(SOURCE_FILES) -o $(PLUGIN_NAME).so -g `pkg-config --cflags pixman-1 libdrm hyprland` -Iinclude -std=c++23 clean: rm ./${PLUGIN_NAME}.so clangd: - printf "%b" "-I/usr/include/pixman-1\n-I/usr/include/libdrm\n-I${HYPRLAND_HEADERS}\n-Iinclude\n-std=c++2b" > compile_flags.txt + printf "%b" "`pkg-config --cflags pixman-1 libdrm hyprland | sed 's/ -/\n-/g'`\n-Iinclude\n-std=c++2b" > compile_flags.txt diff --git a/include/globals.hpp b/include/globals.hpp index 3b61032..66c4f04 100644 --- a/include/globals.hpp +++ b/include/globals.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include inline HANDLE PHANDLE = nullptr; diff --git a/src/main.cpp b/src/main.cpp index 7c3f845..7e93593 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,10 +2,10 @@ #include "globals.hpp" -#include -#include -#include -#include +#include +#include +#include +#include const CColor s_pluginColor = {0x61 / 255.0f, 0xAF / 255.0f, 0xEF / 255.0f, 1.0f};