update for pkg-config

This commit is contained in:
Stanisław Zagórowski 2023-05-08 12:49:49 +02:00
parent 5bb05a9149
commit 90283112bf
7 changed files with 20 additions and 27 deletions

View File

@ -1,5 +1,4 @@
# Hyprland Plugin Template # Hyprland Plugin Template
# WARNING: Due to changes in the way Hyprland distributes headers, this is broken right now.
The goal of this repository is to create a robust `Hyprland` plugin template, with The goal of this repository is to create a robust `Hyprland` plugin template, with
- A working, extensible `Makefile` - A working, extensible `Makefile`
@ -31,26 +30,22 @@ which is a bit more granular.
> like `cannot cast from type 'void (CCompositor::*)(CWindow *, wlr_surface *)' to pointer type 'void *'` > like `cannot cast from type 'void (CCompositor::*)(CWindow *, wlr_surface *)' to pointer type 'void *'`
> This won't happen when building with GCC and can be ignored. > This won't happen when building with GCC and can be ignored.
#### HYPRLAND_HEADERS #### Hyprland headers
The most important part of setting up plugin builds is the `HYPRLAND_HEADERS` variable. The most important part of setting up plugin builds is getting access to Hyprland headers
Plugins can hook directly into Hyprland's C++ code, which is what makes them so powerful. Plugins can hook directly into Hyprland's C++ code, which is what makes them so powerful.
Because of that, they need to be able to *see* the Hyprland source. `HYPRLAND_HEADERS` ensures Because of that, they need to be able to *see* the Hyprland source.
that.
When building your own plugins for testing, you will need to manually define it using When building your own plugins for testing, make sure you have the pkg-config path set up correctly
`export HYPRLAND_HEADERS=(PATH_TO_HYPRLAND_SOURCE_ROOT)` before running `make` commands. You and that your installation of Hyprland has the headers in `/usr/local/include/hyprland`. This
can use a local path if you keep `Hyprland` source anyway, but I'd definitely recommend using requires running `make pluginenv`.
`hyprload`. If you use your local source different from the `hyprload` one, make sure to
run `make pluginenv` in the Hyprland folder.
#### Hyprload, and why it's useful for plugin development #### Hyprload, and why it's useful for plugin development
If you use `hyprload`, handing `HYPRLOAD_HEADERS` becomes a bit easier and more reliable. If you use `hyprload`, it makes sure that the pkg-config path and headers are always available.
By design it keeps a copy of Hyprland source code up to date with the Hyprland version you're By design it keeps a copy of Hyprland source code up to date with the Hyprland version you're
running in `$HOME/.local/share/hyprload/hyprland`, and you can use that as your running in `$HOME/.local/share/hyprload/hyprland`, and builds pluginenv whenever needed.
`HYPRLAND_HEADERS` path.
When users install your plugin via `hyprload`, it will automatically define `HYPRLAND_HEADERS` When users install your plugin via `hyprload`, it will also automatically set up everything
to that path to ensure maximum compatibility. to ensure maximum compatibility.
When developing plugins and frequently changing them, the `make install` command will When developing plugins and frequently changing them, the `make install` command will
automatically place your plugin build in the directory `hyprload` automatically loads. You can automatically place your plugin build in the directory `hyprload` automatically loads. You can
@ -69,9 +64,7 @@ changing (I would like to streamline it somehow, but it's manageable for now)
For more info, see [hyprload docs](https://github.com/Duckonaut/hyprload#format) For more info, see [hyprload docs](https://github.com/Duckonaut/hyprload#format)
## Building and testing ## Building and testing
After making sure you have defined `HYPRLAND_HEADERS` (you might need to do this *every time After having the headers available, the steps to build are simple
you open a new terminal* if you don't put it in your `.bashrc` or `.zshrc` or whatever), the
steps to build are simple
### Manually ### Manually
- `make`: This will build the `PLUGIN_NAME.so` file. - `make`: This will build the `PLUGIN_NAME.so` file.

View File

@ -2,7 +2,7 @@
#define WLR_USE_UNSTABLE #define WLR_USE_UNSTABLE
#include <src/render/decorations/IHyprWindowDecoration.hpp> #include <hyprland/src/render/decorations/IHyprWindowDecoration.hpp>
class CCustomDecoration : public IHyprWindowDecoration { class CCustomDecoration : public IHyprWindowDecoration {
public: public:

View File

@ -2,7 +2,7 @@
#define WLR_USE_UNSTABLE #define WLR_USE_UNSTABLE
#include <src/layout/IHyprLayout.hpp> #include <hyprland/src/layout/IHyprLayout.hpp>
struct SWindowData { struct SWindowData {
CWindow* pWindow = nullptr; CWindow* pWindow = nullptr;

View File

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

View File

@ -1,6 +1,6 @@
#include "customDecoration.hpp" #include "customDecoration.hpp"
#include <src/Window.hpp> #include <hyprland/src/Window.hpp>
#include <src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include "globals.hpp" #include "globals.hpp"
CCustomDecoration::CCustomDecoration(CWindow* pWindow) { CCustomDecoration::CCustomDecoration(CWindow* pWindow) {

View File

@ -1,5 +1,5 @@
#include "customLayout.hpp" #include "customLayout.hpp"
#include <src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include "globals.hpp" #include "globals.hpp"
void CHyprCustomLayout::onWindowCreatedTiling(CWindow* pWindow) { void CHyprCustomLayout::onWindowCreatedTiling(CWindow* pWindow) {

View File

@ -2,8 +2,8 @@
#include "globals.hpp" #include "globals.hpp"
#include <src/Window.hpp> #include <hyprland/src/Window.hpp>
#include <src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include "customLayout.hpp" #include "customLayout.hpp"
#include "customDecoration.hpp" #include "customDecoration.hpp"