improv(just): ability to optionally check library version requirement

We know that the minimum required version of wayland-client is 1.20
This commit is contained in:
Michael Aaron Murphy 2024-03-07 04:30:40 +01:00 committed by Michael Murphy
parent f0603d648f
commit ab298fab2d
2 changed files with 11 additions and 2 deletions

View file

@ -50,6 +50,6 @@ fontconfig
freetype2
libinput
libudev
wayland-client
wayland-client=1.20
xkbcommon
"

View file

@ -31,7 +31,16 @@ dep-cmd cmd:
# Errors if a library does not exist
[private]
dep-lib lib:
@pkg-config --exists {{lib}} || (just print-error 'missing dependency' 'library' {{lib}}; exit 1)
#!/bin/sh
if echo {{lib}} | grep = >/dev/null; then
name=$(echo {{lib}} | cut -d= -f1)
version=$(echo {{lib}} | cut -d= -f2)
pkg-config --exists ${name} --atleast-version ${version} || (
has=$(pkg-config --modversion ${name})
just print-error "expected version ${version}, found ${has}" 'library' ${name}; exit 1)
else
pkg-config --exists {{lib}} || (just print-error 'missing dependency' 'library' {{lib}}; exit 1)
fi
# Display a formatted error for the user.
[private]