Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion Sources/Build/ManifestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,12 @@ extension LLBuildManifestBuilder {
private func addModuleWrapCmd(_ target: SwiftTargetBuildDescription) {
// Add commands to perform the module wrapping Swift modules when debugging statergy is `modulewrap`.
guard buildParameters.debuggingStrategy == .modulewrap else { return }
let moduleWrapArgs = [
var moduleWrapArgs = [
target.buildParameters.toolchain.swiftCompiler.pathString,
"-modulewrap", target.moduleOutputPath.pathString,
"-o", target.wrappedModuleOutputPath.pathString
]
moduleWrapArgs += buildParameters.targetTripleArgs(for: target.target)
manifest.addShellCmd(
name: target.wrappedModuleOutputPath.pathString,
description: "Wrapping AST for \(target.target.name) for debugging",
Expand Down
4 changes: 4 additions & 0 deletions Sources/PackageDescription/SupportedPlatforms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public struct Platform: Encodable {
/// The Android platform
@available(_PackageDescription, introduced: 5.2)
public static let android: Platform = Platform(name: "android")

/// The WASI platform
@available(_PackageDescription, introduced: 5.2)
public static let wasi: Platform = Platform(name: "wasi")
}

/// A platform that the Swift package supports.
Expand Down
4 changes: 3 additions & 1 deletion Sources/PackageModel/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class PlatformRegistry {

/// The static list of known platforms.
private static var _knownPlatforms: [Platform] {
return [.macOS, .iOS, .tvOS, .watchOS, .linux, .android]
return [.macOS, .iOS, .tvOS, .watchOS, .linux, .android, .wasi]
}
}

Expand Down Expand Up @@ -57,6 +57,8 @@ public struct Platform: Equatable, Hashable {
public static let linux: Platform = Platform(name: "linux", oldestSupportedVersion: .unknown)
public static let android: Platform = Platform(name: "android", oldestSupportedVersion: .unknown)
public static let windows: Platform = Platform(name: "windows", oldestSupportedVersion: .unknown)
public static let wasi: Platform = Platform(name: "wasi", oldestSupportedVersion: .unknown)

}

/// Represents a platform version.
Expand Down
2 changes: 2 additions & 0 deletions Sources/SPMBuildCore/BuildParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public struct BuildParameters: Encodable {
return .macOS
} else if self.triple.isAndroid() {
return .android
} else if self.triple.isWASI() {
return .wasi
} else {
return .linux
}
Expand Down
13 changes: 12 additions & 1 deletion Sources/SPMBuildCore/Triple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public struct Triple: Encodable, Equatable {
case aarch64
case armv7
case arm
case wasm32
}

public enum Vendor: String, Encodable {
Expand All @@ -52,12 +53,14 @@ public struct Triple: Encodable, Equatable {
case macOS = "macosx"
case linux
case windows
case wasi

fileprivate static let allKnown:[OS] = [
.darwin,
.macOS,
.linux,
.windows
.windows,
.wasi,
]
}

Expand Down Expand Up @@ -125,6 +128,10 @@ public struct Triple: Encodable, Equatable {
return os == .windows
}

public func isWASI() -> Bool {
return os == .wasi
}

/// Returns the triple string for the given platform version.
///
/// This is currently meant for Apple platforms only.
Expand Down Expand Up @@ -165,6 +172,8 @@ extension Triple {
return ".so"
case .windows:
return ".dll"
case .wasi:
fatalError("WebAssembly/WASI doesn't support dynamic library yet")
}
}

Expand All @@ -174,6 +183,8 @@ extension Triple {
return ""
case .linux:
return ""
case .wasi:
return ""
case .windows:
return ".exe"
}
Expand Down