Skip to content

Commit 69e7040

Browse files
committed
fixup
1 parent 20e1972 commit 69e7040

File tree

4 files changed

+20
-31
lines changed

4 files changed

+20
-31
lines changed

Sources/Build/ArtifactsArchiveMetadata.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ public struct ArtifactsArchiveMetadata: Equatable {
3737

3838
// In the future we are likely to extend the ArtifactsArchive file format to carry other types of artifacts beyond executables.
3939
// Additional fields may be required to support these new artifact types e.g. headers path for libraries.
40+
// This can also support resource-only artifacts as well. For example, 3d models along with associated textures, or fonts, etc.
4041
public enum ArtifactType: String, RawRepresentable, Decodable {
4142
case executable
4243
}
4344

4445
public struct Variant: Equatable {
4546
let path: String
46-
let supportedTriplets: [Triple]
47+
let supportedTriples: [Triple]
4748

48-
public init(path: String, supportedTriplets: [Triple]) {
49+
public init(path: String, supportedTriples: [Triple]) {
4950
self.path = path
50-
self.supportedTriplets = supportedTriplets
51+
self.supportedTriples = supportedTriples
5152
}
5253
}
5354
}
@@ -74,7 +75,7 @@ extension ArtifactsArchiveMetadata {
7475
extension ArtifactsArchiveMetadata: Decodable {
7576
enum CodingKeys: String, CodingKey {
7677
case schemaVersion
77-
case artifacts = "availableArtifacts"
78+
case artifacts
7879
}
7980
}
8081

@@ -83,7 +84,6 @@ extension ArtifactsArchiveMetadata.Artifact: Decodable {
8384
case type
8485
case version
8586
case variants
86-
case supportedTriplets
8787
}
8888

8989
public init(from decoder: Decoder) throws {
@@ -97,12 +97,12 @@ extension ArtifactsArchiveMetadata.Artifact: Decodable {
9797
extension ArtifactsArchiveMetadata.Variant: Decodable {
9898
enum CodingKeys: String, CodingKey {
9999
case path
100-
case supportedTriplets
100+
case supportedTriples
101101
}
102102

103103
public init(from decoder: Decoder) throws {
104104
let container = try decoder.container(keyedBy: CodingKeys.self)
105-
self.supportedTriplets = try container.decode([String].self, forKey: .supportedTriplets).map { try Triple($0) }
105+
self.supportedTriples = try container.decode([String].self, forKey: .supportedTriples).map { try Triple($0) }
106106
self.path = try container.decode(String.self, forKey: .path)
107107
}
108108
}

Sources/Build/BuildPlan.swift

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ public class BuildPlan {
16411641
switch binaryTarget.kind {
16421642
case .xcframework:
16431643
let libraries = try self.parseXCFramework(for: binaryTarget)
1644-
libraries.forEach { library in
1644+
for library in libraries {
16451645
libraryBinaryPaths.insert(library.libraryPath)
16461646
}
16471647
case .artifactsArchive:
@@ -1697,7 +1697,7 @@ public class BuildPlan {
16971697
case let target as BinaryTarget:
16981698
if case .xcframework = target.kind {
16991699
let libraries = try self.parseXCFramework(for: target)
1700-
libraries.forEach { library in
1700+
for library in libraries {
17011701
if let headersPath = library.headersPath {
17021702
clangTarget.additionalFlags += ["-I", headersPath.pathString]
17031703
}
@@ -1734,7 +1734,7 @@ public class BuildPlan {
17341734
case let target as BinaryTarget:
17351735
if case .xcframework = target.kind {
17361736
let libraries = try self.parseXCFramework(for: target)
1737-
libraries.forEach { library in
1737+
for library in libraries {
17381738
if let headersPath = library.headersPath {
17391739
swiftTarget.additionalFlags += ["-Xcc", "-I", "-Xcc", headersPath.pathString]
17401740
}
@@ -1874,8 +1874,8 @@ public class BuildPlan {
18741874
}
18751875

18761876
let libraryDirectory = target.artifactPath.appending(component: library.libraryIdentifier)
1877-
let libraryPath = libraryDirectory.appending(component: library.libraryPath)
1878-
let headersPath = library.headersPath.map({ libraryDirectory.appending(component: $0) })
1877+
let libraryPath = libraryDirectory.appending(RelativePath(library.libraryPath))
1878+
let headersPath = library.headersPath.map({ libraryDirectory.appending(RelativePath($0)) })
18791879

18801880
return [LibraryInfo(libraryPath: libraryPath, headersPath: headersPath)]
18811881
}
@@ -1888,7 +1888,7 @@ public class BuildPlan {
18881888

18891889
// filter the artifacts that are relevant to the triple
18901890
// FIXME: this filter needs to become more sophisticated
1891-
let supportedArtifacts = metadata.artifacts.filter { $0.value.variants.contains(where: { $0.supportedTriplets.contains(buildParameters.triple) }) }
1891+
let supportedArtifacts = metadata.artifacts.filter { $0.value.variants.contains(where: { $0.supportedTriples.contains(buildParameters.triple) }) }
18921892
// TODO: add support for libraries
18931893
let executables = supportedArtifacts.filter { $0.value.type == .executable }
18941894

@@ -2019,14 +2019,3 @@ fileprivate extension Triple {
20192019
isLinux() || arch == .wasm32
20202020
}
20212021
}
2022-
2023-
// FIXME: move this to TSC
2024-
extension Triple: Hashable {
2025-
public func hash(into hasher: inout Hasher) {
2026-
hasher.combine(self.tripleString)
2027-
hasher.combine(self.arch)
2028-
hasher.combine(self.vendor)
2029-
hasher.combine(self.os)
2030-
hasher.combine(self.abi)
2031-
}
2032-
}

Tests/BuildTests/ArtifactsArchiveMetadataTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ final class ArtifactsArchiveMetadataTests: XCTestCase {
2121
bytes: ByteString(encodingAsUTF8: """
2222
{
2323
"schemaVersion": "1.0",
24-
"availableArtifacts": {
24+
"artifacts": {
2525
"protocol-buffer-compiler": {
2626
"type": "executable",
2727
"version": "3.5.1",
2828
"variants": [
2929
{
3030
"path": "x86_64-apple-macosx/protoc",
31-
"supportedTriplets": ["x86_64-apple-macosx"]
31+
"supportedTriples": ["x86_64-apple-macosx"]
3232
},
3333
{
3434
"path": "x86_64-unknown-linux-gnu/protoc",
35-
"supportedTriplets": ["x86_64-unknown-linux-gnu"]
35+
"supportedTriples": ["x86_64-unknown-linux-gnu"]
3636
}
3737
]
3838
}
@@ -51,11 +51,11 @@ final class ArtifactsArchiveMetadataTests: XCTestCase {
5151
variants: [
5252
ArtifactsArchiveMetadata.Variant(
5353
path: "x86_64-apple-macosx/protoc",
54-
supportedTriplets: [Triple("x86_64-apple-macosx")]
54+
supportedTriples: [Triple("x86_64-apple-macosx")]
5555
),
5656
ArtifactsArchiveMetadata.Variant(
5757
path: "x86_64-unknown-linux-gnu/protoc",
58-
supportedTriplets: [Triple("x86_64-unknown-linux-gnu")]
58+
supportedTriples: [Triple("x86_64-unknown-linux-gnu")]
5959
)
6060
]
6161
)

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,14 +2623,14 @@ final class BuildPlanTests: XCTestCase {
26232623
bytes: ByteString(encodingAsUTF8: """
26242624
{
26252625
"schemaVersion": "1.0",
2626-
"availableArtifacts": {
2626+
"artifacts": {
26272627
"\(artifactName)": {
26282628
"type": "executable",
26292629
"version": "1.1.0",
26302630
"variants": [
26312631
{
26322632
"path": "all-platforms/mytool",
2633-
"supportedTriplets": ["\(artifactTriples.map{ $0.tripleString }.joined(separator: "\", \""))"]
2633+
"supportedTriples": ["\(artifactTriples.map{ $0.tripleString }.joined(separator: "\", \""))"]
26342634
}
26352635
]
26362636
}

0 commit comments

Comments
 (0)