Skip to content

Commit e9309c9

Browse files
authored
Merge pull request #291 from compnerd/loader
TSCUtility: deprecate dl*
2 parents d318eaa + 25e7fd1 commit e9309c9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/TSCUtility/dlopen.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import protocol Foundation.CustomNSError
1212
import var Foundation.NSLocalizedDescriptionKey
1313
import TSCLibc
1414

15+
// FIXME: deprecate 2/2022, remove once clients transitioned
16+
@available(*, deprecated, message: "moved to swift-driver")
1517
public final class DLHandle {
1618
#if os(Windows)
1719
typealias Handle = HMODULE
@@ -48,6 +50,8 @@ public final class DLHandle {
4850
}
4951
}
5052

53+
// FIXME: deprecate 2/2022, remove once clients transitioned
54+
@available(*, deprecated, message: "moved to swift-driver")
5155
public struct DLOpenFlags: RawRepresentable, OptionSet {
5256

5357
#if !os(Windows)
@@ -77,6 +81,8 @@ public struct DLOpenFlags: RawRepresentable, OptionSet {
7781
}
7882
}
7983

84+
// FIXME: deprecate 2/2022, remove once clients transitioned
85+
@available(*, deprecated, message: "moved to swift-driver")
8086
public enum DLError: Error {
8187
case `open`(String)
8288
case close(String)
@@ -88,6 +94,8 @@ extension DLError: CustomNSError {
8894
}
8995
}
9096

97+
// FIXME: deprecate 2/2022, remove once clients transitioned
98+
@available(*, deprecated, message: "moved to swift-driver")
9199
public func dlopen(_ path: String?, mode: DLOpenFlags) throws -> DLHandle {
92100
#if os(Windows)
93101
guard let handle = path?.withCString(encodedAs: UTF16.self, LoadLibraryW) else {
@@ -101,6 +109,8 @@ public func dlopen(_ path: String?, mode: DLOpenFlags) throws -> DLHandle {
101109
return DLHandle(rawValue: handle)
102110
}
103111

112+
// FIXME: deprecate 2/2022, remove once clients transitioned
113+
@available(*, deprecated, message: "moved to swift-driver")
104114
public func dlsym<T>(_ handle: DLHandle, symbol: String) -> T? {
105115
#if os(Windows)
106116
guard let ptr = GetProcAddress(handle.rawValue!, symbol) else {
@@ -114,11 +124,15 @@ public func dlsym<T>(_ handle: DLHandle, symbol: String) -> T? {
114124
return unsafeBitCast(ptr, to: T.self)
115125
}
116126

127+
// FIXME: deprecate 2/2022, remove once clients transitioned
128+
@available(*, deprecated, message: "moved to swift-driver")
117129
public func dlclose(_ handle: DLHandle) throws {
118130
try handle.close()
119131
}
120132

121133
#if !os(Windows)
134+
// FIXME: deprecate 2/2022, remove once clients transitioned
135+
@available(*, deprecated, message: "moved to swift-driver")
122136
public func dlerror() -> String? {
123137
if let err: UnsafeMutablePointer<Int8> = dlerror() {
124138
return String(cString: err)

0 commit comments

Comments
 (0)