Skip to content

Commit da7d339

Browse files
authored
Enable armv7em CPU and none OS triples (#6438)
Adds preliminary knowledge of `armv7em` CPU and `none` OS environments to SwiftPM. Future diffs will be required to fully support these triples. This change allows a `armv7em-apple-none-macho` build via a destination v3 bundle to make it further through SwiftPM.
1 parent 4dbef25 commit da7d339

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Sources/Basics/Triple.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public struct Triple: Encodable, Equatable, Sendable {
4848
case aarch64
4949
case amd64
5050
case armv7
51+
case armv7em
5152
case armv6
5253
case armv5
5354
case arm
@@ -73,6 +74,8 @@ public struct Triple: Encodable, Equatable, Sendable {
7374
case windows
7475
case wasi
7576
case openbsd
77+
// 'OS' suffix purely to avoid name clash with Optional.none
78+
case noneOS = "none"
7679
}
7780

7881
public enum ABI: Encodable, Equatable, RawRepresentable, Sendable {
@@ -259,6 +262,8 @@ extension Triple {
259262
return ".dll"
260263
case .wasi:
261264
return ".wasm"
265+
case .noneOS:
266+
fatalError("Cannot create dynamic libraries for os \"none\".")
262267
}
263268
}
264269

@@ -272,6 +277,8 @@ extension Triple {
272277
return ".wasm"
273278
case .windows:
274279
return ".exe"
280+
case .noneOS:
281+
return ""
275282
}
276283
}
277284

Sources/SPMBuildCore/BinaryTarget+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extension Triple.OS {
9797
/// Returns a representation of the receiver that can be compared with platform strings declared in an XCFramework.
9898
fileprivate var asXCFrameworkPlatformString: String? {
9999
switch self {
100-
case .darwin, .linux, .wasi, .windows, .openbsd:
100+
case .darwin, .linux, .wasi, .windows, .openbsd, .noneOS:
101101
return nil // XCFrameworks do not support any of these platforms today.
102102
case .macOS:
103103
return "macos"

Sources/SPMBuildCore/BuildParameters.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,22 @@ public struct BuildParameters: Encodable {
391391
return try buildPath.appending(binaryRelativePath(for: product))
392392
}
393393

394+
/// Returns the path to the dynamic library of a product for the current build parameters.
395+
func potentialDynamicLibraryPath(for product: ResolvedProduct) throws -> RelativePath {
396+
try RelativePath(validating: "\(triple.dynamicLibraryPrefix)\(product.name)\(triple.dynamicLibraryExtension)")
397+
}
398+
394399
/// Returns the path to the binary of a product for the current build parameters, relative to the build directory.
395400
public func binaryRelativePath(for product: ResolvedProduct) throws -> RelativePath {
396401
let potentialExecutablePath = try RelativePath(validating: "\(product.name)\(triple.executableExtension)")
397-
let potentialLibraryPath = try RelativePath(validating: "\(triple.dynamicLibraryPrefix)\(product.name)\(triple.dynamicLibraryExtension)")
398402

399403
switch product.type {
400404
case .executable, .snippet:
401405
return potentialExecutablePath
402406
case .library(.static):
403407
return try RelativePath(validating: "lib\(product.name)\(triple.staticLibraryExtension)")
404408
case .library(.dynamic):
405-
return potentialLibraryPath
409+
return try potentialDynamicLibraryPath(for: product)
406410
case .library(.automatic), .plugin:
407411
fatalError()
408412
case .test:
@@ -418,7 +422,7 @@ public struct BuildParameters: Encodable {
418422
}
419423
case .macro:
420424
#if BUILD_MACROS_AS_DYLIBS
421-
return potentialLibraryPath
425+
return try potentialDynamicLibraryPath(for: product)
422426
#else
423427
return potentialExecutablePath
424428
#endif

0 commit comments

Comments
 (0)