Skip to content

Expose BuildRecordInfo.computeHash #1922

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions Sources/SwiftDriver/IncrementalCompilation/BuildRecordInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import class Dispatch.DispatchQueue
else {
return nil
}
let currentArgsHash = Self.computeArgsHash(parsedOptions)
let currentArgsHash = BuildRecordArguments.computeHash(parsedOptions)
let compilationInputModificationDates =
recordedInputModificationDates.filter { input, _ in
input.type.isPartOfSwiftCompilation
Expand All @@ -113,16 +113,6 @@ import class Dispatch.DispatchQueue
compilationInputModificationDates: compilationInputModificationDates)
}

private static func computeArgsHash(_ parsedOptionsArg: ParsedOptions
) -> String {
var parsedOptions = parsedOptionsArg
let hashInput = parsedOptions
.filter { $0.option.affectsIncrementalBuild && $0.option.kind != .input}
.map { $0.description } // The description includes the spelling of the option itself and, if present, its argument(s).
.joined()
return SHA256().hash(hashInput).hexadecimalRepresentation
}

/// Determine the input and output path for the build record
private static func computeBuildRecordPath(
outputFileMap: OutputFileMap?,
Expand Down Expand Up @@ -209,3 +199,15 @@ import class Dispatch.DispatchQueue
buildRecordPath.parentDirectory
}
}

public struct BuildRecordArguments {
/// Compute a hash of the parsed options that affect incremental builds.
public static func computeHash(_ parsedOptionsArg: ParsedOptions) -> String {
var parsedOptions = parsedOptionsArg
let hashInput = parsedOptions
.filter { $0.option.affectsIncrementalBuild && $0.option.kind != .input}
.map { $0.description } // The description includes the spelling of the option itself and, if present, its argument(s).
.joined()
return SHA256().hash(hashInput).hexadecimalRepresentation
}
}