Skip to content

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

Merged

Conversation

joehsieh
Copy link
Contributor

A refactoring to move isFallback into FileBuildSettings

issue: #861

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thank you.

Comment on lines 54 to 55
public func buildSettings(for uri: DocumentURI, language: Language, isFallback: Bool = true) -> FileBuildSettings? {
var fileBuildSettings: FileBuildSettings?
Copy link
Member

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.

Copy link
Contributor Author

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.
Copy link
Member

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.

Suggested change
/// 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.

Copy link
Member

@ahoppen ahoppen left a 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.

Comment on lines 112 to 133
// 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.
Copy link
Member

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
}

Copy link
Contributor Author

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.

@joehsieh joehsieh force-pushed the move-isFallback-to-FileBuildSettings branch from cd1a02b to 90c4f2d Compare October 20, 2023 01:02
@joehsieh joehsieh force-pushed the move-isFallback-to-FileBuildSettings branch from 90c4f2d to 98ba3ee Compare October 20, 2023 01:07
@joehsieh joehsieh requested a review from ahoppen October 20, 2023 01:10
Comment on lines +161 to +178
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)
"""
)
Copy link
Contributor Author

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.

@ahoppen
Copy link
Member

ahoppen commented Oct 20, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit 8dd93d1 into swiftlang:main Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants