2022-05-10 15:51:43 +02:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, makeSetupHook
|
|
|
|
, dieHook
|
2022-05-11 22:00:24 +02:00
|
|
|
, writeShellScript
|
2022-05-10 15:51:43 +02:00
|
|
|
, tests
|
|
|
|
, cc ? stdenv.cc
|
|
|
|
, sanitizers ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
makeSetupHook {
|
2022-05-10 16:08:46 +02:00
|
|
|
deps = [ dieHook ]
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/148189
|
2022-05-22 21:46:06 +02:00
|
|
|
++ lib.optional (stdenv.isDarwin && stdenv.isAarch64) cc;
|
2022-05-10 15:51:43 +02:00
|
|
|
|
|
|
|
substitutions = {
|
2022-05-12 15:23:38 +02:00
|
|
|
cc = "${cc}/bin/cc ${lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)}";
|
2022-05-10 15:51:43 +02:00
|
|
|
|
2022-05-11 22:00:24 +02:00
|
|
|
# Extract the function call used to create a binary wrapper from its embedded docstring
|
|
|
|
passthru.extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
|
|
|
|
strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
|
|
|
|
'';
|
|
|
|
|
2022-05-10 15:51:43 +02:00
|
|
|
passthru.tests = tests.makeBinaryWrapper;
|
|
|
|
};
|
|
|
|
} ./make-binary-wrapper.sh
|