Skip to content

Commit

Permalink
cmake: add check-pc-files hook to check broken pc files
Browse files Browse the repository at this point in the history
see nixpkgs pr 172150
  • Loading branch information
Artturin committed Sep 8, 2022
1 parent eb15a96 commit b1149dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions pkgs/development/tools/build-managers/cmake/check-pc-files-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmakePcfileCheckPhase() {
while IFS= read -rd $'\0' file; do
grepout=$(grep --line-number '}//nix/store' "$file" || true)
if [ -n "$grepout" ]; then
{
echo "Broken paths found in a .pc file! $file"
echo "The following lines have issues (specifically '//' in paths)."
echo "$grepout"
echo "It is very likely that paths are being joined improperly."
echo 'ex: "${prefix}/@CMAKE_INSTALL_LIBDIR@" should be "@CMAKE_INSTALL_FULL_LIBDIR@"'
echo "Please see https://github.com/NixOS/nixpkgs/issues/144170 for more details."
exit 1
} 1>&2
fi
done < <(find "${!outputDev}" -iname "*.pc" -print0)
}

postFixupHooks+=(cmakePcfileCheckPhase)
8 changes: 5 additions & 3 deletions pkgs/development/tools/build-managers/cmake/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ stdenv.mkDerivation rec {
outputs = [ "out" ] ++ lib.optionals buildDocs [ "man" "info" ];
setOutputFlags = false;

setupHook = ./setup-hook.sh;
setupHooks = [
./setup-hook.sh
./check-pc-files-hook.sh
];

depsBuildBuild = [ buildPackages.stdenv.cc ];

nativeBuildInputs = [
nativeBuildInputs = setupHooks ++ [
pkg-config
setupHook
]
++ lib.optionals buildDocs [ texinfo ]
++ lib.optionals qt5UI [ wrapQtAppsHook ];
Expand Down

0 comments on commit b1149dc

Please sign in to comment.