darwin.libutil: convert to Meson and use mkAppleDerivation

This commit is contained in:
Randy Eckenrode
2024-10-10 16:23:06 -04:00
parent b8be4c4e6d
commit 4b4270cca3
5 changed files with 77 additions and 45 deletions
@@ -296,7 +296,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
libpthread = applePackage "libpthread" "osx-10.12.6" "sha256-QvJ9PERmrCWBiDmOWrLvQUKZ4JxHuh8gS5nlZKDLqE8=" {};
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=" {};
libutil = callPackage ./libutil/package.nix { };
libunwind = applePackage "libunwind" "osx-10.12.6" "sha256-CC0sndP/mKYe3dZu3v7fjuDASV4V4w7dAcnWMvpoquE=" {};
mDNSResponder = applePackage "mDNSResponder" "osx-10.12.6" "sha256-ddZr6tropkpdMJhq/kUlm3OwO8b0yxtkrMpwec8R4FY=" {};
objc4 = applePackage "objc4" "osx-10.12.6" "sha256-ZsxRpdsfv3Dxs7yBBCkjbKXKR6aXwkEpxc1XYXz7ueM=" {};
@@ -328,7 +328,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
Security = null;
xpc = null;
};
libutilHeaders = pkgs.darwin.libutil.override { headersOnly = true; };
libutilHeaders = lib.getDev self.libutil;
hfsHeaders = pkgs.darwin.hfs.override { headersOnly = true; };
libresolvHeaders= lib.getDev self.libresolv;
@@ -1,43 +0,0 @@
{ lib, stdenv, stdenvNoCC, appleDerivation', xcbuildHook
# headersOnly is true when building for libSystem
, headersOnly ? false }:
appleDerivation' (if headersOnly then stdenvNoCC else stdenv) {
nativeBuildInputs = lib.optional (!headersOnly) xcbuildHook;
prePatch = ''
substituteInPlace tzlink.c \
--replace '#include <xpc/xpc.h>' ""
'';
xcbuildFlags = [ "-target" "util" ];
installPhase = ''
mkdir -p $out/include
'' + lib.optionalString headersOnly ''
cp *.h $out/include
'' + lib.optionalString (!headersOnly)''
mkdir -p $out/lib $out/include
cp Products/Release/*.dylib $out/lib
cp Products/Release/*.h $out/include
# TODO: figure out how to get this to be right the first time around
install_name_tool -id $out/lib/libutil.dylib $out/lib/libutil.dylib
'';
# FIXME: headers are different against headersOnly. And all the headers are NOT in macos, do we really want them?
# appleHeaders = ''
# libutil.h
# mntopts.h
# tzlink.h
# wipefs.h
# '';
meta = with lib; {
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apple-psl20;
};
}
@@ -0,0 +1,49 @@
# Build settings based on the upstream Xcode project.
# See: https://github.com/apple-oss-distributions/libutil/blob/main/libutil.xcodeproj/project.pbxproj
# Project settings
project('libutil', 'c', 'cpp', version : '@version@')
# Dependencies
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
# Libraries
libutil = library(
'util',
darwin_versions : '1',
install : true,
sources : [
'ExtentManager.cpp',
'expand_number.c',
'getmntopts.c',
'humanize_number.c',
'pidfile.c',
'realhostname.c',
'reexec_to_match_kernel.c',
'trimdomain.c',
'tzbootuuid.c',
'tzlink.c',
'tzlink.h',
'wipefs.cpp',
],
)
install_headers(
'libutil.h',
'mntopts.h',
'tzlink.h',
'wipefs.h',
)
install_man(
'expand_number.3',
'getmntopts.3',
'humanize_number.3',
'pidfile.3',
'realhostname.3',
'realhostname_sa.3',
'reexec_to_match_kernel.3',
'trimdomain.3',
'wipefs.3',
)
@@ -0,0 +1,22 @@
{
copyfile,
mkAppleDerivation,
}:
mkAppleDerivation {
releaseName = "libutil";
outputs = [
"out"
"dev"
"man"
];
xcodeHash = "sha256-7t2yz022PUuVwMQP7NBB3I9neuhxJin5W2C+Y5IQYAA=";
buildInputs = [
copyfile
];
meta.description = "System utilities library";
}
@@ -46,5 +46,9 @@
"libresolv": {
"hash": "sha256-FtvwjJKSFX6j9APYPC8WLXVOjbHLZa1Gcoc8yxLy8qE=",
"version": "64"
},
"libutil": {
"hash": "sha256-4PFuk+CTLwvd/Ll9GLBkiIM0Sh/CVaiKwh5m1noheRs=",
"version": "47.30.1"
}
}