Skip to content

Commit 4e2db6d

Browse files
committed
Fix Package.swift include behavior for Mac
1 parent d48550c commit 4e2db6d

File tree

3 files changed

+69
-67
lines changed

3 files changed

+69
-67
lines changed

ci/LDKSwift/Libraries/arm64/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Dynamic Compilation Instructions
2+
3+
// todo

ci/LDKSwift/Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/LDKSwift/Package.swift

Lines changed: 50 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,63 @@ import Foundation
66

77
var cBindingsBase = "/Users/arik/Developer/ldk-c-bindings"
88
if let bindingsBase = getenv("LDK_C_BINDINGS_BASE") {
9-
cBindingsBase = String(utf8String: bindingsBase)!
9+
cBindingsBase = String(utf8String: bindingsBase)!
1010
}
1111

12-
var fileExtension = ".dylib"
13-
#if os(Linux)
14-
fileExtension = ".a"
15-
#endif
16-
1712
var linkerSettings: [PackageDescription.LinkerSetting] = [
18-
.linkedLibrary("\(cBindingsBase)/lightning-c-bindings/target/debug/libldk\(fileExtension)")
13+
.linkedLibrary("\(cBindingsBase)/lightning-c-bindings/target/debug/libldk.a")
1914
]
2015

21-
#if os(Linux)
22-
linkerSettings.append(.linkedLibrary(String(utf8String: getenv("LLVM_CLANG_ASAN_PATH")!)!))
16+
#if os(macOS)
17+
linkerSettings = [
18+
.unsafeFlags(["-L\(cBindingsBase)/lightning-c-bindings/target/debug"]),
19+
.linkedLibrary("ldk")
20+
]
21+
#elseif os(Linux)
22+
linkerSettings.append(.linkedLibrary(String(utf8String: getenv("LLVM_CLANG_ASAN_PATH")!)!, .when(platforms: [.linux])))
2323
#endif
2424

2525
let package = Package(
26-
name: "LDKSwift",
27-
products: [
28-
.library(
29-
name: "LDKSwift",
30-
targets: ["LDKSwift"]),
31-
// .library(name: "LDKSwift", type: .dynamic, targets: ["LDKSwift"])
32-
],
33-
dependencies: [
34-
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"3.0.0")
35-
],
36-
targets: [
37-
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
38-
// Targets can depend on other targets in this package, and on products in packages this package depends on.
39-
.target(name: "LDKHeaders"),
40-
// .systemLibrary(name: "LDKHeaders"),
41-
.target(
42-
name: "LDKSwift",
43-
dependencies: [
44-
"LDKHeaders"
45-
],
46-
path: nil,
47-
exclude: [],
48-
sources: nil,
49-
// sources: [
50-
// "ldk_net.h",
51-
// "ldk_net.c",
52-
// "ldk_rust_types.h",
53-
// "ldk_ver.h",
54-
// "lightning.h",
55-
// "SanitySample.swift"
56-
// ],
57-
resources: nil,
58-
publicHeadersPath: "include",
59-
cSettings: nil,
60-
// cSettings: [
61-
// .headerSearchPath("include"),
62-
// ],
63-
cxxSettings: nil,
64-
swiftSettings: nil,
65-
linkerSettings: linkerSettings
66-
),
67-
.testTarget(
68-
name: "LDKSwiftTests",
69-
dependencies: [
70-
"LDKSwift",
71-
"LDKHeaders",
72-
.product(name: "Crypto", package: "swift-crypto")
73-
],
74-
path: nil,
75-
exclude: [],
76-
// exclude: ["SampleTest.swift"],
77-
sources: nil,
78-
// sources: [
79-
// "SampleTest.swift"
80-
// ],
81-
cSettings: nil, cxxSettings: nil, swiftSettings: nil,
82-
linkerSettings: nil)
26+
name: "LDKSwift",
27+
products: [
28+
.library(
29+
name: "LDKSwift",
30+
targets: ["LDKSwift"]),
31+
],
32+
dependencies: [
33+
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"3.0.0")
34+
],
35+
targets: [
36+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
37+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
38+
.target(name: "LDKHeaders"),
39+
.target(
40+
name: "LDKSwift",
41+
dependencies: [
42+
"LDKHeaders"
43+
],
44+
path: nil,
45+
exclude: [],
46+
sources: nil,
47+
resources: nil,
48+
publicHeadersPath: "include",
49+
cSettings: nil,
50+
cxxSettings: nil,
51+
swiftSettings: nil,
52+
linkerSettings: linkerSettings
53+
),
54+
.testTarget(
55+
name: "LDKSwiftTests",
56+
dependencies: [
57+
"LDKSwift",
58+
"LDKHeaders",
59+
.product(name: "Crypto", package: "swift-crypto")
60+
],
61+
path: nil,
62+
exclude: [],
63+
sources: nil,
64+
cSettings: nil, cxxSettings: nil, swiftSettings: nil,
65+
linkerSettings: nil)
8366

84-
]
67+
]
8568
)

0 commit comments

Comments
 (0)