-
Notifications
You must be signed in to change notification settings - Fork 1.4k
add artifacts archive file format #3295
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
Conversation
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
motivation: to support the package extensions feature, we need to support binary dependencies with tools that can be distributed across different platforms changes: * introuce new binary dependency type "toolsArchive" with the extension "toar" * the structure of the archive is inspired by XCFramework, and it can contain multiple tools/executables targeting multiple platforms and architectures using target triplets to indicate such support * update BuildPlan code to parse "toar" files and extract the tools available to the target in a [String: AbsolutePath] which can be later hooks to be used by extensions * refactory XCFramework code * update call-sites and tests and add new tests
fadb274
to
e79384c
Compare
@swift-ci please smoke test |
@swift-ci please smoke test |
|
||
public struct Variant: Equatable { | ||
let path: String | ||
let supportedTriplets: [Triple] |
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 suggest supportedTriples
for consistency.
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.
:D typo
extension ArtifactsArchiveMetadata: Decodable { | ||
enum CodingKeys: String, CodingKey { | ||
case schemaVersion | ||
case artifacts = "availableArtifacts" |
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.
Nit: should this just be "artifacts"? Are there any artifacts in the archive that aren't available?
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 just saw the example of the existing XCFrameworks format in the unit test, which uses AvailableLibraries, so now I understand where this comes from. I could go either way on this: if we expect to move to arar
as the future format that can handle all types of artifacts than maybe it's more important to pick names we think are clear than to be consistent with XCFrameworks. Could go either way for me.
case type | ||
case version | ||
case variants | ||
case supportedTriplets |
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 suggest supportedTriples
to be consistent.
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.
Also: since an Artifact
has Variants
, and both have supportedTriples
, is this one a union of all the ones for all the variants?
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.
hmm no, this is a typo
Sources/Build/BuildPlan.swift
Outdated
switch binaryTarget.kind { | ||
case .xcframework: | ||
let libraries = try self.parseXCFramework(for: binaryTarget) | ||
libraries.forEach { library in |
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.
Nit: what is our stance on for _ in
vs forEach
in the SwiftPM codebase? Historically I think we've been using for _ in
, which I personally find much easier to read, but we should probably choose one and use the same in the codebase.
Sources/Build/BuildPlan.swift
Outdated
} | ||
|
||
let libraryDirectory = target.artifactPath.appending(component: library.libraryIdentifier) | ||
let binaryPath = libraryDirectory.appending(component: library.libraryPath) | ||
let libraryPath = libraryDirectory.appending(component: library.libraryPath) | ||
let headersPath = library.headersPath.map({ libraryDirectory.appending(component: $0) }) |
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 realize this is existing code but this one should probably be .appending(RelativePath($0))
as well, if the path can be a relative path.
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.
Left a few comments, which are mostly suggestions but saw a couple of places of appending(component: ))
in existing code that should probably be appending(RelativePath())
now if we support subpaths in those keys.
Sources/Build/BuildPlan.swift
Outdated
} | ||
|
||
let libraryDirectory = target.artifactPath.appending(component: library.libraryIdentifier) | ||
let binaryPath = libraryDirectory.appending(component: library.libraryPath) | ||
let libraryPath = libraryDirectory.appending(component: library.libraryPath) |
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 realize this is existing code but this one should probably be .appending(RelativePath($0))
as well, if the path can be a relative path.
extension ArtifactsArchiveMetadata: Decodable { | ||
enum CodingKeys: String, CodingKey { | ||
case schemaVersion | ||
case artifacts = "availableArtifacts" |
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 just saw the example of the existing XCFrameworks format in the unit test, which uses AvailableLibraries, so now I understand where this comes from. I could go either way on this: if we expect to move to arar
as the future format that can handle all types of artifacts than maybe it's more important to pick names we think are clear than to be consistent with XCFrameworks. Could go either way for me.
69e7040
to
17771f4
Compare
@swift-ci please smoke test |
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.
Looks great to me! Thanks for taking this on!
motivation: to support the package extensions feature, we need to support binary dependencies with tools that can be distributed across different platforms
changes:
the new archive file name, extension and structure are all up to debate and would take final shape in an evolution proposal, but we can start discussing them now in preparation to such proposal.
the file structure proposed
having the metadata file look like
concrete example:
open questions:
how do we deal with system dependencies these tools may have? we could require that the archive metadata includes information on such dependencies and do basic validation for the user, but this could get very messy.
what about versioning? do we need to add metadata about the tool version?
We are likely to extend the ArtifactsArchive file format to carry other types of artifacts beyond executables. Additional fields are likely to be required to support such artifact types, e.g. headers path for libraries.