diff options
author | Daniël de Kok <me@danieldk.eu> | 2020-05-15 08:32:24 +0200 |
---|---|---|
committer | Daniël de Kok <me@danieldk.eu> | 2020-05-31 20:45:03 +0200 |
commit | 13083b1a012990dbb8f87bbc92c9c2be962b4878 (patch) | |
tree | 098d71e67ae76a74c1452f7cc6026560ae9cb63b | |
parent | f6bfb371cba2b5a02f200c2747c1fe2c72bd782f (diff) | |
download | nixpkgs-13083b1a012990dbb8f87bbc92c9c2be962b4878.tar nixpkgs-13083b1a012990dbb8f87bbc92c9c2be962b4878.tar.gz nixpkgs-13083b1a012990dbb8f87bbc92c9c2be962b4878.tar.bz2 nixpkgs-13083b1a012990dbb8f87bbc92c9c2be962b4878.tar.lz nixpkgs-13083b1a012990dbb8f87bbc92c9c2be962b4878.tar.xz nixpkgs-13083b1a012990dbb8f87bbc92c9c2be962b4878.tar.zst nixpkgs-13083b1a012990dbb8f87bbc92c9c2be962b4878.zip |
validatePkgConfig: init
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.
-rw-r--r-- | doc/stdenv/stdenv.xml | 10 | ||||
-rw-r--r-- | pkgs/build-support/setup-hooks/validate-pkg-config.sh | 19 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 4 |
3 files changed, 33 insertions, 0 deletions
diff --git a/doc/stdenv/stdenv.xml b/doc/stdenv/stdenv.xml index 65a343d7edd..64fc91fabca 100644 --- a/doc/stdenv/stdenv.xml +++ b/doc/stdenv/stdenv.xml @@ -2085,6 +2085,16 @@ postInstall = '' </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 </term> <listitem> diff --git a/pkgs/build-support/setup-hooks/validate-pkg-config.sh b/pkgs/build-support/setup-hooks/validate-pkg-config.sh new file mode 100644 index 00000000000..54fc9cc122c --- /dev/null +++ b/pkgs/build-support/setup-hooks/validate-pkg-config.sh @@ -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 +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0db4b476682..6fe9ebd3999 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 {}; |