Skip to content

Commit d255ccb

Browse files
authored
Merge pull request #1922 from plemarquand/expose-build-record-args-hash
2 parents 134d830 + a7399d8 commit d255ccb

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Sources/SwiftDriver/IncrementalCompilation/BuildRecordInfo.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ import class Dispatch.DispatchQueue
9797
else {
9898
return nil
9999
}
100-
let currentArgsHash = Self.computeArgsHash(parsedOptions)
100+
let currentArgsHash = BuildRecordArguments.computeHash(parsedOptions)
101101
let compilationInputModificationDates =
102102
recordedInputModificationDates.filter { input, _ in
103103
input.type.isPartOfSwiftCompilation
@@ -113,16 +113,6 @@ import class Dispatch.DispatchQueue
113113
compilationInputModificationDates: compilationInputModificationDates)
114114
}
115115

116-
private static func computeArgsHash(_ parsedOptionsArg: ParsedOptions
117-
) -> String {
118-
var parsedOptions = parsedOptionsArg
119-
let hashInput = parsedOptions
120-
.filter { $0.option.affectsIncrementalBuild && $0.option.kind != .input}
121-
.map { $0.description } // The description includes the spelling of the option itself and, if present, its argument(s).
122-
.joined()
123-
return SHA256().hash(hashInput).hexadecimalRepresentation
124-
}
125-
126116
/// Determine the input and output path for the build record
127117
private static func computeBuildRecordPath(
128118
outputFileMap: OutputFileMap?,
@@ -209,3 +199,15 @@ import class Dispatch.DispatchQueue
209199
buildRecordPath.parentDirectory
210200
}
211201
}
202+
203+
public struct BuildRecordArguments {
204+
/// Compute a hash of the parsed options that affect incremental builds.
205+
public static func computeHash(_ parsedOptionsArg: ParsedOptions) -> String {
206+
var parsedOptions = parsedOptionsArg
207+
let hashInput = parsedOptions
208+
.filter { $0.option.affectsIncrementalBuild && $0.option.kind != .input}
209+
.map { $0.description } // The description includes the spelling of the option itself and, if present, its argument(s).
210+
.joined()
211+
return SHA256().hash(hashInput).hexadecimalRepresentation
212+
}
213+
}

0 commit comments

Comments
 (0)