darwin.AvailabilityVersions: also generate _symbol_aliasing.h

This commit is contained in:
Randy Eckenrode 2024-09-21 19:09:51 -04:00
parent 78076b3c12
commit 129a959fad
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9

View File

@ -8,6 +8,7 @@
let
inherit (buildPackages) gnused python3;
xnu = apple-sdk.sourceRelease "xnu";
in
mkAppleDerivation (finalAttrs: {
releaseName = "AvailabilityVersions";
@ -47,6 +48,16 @@ mkAppleDerivation (finalAttrs: {
--replace-fail 'f"{os.path.abspath(os.path.dirname(sys.argv[0]))}/' "\"$out/share/availability/"
chmod a+x "$out/libexec/availability"
substitute ${xnu}/bsd/sys/make_symbol_aliasing.sh "$out/libexec/make_symbol_aliasing.sh" \
${
if lib.versionOlder (lib.getVersion xnu) "6153.11.26" then
''--replace-fail "\''${SDKROOT}/usr/local/libexec/availability.pl" "$out/libexec/availability" \''
else
''--replace-fail "\''${SDKROOT}/\''${DRIVERKITROOT}/usr/local/libexec/availability.pl" "$out/libexec/availability" \''
}
--replace-fail '--macosx' '--macosx --threshold $SDKROOT'
chmod a+x "$out/libexec/make_symbol_aliasing.sh"
cat <<SCRIPT > "$out/bin/gen-headers"
#!/usr/bin/env bash
set -eu
@ -71,6 +82,8 @@ mkAppleDerivation (finalAttrs: {
--preprocess "$out/share/availability/templates/\$header_src" "\$dest/include/\$header"
done
"$out/libexec/make_symbol_aliasing.sh" \$threshold "\$dest/include/sys/_symbol_aliasing.h"
# __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ is only defined by clang 17+, so define it for older versions.
${lib.getExe gnused} -E '/#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED/{
i#ifndef __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__