swiftPackages.swiftpm: patch swift-crypto as needed

This commit is contained in:
Sam
2025-09-18 11:40:55 -07:00
parent 0800438fcd
commit 6e1a464f82
3 changed files with 34 additions and 1 deletions

View File

@@ -88,6 +88,11 @@ lib.mapAttrs mkInstallScript {
SwiftCrypto = ''
add_library(Crypto SHARED IMPORTED)
set_property(TARGET Crypto PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCrypto@sharedLibExt@")
add_library(_CryptoExtras SHARED IMPORTED)
# this can't possibly be right... I really think it should be `libCryptoExtras`
# swift-certificates did build with this though.....
set_property(TARGET _CryptoExtras PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCrypto@sharedLibExt@")
'';
SwiftASN1 = ''

View File

@@ -23,7 +23,11 @@
let
inherit (swift) swiftOs swiftModuleSubdir swiftStaticModuleSubdir;
inherit (swift)
swiftOs
swiftModuleSubdir
swiftStaticModuleSubdir
;
sharedLibraryExt = stdenv.hostPlatform.extensions.sharedLibrary;
sources = callPackage ../sources.nix { };
@@ -322,6 +326,14 @@ let
fetchSubmodules = true;
};
buildInputs = [
swift-asn1
];
patches = [
./patches/install-crypto-extras.patch
];
postPatch = ''
# Fix use of hardcoded tool paths on Darwin.
substituteInPlace CMakeLists.txt \
@@ -336,6 +348,12 @@ let
# Headers are not installed.
cp -r ../Sources/CCryptoBoringSSL/include $out/include
# Swift modules are put in the wrong place by default (and not all are linked)
mkdir -p $out/${swiftModuleSubdir}
rm -rf $out/${swiftModuleSubdir}/*.swift{module,doc}
# I assume we don't care about .swiftsourceinfo
cp swift/*.swift{module,doc} $out/${swiftModuleSubdir}/
'';
};

View File

@@ -0,0 +1,10 @@
Install _CryptoExtras target when building with CMake
--- a/Sources/_CryptoExtras/CMakeLists.txt
+++ b/Sources/_CryptoExtras/CMakeLists.txt
@@ -42,4 +42,5 @@ target_link_options(_CryptoExtras PRIVATE
set_target_properties(_CryptoExtras PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
+_install_target(_CryptoExtras)
set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS _CryptoExtras)