-
Notifications
You must be signed in to change notification settings - Fork 125
Add initial support for object library product type #631
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Sources/SWBCore/SpecImplementations/Tools/ObjectLibraryAssembler.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
public final class ObjectLibraryAssemblerSpec : GenericLinkerSpec, SpecIdentifierType, @unchecked Sendable { | ||
public static let identifier: String = "org.swift.linkers.object-library-assembler" | ||
|
||
public override func createTaskAction(_ cbc: CommandBuildContext, _ delegate: any TaskGenerationDelegate) -> (any PlannedTaskAction)? { | ||
return delegate.taskActionCreationDelegate.createObjectLibraryAssemblerTaskAction() | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
Sources/SWBTaskExecution/TaskActions/LinkerTaskAction.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Foundation | ||
public import SWBCore | ||
public import SWBUtil | ||
|
||
public final class LinkerTaskAction: TaskAction { | ||
|
||
public override class var toolIdentifier: String { | ||
return "linker" | ||
} | ||
|
||
/// Whether response files should be expanded before invoking the linker. | ||
private let expandResponseFiles: Bool | ||
|
||
public init(expandResponseFiles: Bool) { | ||
self.expandResponseFiles = expandResponseFiles | ||
super.init() | ||
} | ||
|
||
public override func serialize<T: Serializer>(to serializer: T) { | ||
serializer.beginAggregate(2) | ||
serializer.serialize(expandResponseFiles) | ||
super.serialize(to: serializer) | ||
serializer.endAggregate() | ||
} | ||
|
||
public required init(from deserializer: any Deserializer) throws { | ||
try deserializer.beginAggregate(2) | ||
self.expandResponseFiles = try deserializer.deserialize() | ||
try super.init(from: deserializer) | ||
} | ||
|
||
public override func performTaskAction( | ||
_ task: any ExecutableTask, | ||
dynamicExecutionDelegate: any DynamicTaskExecutionDelegate, | ||
executionDelegate: any TaskExecutionDelegate, | ||
clientDelegate: any TaskExecutionClientDelegate, | ||
outputDelegate: any TaskOutputDelegate | ||
) async -> CommandResult { | ||
var commandLine = Array(task.commandLineAsStrings) | ||
|
||
if expandResponseFiles { | ||
do { | ||
commandLine = try ResponseFiles.expandResponseFiles( | ||
commandLine, | ||
fileSystem: executionDelegate.fs, | ||
relativeTo: task.workingDirectory | ||
) | ||
} catch { | ||
outputDelegate.emitError("Failed to expand response files: \(error.localizedDescription)") | ||
return .failed | ||
} | ||
} | ||
|
||
let processDelegate = TaskProcessDelegate(outputDelegate: outputDelegate) | ||
do { | ||
let success = try await dynamicExecutionDelegate.spawn( | ||
commandLine: commandLine, | ||
environment: task.environment.bindingsDictionary, | ||
workingDirectory: task.workingDirectory, | ||
processDelegate: processDelegate | ||
) | ||
|
||
if let error = processDelegate.executionError { | ||
outputDelegate.emitError(error) | ||
return .failed | ||
} | ||
|
||
if success { | ||
if let spec = task.type as? CommandLineToolSpec, let files = task.dependencyData { | ||
do { | ||
try spec.adjust(dependencyFiles: files, for: task, fs: executionDelegate.fs) | ||
} catch { | ||
outputDelegate.emitWarning("Unable to perform dependency info modifications: \(error)") | ||
} | ||
} | ||
} | ||
|
||
return success ? .succeeded : .failed | ||
} catch { | ||
outputDelegate.emitError("Process execution failed: \(error.localizedDescription)") | ||
return .failed | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.