Skip to content

Commit 5983944

Browse files
committed
Simplify PIF workspace encoding
1 parent 883c48e commit 5983944

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

Sources/SwiftBuildSupport/PIF.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import enum SwiftBuild.ProjectModel
3030
/// incrementally updated by clients when something changes.
3131
public enum PIF {
3232
/// This is used as part of the signature for the high-level PIF objects, to ensure that changes to the PIF schema
33-
/// are represented by the objects which do not use a content-based signature scheme (workspaces and projects,
34-
/// currently).
33+
/// are represented by the objects which do not use a content-based signature scheme
34+
/// (workspaces and projects, currently).
3535
static let schemaVersion = 11
3636

3737
/// The type used for identifying PIF objects.
@@ -103,13 +103,13 @@ public enum PIF {
103103
}
104104

105105
public func encode(to encoder: Encoder) throws {
106-
var container = encoder.container(keyedBy: CodingKeys.self)
107-
try container.encode(type, forKey: .type)
106+
var superContainer = encoder.container(keyedBy: CodingKeys.self)
107+
try superContainer.encode(type, forKey: .type)
108108
}
109109

110110
required public init(from decoder: Decoder) throws {
111-
let container = try decoder.container(keyedBy: CodingKeys.self)
112-
self.type = try container.decode(String.self, forKey: .type)
111+
let superContainer = try decoder.container(keyedBy: CodingKeys.self)
112+
self.type = try superContainer.decode(String.self, forKey: .type)
113113

114114
guard self.type == Self.type else {
115115
throw InternalError("Expected same type for high-level object: \(self.type)")
@@ -148,7 +148,7 @@ public enum PIF {
148148
var superContainer = encoder.container(keyedBy: HighLevelObject.CodingKeys.self)
149149
var contents = superContainer.nestedContainer(keyedBy: CodingKeys.self, forKey: .contents)
150150

151-
try contents.encode("\(guid)@\(schemaVersion)", forKey: .guid)
151+
try contents.encode("\(guid)", forKey: .guid)
152152
try contents.encode(name, forKey: .name)
153153
try contents.encode(path, forKey: .path)
154154
try contents.encode(projects.map(\.signature), forKey: .projects)
@@ -165,8 +165,7 @@ public enum PIF {
165165
let superContainer = try decoder.container(keyedBy: HighLevelObject.CodingKeys.self)
166166
let contents = try superContainer.nestedContainer(keyedBy: CodingKeys.self, forKey: .contents)
167167

168-
let guidString = try contents.decode(GUID.self, forKey: .guid)
169-
self.guid = String(guidString.dropLast("\(schemaVersion)".count + 1))
168+
self.guid = try contents.decode(GUID.self, forKey: .guid)
170169
self.name = try contents.decode(String.self, forKey: .name)
171170
self.path = try contents.decode(AbsolutePath.self, forKey: .path)
172171
self.projects = try contents.decode([Project].self, forKey: .projects)
@@ -247,6 +246,7 @@ public enum PIF {
247246
}
248247

249248
public required init(from decoder: Decoder) throws {
249+
// FIXME: Remove all support for decoding PIF objects in SwiftBuildSupport? rdar://149003797
250250
fatalError("Decoding not implemented")
251251
/*
252252
let superContainer = try decoder.container(keyedBy: HighLevelObject.CodingKeys.self)

Sources/XCBuildSupport/PIF.swift

-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ import struct TSCBasic.ByteString
2727
/// between builds which use different schemes or configurations), and can be
2828
/// incrementally updated by clients when something changes.
2929
public enum PIF {
30-
/// This is used as part of the signature for the high-level PIF objects, to ensure that changes to the PIF schema
31-
/// are represented by the objects which do not use a content-based signature scheme (workspaces and projects,
32-
/// currently).
33-
static let schemaVersion = 11
34-
3530
/// The type used for identifying PIF objects.
3631
public typealias GUID = String
3732

0 commit comments

Comments
 (0)