mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-27 02:34:53 +00:00
40 lines
983 B
Nix
40 lines
983 B
Nix
{
|
|
targetPackages,
|
|
lib,
|
|
makeSetupHook,
|
|
dieHook,
|
|
writeShellScript,
|
|
tests,
|
|
cc ? targetPackages.stdenv.cc,
|
|
sanitizers ? [ ],
|
|
}:
|
|
|
|
makeSetupHook {
|
|
name = "make-binary-wrapper-hook";
|
|
propagatedBuildInputs = [ dieHook ];
|
|
|
|
substitutions = {
|
|
cc = "${cc}/bin/${cc.targetPrefix}cc ${
|
|
lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)
|
|
+ lib.optionalString (
|
|
cc.isClang && !cc.stdenv.hostPlatform.isDarwin
|
|
) "--ld-path=${cc.targetPrefix}ld"
|
|
}";
|
|
};
|
|
|
|
passthru = {
|
|
# Extract the function call used to create a binary wrapper from its embedded docstring
|
|
extractCmd =
|
|
let
|
|
bintools = targetPackages.gnuStdenv.cc.bintools;
|
|
in
|
|
writeShellScript "extract-binary-wrapper-cmd" ''
|
|
${lib.getExe' bintools "${bintools.targetPrefix}strings"} -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
|
|
'';
|
|
|
|
tests = tests.makeBinaryWrapper;
|
|
};
|
|
|
|
meta.license = lib.licenses.mit;
|
|
} ./make-binary-wrapper.sh
|