Skip to content
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
1 change: 1 addition & 0 deletions Sources/SWBBuildService/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ private extension PreviewInfoOutput {
case let .targetDependencyInfo(info):
kind = .targetDependencyInfo(
PreviewInfoTargetDependencyInfo(
productModuleName: info.productModuleName,
objectFileInputMap: info.objectFileInputMap,
linkCommandLine: info.linkCommandLine,
linkerWorkingDirectory: info.linkerWorkingDirectory,
Expand Down
2 changes: 2 additions & 0 deletions Sources/SWBBuildService/PreviewInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ package struct PreviewInfoOutput: Sendable {
}

package struct TargetDependencyInfo: Sendable {
package let productModuleName: String
package let objectFileInputMap: [String: Set<String>]
package let linkCommandLine: [String]
package let linkerWorkingDirectory: String?
Expand Down Expand Up @@ -265,6 +266,7 @@ extension BuildDescription {
case .targetDependencyInfo:
let swiftInfos = Dictionary(grouping: relevantPreviewInfos.filter({ $0.type == .Swift }), by: { $0.output.str }).mapValues { Set($0.map { $0.input.str }) }
let targetInfo = PreviewInfoOutput.TargetDependencyInfo(
productModuleName: settings.globalScope.evaluate(BuiltinMacros.PRODUCT_MODULE_NAME),
objectFileInputMap: swiftInfos,
linkCommandLine: linkInfo?.commandLine ?? [],
linkerWorkingDirectory: linkInfo?.workingDirectory.str,
Expand Down
3 changes: 3 additions & 0 deletions Sources/SWBProtocol/MessageSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ public struct PreviewInfoThunkInfo: Codable, Equatable, Sendable {
}

public struct PreviewInfoTargetDependencyInfo: Codable, Equatable, Sendable {
public let productModuleName: String
public let objectFileInputMap: [String: Set<String>]
public let linkCommandLine: [String]
public let linkerWorkingDirectory: String?
Expand All @@ -455,6 +456,7 @@ public struct PreviewInfoTargetDependencyInfo: Codable, Equatable, Sendable {
public let enableUndefinedBehaviorSanitizer: Bool

public init(
productModuleName: String,
objectFileInputMap: [String : Set<String>],
linkCommandLine: [String],
linkerWorkingDirectory: String?,
Expand All @@ -466,6 +468,7 @@ public struct PreviewInfoTargetDependencyInfo: Codable, Equatable, Sendable {
enableThreadSanitizer: Bool,
enableUndefinedBehaviorSanitizer: Bool
) {
self.productModuleName = productModuleName
self.objectFileInputMap = objectFileInputMap
self.linkCommandLine = linkCommandLine
self.linkerWorkingDirectory = linkerWorkingDirectory
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftBuild/SWBBuildServiceSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ fileprivate extension SWBPreviewTargetDependencyInfo {
case .thunkInfo:
throw StubError.error("Unexpected response type for request")
case let .targetDependencyInfo(targetDependencyInfo):
self.productModuleName = targetDependencyInfo.productModuleName
self.objectFileInputMap = targetDependencyInfo.objectFileInputMap
self.linkCommandLine = targetDependencyInfo.linkCommandLine
self.linkerWorkingDirectory = targetDependencyInfo.linkerWorkingDirectory
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftBuild/SWBPreviewSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public struct SWBPreviewTargetDependencyInfo: SWBPreviewInfoContext, Hashable, S

public let pifGUID: String

public let productModuleName: String

/// Mapping of object files to the source file inputs they came from.
public let objectFileInputMap: [String: Set<String>]

Expand Down Expand Up @@ -110,6 +112,7 @@ public struct SWBPreviewTargetDependencyInfo: SWBPreviewInfoContext, Hashable, S
buildVariant: String,
architecture: String,
pifGUID: String,
productModuleName: String,
objectFileInputMap: [String : Set<String>],
linkCommandLine: [String],
linkerWorkingDirectory: String?,
Expand All @@ -126,6 +129,7 @@ public struct SWBPreviewTargetDependencyInfo: SWBPreviewInfoContext, Hashable, S
self.buildVariant = buildVariant
self.architecture = architecture
self.pifGUID = pifGUID
self.productModuleName = productModuleName
self.objectFileInputMap = objectFileInputMap
self.linkCommandLine = linkCommandLine
self.linkerWorkingDirectory = linkerWorkingDirectory
Expand Down
2 changes: 2 additions & 0 deletions Tests/SWBBuildSystemTests/PreviewsBuildOperationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ fileprivate struct PreviewsBuildOperationTests: CoreBasedTests {
#expect(targetPreviewInfo.context.sdkRoot == core.loadSDK(.iOSSimulator).name)
#expect(targetPreviewInfo.context.sdkVariant == "iphonesimulator")

#expect(targetPreviewInfo.targetDependencyInfo?.productModuleName == "AppTarget")
#expect(targetPreviewInfo.targetDependencyInfo?.objectFileInputMap == [
"\(srcRoot.str)/build/ProjectName.build/Debug-iphonesimulator/AppTarget.build/Objects-normal/\(results.runDestinationTargetArchitecture)/main.o": Set(["\(srcRoot.str)/Sources/main.swift"])
])
Expand Down Expand Up @@ -603,6 +604,7 @@ fileprivate struct PreviewsBuildOperationTests: CoreBasedTests {
#expect(targetPreviewInfo.context.sdkRoot == core.loadSDK(.iOSSimulator).name)
#expect(targetPreviewInfo.context.sdkVariant == "iphonesimulator")

#expect(targetPreviewInfo.targetDependencyInfo?.productModuleName == "AppTarget")
#expect(targetPreviewInfo.targetDependencyInfo?.objectFileInputMap == [
"\(srcRoot.str)/build/ProjectName.build/Debug-iphonesimulator/AppTarget.build/Objects-normal/\(results.runDestinationTargetArchitecture)/main.o": Set(["\(srcRoot.str)/Sources/main.swift"]),
"\(srcRoot.str)/build/ProjectName.build/Debug-iphonesimulator/AppTarget.build/Objects-normal/\(results.runDestinationTargetArchitecture)/File1.o": Set(["\(srcRoot.str)/Sources/File1.swift"]),
Expand Down
3 changes: 3 additions & 0 deletions Tests/SwiftBuildTests/GeneratePreviewInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ fileprivate struct GeneratePreviewInfoTests: CoreBasedTests {
buildVariant: "normal",
architecture: activeRunDestination.targetArchitecture,
pifGUID: appTarget.guid,
productModuleName: "App",
objectFileInputMap: [
"\(tmpDir.str)/Test/build/Test.build/Debug-iphoneos/App.build/Objects-normal/\(activeRunDestination.targetArchitecture)/TestFile4.o": Set(["\(tmpDir.str)/Test/TestFile4.swift"]),
"\(tmpDir.str)/Test/build/Test.build/Debug-iphoneos/App.build/Objects-normal/\(activeRunDestination.targetArchitecture)/GeneratedAssetSymbols.o": Set(["\(tmpDir.str)/Test/build/Test.build/Debug-iphoneos/App.build/DerivedSources/GeneratedAssetSymbols.swift"])
Expand Down Expand Up @@ -381,6 +382,7 @@ fileprivate struct GeneratePreviewInfoTests: CoreBasedTests {
buildVariant: "normal",
architecture: activeRunDestination.targetArchitecture,
pifGUID: libTarget.guid,
productModuleName: "StaticLib",
objectFileInputMap: [
"\(tmpDir.str)/Test/build/Test.build/Debug-iphoneos/StaticLib.build/Objects-normal/arm64/TestFile4.o": Set(["\(tmpDir.str)/Test/TestFile4.swift"])
],
Expand Down Expand Up @@ -505,6 +507,7 @@ fileprivate struct GeneratePreviewInfoTests: CoreBasedTests {
buildVariant: "normal",
architecture: activeRunDestination.targetArchitecture,
pifGUID: target.guid,
productModuleName: "CApplication",
objectFileInputMap: [:],
linkCommandLine: [
"\(developerDir)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang",
Expand Down
Loading