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
[SR-8135] Changes for bug fix to do a clang check only when needed for certain … #1695
Conversation
Sources/Commands/UserToolchain.swift
Outdated
self.destination = destination | ||
|
||
// Get the search paths from PATH. | ||
let envSearchPaths = getEnvSearchPaths( |
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 think we should convert this into a property so we don't need to construct it again in the getClangCompiler method.
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.
done
Sources/Commands/UserToolchain.swift
Outdated
let envSearchPaths = getEnvSearchPaths( | ||
pathString: getenv("PATH"), currentWorkingDirectory: localFileSystem.currentWorkingDirectory) | ||
|
||
func lookup(fromEnv: String) -> AbsolutePath? { |
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.
Similarly this could be a private method in this class.
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.
done
@@ -32,6 +31,9 @@ private struct MockToolchain: Toolchain { | |||
#else | |||
let dynamicLibraryExtension = "so" | |||
#endif | |||
public func getClangCompiler() throws -> AbsolutePath { |
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.
nit: remove public
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.
done
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.
Looks good, I added some minor comments.
Sources/Commands/UserToolchain.swift
Outdated
@@ -69,6 +66,9 @@ public struct UserToolchain: Toolchain { | |||
/// The compilation destination object. | |||
let destination: Destination | |||
|
|||
// Get the search paths from PATH |
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.
nit: /// Search paths from the PATH environment variable.
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.
done
Sources/Commands/UserToolchain.swift
Outdated
private static func lookup(fromEnv: String, searchPaths: [AbsolutePath]) -> AbsolutePath? { | ||
return lookupExecutablePath( | ||
filename: getenv(fromEnv), | ||
searchPaths: searchPaths) |
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.
nit: all this could be in one line.
return lookupExecutablePath(filename: getenv(fromEnv), searchPaths: searchPaths)
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.
done
Sources/Commands/UserToolchain.swift
Outdated
|
||
// Get the binDir from destination. | ||
let binDir = destination.binDir | ||
private static func lookup(fromEnv: String, searchPaths: [AbsolutePath]) -> AbsolutePath? { |
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 think we should rename "fromEnv" to "executable", so the signature becomes:
private static func lookup(executable: String, searchPaths: [AbsolutePath]) -> AbsolutePath?
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.
actually, it should be "variable" not "executable".
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.
done
Sources/Commands/UserToolchain.swift
Outdated
// Get the binDir from destination. | ||
let binDir = destination.binDir | ||
|
||
let swiftCompilers = try UserToolchain.determineSwiftCompilers(binDir: binDir, lookup: {UserToolchain.lookup(fromEnv: $0, searchPaths: searchPaths)}) |
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.
nit: needs a space after {
and before }
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.
done
Sources/Commands/UserToolchain.swift
Outdated
@@ -69,6 +66,9 @@ public struct UserToolchain: Toolchain { | |||
/// The compilation destination object. | |||
let destination: Destination | |||
|
|||
/// Search paths from the PATH environment variable |
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.
nit: missing .
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.
done
… and property of UserToolchain class
@swift-ci please smoke test |
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.
Thanks!
…commands