2022-06-16 17:23:12 +00:00
|
|
|
{ stdenv
|
|
|
|
, targetPackages
|
|
|
|
, lib
|
|
|
|
, makeSetupHook
|
|
|
|
, dieHook
|
|
|
|
, writeShellScript
|
|
|
|
, tests
|
|
|
|
, cc ? targetPackages.stdenv.cc
|
|
|
|
, sanitizers ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
makeSetupHook {
|
|
|
|
deps = [ 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)}";
|
2022-10-21 18:38:19 +00:00
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
passthru = {
|
2022-06-16 17:23:12 +00:00
|
|
|
# Extract the function call used to create a binary wrapper from its embedded docstring
|
2022-10-21 18:38:19 +00:00
|
|
|
extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
|
2022-06-16 17:23:12 +00:00
|
|
|
strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
|
|
|
|
'';
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
tests = tests.makeBinaryWrapper;
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
} ./make-binary-wrapper.sh
|