From 5b25d00c528b4fa3a7faf6c8fb02d7b14c2f5f06 Mon Sep 17 00:00:00 2001 From: nil4 Date: Wed, 23 Oct 2024 10:28:32 +0200 Subject: [PATCH] [windows] use `bin/deps-windows` for Swift Set up include and lib paths for pickup --- Package.swift | 57 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/Package.swift b/Package.swift index d7f01b65..29b76398 100644 --- a/Package.swift +++ b/Package.swift @@ -2,6 +2,41 @@ import PackageDescription +// swift-tools-version: 6.0 + +import PackageDescription + +#if os(Windows) +let thisFilePath = #filePath +let depsWindowsPath = "\(thisFilePath)\\bin\\deps-windows" + +let cSettings: [CSetting]? = [ + .unsafeFlags([ + "-I\(depsWindowsPath)\\include" + ]) +] +let linkerSettings: [LinkerSetting]? = [ + .unsafeFlags([ + "-L./\(depsWindowsPath)\\lib" + ]) +] + +let libtommathTarget = Target.systemLibrary(name: "libtommath", path: "Sources/libtommath-win") +let libtomcryptTarget = Target.systemLibrary(name: "libtomcrypt", path: "Sources/libtomcrypt-win") +let zTarget = Target.systemLibrary(name: "Z", path: "Sources/Z-win") +#else +let cSettings: [CSetting]? = [] +let linkerSettings: [LinkerSetting]? = [] + +let libtommathTarget = Target.target(name: "libtommath") +let libtomcryptTarget = Target.target(name: "libtomcrypt", cSettings: [ + .unsafeFlags([ "-Wno-shorten-64-to-32" ]) +]) +let zTarget = Target.target(name: "Z", linkerSettings: [ + .linkedLibrary("z") +]) +#endif + let package = Package( name: "RoyalVNCKit", @@ -35,24 +70,20 @@ let package = Package( dependencies: [ "RoyalVNCKitC", "d3des", - "libtommath", - "libtomcrypt", - "Z" + .byName(name: libtommathTarget.name), + .byName(name: libtomcryptTarget.name), + .byName(name: zTarget.name) ], - swiftSettings: [ .swiftLanguageMode(.v5) ] + cSettings: cSettings, + swiftSettings: [ .swiftLanguageMode(.v5) ], + linkerSettings: linkerSettings ), .target(name: "d3des"), - .target(name: "libtommath"), - - .target(name: "libtomcrypt", cSettings: [ - .unsafeFlags([ "-Wno-shorten-64-to-32" ]) - ]), - - .target(name: "Z", linkerSettings: [ - .linkedLibrary("z") - ]), + libtommathTarget, + libtomcryptTarget, + zTarget, .executableTarget( name: "RoyalVNCKitDemo",