2023-08-22 20:05:09 +00:00
|
|
|
{ targetPackages
|
2022-06-16 17:23:12 +00:00
|
|
|
, lib
|
|
|
|
, makeSetupHook
|
|
|
|
, dieHook
|
|
|
|
, writeShellScript
|
|
|
|
, tests
|
|
|
|
, cc ? targetPackages.stdenv.cc
|
|
|
|
, sanitizers ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
makeSetupHook {
|
2023-02-02 18:25:31 +00:00
|
|
|
name = "make-binary-wrapper-hook";
|
2023-08-22 20:05:09 +00:00
|
|
|
propagatedBuildInputs = [ dieHook ];
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
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" ''
|
2023-10-09 19:29:22 +00:00
|
|
|
${cc.bintools.targetPrefix}strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
|
2022-06-16 17:23:12 +00:00
|
|
|
'';
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
tests = tests.makeBinaryWrapper;
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
} ./make-binary-wrapper.sh
|