Merge pull request #87866 from danieldk/validate-pkgconfig-hook

validatePkgConfig: init
This commit is contained in:
Benjamin Hipple 2020-06-02 23:27:27 -04:00 committed by GitHub
commit 4af635feff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 12 deletions

View file

@ -2081,6 +2081,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

View file

@ -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
}

View file

@ -1,9 +1,9 @@
{ stdenvNoCC
, fetchurl
, pkgconfig
, rpmextract
, undmg
, darwin
, validatePkgConfig
, enableStatic ? false
}:
@ -46,15 +46,11 @@ in stdenvNoCC.mkDerivation {
sha256 = "0v86hrqg15mbc78m9qk8dbkaaq3mlwashgbf9n79kxpl1gilnah8";
});
nativeBuildInputs = if stdenvNoCC.isDarwin
nativeBuildInputs = [ validatePkgConfig ] ++ (if stdenvNoCC.isDarwin
then
[ undmg darwin.cctools ]
else
[ rpmextract ];
installCheckInputs = [ pkgconfig ];
doInstallCheck = true;
[ rpmextract ]);
buildPhase = if stdenvNoCC.isDarwin then ''
for f in Contents/Resources/pkg/*.tgz; do
@ -152,11 +148,6 @@ in stdenvNoCC.mkDerivation {
install_name_tool -change @rpath/libtbbmalloc.dylib $out/lib/libtbbmalloc.dylib $out/lib/libtbbmalloc_proxy.dylib
'';
# Validate pkgconfig files, since they break often on updates.
installCheckPhase = ''
pkg-config --validate $out/lib/pkgconfig/*.pc
'';
# Per license agreement, do not modify the binary
dontStrip = true;
dontPatchELF = true;

View file

@ -507,6 +507,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 {};