darwin.libresolv: convert to Meson and use mkAppleDerivation

This commit is contained in:
Randy Eckenrode 2024-09-22 09:05:39 -04:00
parent 9af3511fb2
commit 375057b9f5
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9
5 changed files with 112 additions and 54 deletions

View File

@ -294,7 +294,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
applePackage "libplatform" "osx-10.12.6" "sha256-6McMTjw55xtnCsFI3AB1osRagnuB5pSTqeMKD3gpGtM=" {}
else macosPackages_11_0_1.libplatform;
libpthread = applePackage "libpthread" "osx-10.12.6" "sha256-QvJ9PERmrCWBiDmOWrLvQUKZ4JxHuh8gS5nlZKDLqE8=" {};
libresolv = applePackage "libresolv" "osx-10.12.6" "sha256-FtvwjJKSFX6j9APYPC8WLXVOjbHLZa1Gcoc8yxLy8qE=" {};
libresolv = callPackage ./libresolv/package.nix { };
Libsystem = applePackage "Libsystem" "osx-10.12.6" "sha256-zvRdCP//TjKCGAqm/5nJXPppshU1cv2fg/L/yK/olGQ=" { inherit (pkgs.darwin.apple_sdk) sdkRoot; };
libutil = applePackage "libutil" "osx-10.12.6" "sha256-4PFuk+CTLwvd/Ll9GLBkiIM0Sh/CVaiKwh5m1noheRs=" {};
libunwind = applePackage "libunwind" "osx-10.12.6" "sha256-CC0sndP/mKYe3dZu3v7fjuDASV4V4w7dAcnWMvpoquE=" {};
@ -330,7 +330,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
};
libutilHeaders = pkgs.darwin.libutil.override { headersOnly = true; };
hfsHeaders = pkgs.darwin.hfs.override { headersOnly = true; };
libresolvHeaders= pkgs.darwin.libresolv.override { headersOnly = true; };
libresolvHeaders= lib.getDev self.libresolv;
# TODO(matthewbauer):
# To be removed, once I figure out how to build a newer Security version.

View File

@ -1,52 +0,0 @@
{ lib, appleDerivation', stdenv, stdenvNoCC, Libinfo, configdHeaders, mDNSResponder
, headersOnly ? false
}:
appleDerivation' (if headersOnly then stdenvNoCC else stdenv) {
buildInputs = lib.optionals (!headersOnly) [ Libinfo configdHeaders mDNSResponder ];
buildPhase = lib.optionalString (!headersOnly) ''
$CC -I. -c dns_util.c
$CC -I. -c dns.c
$CC -I. -c dns_async.c
$CC -I. -c base64.c
$CC -I. -c dst_api.c
$CC -I. -c dst_hmac_link.c
$CC -I. -c dst_support.c
$CC -I. -c ns_date.c
$CC -I. -c ns_name.c
$CC -I. -c ns_netint.c
$CC -I. -c ns_parse.c
$CC -I. -c ns_print.c
$CC -I. -c ns_samedomain.c
$CC -I. -c ns_sign.c
$CC -I. -c ns_ttl.c
$CC -I. -c ns_verify.c
$CC -I. -c res_comp.c
$CC -I. -c res_data.c
$CC -I. -c res_debug.c
$CC -I. -c res_findzonecut.c
$CC -I. -c res_init.c
$CC -I. -c res_mkquery.c
$CC -I. -c res_mkupdate.c
$CC -I. -c res_query.c
$CC -I. -c res_send.c
$CC -I. -c res_sendsigned.c
$CC -I. -c res_update.c
$CC -dynamiclib -install_name $out/lib/libresolv.9.dylib -current_version 1.0.0 -compatibility_version 1.0.0 -o libresolv.9.dylib *.o
'';
installPhase = ''
mkdir -p $out/include $out/include/arpa $out/lib
cp dns.h $out/include/
cp dns_util.h $out/include
cp nameser.h $out/include
ln -s ../nameser.h $out/include/arpa
cp resolv.h $out/include
'' + lib.optionalString (!headersOnly) ''
cp libresolv.9.dylib $out/lib
ln -s libresolv.9.dylib $out/lib/libresolv.dylib
'';
}

View File

@ -0,0 +1,57 @@
# Build settings based on the upstream Xcode project.
# See: https://github.com/apple-oss-distributions/libresolv/blob/main/libresolv.xcodeproj/project.pbxproj
# Project settings
project('libresolv', 'c', version : '@version@')
# Dependencies
cc = meson.get_compiler('c')
# Libraries
libresolv = library(
'resolv',
darwin_versions : '1',
install : true,
sources : [
'base64.c',
'dns.c',
'dns_async.c',
'dns_util.c',
'dst_api.c',
'dst_hmac_link.c',
'dst_support.c',
'ns_date.c',
'ns_name.c',
'ns_netint.c',
'ns_parse.c',
'ns_print.c',
'ns_samedomain.c',
'ns_sign.c',
'ns_ttl.c',
'ns_verify.c',
'res_comp.c',
'res_data.c',
'res_debug.c',
'res_findzonecut.c',
'res_init.c',
'res_mkquery.c',
'res_mkupdate.c',
'res_query.c',
'res_send.c',
'res_sendsigned.c',
'res_update.c',
],
soversion : '9'
)
install_headers(
'dns.h',
'dns_util.h',
'nameser.h',
'resolv.h',
)
install_man(
'resolver.3',
'resolver.5',
)

View File

@ -0,0 +1,49 @@
{
lib,
apple-sdk_11,
mkAppleDerivation,
}:
let
configd = apple-sdk_11.sourceRelease "configd";
Libinfo = apple-sdk_11.sourceRelease "Libinfo";
# `arpa/nameser_compat.h` is included in the Libc source release instead of libresolv.
Libc = apple-sdk_11.sourceRelease "Libc";
in
mkAppleDerivation {
releaseName = "libresolv";
outputs = [
"out"
"dev"
"man"
];
xcodeHash = "sha256-YcqscjaTBvqXePItsGLImij7sFQ6u0AP/MlfkKsGND8=";
postUnpack = ''
mkdir -p "$sourceRoot/arpa"
ln -s "$NIX_BUILD_TOP/$sourceRoot/nameser.h" "$sourceRoot/arpa/nameser.h"
'';
# Remove unsupported availability annotations to support SDK without updated availability headers.
postPatch = ''
substituteInPlace dns_util.h \
--replace-fail 'API_DEPRECATED_BEGIN("dns_util is deprecated.", macos(10.0, 13.0), ios(1.0, 16.0), watchos(1.0, 9.0), tvos(1.0, 16.0))' "" \
--replace-fail API_DEPRECATED_END ""
'';
env.NIX_CFLAGS_COMPILE = "-I${configd}/dnsinfo -I${Libinfo}/lookup.subproj";
postInstall = ''
mkdir -p "$out/include/arpa"
ln -s ../nameser.h "$out/include/arpa"
cp ${Libc}/include/arpa/nameser_compat.h "$out/include/arpa"
'';
meta = {
description = "libresolv implementation for Darwin";
license = lib.licenses.apple-psl10;
};
}

View File

@ -42,5 +42,9 @@
"libiconv": {
"hash": "sha256-TGt6rsU52ztfW2rCqwnhMAExLbexI/59IoDOGY+XGu0=",
"version": "99"
},
"libresolv": {
"hash": "sha256-FtvwjJKSFX6j9APYPC8WLXVOjbHLZa1Gcoc8yxLy8qE=",
"version": "64"
}
}