-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for a prebuilt swift-syntax library for macros #8142
Merged
Merged
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4de8400
[WIP] Add support for prebuilt libraries, specifically swift-syntax
dschaefer2 ecbfd4e
Get bootstrap and tests building.
dschaefer2 d8bb3fd
Add progress messages for prebuilts download.
dschaefer2 a725ca6
Started utility to build prebuilts.
dschaefer2 c6f8b18
Add publishing of prebuilts for Windows.
dschaefer2 e371880
Fix linking on Windows.
1961868
Make sure update prebuilts is called from all paths.
dschaefer2 2f2bf48
Complete prebuilts generator.
dschaefer2 6ebb14f
Merge branch 'main' of https://github.com/swiftlang/swift-package-man…
dschaefer2 2dc8caa
Fix when there is no manifest file yet.
dschaefer2 5b4d66f
Fix up Linux distro selectors.
dschaefer2 15a3811
Use absolute path to tar.exe.
dschaefer2 3521f30
Completed initial test suite.
dschaefer2 fd036a6
Added option to turn off, default is off until more testing.
dschaefer2 511542c
Merge remote-tracking branch 'origin/main' into prebuilts
dschaefer2 aaa883a
Add new source file to CMakeLists.
dschaefer2 97311e4
Added missing source to Workspace CMakeLists.txt file.
dschaefer2 66d016c
Fix tests on Windows.
dschaefer2 3f09afa
Better way to finding tar on Windows plus other review comments.
dschaefer2 8481aee
Remove debug print from ZipArchiver.
dschaefer2 2e91718
Adopt ArgumentParser and AbsolutePath in the prebuilt build script.
dschaefer2 d30d2ae
Some final cleanup based on comments.
dschaefer2 fcdaf0d
Final fixes to get the build and tests on Windows.
dschaefer2 7eafe65
Switch to using AsyncProcess in the build prebuilts script.
dschaefer2 0e6631f
Fix AsyncProcess call from BuildPrebuilts on Windows.
dschaefer2 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 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 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 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 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 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 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 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 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 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,109 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2014-2024 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 Basics | ||
import PackageModel | ||
|
||
extension Workspace { | ||
/// A downloaded prebuilt managed by the workspace. | ||
public struct ManagedPrebuilt { | ||
/// The package reference. | ||
public let packageRef: PackageReference | ||
|
||
/// The name of the binary target the artifact corresponds to. | ||
public let libraryName: String | ||
|
||
/// The path to the extracted prebuilt artifacts | ||
public let path: AbsolutePath | ||
|
||
/// The products in the library | ||
public let products: [String] | ||
|
||
/// The C modules that need their includes directory added to the include path | ||
public let cModules: [String] | ||
} | ||
} | ||
|
||
extension Workspace.ManagedPrebuilt: CustomStringConvertible { | ||
public var description: String { | ||
return "<ManagedArtifact: \(self.packageRef.identity).\(self.libraryName)>" | ||
} | ||
} | ||
|
||
// MARK: - ManagedArtifacts | ||
|
||
extension Workspace { | ||
/// A collection of managed artifacts which have been downloaded. | ||
public final class ManagedPrebuilts { | ||
/// A mapping from package identity, to target name, to ManagedArtifact. | ||
private var artifactMap: [PackageIdentity: [String: ManagedPrebuilt]] | ||
|
||
internal var artifacts: AnyCollection<ManagedPrebuilt> { | ||
AnyCollection(self.artifactMap.values.lazy.flatMap{ $0.values }) | ||
} | ||
|
||
init() { | ||
self.artifactMap = [:] | ||
} | ||
|
||
init(_ artifacts: [ManagedPrebuilt]) throws { | ||
let artifactsByPackagePath = Dictionary(grouping: artifacts, by: { $0.packageRef.identity }) | ||
self.artifactMap = try artifactsByPackagePath.mapValues{ artifacts in | ||
// rdar://86857825 do not use Dictionary(uniqueKeysWithValues:) as it can crash the process when input is incorrect such as in older versions of SwiftPM | ||
dschaefer2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var map = [String: ManagedPrebuilt]() | ||
for artifact in artifacts { | ||
if map[artifact.libraryName] != nil { | ||
throw StringError("binary artifact for '\(artifact.libraryName)' already exists in managed artifacts") | ||
} | ||
map[artifact.libraryName] = artifact | ||
} | ||
return map | ||
} | ||
} | ||
|
||
public subscript(packageIdentity packageIdentity: PackageIdentity, targetName targetName: String) -> ManagedPrebuilt? { | ||
self.artifactMap[packageIdentity]?[targetName] | ||
} | ||
|
||
public func add(_ artifact: ManagedPrebuilt) { | ||
self.artifactMap[artifact.packageRef.identity, default: [:]][artifact.libraryName] = artifact | ||
} | ||
|
||
public func remove(packageIdentity: PackageIdentity, targetName: String) { | ||
self.artifactMap[packageIdentity]?[targetName] = nil | ||
} | ||
} | ||
} | ||
|
||
extension Workspace.ManagedPrebuilts: Collection { | ||
public var startIndex: AnyIndex { | ||
self.artifacts.startIndex | ||
} | ||
|
||
public var endIndex: AnyIndex { | ||
self.artifacts.endIndex | ||
} | ||
|
||
public subscript(index: AnyIndex) -> Workspace.ManagedPrebuilt { | ||
self.artifacts[index] | ||
} | ||
|
||
public func index(after index: AnyIndex) -> AnyIndex { | ||
self.artifacts.index(after: index) | ||
} | ||
} | ||
|
||
extension Workspace.ManagedPrebuilts: CustomStringConvertible { | ||
dschaefer2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public var description: String { | ||
"<ManagedArtifacts: \(Array(self.artifacts))>" | ||
} | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if that's related to swiftlang/swift-foundation#860