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/.
This commit is contained in:
ItsDrike 2023-06-06 23:37:45 +02:00
parent a826dfbebc
commit 6218a99a3a
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
3 changed files with 11 additions and 10 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
#pragma once
#include <src/plugins/PluginAPI.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp>
inline HANDLE PHANDLE = nullptr;

View file

@ -2,10 +2,10 @@
#include "globals.hpp"
#include <src/Window.hpp>
#include <src/layout/DwindleLayout.hpp>
#include <src/managers/KeybindManager.hpp>
#include <src/managers/LayoutManager.hpp>
#include <hyprland/src/Window.hpp>
#include <hyprland/src/layout/DwindleLayout.hpp>
#include <hyprland/src/managers/KeybindManager.hpp>
#include <hyprland/src/managers/LayoutManager.hpp>
const CColor s_pluginColor = {0x61 / 255.0f, 0xAF / 255.0f, 0xEF / 255.0f, 1.0f};