nixpkgs/pkgs/test/pkg-config-packages.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.1 KiB
Nix
Raw Normal View History

2022-04-23 21:37:49 +00:00
{ lib, pkg-config, pkg-configPackages, runCommand }:
let
allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTest k v) pkg-configPackages;
# nix-build rejects attribute names with periods
# This will build those regardless.
tests-combined = runCommand "pkg-config-checks" {
allTests = lib.attrValues allTests;
} ''
touch $out
'';
makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ pkg ];
inherit moduleName;
} ''
echo "checking pkg-config module $moduleName in $buildInputs"
set +e
version="$(pkg-config --modversion $moduleName)"
r=$?
set -e
if [[ $r = 0 ]]; then
echo " pkg-config module $moduleName exists and has version $version"
echo "$version" > $out
else
echo "These modules were available in the input propagation closure:"
pkg-config --list-all
echo " pkg-config module $moduleName was not found"
false
fi
'';
in
allTests // { inherit tests-combined; }