Skip to content

Commit

Permalink
validatePkgConfig: init
Browse files Browse the repository at this point in the history
This adds the `validatePkgConfig` hook, which can be used to validate
pkg-config files in the output(s). Currently, this will just run
`pkg-config --validate` on all `.pc` files, capturing errors such as
the issue that was fixed in #87789.

The hook could be extended in the future with more fine-grained
checks.
  • Loading branch information
danieldk committed May 31, 2020
1 parent f6bfb37 commit 13083b1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/stdenv/stdenv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,16 @@ postInstall = ''
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
validatePkgConfig
</term>
<listitem>
<para>
The <literal>validatePkgConfig</literal> hook validates all pkg-config (<filename>.pc</filename>) files in a package. This helps catching some common errors in pkg-config files, such as undefined variables.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
cmake
Expand Down
19 changes: 19 additions & 0 deletions pkgs/build-support/setup-hooks/validate-pkg-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This setup hook validates each pkgconfig file in each output.

fixupOutputHooks+=(_validatePkgConfig)

_validatePkgConfig() {
for pc in $(find "$prefix" -name '*.pc'); do
local bail=0

# Do not fail immediately. It's nice to see all errors when
# there are multiple pkgconfig files.
if ! pkg-config --validate "$pc"; then
bail=1
fi
done

if [ $bail -eq 1 ]; then
exit 1
fi
}
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ in

iconConvTools = callPackage ../build-support/icon-conv-tools {};

validatePkgConfig = makeSetupHook
{ name = "validate-pkg-config"; deps = [ findutils pkgconfig ]; }
../build-support/setup-hooks/validate-pkg-config.sh;

#package writers
writers = callPackage ../build-support/writers {};

Expand Down

0 comments on commit 13083b1

Please sign in to comment.