diff --git a/Sources/SWBCore/SDKRegistry.swift b/Sources/SWBCore/SDKRegistry.swift index 3a8dc465..0777dc4d 100644 --- a/Sources/SWBCore/SDKRegistry.swift +++ b/Sources/SWBCore/SDKRegistry.swift @@ -515,6 +515,9 @@ public protocol SDKRegistryLookup: Sendable { /// - returns: The found `SDK`, or `nil` if no SDK with the given name could be found or `name` was in an invalid format. func lookup(_ name: String, activeRunDestination: RunDestinationInfo?) throws -> SDK? + /// Synthesize an SDK for the given platform with the given manifest JSON file path + func synthesizedSDK(platform: Platform, sdkManifestPath: String, triple: String) throws -> SDK? + /// Look up the SDK with the given path. If the registry is immutable, then this will only return the SDK if it was loaded when the registry was created; only mutable registries can discover and load new SDKs after that point. /// - parameter path: Absolute path of the SDK to look up. /// - returns: The found `SDK`, or `nil` if no SDK was found at the given path. @@ -1153,6 +1156,96 @@ public final class SDKRegistry: SDKRegistryLookup, CustomStringConvertible, Send return sdk } + public func synthesizedSDK(platform: Platform, sdkManifestPath: String, triple: String) throws -> SDK? { + // Let's check the active run destination to see if there's an SDK path that we should be using + let llvmTriple = try LLVMTriple(triple) + + let host = hostOperatingSystem + + // Don't allow re-registering the same SDK + if let existing = sdksByPath[Path(sdkManifestPath)] { + return existing + } + + if let swiftSDK = try SwiftSDK(identifier: sdkManifestPath, version: "1.0.0", path: Path(sdkManifestPath), fs: localFS) { + let defaultProperties: [String: PropertyListItem] = [ + "SDK_STAT_CACHE_ENABLE": "NO", + + "GENERATE_TEXT_BASED_STUBS": "NO", + "GENERATE_INTERMEDIATE_TEXT_BASED_STUBS": "NO", + + // TODO check how this impacts operation on Windows + "CHOWN": "/usr/bin/chown", + + // TODO are these going to be appropriate for all kinds of SDK's? + // SwiftSDK _could_ have tool entries for these, so use them if they are available + "LIBTOOL": .plString(host.imageFormat.executableName(basename: "llvm-lib")), + "AR": .plString(host.imageFormat.executableName(basename: "llvm-ar")), + ] + + for (sdkTriple, tripleProperties) in swiftSDK.targetTriples { + guard triple == sdkTriple else { + continue + } + + let toolsets = try tripleProperties.loadToolsets(sdk: swiftSDK, fs: localFS) + + let sysroot = swiftSDK.path.join(tripleProperties.sdkRootPath) + + // TODO support dynamic resources path + let swiftResourceDir = swiftSDK.path.join(tripleProperties.swiftStaticResourcesPath) + let clangResourceDir = swiftSDK.path.join(tripleProperties.clangStaticResourcesPath) + + let tripleSystem = llvmTriple.system + (llvmTriple.systemVersion?.description ?? "") + + // TODO handle tripleProperties.toolSearchPaths + + let extraSwiftCompilerSettings = Array(toolsets.map( { $0.swiftCompiler?.extraCLIOptions ?? [] }).flatMap( { $0 })) + let headerSearchPaths: [PropertyListItem] = ["$(inherited)"] + (tripleProperties.includeSearchPaths ?? []).map( { PropertyListItem.plString($0) } ) + let librarySearchPaths: [PropertyListItem] = ["$(inherited)"] + (tripleProperties.librarySearchPaths ?? []).map( { PropertyListItem.plString($0) } ) + + let sdk = registerSDK(sysroot, sysroot, platform, .plDict([ + "Type": .plString("SDK"), + "Version": .plString(swiftSDK.version), + "CanonicalName": .plString(swiftSDK.identifier), + "Aliases": [], + "IsBaseSDK": .plBool(true), + "DefaultProperties": .plDict([ + "PLATFORM_NAME": .plString(platform.name), + ].merging(defaultProperties, uniquingKeysWith: { _, new in new })), + "CustomProperties": .plDict([ + "LIBRARY_SEARCH_PATHS": .plArray(librarySearchPaths), + "HEADER_SEARCH_PATHS": .plArray(headerSearchPaths), + "OTHER_SWIFT_FLAGS": .plArray(["$(inherited)"] + extraSwiftCompilerSettings.map( {.plString($0)} )), + "SWIFTC_RESOURCE_DIR": .plString(swiftResourceDir.str), // Resource dir for linking Swift + "SWIFT_RESOURCE_DIR": .plString(swiftResourceDir.str), // Resource dir for compiling Swift + "CLANG_RESOURCE_DIR": .plString(clangResourceDir.str), // Resource dir for linking C/C++/Obj-C + "SDKROOT": .plString(sysroot.str), + "OTHER_LDFLAGS": .plArray(["$(inherited)"] + extraSwiftCompilerSettings.map( {.plString($0)} )), // The extra swift compiler settings in JSON are intended to go to the linker driver too + ]), + "SupportedTargets": .plDict([ + platform.name: .plDict([ + "Archs": .plArray([.plString(llvmTriple.arch)]), + "LLVMTargetTripleEnvironment": .plString(llvmTriple.environment ?? ""), + "LLVMTargetTripleSys": .plString(tripleSystem), + "LLVMTargetTripleVendor": .plString(llvmTriple.vendor), + ]) + ]), + // TODO: Leave compatible toolchain information in Swift SDKs + // "Toolchains": .plArray([]) + ])) + + if let sdk { + try sdk.loadExtendedInfo(delegate.namespace) + sdksByPath[Path(sdkManifestPath)] = sdk + return sdk + } + } + } + + return nil + } + public func lookup(nameOrPath key: String, basePath: Path, activeRunDestination: RunDestinationInfo?) throws -> SDK? { #if !os(Windows) // TODO: Turn this validation back on once our path handling is cleaned up a bit more diff --git a/Sources/SWBCore/Settings/Settings.swift b/Sources/SWBCore/Settings/Settings.swift index cc6f3283..24c20d7b 100644 --- a/Sources/SWBCore/Settings/Settings.swift +++ b/Sources/SWBCore/Settings/Settings.swift @@ -1803,11 +1803,24 @@ private class SettingsBuilder: ProjectMatchLookup { } do { - sdk = try project.map { try sdkRegistry.lookup(nameOrPath: sdkroot, basePath: $0.sourceRoot, activeRunDestination: parameters.activeRunDestination) } ?? nil + sdk = try project.map { + switch parameters.activeRunDestination?.buildTarget { + case let .swiftSDK(sdkManifestPath: sdkManifestPath, triple: triple): + // FIXME platform should be decided by the triple + guard let platform = core.platformRegistry.lookup(name: "webassembly") else { + errors.append("unable to find platform 'webassembly'") + return nil + } + return try sdkRegistry.synthesizedSDK(platform: platform, sdkManifestPath: sdkManifestPath, triple: triple) + default: + return try sdkRegistry.lookup(nameOrPath: sdkroot, basePath: $0.sourceRoot, activeRunDestination: parameters.activeRunDestination) + } + } ?? nil } catch { sdk = nil sdkLookupErrors.append(error) } + if let s = sdk { // Evaluate the SDK variant, if there is one. let sdkVariantName: String @@ -3512,23 +3525,46 @@ private class SettingsBuilder: ProjectMatchLookup { // Destination info: since runDestination.{platform,sdk} were set by the IDE, we expect them to resolve in Swift Build correctly guard let runDestination = self.parameters.activeRunDestination else { return } - guard let destinationPlatform: Platform = self.core.platformRegistry.lookup(name: runDestination.platform) else { - self.errors.append("unable to resolve run destination platform: '\(runDestination.platform)'") - return - } + + let destinationPlatform: Platform let destinationSDK: SDK - do { - guard let sdk = try sdkRegistry.lookup(runDestination.sdk, activeRunDestination: runDestination) else { - self.errors.append("unable to resolve run destination SDK: '\(runDestination.sdk)'") + switch runDestination.buildTarget { + case let .swiftSDK(sdkManifestPath: sdkManifestPath, triple: triple): + // FIXME: the platform should be determined using the triple + guard let platform = self.core.platformRegistry.lookup(name: "webassembly") else { + self.errors.append("unable to resolve run destination platform: 'webassembly'") + return + } + + destinationPlatform = platform + + guard let sdk = try? sdkRegistry.synthesizedSDK(platform: platform, sdkManifestPath: sdkManifestPath, triple: triple) else { + self.errors.append("unable to synthesize SDK for Swift SDK build target: '\(runDestination.buildTarget)'") return } destinationSDK = sdk - } catch let error as AmbiguousSDKLookupError { - self.diagnostics.append(error.diagnostic) - return - } catch { - self.errors.append("\(error)") - return + default: + guard let platform = self.core.platformRegistry.lookup(name: runDestination.platform) else { + self.errors.append("unable to resolve run destination platform: '\(runDestination.platform)'") + return + } + + destinationPlatform = platform + + do { + if let sdk = try sdkRegistry.lookup(runDestination.sdk, activeRunDestination: runDestination) { + destinationSDK = sdk + } else { + self.errors.append("unable to resolve run destination SDK: '\(runDestination.sdk)'") + return + } + } catch let error as AmbiguousSDKLookupError { + self.diagnostics.append(error.diagnostic) + return + } catch { + self.errors.append("\(error)") + return + } } let destinationPlatformIsMacOS = destinationPlatform.name == "macosx" @@ -3639,9 +3675,23 @@ private class SettingsBuilder: ProjectMatchLookup { // Destination info: since runDestination.{platform,sdk} were set by the IDE, we expect them to resolve in Swift Build correctly guard let runDestination = self.parameters.activeRunDestination else { return } - guard let destinationPlatform: Platform = self.core.platformRegistry.lookup(name: runDestination.platform) else { - self.errors.append("unable to resolve run destination platform: '\(runDestination.platform)'") - return + + let destinationPlatform: Platform + + switch runDestination.buildTarget { + case .swiftSDK: + // TODO use the triple to decide the platform, or use a fallback + guard let platform: Platform = self.core.platformRegistry.lookup(name: "webassembly") else { + self.errors.append("unable to resolve run destination platform: '\(runDestination.platform)'") + return + } + destinationPlatform = platform + default: + guard let platform: Platform = self.core.platformRegistry.lookup(name: runDestination.platform) else { + self.errors.append("unable to resolve run destination platform: '\(runDestination.platform)'") + return + } + destinationPlatform = platform } // Target info diff --git a/Sources/SWBCore/SwiftSDK.swift b/Sources/SWBCore/SwiftSDK.swift index c8f7f43f..7edbb71b 100644 --- a/Sources/SWBCore/SwiftSDK.swift +++ b/Sources/SWBCore/SwiftSDK.swift @@ -25,22 +25,53 @@ public struct SwiftSDK: Sendable { public var sdkRootPath: String public var swiftResourcesPath: String? public var swiftStaticResourcesPath: String? + public var clangResourcesPath: String? { + guard let swiftResourcesPath = self.swiftResourcesPath else { + return nil + } + + // The clang resource path is conventionally the clang subdirectory of the swift resource path + return Path(swiftResourcesPath).join("clang").str + } + public var clangStaticResourcesPath: String? { + guard let swiftResourcesPath = self.swiftStaticResourcesPath else { + return nil + } + + // The clang resource path is conventionally the clang subdirectory of the swift resource path + return Path(swiftResourcesPath).join("clang").str + } public var includeSearchPaths: [String]? public var librarySearchPaths: [String]? public var toolsetPaths: [String]? + + public func loadToolsets(sdk: SwiftSDK, fs: any FSProxy) throws -> [Toolset] { + var toolsets: [Toolset] = [] + + for toolsetPath in self.toolsetPaths ?? [] { + let metadataData = try Data(fs.read(sdk.path.join(toolsetPath))) + + let schema = try JSONDecoder().decode(SchemaVersionInfo.self, from: metadataData) + guard schema.schemaVersion == "1.0" else { return [] } // FIXME throw an error + + let toolset = try JSONDecoder().decode(Toolset.self, from: metadataData) + toolsets.append(toolset) + } + + return toolsets + } } struct MetadataV4: Codable { let targetTriples: [String: TripleProperties] } - struct Toolset: Codable { - struct ToolProperties: Codable { - var path: String? - var extraCLIOptions: [String] + public struct Toolset: Codable { + public struct Tool: Codable { + public let extraCLIOptions: [String]? } - var knownTools: [String: ToolProperties] = [:] - var rootPaths: [String] = [] + public let rootPath: String + public let swiftCompiler: Tool? } /// The identifier of the artifact bundle containing this SDK. @@ -55,12 +86,11 @@ public struct SwiftSDK: Sendable { init?(identifier: String, version: String, path: Path, fs: any FSProxy) throws { self.identifier = identifier self.version = version - self.path = path + self.path = path.dirname - let metadataPath = path.join("swift-sdk.json") - guard fs.exists(metadataPath) else { return nil } + guard fs.exists(path) else { return nil } - let metadataData = try Data(fs.read(metadataPath)) + let metadataData = try Data(fs.read(path)) let schema = try JSONDecoder().decode(SchemaVersionInfo.self, from: metadataData) guard schema.schemaVersion == "4.0" else { return nil } @@ -118,7 +148,7 @@ public struct SwiftSDK: Sendable { } /// Find Swift SDKs in an artifact bundle supporting one of the given targets. - private static func findSDKs(artifactBundle: Path, targetTriples: [String]?, fs: any FSProxy) throws -> [SwiftSDK] { + public static func findSDKs(artifactBundle: Path, targetTriples: [String]?, fs: any FSProxy) throws -> [SwiftSDK] { // Load info.json from the artifact bundle let infoPath = artifactBundle.join("info.json") guard try fs.isFile(infoPath) else { return [] } diff --git a/Sources/SWBCore/WorkspaceContext.swift b/Sources/SWBCore/WorkspaceContext.swift index 5f0e4f6b..1b8a3cc5 100644 --- a/Sources/SWBCore/WorkspaceContext.swift +++ b/Sources/SWBCore/WorkspaceContext.swift @@ -213,6 +213,10 @@ public struct WorkspaceContextSDKRegistry: SDKRegistryLookup, Sendable { public func lookup(nameOrPath: String, basePath: Path, activeRunDestination: RunDestinationInfo?) throws -> SDK? { return try lookupInEach { try $0.lookup(nameOrPath: nameOrPath, basePath: basePath, activeRunDestination: activeRunDestination) } } + + func synthesizedSDK(platform: Platform, sdkManifestPath: String, triple: String) throws -> SDK? { + return try lookupInEach { try $0.synthesizedSDK(platform: platform, sdkManifestPath: sdkManifestPath, triple: triple) } + } } @_spi(Testing) public init(coreSDKRegistry: SDKRegistry, delegate: any SDKRegistryDelegate, userNamespace: MacroNamespace, overridingSDKsDir: Path?) { @@ -246,6 +250,10 @@ public struct WorkspaceContextSDKRegistry: SDKRegistryLookup, Sendable { public func lookup(nameOrPath: String, basePath: Path, activeRunDestination: RunDestinationInfo?) throws -> SDK? { return try underlyingLookup.lookup(nameOrPath: nameOrPath, basePath: basePath, activeRunDestination: activeRunDestination) } + + public func synthesizedSDK(platform: Platform, sdkManifestPath: String, triple: String) throws -> SDK? { + return try underlyingLookup.synthesizedSDK(platform: platform, sdkManifestPath: sdkManifestPath, triple: triple) + } } /// Wrapper for information needed to use a workspace. diff --git a/Sources/SWBProtocol/MessageSupport.swift b/Sources/SWBProtocol/MessageSupport.swift index 65e79bfc..5124c9e2 100644 --- a/Sources/SWBProtocol/MessageSupport.swift +++ b/Sources/SWBProtocol/MessageSupport.swift @@ -318,13 +318,16 @@ public struct BuildParametersMessagePayload: SerializableCodable, Equatable, Sen } public struct RunDestinationInfo: SerializableCodable, Hashable, Sendable { + public var disableOnlyActiveArch: Bool + public var hostTargetedPlatform: String? + + public var buildTarget: BuildTarget? + public var platform: String public var sdk: String public var sdkVariant: String? public var targetArchitecture: String public var supportedArchitectures: OrderedSet - public var disableOnlyActiveArch: Bool - public var hostTargetedPlatform: String? public init(platform: String, sdk: String, sdkVariant: String?, targetArchitecture: String, supportedArchitectures: OrderedSet, disableOnlyActiveArch: Bool, hostTargetedPlatform: String?) { self.platform = platform @@ -334,7 +337,23 @@ public struct RunDestinationInfo: SerializableCodable, Hashable, Sendable { self.supportedArchitectures = supportedArchitectures self.disableOnlyActiveArch = disableOnlyActiveArch self.hostTargetedPlatform = hostTargetedPlatform + self.buildTarget = nil } + + public init(buildTarget: BuildTarget, disableOnlyActiveArch: Bool, hostTargetedPlatform: String? = nil) { + self.platform = "" + self.sdk = "" + self.sdkVariant = nil + self.targetArchitecture = "" + self.supportedArchitectures = [] + self.buildTarget = buildTarget + self.disableOnlyActiveArch = disableOnlyActiveArch + self.hostTargetedPlatform = hostTargetedPlatform + } +} + +public enum BuildTarget: SerializableCodable, Hashable, Sendable { + case swiftSDK(sdkManifestPath: String, triple: String) } /// The arena info being sent in a Message. diff --git a/Sources/SWBUniversalPlatform/Specs/Ld.xcspec b/Sources/SWBUniversalPlatform/Specs/Ld.xcspec index 40022fee..362585fc 100644 --- a/Sources/SWBUniversalPlatform/Specs/Ld.xcspec +++ b/Sources/SWBUniversalPlatform/Specs/Ld.xcspec @@ -173,6 +173,27 @@ CommandLineFlag = "-sdk"; IsInputDependency = Yes; }, + { + Name = CLANG_RESOURCE_DIR; + Type = Path; + Condition = "$(LINKER_DRIVER) == clang"; + CommandLineFlag = "-resource-dir"; + IsInputDependency = Yes; + }, + { + Name = CLANG_RESOURCE_DIR; + Type = Path; + Condition = "$(LINKER_DRIVER) == swiftc"; + CommandLineArgs = ("-Xclang-linker", "-resource-dir", "-Xclang-linker", "$(CLANG_RESOURCE_DIR)"); + IsInputDependency = Yes; + }, + { + Name = SWIFTC_RESOURCE_DIR; + Type = Path; + Condition = "$(LINKER_DRIVER) == swiftc"; + CommandLineArgs = ("-resource-dir", "$(SWIFTC_RESOURCE_DIR)"); + IsInputDependency = Yes; + }, { Name = "LD_OPTIMIZATION_LEVEL"; Type = String; diff --git a/Sources/SWBWebAssemblyPlatform/Specs/WasmLd.xcspec b/Sources/SWBWebAssemblyPlatform/Specs/WasmLd.xcspec index ba106172..dc6ba13a 100644 --- a/Sources/SWBWebAssemblyPlatform/Specs/WasmLd.xcspec +++ b/Sources/SWBWebAssemblyPlatform/Specs/WasmLd.xcspec @@ -52,6 +52,14 @@ DefaultValue = ""; Condition = "NO"; }, + { + // Wasm doesn't have search paths + Name = "LD_RUNPATH_SEARCH_PATHS"; + //Note: Cannot be of type 'PathList' as value is used with relative '../' paths + Type = StringList; + Condition = "NO"; + CommandLineArgs = (); + }, { Name = GOLD_BUILDID; Type = Boolean; @@ -129,6 +137,14 @@ Type = Path; DefaultValue = ""; }, + { + Name = SWIFTC_SDKROOT_LINKER_INPUT; + Type = Path; + DefaultValue = "$(SYSROOT:default=$(SDKROOT))"; + Condition = "$(LINKER_DRIVER) == swiftc"; + CommandLineFlag = "-sdk"; + IsInputDependency = Yes; + }, { Name = "__INPUT_FILE_LIST_PATH__"; Type = Path; diff --git a/Sources/SWBWebAssemblyPlatform/Specs/WebAssembly.xcspec b/Sources/SWBWebAssemblyPlatform/Specs/WebAssembly.xcspec index b7cfeaf8..5a30bd12 100644 --- a/Sources/SWBWebAssemblyPlatform/Specs/WebAssembly.xcspec +++ b/Sources/SWBWebAssemblyPlatform/Specs/WebAssembly.xcspec @@ -23,4 +23,10 @@ ); SortNumber = 0; }, + { + Domain = webassembly; + Type = ProductType; + Identifier = org.swift.product-type.common.object; + BasedOn = com.apple.product-type.library.static; + }, ) diff --git a/Sources/SwiftBuild/SWBBuildParameters.swift b/Sources/SwiftBuild/SWBBuildParameters.swift index 11d07745..c3a8ca81 100644 --- a/Sources/SwiftBuild/SWBBuildParameters.swift +++ b/Sources/SwiftBuild/SWBBuildParameters.swift @@ -36,13 +36,47 @@ public struct SWBBuildParameters: Codable, Sendable { /// Refer to `SWBProtocol.RunDestinationInfo` public struct SWBRunDestinationInfo: Codable, Sendable { + public enum SWBBuildTarget: Codable, Sendable { + case appleSDK(platform: String, sdk: String, sdkVariant: String?, targetArchitecture: String, supportedArchitectures: [String]) + case swiftSDK(sdkManifestPath: String, triple: String) + } + public var disableOnlyActiveArch: Bool + public var hostTargetedPlatform: String? + + public var _internalBuildTarget: SWBBuildTarget? + + public var buildTarget: SWBBuildTarget { + get { + if let bt = _internalBuildTarget { + return bt + } + + return .appleSDK(platform: self.platform, sdk: self.sdk, sdkVariant: self.sdkVariant, targetArchitecture: self.targetArchitecture, supportedArchitectures: self.supportedArchitectures) + } + set { + switch newValue { + case let .appleSDK(platform: platform, sdk: sdk, sdkVariant: sdkVariant, targetArchitecture: targetArchitecture, supportedArchitectures: supportedArchitectures): + self.platform = platform + self.sdk = sdk + self.sdkVariant = sdkVariant + self.targetArchitecture = targetArchitecture + self.supportedArchitectures = supportedArchitectures + case .swiftSDK: + self._internalBuildTarget = newValue + self.platform = "" + self.sdk = "" + self.sdkVariant = nil + self.targetArchitecture = "" + self.supportedArchitectures = [] + } + } + } + public var platform: String public var sdk: String public var sdkVariant: String? public var targetArchitecture: String public var supportedArchitectures: [String] - public var disableOnlyActiveArch: Bool - public var hostTargetedPlatform: String? public init(platform: String, sdk: String, sdkVariant: String?, targetArchitecture: String, supportedArchitectures: [String], disableOnlyActiveArch: Bool) { self.platform = platform @@ -53,6 +87,27 @@ public struct SWBRunDestinationInfo: Codable, Sendable { self.disableOnlyActiveArch = disableOnlyActiveArch } + public init(buildTarget: SWBBuildTarget, disableOnlyActiveArch: Bool, hostTargetedPlatform: String? = nil) { + switch buildTarget { + case let .appleSDK(platform: platform, sdk: sdk, sdkVariant: sdkVariant, targetArchitecture: targetArchitecture, supportedArchitectures: supportedArchitectures): + self.platform = platform + self.sdk = sdk + self.sdkVariant = sdkVariant + self.targetArchitecture = targetArchitecture + self.supportedArchitectures = supportedArchitectures + break + case .swiftSDK: + self._internalBuildTarget = buildTarget + self.platform = "" + self.sdk = "" + self.sdkVariant = nil + self.targetArchitecture = "" + self.supportedArchitectures = [] + } + self.disableOnlyActiveArch = disableOnlyActiveArch + self.hostTargetedPlatform = hostTargetedPlatform + } + public init(platform: String, sdk: String, sdkVariant: String?, targetArchitecture: String, supportedArchitectures: [String], disableOnlyActiveArch: Bool, hostTargetedPlatform: String?) { self.init(platform: platform, sdk: sdk, sdkVariant: sdkVariant, targetArchitecture: targetArchitecture, supportedArchitectures: supportedArchitectures, disableOnlyActiveArch: disableOnlyActiveArch) self.hostTargetedPlatform = hostTargetedPlatform diff --git a/Sources/SwiftBuild/SWBBuildServiceSession.swift b/Sources/SwiftBuild/SWBBuildServiceSession.swift index b86e3a52..dcd31b87 100644 --- a/Sources/SwiftBuild/SWBBuildServiceSession.swift +++ b/Sources/SwiftBuild/SWBBuildServiceSession.swift @@ -838,7 +838,12 @@ extension SWBBuildParameters { fileprivate extension RunDestinationInfo { init(_ x: SWBRunDestinationInfo) { - self.init(platform: x.platform, sdk: x.sdk, sdkVariant: x.sdkVariant, targetArchitecture: x.targetArchitecture, supportedArchitectures: OrderedSet(x.supportedArchitectures), disableOnlyActiveArch: x.disableOnlyActiveArch, hostTargetedPlatform: x.hostTargetedPlatform) + switch x.buildTarget { + case .appleSDK: + self.init(platform: x.platform, sdk: x.sdk, sdkVariant: x.sdkVariant, targetArchitecture: x.targetArchitecture, supportedArchitectures: OrderedSet(x.supportedArchitectures), disableOnlyActiveArch: x.disableOnlyActiveArch, hostTargetedPlatform: x.hostTargetedPlatform) + case let .swiftSDK(sdkManifestPath: sdkManifestPath, triple: triple): + self.init(buildTarget: .swiftSDK(sdkManifestPath: sdkManifestPath, triple: triple), disableOnlyActiveArch: x.disableOnlyActiveArch, hostTargetedPlatform: x.hostTargetedPlatform) + } } }