depot/third_party/nixpkgs/pkgs/build-support/setup-hooks/make-binary-wrapper/default.nix
Default email 4d5a95770c Project import generated by Copybara.
GitOrigin-RevId: 3c5319ad3aa51551182ac82ea17ab1c6b0f0df89
2023-03-04 15:14:45 +03:00

30 lines
786 B
Nix

{ stdenv
, targetPackages
, lib
, makeSetupHook
, dieHook
, writeShellScript
, tests
, cc ? targetPackages.stdenv.cc
, sanitizers ? []
}:
makeSetupHook {
name = "make-binary-wrapper-hook";
propagatedBuildInputs = [ dieHook ]
# https://github.com/NixOS/nixpkgs/issues/148189
++ lib.optional (stdenv.isDarwin && stdenv.isAarch64) cc;
substitutions = {
cc = "${cc}/bin/${cc.targetPrefix}cc ${lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)}";
};
passthru = {
# Extract the function call used to create a binary wrapper from its embedded docstring
extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
'';
tests = tests.makeBinaryWrapper;
};
} ./make-binary-wrapper.sh