2023-11-01 21:23:22 -04:00
|
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchurl, makeSetupHook, cmake, pkg-config, launchd, libdispatch, python3Minimal, libxml2, objc4, icu }:
|
2016-08-24 07:35:30 -04:00
|
|
|
|
|
2018-09-07 02:18:36 -04:00
|
|
|
|
let
|
|
|
|
|
# 10.12 adds a new sysdir.h that our version of CF in the main derivation depends on, but
|
|
|
|
|
# isn't available publicly, so instead we grab an older version of the same file that did
|
|
|
|
|
# not use sysdir.h, but provided the same functionality. Luckily it's simple :) hack hack
|
|
|
|
|
sysdir-free-system-directories = fetchurl {
|
|
|
|
|
url = "https://raw.githubusercontent.com/apple/swift-corelibs-foundation/9a5d8420f7793e63a8d5ec1ede516c4ebec939f0/CoreFoundation/Base.subproj/CFSystemDirectories.c";
|
|
|
|
|
sha256 = "0krfyghj4f096arvvpf884ra5czqlmbrgf8yyc0b3avqmb613pcc";
|
|
|
|
|
};
|
2019-02-11 18:29:28 -05:00
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2021-12-05 09:39:11 -05:00
|
|
|
|
pname = "swift-corefoundation";
|
|
|
|
|
version = "unstable-2018-09-14";
|
2016-08-24 07:35:30 -04:00
|
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
|
owner = "apple";
|
|
|
|
|
repo = "swift-corelibs-foundation";
|
2018-09-09 13:36:05 -04:00
|
|
|
|
rev = "71aaba20e1450a82c516af1342fe23268e15de0a";
|
|
|
|
|
sha256 = "17kpql0f27xxz4jjw84vpas5f5sn4vdqwv10g151rc3rswbwln1z";
|
2016-08-24 07:35:30 -04:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-01 21:23:22 -04:00
|
|
|
|
nativeBuildInputs = [ cmake pkg-config python3Minimal ];
|
2023-06-29 20:33:10 -04:00
|
|
|
|
buildInputs = [ (lib.getDev launchd) libdispatch libxml2 objc4 icu ];
|
2023-06-29 20:31:15 -04:00
|
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
|
./0001-Add-missing-TARGET_OS_-defines.patch
|
|
|
|
|
# CFMessagePort.h uses `bootstrap_check_in` without declaring it, which is defined in the launchd headers.
|
|
|
|
|
./0002-Add-missing-launchd-header.patch
|
|
|
|
|
# CFURLComponents fails to build with clang 16 due to an invalid pointer conversion. This is fixed upstream.
|
|
|
|
|
./0003-Fix-incompatible-pointer-conversion.patch
|
2023-06-29 20:33:10 -04:00
|
|
|
|
# Fix `CMakeLists.txt` to allow it to be used instead of `build.py` to build on Darwin.
|
|
|
|
|
./0004-Fix-Darwin-cmake-build.patch
|
|
|
|
|
# Install CF framework in `$out/Library/Frameworks` instead of `$out/System/Frameworks`.
|
|
|
|
|
./0005-Fix-framework-installation-path.patch
|
|
|
|
|
# Build a framework that matches the contents of the system CoreFoundation. This patch adds
|
|
|
|
|
# versioning and drops the prefix and suffix, so the dynamic library is named `CoreFoundation`
|
|
|
|
|
# instead of `libCoreFoundation.dylib`.
|
|
|
|
|
./0006-System-CF-framework-compatibility.patch
|
2023-06-29 20:35:48 -04:00
|
|
|
|
# Link against the nixpkgs ICU instead of using Apple’s vendored version.
|
|
|
|
|
./0007-Use-nixpkgs-icu.patch
|
2023-06-29 20:38:08 -04:00
|
|
|
|
# Don’t link against libcurl. This breaks a cycle between CF and curl, which depends on CF and
|
|
|
|
|
# uses the SystemConfiguration framework to support NAT64.
|
|
|
|
|
# This is safe because the symbols provided in CFURLSessionInterface are not provided by the
|
|
|
|
|
# system CoreFoundation. They are meant to be used by the implementation of `NSURLSession` in
|
|
|
|
|
# swift-corelibs-foundation, which is not built because it is not fully compatible with the
|
|
|
|
|
# system Foundation used on Darwin.
|
|
|
|
|
./0008-Dont-link-libcurl.patch
|
2023-06-29 20:31:15 -04:00
|
|
|
|
];
|
2021-04-26 15:24:03 -04:00
|
|
|
|
|
2021-01-28 16:55:53 -05:00
|
|
|
|
postPatch = ''
|
|
|
|
|
cd CoreFoundation
|
2016-08-24 07:35:30 -04:00
|
|
|
|
|
2018-09-07 02:18:36 -04:00
|
|
|
|
cp ${sysdir-free-system-directories} Base.subproj/CFSystemDirectories.c
|
|
|
|
|
|
|
|
|
|
# Includes xpc for some initialization routine that they don't define anyway, so no harm here
|
|
|
|
|
substituteInPlace PlugIn.subproj/CFBundlePriv.h \
|
|
|
|
|
--replace '#if (TARGET_OS_MAC' '#if (0'
|
|
|
|
|
|
|
|
|
|
# Why do we define __GNU__? Is that normal?
|
|
|
|
|
substituteInPlace Base.subproj/CFAsmMacros.h \
|
|
|
|
|
--replace '#if defined(__GNU__) ||' '#if 0 &&'
|
2016-08-24 07:35:30 -04:00
|
|
|
|
|
2018-09-07 02:18:36 -04:00
|
|
|
|
# The MIN macro doesn't seem to be defined sensibly for us. Not sure if our stdenv or their bug
|
|
|
|
|
substituteInPlace Base.subproj/CoreFoundation_Prefix.h \
|
|
|
|
|
--replace '#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX' '#if 1'
|
2016-08-24 07:35:30 -04:00
|
|
|
|
'';
|
|
|
|
|
|
2023-06-29 20:33:10 -04:00
|
|
|
|
env.NIX_CFLAGS_COMPILE = toString [
|
|
|
|
|
# Silence warnings regarding other targets
|
|
|
|
|
"-Wno-error=undef-prefix"
|
|
|
|
|
# Avoid redefinitions when including objc headers
|
|
|
|
|
"-DINCLUDE_OBJC=1"
|
|
|
|
|
];
|
2019-11-17 08:55:00 -05:00
|
|
|
|
|
2023-06-29 20:33:10 -04:00
|
|
|
|
cmakeFlags = [
|
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
|
|
|
|
"-DCF_ENABLE_LIBDISPATCH=OFF"
|
|
|
|
|
];
|
2018-09-07 02:18:36 -04:00
|
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
2019-11-17 08:55:00 -05:00
|
|
|
|
|
2023-06-29 20:33:10 -04:00
|
|
|
|
postInstall = ''
|
|
|
|
|
install_name_tool -id '@rpath/CoreFoundation.framework/Versions/A/CoreFoundation' \
|
|
|
|
|
"$out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation"
|
2023-05-19 15:49:09 -04:00
|
|
|
|
|
2023-06-21 08:20:55 -04:00
|
|
|
|
mkdir -p "$out/nix-support"
|
|
|
|
|
'';
|
2016-08-24 07:35:30 -04:00
|
|
|
|
}
|