depot/pkgs/by-name/ap/apple-sdk/common/process-stubs.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

46 lines
1.8 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let
removedDylibs = [
# corecrypto is available under a very restrictive license (effectively: non-free, cant use).
# Without the headers and not being able to use corecrypto due to its license, its not very useful.
# Stubs are included in the SDK for all dylibs, including corecrypto. They should be removed.
"/usr/lib/system/libcorecrypto.dylib"
];
in
{
lib,
jq,
libtapi,
}:
self: super: {
nativeBuildInputs = super.nativeBuildInputs or [ ] ++ [
jq
libtapi
];
buildPhase =
super.buildPhase or ""
+ ''
echo "Removing the following dylibs from the libSystem reexported libraries list: ${lib.escapeShellArg (lib.concatStringsSep ", " removedDylibs)}"
for libSystem in libSystem.B.tbd libSystem.B_asan.tbd; do
test ! -e usr/lib/$libSystem && continue # TODO: remove once the minimum SDK is 10.14 or newer.
tapi stubify --filetype=tbd-v5 usr/lib/$libSystem -o usr/lib/$libSystem # tbd-v5 is a JSON-based format.
jq --argjson libs ${lib.escapeShellArg (builtins.toJSON removedDylibs)} '
if .libraries then
.libraries[] |= select(.install_names[] | any([.] | inside($libs)) | not)
else
.
end
| .main_library.reexported_libraries[].names[] |= select([.] | inside($libs) | not)
' usr/lib/$libSystem > usr/lib/$libSystem~
mv usr/lib/$libSystem~ usr/lib/$libSystem
done
# Rewrite the text-based stubs to v4 using `tapi`. This ensures a consistent format between SDK versions.
# tbd-v4 also drops certain elements that are no longer necessary (such as GUID lists).
find . -name '*.tbd' -type f \
-exec echo "Converting {} to tbd-v4" \; \
-exec tapi stubify --filetype=tbd-v4 {} -o {} \;
'';
}