I came up with this process when I needed to compile the latest commit of Sway to test a new feature, and my distro (NixOS) didn't have the required wlroots version packaged so I needed to compile that too. Here are the commands I ran for each repo:
git clone https://gitlab.freedesktop.org/wlroots/wlroots
(NixOS users: use a shell.nix to get all the necessary deps. A sample file is attached to this gist) Now you can compile wlroots. Notes:
-Doptimization
avoids compile errors due to default nix fortify flags--prefix
tells meson to use a newout
subdir as the prefix instead of the default/usr/local
meson setup build -Ddebug=true -Doptimization=2 --prefix=/home/<user>/dev/wlroots/build/out
ninja -C build install # installs to the previously specified prefix
git clone https://github.com/swaywm/sway/
(NixOS users: another nearly identical shell.nix can be used to get all of Sway's deps (not shown)) Now, the fun part: setup Sway to use our local wlroots
PKG_CONFIG_LIBDIR="/home/<user>/dev/wlroots/build/out/lib/pkgconfig/" meson setup build -Ddebug=true -Doptimization=2
And now compile:
ninja -C build