swiftPackages.Foundation: init at 5.7

This commit is contained in:
Stéphan Kochen 2022-07-25 21:42:22 +02:00
parent 3c54a5dce6
commit 89f9790858
3 changed files with 72 additions and 0 deletions

View File

@ -61,6 +61,10 @@ let
then null # part of libsystem
else callPackage ./libdispatch { };
Foundation = if stdenv.isDarwin
then apple_sdk.frameworks.Foundation
else callPackage ./foundation { };
};
in self

View File

@ -0,0 +1,60 @@
{ lib
, stdenv
, fetchFromGitHub
, cmake
, ninja
, swift
, Dispatch
, icu
, libxml2
, curl
}:
stdenv.mkDerivation rec {
pname = "swift-corelibs-foundation";
# Releases are made as part of the Swift toolchain, so versions should match.
version = "5.7";
src = fetchFromGitHub {
owner = "apple";
repo = "swift-corelibs-foundation";
rev = "swift-${version}-RELEASE";
hash = "sha256-6XUSC6759dcG24YapWicjRzUnmVVe0QPSsLEw4sQNjI=";
};
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ninja swift ];
buildInputs = [ icu libxml2 curl ];
propagatedBuildInputs = [ Dispatch ];
preConfigure = ''
# Fails to build with -D_FORTIFY_SOURCE.
NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}
'';
postInstall = ''
# Split up the output.
mkdir $dev
mv $out/lib/swift/${swift.swiftOs} $out/swiftlibs
mv $out/lib/swift $dev/include
mkdir $out/lib/swift
mv $out/swiftlibs $out/lib/swift/${swift.swiftOs}
# Provide a CMake module. This is primarily used to glue together parts of
# the Swift toolchain. Modifying the CMake config to do this for us is
# otherwise more trouble.
mkdir -p $dev/lib/cmake/Foundation
export dylibExt="${stdenv.hostPlatform.extensions.sharedLibrary}"
export swiftOs="${swift.swiftOs}"
substituteAll ${./glue.cmake} $dev/lib/cmake/Foundation/FoundationConfig.cmake
'';
meta = {
description = "Core utilities, internationalization, and OS independence for Swift";
homepage = "https://github.com/apple/swift-corelibs-foundation";
platforms = lib.platforms.linux;
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ dtzWill trepetti dduan trundle stephank ];
};
}

View File

@ -0,0 +1,8 @@
add_library(Foundation SHARED IMPORTED)
set_property(TARGET Foundation PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libFoundation@dylibExt@")
add_library(FoundationNetworking SHARED IMPORTED)
set_property(TARGET FoundationNetworking PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libFoundationNetworking@dylibExt@")
add_library(FoundationXML SHARED IMPORTED)
set_property(TARGET FoundationXML PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libFoundationXML@dylibExt@")