From 3c54a5dce6119d1dab8838ca6766ea4e3d257e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Kochen?= Date: Mon, 25 Jul 2022 20:36:50 +0200 Subject: [PATCH] swiftPackages.Dispatch: 5.5 -> 5.7 --- pkgs/development/compilers/swift/default.nix | 4 ++ .../compilers/swift/libdispatch/default.nix | 46 +++++++++++++++++++ .../libdispatch/disable-swift-overlay.patch | 35 ++++++++++++++ .../compilers/swift/libdispatch/glue.cmake | 5 ++ .../swift-corelibs-libdispatch/default.nix | 42 ----------------- pkgs/top-level/all-packages.nix | 2 +- 6 files changed, 91 insertions(+), 43 deletions(-) create mode 100644 pkgs/development/compilers/swift/libdispatch/default.nix create mode 100644 pkgs/development/compilers/swift/libdispatch/disable-swift-overlay.patch create mode 100644 pkgs/development/compilers/swift/libdispatch/glue.cmake delete mode 100644 pkgs/development/libraries/swift-corelibs-libdispatch/default.nix diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix index bd4372593b25..6f2b61a2aba8 100644 --- a/pkgs/development/compilers/swift/default.nix +++ b/pkgs/development/compilers/swift/default.nix @@ -57,6 +57,10 @@ let swift = swift-unwrapped; }; + Dispatch = if stdenv.isDarwin + then null # part of libsystem + else callPackage ./libdispatch { }; + }; in self diff --git a/pkgs/development/compilers/swift/libdispatch/default.nix b/pkgs/development/compilers/swift/libdispatch/default.nix new file mode 100644 index 000000000000..57a0633ef76a --- /dev/null +++ b/pkgs/development/compilers/swift/libdispatch/default.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, ninja +, useSwift ? true, swift +}: + +stdenv.mkDerivation rec { + pname = "swift-corelibs-libdispatch"; + + # Releases are made as part of the Swift toolchain, so versions should match. + version = "5.7"; + src = fetchFromGitHub { + owner = "apple"; + repo = "swift-corelibs-libdispatch"; + rev = "swift-${version}-RELEASE"; + hash = "sha256-1qbXiC1k9+T+L6liqXKg6EZXqem6KEEx8OctuL4Kb2o="; + }; + + outputs = [ "out" "dev" "man" ]; + + nativeBuildInputs = [ cmake ] + ++ lib.optionals useSwift [ ninja swift ]; + + patches = [ ./disable-swift-overlay.patch ]; + + cmakeFlags = lib.optional useSwift "-DENABLE_SWIFT=ON"; + + postInstall = '' + # 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/dispatch + export dylibExt="${stdenv.hostPlatform.extensions.sharedLibrary}" + substituteAll ${./glue.cmake} $dev/lib/cmake/dispatch/dispatchConfig.cmake + ''; + + meta = { + description = "Grand Central Dispatch"; + homepage = "https://github.com/apple/swift-corelibs-libdispatch"; + platforms = lib.platforms.linux; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ cmm dtzWill trepetti dduan trundle stephank ]; + }; +} diff --git a/pkgs/development/compilers/swift/libdispatch/disable-swift-overlay.patch b/pkgs/development/compilers/swift/libdispatch/disable-swift-overlay.patch new file mode 100644 index 000000000000..0ea1869d5528 --- /dev/null +++ b/pkgs/development/compilers/swift/libdispatch/disable-swift-overlay.patch @@ -0,0 +1,35 @@ +Enabling Swift support is normally intended for building an overlay for a +Swift SDK, which changes the installation layout. Prevent this. + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -287,7 +287,7 @@ configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in" + add_compile_definitions($<$,$>:HAVE_CONFIG_H>) + + +-if(ENABLE_SWIFT) ++if(0) + set(INSTALL_TARGET_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$>:_static>/$" CACHE PATH "Path where the libraries will be installed") + set(INSTALL_DISPATCH_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$>:_static>/dispatch" CACHE PATH "Path where the headers will be installed for libdispatch") + set(INSTALL_BLOCK_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$>:_static>/Block" CACHE PATH "Path where the headers will be installed for the blocks runtime") +--- a/man/CMakeLists.txt ++++ b/man/CMakeLists.txt +@@ -1,6 +1,6 @@ + + # TODO(compnerd) add symlinks +-if(NOT ENABLE_SWIFT) ++if(1) + install(FILES + dispatch.3 + dispatch_after.3 +--- a/src/swift/CMakeLists.txt ++++ b/src/swift/CMakeLists.txt +@@ -47,7 +47,7 @@ get_swift_host_arch(swift_arch) + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftmodule + ${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftdoc +- DESTINATION ${INSTALL_TARGET_DIR}/${swift_arch}) ++ DESTINATION ${INSTALL_TARGET_DIR}/swift) + set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS swiftDispatch) + install(TARGETS swiftDispatch + EXPORT dispatchExports diff --git a/pkgs/development/compilers/swift/libdispatch/glue.cmake b/pkgs/development/compilers/swift/libdispatch/glue.cmake new file mode 100644 index 000000000000..dd696dc61085 --- /dev/null +++ b/pkgs/development/compilers/swift/libdispatch/glue.cmake @@ -0,0 +1,5 @@ +add_library(dispatch SHARED IMPORTED) +set_property(TARGET dispatch PROPERTY IMPORTED_LOCATION "@out@/lib/libdispatch@dylibExt@") + +add_library(swiftDispatch SHARED IMPORTED) +set_property(TARGET swiftDispatch PROPERTY IMPORTED_LOCATION "@out@/lib/libswiftDispatch@dylibExt@") diff --git a/pkgs/development/libraries/swift-corelibs-libdispatch/default.nix b/pkgs/development/libraries/swift-corelibs-libdispatch/default.nix deleted file mode 100644 index 76cc0d3e30ef..000000000000 --- a/pkgs/development/libraries/swift-corelibs-libdispatch/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ lib -, clangStdenv -, fetchFromGitHub -, cmake -, ninja -, libbsd -, libsystemtap -}: - -let - version = "5.5"; -in clangStdenv.mkDerivation { - pname = "swift-corelibs-libdispatch"; - inherit version; - - outputs = [ "out" "dev" "man" ]; - - src = fetchFromGitHub { - owner = "apple"; - repo = "swift-corelibs-libdispatch"; - rev = "swift-${version}-RELEASE"; - sha256 = "sha256-MbLgmS6qRSRT+2dGqbYTNb5MTM4Wz/grDXFk1kup+jk="; - }; - - nativeBuildInputs = [ - cmake - ninja - ]; - - buildInputs = [ - libbsd - libsystemtap - ]; - - meta = { - description = "Grand Central Dispatch"; - homepage = "https://github.com/apple/swift-corelibs-libdispatch"; - platforms = lib.platforms.linux; - license = lib.licenses.asl20; - maintainers = [ lib.maintainers.cmm ]; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index da9854171028..2f15ac166b59 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -37567,7 +37567,7 @@ with pkgs; mictray = callPackage ../tools/audio/mictray { }; - swift-corelibs-libdispatch = callPackage ../development/libraries/swift-corelibs-libdispatch { }; + swift-corelibs-libdispatch = swiftPackages.Dispatch; swaysettings = callPackage ../applications/misc/swaysettings { };