Skip to content

Enable armv7em and os none triples #6438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/Basics/Triple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public struct Triple: Encodable, Equatable, Sendable {
case aarch64
case amd64
case armv7
case armv7em
case armv6
case armv5
case arm
Expand All @@ -73,6 +74,8 @@ public struct Triple: Encodable, Equatable, Sendable {
case windows
case wasi
case openbsd
// 'OS' suffix purely to avoid name clash with Optional.none
case noneOS = "none"
}

public enum ABI: Encodable, Equatable, RawRepresentable, Sendable {
Expand Down Expand Up @@ -259,6 +262,8 @@ extension Triple {
return ".dll"
case .wasi:
return ".wasm"
case .noneOS:
fatalError("Cannot create dynamic libraries for os \"none\".")
}
}

Expand All @@ -272,6 +277,8 @@ extension Triple {
return ".wasm"
case .windows:
return ".exe"
case .noneOS:
return ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An argument could be made that it should be ".exe" or "". Embedded systems are really heterogenous and some recommend the .exe and some don't. I'm worried that loaders might care about the extension and we don't have a way to specify that in the Package Manifest.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could conditionalize this based on the vendor I guess? But for now I feel like "" is probably sufficient?

}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SPMBuildCore/BinaryTarget+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ extension Triple.OS {
/// Returns a representation of the receiver that can be compared with platform strings declared in an XCFramework.
fileprivate var asXCFrameworkPlatformString: String? {
switch self {
case .darwin, .linux, .wasi, .windows, .openbsd:
case .darwin, .linux, .wasi, .windows, .openbsd, .noneOS:
return nil // XCFrameworks do not support any of these platforms today.
case .macOS:
return "macos"
Expand Down
10 changes: 7 additions & 3 deletions Sources/SPMBuildCore/BuildParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,22 @@ public struct BuildParameters: Encodable {
return try buildPath.appending(binaryRelativePath(for: product))
}

/// Returns the path to the dynamic library of a product for the current build parameters.
func potentialDynamicLibraryPath(for product: ResolvedProduct) throws -> RelativePath {
try RelativePath(validating: "\(triple.dynamicLibraryPrefix)\(product.name)\(triple.dynamicLibraryExtension)")
}

/// Returns the path to the binary of a product for the current build parameters, relative to the build directory.
public func binaryRelativePath(for product: ResolvedProduct) throws -> RelativePath {
let potentialExecutablePath = try RelativePath(validating: "\(product.name)\(triple.executableExtension)")
let potentialLibraryPath = try RelativePath(validating: "\(triple.dynamicLibraryPrefix)\(product.name)\(triple.dynamicLibraryExtension)")

switch product.type {
case .executable, .snippet:
return potentialExecutablePath
case .library(.static):
return try RelativePath(validating: "lib\(product.name)\(triple.staticLibraryExtension)")
case .library(.dynamic):
return potentialLibraryPath
return try potentialDynamicLibraryPath(for: product)
case .library(.automatic), .plugin:
fatalError()
case .test:
Expand All @@ -418,7 +422,7 @@ public struct BuildParameters: Encodable {
}
case .macro:
#if BUILD_MACROS_AS_DYLIBS
return potentialLibraryPath
return try potentialDynamicLibraryPath(for: product)
#else
return potentialExecutablePath
#endif
Expand Down