Skip to content

Commit ed54203

Browse files
authored
Replace partial MiniFoundation with FoundationEssentials (#307)
Give up on the overwhelming –and dumb– task of replacing Foundation completely. The footprint with FoundationEssentials is only marginally bigger, for dramatic benefits. If going serious at some point, dropping Swift would be a much wiser choice in the future. Basically, merge MiniFoundation Native and Compat targets. Then export Foundation on Apple, and FoundationEssentials everywhere else. In the latter case, add some custom code behind the MINIF_COMPAT symbol to attain feature-parity with Foundation for the sake of the library. MiniFoundation folders: - Foundation (Apple) - FoundationCompat (cross) - FoundationEssentials (Apple and cross) - Everything else is shared as before Steps: - Delete SWON, rely on Codable/JSONEncoder/JSONDecoder - Delete redundant reimplementations (Data, Date, FileManager, URL, UUID) - Delete unused C code - Delete "mini" wrappers in the middle (e.g. MiniURLProtocol) - Return contents of URL path, not of a generic URL (would potentially require networking) - Implement compatible regular expressions in C++ (still targeting Swift 5.x) - Always export Dispatch - Disambiguate UUID on Windows CMake issues: - Enforce FoundationEssentials autolinked libs manually in Linux/Android toolchains ([dynamic linking failure if autolinked libs are not provided](https://forums.swift.org/t/missing-symbol-with-static-foundationessentials-on-linux/85044/))
1 parent e23ba70 commit ed54203

File tree

83 files changed

+297
-3028
lines changed

Some content is hidden

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

83 files changed

+297
-3028
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ jobs:
1717
- uses: partout-io/action-prepare-xcode-build@master
1818
with:
1919
access-token: ${{ secrets.GITHUB_TOKEN }}
20-
- name: Fetch SWON submodule
21-
run: |
22-
git submodule init vendors/swon
23-
git submodule update --depth 1 vendors/swon
2420
- name: Ensure previews are off
2521
run: |
2622
expected="let forPreviews = false"

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44
[submodule "vendors/openssl"]
55
path = vendors/openssl
66
url = https://github.com/openssl/openssl
7-
[submodule "vendors/swon"]
8-
path = vendors/swon
9-
url = https://github.com/keeshux/swon

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ if(PP_BUILD_USE_WGGO)
3737
include("vendors/wg-go.cmake")
3838
endif()
3939

40-
# Include SWON macros
41-
add_subdirectory("vendors/swon")
42-
4340
# Fetch wintun.dll on Windows
4441
if(WIN32)
4542
set(WINTUN_VERSION "0.14.1")
@@ -57,5 +54,4 @@ if(PP_BUILD_LIBRARY)
5754
if(PP_BUILD_USE_WGGO)
5855
target_link_libraries(partout_c PUBLIC WireGuardGoInterface)
5956
endif()
60-
target_link_libraries(partout PUBLIC SWONInterface)
6157
endif()

Package.swift

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ let package = Package(
112112
]
113113
)
114114

115-
// SWON macros (submodule)
116-
package.dependencies.append(
117-
.package(url: "https://github.com/keeshux/swon", from: "0.1.0")
118-
)
119-
120115
// Swift-DocC for documentation, do not include by default
121116
if envDocs {
122117
package.dependencies.append(
@@ -141,8 +136,7 @@ package.targets.append(contentsOf: [
141136
dependencies: [
142137
"MiniFoundation",
143138
"PartoutABI_C",
144-
"PartoutCore_C",
145-
"swon"
139+
"PartoutCore_C"
146140
],
147141
swiftSettings: useFoundationCompatibility.swiftSettings
148142
),
@@ -426,27 +420,11 @@ package.products.append(
426420
package.targets.append(contentsOf: [
427421
.target(
428422
name: "MiniFoundation",
429-
dependencies: [
430-
useFoundationCompatibility == .on ?
431-
.target(name: "MiniFoundationCompat") :
432-
.target(name: "MiniFoundationNative")
433-
],
423+
dependencies: ["MiniFoundation_C"],
434424
swiftSettings: useFoundationCompatibility.swiftSettings
435425
),
436426
.target(
437-
name: "MiniFoundationCore",
438-
dependencies: ["MiniFoundationCore_C"]
439-
),
440-
.target(
441-
name: "MiniFoundationCore_C"
442-
),
443-
.target(
444-
name: "MiniFoundationCompat",
445-
dependencies: ["MiniFoundationCore"]
446-
),
447-
.executableTarget(
448-
name: "MiniFoundationExample",
449-
dependencies: ["MiniFoundation"]
427+
name: "MiniFoundation_C"
450428
),
451429
.testTarget(
452430
name: "MiniFoundationTests",
@@ -458,15 +436,6 @@ package.targets.append(contentsOf: [
458436
)
459437
])
460438

461-
if useFoundationCompatibility == .off {
462-
package.targets.append(
463-
.target(
464-
name: "MiniFoundationNative",
465-
dependencies: ["MiniFoundationCore"]
466-
)
467-
)
468-
}
469-
470439
// MARK: - Configuration structures
471440

472441
enum Area: CaseIterable {

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ Libraries:
129129
- [MbedTLS][credits-mbedtls]
130130
- [OpenSSL][credits-openssl]
131131
- [url.c][credits-url.c]
132-
- [uuidv4][credits-uuidv4]
133132
- [Wintun][credits-wintun]
134133
- [WireGuard (Go)][credits-wireguard-go]
135134

Sources/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ target_compile_options(partout_c PRIVATE
1212

1313
# Header search paths from all C targets
1414
set(PARTOUT_C_INCLUDE_DIRS
15-
${CMAKE_CURRENT_SOURCE_DIR}/MiniFoundationCore_C/include
15+
${CMAKE_CURRENT_SOURCE_DIR}/MiniFoundation_C/include
1616
${CMAKE_CURRENT_SOURCE_DIR}/PartoutABI_C/include
1717
${CMAKE_CURRENT_SOURCE_DIR}/PartoutCore_C/include
1818
${CMAKE_CURRENT_SOURCE_DIR}/PartoutOpenVPN_C/include
@@ -92,15 +92,9 @@ if(USE_COMPAT)
9292
-DMINIF_COMPAT
9393
)
9494
set(EXCLUDED_PATTERNS
95-
MiniFoundationNative.*
9695
PartoutOS\/Apple.*
9796
)
98-
else()
99-
set(EXCLUDED_PATTERNS
100-
MiniFoundationCompat.*
101-
)
10297
endif()
103-
list(APPEND EXCLUDED_PATTERNS MiniFoundationExample.*)
10498

10599
foreach(pattern ${EXCLUDED_PATTERNS})
106100
list(FILTER PARTOUT_SOURCES EXCLUDE REGEX ${pattern})

Sources/MiniFoundationCore/MiniRegularExpression.swift renamed to Sources/MiniFoundation/Core/EnumeratingRegex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
//
33
// SPDX-License-Identifier: MIT
44

5-
public protocol MiniRegularExpression: Sendable {
5+
public protocol EnumeratingRegex: Sendable {
66
func enumerateMatches(in string: String, using block: @escaping (String) -> Void)
77
}
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// SPDX-License-Identifier: MIT
44

5-
internal import _MiniFoundationCore_C
5+
internal import _MiniFoundation_C
66

77
public final class PRNG {
88
public init() {
File renamed without changes.

0 commit comments

Comments
 (0)