2020-06-18 07:06:33 +00:00
|
|
|
# The wrapper script ensures variables like PKG_CONFIG_PATH and
|
|
|
|
# PKG_CONFIG_PATH_FOR_BUILD work properly.
|
|
|
|
|
|
|
|
{ stdenvNoCC
|
2021-02-05 17:12:51 +00:00
|
|
|
, lib
|
2020-06-18 07:06:33 +00:00
|
|
|
, buildPackages
|
|
|
|
, pkg-config
|
|
|
|
, baseBinName ? "pkg-config"
|
|
|
|
, propagateDoc ? pkg-config != null && pkg-config ? man
|
|
|
|
, extraPackages ? [], extraBuildCommands ? ""
|
|
|
|
}:
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
with lib;
|
2020-06-18 07:06:33 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
stdenv = stdenvNoCC;
|
|
|
|
inherit (stdenv) hostPlatform targetPlatform;
|
|
|
|
|
|
|
|
# Prefix for binaries. Customarily ends with a dash separator.
|
|
|
|
#
|
|
|
|
# TODO(@Ericson2314) Make unconditional, or optional but always true by
|
|
|
|
# default.
|
2021-02-05 17:12:51 +00:00
|
|
|
targetPrefix = lib.optionalString (targetPlatform != hostPlatform)
|
2020-06-18 07:06:33 +00:00
|
|
|
(targetPlatform.config + "-");
|
|
|
|
|
|
|
|
# See description in cc-wrapper.
|
|
|
|
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = targetPrefix + pkg-config.pname + "-wrapper";
|
|
|
|
inherit (pkg-config) version;
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
outputs = [ "out" ] ++ optionals propagateDoc ([ "man" ] ++ optional (pkg-config ? doc) "doc");
|
|
|
|
|
|
|
|
passthru = {
|
2023-01-20 10:41:00 +00:00
|
|
|
inherit targetPrefix suffixSalt;
|
2020-06-18 07:06:33 +00:00
|
|
|
inherit pkg-config;
|
|
|
|
};
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
strictDeps = true;
|
2020-06-18 07:06:33 +00:00
|
|
|
dontBuild = true;
|
|
|
|
dontConfigure = true;
|
|
|
|
|
2021-12-26 17:43:05 +00:00
|
|
|
# Additional flags passed to pkg-config.
|
|
|
|
addFlags = lib.optional stdenv.targetPlatform.isStatic "--static";
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
unpackPhase = ''
|
|
|
|
src=$PWD
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase =
|
|
|
|
''
|
|
|
|
mkdir -p $out/bin $out/nix-support
|
|
|
|
|
|
|
|
wrap() {
|
|
|
|
local dst="$1"
|
|
|
|
local wrapper="$2"
|
|
|
|
export prog="$3"
|
|
|
|
substituteAll "$wrapper" "$out/bin/$dst"
|
|
|
|
chmod +x "$out/bin/$dst"
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $pkg-config > $out/nix-support/orig-pkg-config
|
|
|
|
|
|
|
|
wrap ${targetPrefix}${baseBinName} ${./pkg-config-wrapper.sh} "${getBin pkg-config}/bin/${baseBinName}"
|
|
|
|
''
|
|
|
|
# symlink in share for autoconf to find macros
|
|
|
|
|
|
|
|
# TODO(@Ericson2314): in the future just make the unwrapped pkg-config a
|
|
|
|
# propagated dep once we can rely on downstream deps comming first in
|
|
|
|
# search paths. (https://github.com/NixOS/nixpkgs/pull/31414 took a crack
|
|
|
|
# at this.)
|
|
|
|
+ ''
|
|
|
|
ln -s ${pkg-config}/share $out/share
|
|
|
|
'';
|
|
|
|
|
|
|
|
setupHooks = [
|
|
|
|
../setup-hooks/role.bash
|
|
|
|
./setup-hook.sh
|
|
|
|
];
|
|
|
|
|
|
|
|
postFixup =
|
|
|
|
##
|
|
|
|
## User env support
|
|
|
|
##
|
|
|
|
|
|
|
|
# Propagate the underling unwrapped pkg-config so that if you
|
|
|
|
# install the wrapper, you get anything else it might provide.
|
|
|
|
''
|
|
|
|
printWords ${pkg-config} > $out/nix-support/propagated-user-env-packages
|
|
|
|
''
|
|
|
|
|
|
|
|
##
|
|
|
|
## Man page and doc support
|
|
|
|
##
|
|
|
|
+ optionalString propagateDoc (''
|
|
|
|
ln -s ${pkg-config.man} $man
|
|
|
|
'' + optionalString (pkg-config ? doc) ''
|
|
|
|
ln -s ${pkg-config.doc} $doc
|
|
|
|
'')
|
|
|
|
|
|
|
|
+ ''
|
|
|
|
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
|
|
|
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
|
|
|
''
|
|
|
|
|
|
|
|
##
|
|
|
|
## Extra custom steps
|
|
|
|
##
|
|
|
|
+ extraBuildCommands;
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
env = {
|
|
|
|
shell = getBin stdenvNoCC.shell + stdenvNoCC.shell.shellPath or "";
|
|
|
|
wrapperName = "PKG_CONFIG_WRAPPER";
|
|
|
|
inherit targetPrefix suffixSalt baseBinName;
|
|
|
|
};
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
meta =
|
|
|
|
let pkg-config_ = if pkg-config != null then pkg-config else {}; in
|
|
|
|
(if pkg-config_ ? meta then removeAttrs pkg-config.meta ["priority"] else {}) //
|
|
|
|
{ description =
|
2021-02-05 17:12:51 +00:00
|
|
|
lib.attrByPath ["meta" "description"] "pkg-config" pkg-config_
|
2020-06-18 07:06:33 +00:00
|
|
|
+ " (wrapper script)";
|
|
|
|
priority = 10;
|
|
|
|
};
|
|
|
|
}
|