2023-08-04 17:14:20 +00:00
|
|
|
{ targetPackages
|
2022-05-10 13:51:43 +00:00
|
|
|
, lib
|
|
|
|
, makeSetupHook
|
|
|
|
, dieHook
|
2022-05-11 20:00:24 +00:00
|
|
|
, writeShellScript
|
2022-05-10 13:51:43 +00:00
|
|
|
, tests
|
2022-05-29 15:26:23 +00:00
|
|
|
, cc ? targetPackages.stdenv.cc
|
2022-05-10 13:51:43 +00:00
|
|
|
, sanitizers ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
makeSetupHook {
|
2023-01-18 16:29:22 +00:00
|
|
|
name = "make-binary-wrapper-hook";
|
2023-08-04 17:14:20 +00:00
|
|
|
propagatedBuildInputs = [ dieHook ];
|
2022-05-10 13:51:43 +00:00
|
|
|
|
|
|
|
substitutions = {
|
2022-05-29 15:26:23 +00:00
|
|
|
cc = "${cc}/bin/${cc.targetPrefix}cc ${lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)}";
|
2022-08-13 08:29:10 +00:00
|
|
|
};
|
2022-05-10 13:51:43 +00:00
|
|
|
|
2022-08-13 08:29:10 +00:00
|
|
|
passthru = {
|
2022-05-11 20:00:24 +00:00
|
|
|
# Extract the function call used to create a binary wrapper from its embedded docstring
|
2022-08-13 08:29:10 +00:00
|
|
|
extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
|
2023-09-14 21:51:06 +00:00
|
|
|
${cc.bintools.targetPrefix}strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
|
2022-05-11 20:00:24 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-13 08:29:10 +00:00
|
|
|
tests = tests.makeBinaryWrapper;
|
2022-05-10 13:51:43 +00:00
|
|
|
};
|
|
|
|
} ./make-binary-wrapper.sh
|