-
Notifications
You must be signed in to change notification settings - Fork 314
Move isFallback to FileBuildSettings #908
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
Move isFallback to FileBuildSettings #908
Conversation
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.
Nice. Thank you.
public func buildSettings(for uri: DocumentURI, language: Language, isFallback: Bool = true) -> FileBuildSettings? { | ||
var fileBuildSettings: FileBuildSettings? |
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.
Instead of passing isFallback
here, I would prefer to set it to true
here, since it is coming from a fallback build system and overriding it to false
in BuildSystem
if we don’t have a real build system.
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.
right, by doing so, the func buildSettings in FallbackBuildSystem would be more clean.
@@ -25,9 +25,13 @@ public struct FileBuildSettings: Equatable { | |||
/// The working directory to resolve any relative paths in `compilerArguments`. | |||
public var workingDirectory: String? = nil | |||
|
|||
public init(compilerArguments: [String], workingDirectory: String? = nil) { | |||
/// The isFallback to know if the fileBuildSetting is specified or the default one. |
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 would phrase this slightly differently.
/// The isFallback to know if the fileBuildSetting is specified or the default one. | |
/// Whether the build settings were computed from a real build system or whether they are synthesized fallback arguments while the build system is still busy computing build settings. |
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.
One last minor comment, then it’s ready to ship.
Also: Could you squash your commits? It makes for a nicer git history.
// If there is no build system and we only have the fallback build system, | ||
// we will never get real build settings. Consider the build settings | ||
// non-fallback. |
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.
This comment now applies to the settings.isFallback = buildSystem != nil
line, which, just to make it even more readable would write as
if buildSystem == nil {
// If there is no build system and we only have the fallback build system,
// we will never get real build settings. Consider the build settings
// non-fallback.
settings.isFallback = false
}
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.
agree, let me update the code.
cd1a02b
to
90c4f2d
Compare
90c4f2d
to
98ba3ee
Compare
settings = settings.patching(newFile: document.pseudoPath, originalFile: mainFile.pseudoPath) | ||
} | ||
if let buildSettings { | ||
let log = """ | ||
Compiler Arguments: | ||
\(buildSettings.buildSettings.compilerArguments.joined(separator: "\n")) | ||
let log = """ | ||
Compiler Arguments: | ||
\(settings.compilerArguments.joined(separator: "\n")) | ||
|
||
Working directory: | ||
\(buildSettings.buildSettings.workingDirectory ?? "<nil>") | ||
""" | ||
Working directory: | ||
\(settings.workingDirectory ?? "<nil>") | ||
""" | ||
|
||
let chunks = splitLongMultilineMessage(message: log, maxChunkSize: 800) | ||
for (index, chunk) in chunks.enumerated() { | ||
logger.log( | ||
""" | ||
Build settings for \(document.forLogging) (\(index + 1)/\(chunks.count)) | ||
\(chunk) | ||
""" | ||
) | ||
} | ||
let chunks = splitLongMultilineMessage(message: log, maxChunkSize: 800) | ||
for (index, chunk) in chunks.enumerated() { | ||
logger.log( | ||
""" | ||
Build settings for \(document.forLogging) (\(index + 1)/\(chunks.count)) | ||
\(chunk) | ||
""" | ||
) |
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.
note: this part is a new change for solving the conflicts after rebasing.
@swift-ci Please test |
A refactoring to move isFallback into FileBuildSettings
issue: #861