Skip to content

Commit fd7cf87

Browse files
committed
Start converting libraries to use FoundationEssentials
This helps on binary size if we can successfully get all Foundation imports out of our dep chain. It seems Foundation brings in a 30MiB ICU blob, which bloats vmexec and vminitd.
1 parent 250546f commit fd7cf87

File tree

16 files changed

+125
-7
lines changed

16 files changed

+125
-7
lines changed

Sources/ContainerizationOS/AsyncSignalHandler.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414
// limitations under the License.
1515
//===----------------------------------------------------------------------===//
1616

17-
import Foundation
17+
import Dispatch
1818
import Synchronization
1919

20+
#if canImport(Musl)
21+
import Musl
22+
#elseif canImport(Glibc)
23+
import Glibc
24+
#elseif canImport(Darwin)
25+
import Darwin
26+
#endif
27+
2028
/// Async friendly wrapper around `DispatchSourceSignal`. Provides an `AsyncStream`
2129
/// interface to get notified of received signals.
2230
public final class AsyncSignalHandler: Sendable {

Sources/ContainerizationOS/File.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@
1414
// limitations under the License.
1515
//===----------------------------------------------------------------------===//
1616

17+
#if canImport(Musl)
18+
import Musl
19+
#elseif canImport(Glibc)
20+
import Glibc
21+
#elseif canImport(Darwin)
22+
import Darwin
23+
#endif
24+
25+
#if canImport(FoundationEssentials)
26+
import FoundationEssentials
27+
#else
1728
import Foundation
29+
#endif
1830

1931
/// Trivial type to discover information about a given file (uid, gid, mode...).
2032
public struct File: Sendable {
@@ -52,7 +64,7 @@ public struct File: Sendable {
5264
/// `FileInfo` holds and provides easy access to stat(2) data
5365
/// for a file.
5466
public struct FileInfo: Sendable {
55-
private let _stat_t: Foundation.stat
67+
private let _stat_t: stat
5668
private let _path: String
5769

5870
init(_ path: String, stat: stat) {

Sources/ContainerizationOS/Keychain/KeychainQuery.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#if os(macOS)
18+
#if canImport(FoundationEssentials)
19+
import FoundationEssentials
20+
#else
1821
import Foundation
22+
#endif
1923

2024
/// Holds the result of a query to the keychain.
2125
public struct KeychainQueryResult {

Sources/ContainerizationOS/Keychain/RegistryInfo.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
// limitations under the License.
1515
//===----------------------------------------------------------------------===//
1616

17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
1720
import Foundation
21+
#endif
1822

1923
/// Holds the stored attributes for a registry.
2024
public struct RegistryInfo: Sendable {

Sources/ContainerizationOS/Linux/Binfmt.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
// limitations under the License.
1515
//===----------------------------------------------------------------------===//
1616

17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
1720
import Foundation
21+
#endif
1822

1923
#if canImport(Musl)
2024
import Musl

Sources/ContainerizationOS/Linux/Capabilities.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
//===----------------------------------------------------------------------===//
1616

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

2025
// MARK: - Configuration Types
2126

Sources/ContainerizationOS/Linux/Epoll.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#if os(Linux)
18+
#if canImport(FoundationEssentials)
19+
import FoundationEssentials
20+
#else
1821
import Foundation
22+
#endif
1923

2024
#if canImport(Musl)
2125
import Musl

Sources/ContainerizationOS/Mount/Mount.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
//===----------------------------------------------------------------------===//
1616

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

2025
#if canImport(Musl)
2126
import Musl

Sources/ContainerizationOS/POSIXError+Helpers.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@
1414
// limitations under the License.
1515
//===----------------------------------------------------------------------===//
1616

17+
#if canImport(Musl)
18+
import Musl
19+
#elseif canImport(Glibc)
20+
import Glibc
21+
#elseif canImport(Darwin)
22+
import Darwin
23+
#endif
24+
25+
#if canImport(FoundationEssentials)
26+
import FoundationEssentials
27+
#else
1728
import Foundation
29+
#endif
1830

1931
extension POSIXError {
2032
public static func fromErrno() -> POSIXError {

Sources/ContainerizationOS/Path.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
// limitations under the License.
1515
//===----------------------------------------------------------------------===//
1616

17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
1720
import Foundation
21+
#endif
1822

1923
/// `Path` provides utilities to look for binaries in the current PATH,
2024
/// or to return the current PATH.

0 commit comments

Comments
 (0)