Skip to content

Commit da0b8ba

Browse files
authored
Use FoundationEssentials (#683)
1 parent 510e4ca commit da0b8ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+370
-188
lines changed

Benchmark/Sources/soto-benchmark/AWSSignerV4Suite.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2017-2020 the Soto project authors
5+
// Copyright (c) 2017-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

Benchmark/Sources/soto-benchmark/EncoderSuites.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2017-2020 the Soto project authors
5+
// Copyright (c) 2017-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

Sources/SotoCore/AWSClient.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2017-2023 the Soto project authors
5+
// Copyright (c) 2017-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -23,8 +23,11 @@ import NIOHTTP1
2323
import NIOTransportServices
2424
import SotoSignerV4
2525

26-
import struct Foundation.URL
27-
import struct Foundation.URLQueryItem
26+
#if canImport(FoundationEssentials)
27+
import FoundationEssentials
28+
#else
29+
import Foundation
30+
#endif
2831

2932
/// Client managing communication with AWS services
3033
///

Sources/SotoCore/AWSEndpointDiscovery.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2021-2022 the Soto project authors
5+
// Copyright (c) 2021-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -16,8 +16,11 @@ import Logging
1616
import NIOConcurrencyHelpers
1717
import NIOCore
1818

19-
import struct Foundation.Date
20-
import struct Foundation.TimeInterval
19+
#if canImport(FoundationEssentials)
20+
import FoundationEssentials
21+
#else
22+
import Foundation
23+
#endif
2124

2225
/// Endpoint list
2326
public struct AWSEndpoints {

Sources/SotoCore/AWSService.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2020-2022 the Soto project authors
5+
// Copyright (c) 2020-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -14,7 +14,11 @@
1414

1515
import NIOCore
1616

17-
import struct Foundation.URL
17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
20+
import Foundation
21+
#endif
1822

1923
/// Services object protocol. Contains a client to communicate with AWS and configuration for defining how to communicate.
2024
public protocol AWSService: Sendable {

Sources/SotoCore/Concurrency/EventStream.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2023 the Soto project authors
5+
// Copyright (c) 2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -12,9 +12,14 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import NIOCore
1716

17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
20+
import Foundation
21+
#endif
22+
1823
/// AsyncSequence of Event stream events
1924
public struct AWSEventStream<Event: Sendable>: Sendable {
2025
let base: AnyAsyncSequence<ByteBuffer>

Sources/SotoCore/Concurrency/ExpiringValue.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2023 the Soto project authors
5+
// Copyright (c) 2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -12,9 +12,14 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import Logging
1716

17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
20+
import Foundation
21+
#endif
22+
1823
/// Type holding a value and an expiration value.
1924
///
2025
/// When accessing the value you have to provide a closure that will update the

Sources/SotoCore/Credential/ConfigFileLoader.swift

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2017-2020 the Soto project authors
5+
// Copyright (c) 2017-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -12,12 +12,29 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import INIParser
1716
import Logging
1817
import NIOCore
1918
import NIOPosix
2019

20+
#if canImport(Glibc)
21+
import Glibc
22+
#elseif canImport(Musl)
23+
import Musl
24+
#elseif canImport(Darwin)
25+
import Darwin.C
26+
#elseif canImport(Android)
27+
import Android
28+
#else
29+
#error("Unsupported platform")
30+
#endif
31+
32+
#if canImport(FoundationEssentials)
33+
import FoundationEssentials
34+
#else
35+
import Foundation
36+
#endif
37+
2138
/// Load settings from AWS credentials and profile configuration files
2239
/// https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
2340
enum ConfigFileLoader {
@@ -310,16 +327,17 @@ enum ConfigFileLoader {
310327

311328
return pth
312329
}
313-
#elseif os(macOS)
314-
// can not use wordexp on macOS because for sandboxed application wexp.we_wordv == nil
330+
#elseif os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Android)
331+
// can not use wordexp on Apple OS's because for sandboxed application wexp.we_wordv == nil
332+
// wordexp does not exist on Android
315333
guard let home = getpwuid(getuid())?.pointee.pw_dir,
316334
let homePath = String(cString: home, encoding: .utf8)
317335
else {
318336
return filePath
319337
}
320338
return filePath.starts(with: "~") ? homePath + filePath.dropFirst() : filePath
321339
#else
322-
return NSString(string: filePath).expandingTildeInPath
340+
#error("Unsupported platform")
323341
#endif
324342
}
325343
}

Sources/SotoCore/Credential/ExpiringCredential.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2017-2023 the Soto project authors
5+
// Copyright (c) 2017-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -14,8 +14,11 @@
1414

1515
import SotoSignerV4
1616

17-
import struct Foundation.Date
18-
import struct Foundation.TimeInterval
17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
20+
import Foundation
21+
#endif
1922

2023
/// Credential provider whose credentials expire over tiem.
2124
public protocol ExpiringCredential: Credential {

Sources/SotoCore/Credential/Login/DPoPTokenGenerator.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Soto for AWS open source project
44
//
5-
// Copyright (c) 2017-2023 the Soto project authors
5+
// Copyright (c) 2017-2026 the Soto project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -15,7 +15,12 @@
1515
// DPoP Token Generator - JWT with EC Signing
1616

1717
import Crypto
18+
19+
#if canImport(FoundationEssentials)
20+
import FoundationEssentials
21+
#else
1822
import Foundation
23+
#endif
1924

2025
@available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
2126
struct DPoPTokenGenerator<JTI: JTIGenerator, Time: TimeProvider> {

0 commit comments

Comments
 (0)