Skip to content

Remove trailing whitespaces #70

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 1 commit into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public struct Driver {
case subcommandPassedToDriver
case relativeFrontendPath(String)
}

/// The set of environment variables that are visible to the driver and
/// processes it launches. This is a hook for testing; in actual use
/// it should be identical to the real environment.
Expand Down Expand Up @@ -441,7 +441,7 @@ extension Driver {
var isEscaping = false
// Indicates if we are currently parsing quoted text.
var quoted = false

for char in line {
// Backslash escapes to the next character.
if char == #"\"#, !isEscaping {
Expand Down Expand Up @@ -480,7 +480,7 @@ extension Driver {
return content.split { $0 == "\n" || $0 == "\r\n" }
.flatMap { tokenizeResponseFileLine($0) }
}

/// Recursively expands the response files.
/// - Parameter visitedResponseFiles: Set containing visited response files to detect recursive parsing.
private static func expandResponseFiles(
Expand Down Expand Up @@ -1251,7 +1251,7 @@ extension Driver {
// This value will fail the isSwiftIdentifier test below.
moduleName = ""
}

func fallbackOrDiagnose(_ error: Diagnostic.Message) {
// FIXME: Current driver notes that this is a "fallback module name".
if compilerOutputType == nil || maybeBuildingExecutable(&parsedOptions, linkerOutputType: linkerOutputType) {
Expand Down Expand Up @@ -1330,7 +1330,7 @@ extension Driver {
sdkPath = try? toolchain.defaultSDKPath()?.pathString
}
}

// An empty string explicitly clears the SDK.
if sdkPath == "" {
sdkPath = nil
Expand Down Expand Up @@ -1445,7 +1445,7 @@ extension Driver {
#else
static let defaultToolchainType: Toolchain.Type = GenericUnixToolchain.self
#endif

static func computeToolchain(
_ explicitTarget: Triple?,
diagnosticsEngine: DiagnosticsEngine,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Driver/DriverKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension DriverKind {
return "Swift Module Wrapper"
}
}

public var seeAlsoHelpMessage: String? {
switch self {
case .interactive:
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Execution/JobExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public final class JobExecutor {

/// The resolver for argument template.
let argsResolver: ArgsResolver

/// The environment variables.
let env: [String: String]

Expand Down
10 changes: 5 additions & 5 deletions Sources/SwiftDriver/Jobs/DarwinToolchain+LinkerSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ extension DarwinToolchain {
targetTriple: Triple
) {
// FIXME: Properly handle deployment targets.

let flag: String

switch targetTriple.darwinPlatform! {
case .iOS(.device):
flag = "-iphoneos_version_min"
Expand All @@ -135,11 +135,11 @@ extension DarwinToolchain {
case .watchOS(.simulator):
flag = "-watchos_simulator_version_min"
}

commandLine.appendFlag(flag)
commandLine.appendFlag(targetTriple.version().description)
}

private func addArgsToLinkARCLite(
to commandLine: inout [Job.ArgTemplate],
parsedOptions: inout ParsedOptions,
Expand Down Expand Up @@ -215,7 +215,7 @@ extension DarwinToolchain {
commandLine.appendFlag(.F)
commandLine.appendPath(try VirtualPath(path: opt.argument.asSingle))
}

// Linking sanitizers will add rpaths, which might negatively interact when
// other rpaths are involved, so we should make sure we add the rpaths after
// all user-specified rpaths.
Expand Down
10 changes: 5 additions & 5 deletions Sources/SwiftDriver/Jobs/GeneratePCHJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ extension Driver {
mutating func generatePCHJob(input: TypedVirtualPath, output: TypedVirtualPath) throws -> Job {
var inputs = [TypedVirtualPath]()
var outputs = [TypedVirtualPath]()

var commandLine: [Job.ArgTemplate] = swiftCompilerPrefixArgs.map { Job.ArgTemplate.flag($0) }

commandLine.appendFlag("-frontend")

try addCommonFrontendOptions(
commandLine: &commandLine, bridgingHeaderHandling: .parsed)

try commandLine.appendLast(.indexStorePath, from: &parsedOptions)

// TODO: Should this just be pch output with extension changed?
Expand Down Expand Up @@ -52,15 +52,15 @@ extension Driver {
try commandLine.appendLast(.indexStorePath, from: &parsedOptions)

commandLine.appendFlag(.emitPch)

if parsedOptions.hasArgument(.pchOutputDir) {
try commandLine.appendLast(.pchOutputDir, from: &parsedOptions)
} else {
commandLine.appendFlag(.o)
commandLine.appendPath(output.file)
}
outputs.append(output)

return Job(
kind: .generatePCH,
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Jobs/Job.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct Job: Codable, Equatable, Hashable {

/// The outputs produced by the job.
public var outputs: [TypedVirtualPath]

/// Any extra environment variables which should be set while running the job.
public var extraEnvironment: [String: String]

Expand Down
10 changes: 5 additions & 5 deletions Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ extension DarwinToolchain {
commandLine.appendFlag(.L)
commandLine.appendPath(path)
}

let rpaths = StdlibRpathRule(
parsedOptions: &parsedOptions,
targetTriple: targetTriple
Expand All @@ -182,21 +182,21 @@ extension DarwinToolchain {
commandLine.appendPath(path)
}
}

/// Represents the rpaths we need to add in order to find the
/// desired standard library at runtime.
fileprivate enum StdlibRpathRule {
/// Add a set of rpaths that will allow the compiler resource directory
/// to override Swift-in-the-OS dylibs.
case toolchain

/// Add an rpath that will search Swift-in-the-OS dylibs, but not
/// compiler resource directory dylibs.
case os

/// Do not add any rpaths at all.
case none

/// Determines the appropriate rule for the
init(parsedOptions: inout ParsedOptions, targetTriple: Triple) {
if parsedOptions.hasFlag(
Expand Down Expand Up @@ -244,7 +244,7 @@ extension DarwinToolchain {
self = .os
}
}

func paths(runtimeLibraryPaths: [AbsolutePath]) -> [AbsolutePath] {
switch self {
case .toolchain:
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Options/Option.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// Attributes that describe where and how the option is used.
public struct OptionAttributes: OptionSet, Hashable {
public let rawValue: UInt

public init(rawValue: UInt) {
self.rawValue = rawValue
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Options/OptionTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extension OptionTable {
let rightPadding = String(
repeating: " ",
count: maxDisplayNameLength - displayName.count)

print(" \(displayName)\(rightPadding) \(helpText)")
} else {
print(" \(displayName)")
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftDriver/Toolchains/DarwinToolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public final class DarwinToolchain: Toolchain {

/// Doubles as path cache and point for overriding normal lookup
private var toolPaths = [Tool: AbsolutePath]()

public init(env: [String: String]) {
self.env = env
}

/// Retrieve the absolute path for a given tool.
public func getToolPath(_ tool: Tool) throws -> AbsolutePath {
// Check the cache
Expand Down
24 changes: 12 additions & 12 deletions Sources/SwiftDriver/Toolchains/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public enum Tool {
/// and other tools required to build Swift code.
public protocol Toolchain {
init(env: [String: String])

var env: [String: String] { get }

var searchPaths: [AbsolutePath] { get }

/// Retrieve the absolute path to a particular tool.
func getToolPath(_ tool: Tool) throws -> AbsolutePath

Expand Down Expand Up @@ -76,14 +76,14 @@ extension Toolchain {
public var searchPaths: [AbsolutePath] {
getEnvSearchPaths(pathString: env["PATH"], currentWorkingDirectory: localFileSystem.currentWorkingDirectory)
}

public func swiftCompilerVersion() throws -> String {
try Process.checkNonZeroExit(
args: getToolPath(.swiftCompiler).pathString, "-version",
environment: env
).split(separator: "\n").first.map(String.init) ?? ""
}

/// Returns the target triple string for the current host.
public func hostTargetTriple() throws -> Triple {
let triple = try Process.checkNonZeroExit(
Expand All @@ -92,34 +92,34 @@ extension Toolchain {
).spm_chomp()
return Triple(triple)
}

/// Returns the `executablePath`'s directory.
public var executableDir: AbsolutePath {
guard let path = Bundle.main.executablePath else {
fatalError("Could not find executable path.")
}
return AbsolutePath(path).parentDirectory
}

/// Looks for `SWIFT_DRIVER_TOOLNAME_EXEC` in the `env` property.
/// - Returns: Environment variable value, if any.
func envVar(forExecutable toolName: String) -> String? {
return env[envVarName(for: toolName)]
}

/// - Returns: String in the form of: `SWIFT_DRIVER_TOOLNAME_EXEC`
private func envVarName(for toolName: String) -> String {
return "SWIFT_DRIVER_\(toolName.uppercased())_EXEC"
}

/// Use this property only for testing purposes, for example,
/// to enable cross-compiling tests that depends on macOS tooling such as `dsymutil`.
///
/// Returns true if `SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK` is set to `1`.
private var fallbackToExecutableDefaultPath: Bool {
env["SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK"] == "1"
}

/// Looks for the executable in the `SWIFT_DRIVER_TOOLNAME_EXEC` environment variable, if found nothing,
/// looks in the `executableDir`, `xcrunFind` or in the `searchPaths`.
/// - Parameter executable: executable to look for [i.e. `swift`].
Expand All @@ -138,13 +138,13 @@ extension Toolchain {
throw ToolchainError.unableToFind(tool: executable)
}
}

private func xcrunFind(executable: String) throws -> AbsolutePath {
let xcrun = "xcrun"
guard lookupExecutablePath(filename: xcrun, searchPaths: searchPaths) != nil else {
throw ToolchainError.unableToFind(tool: xcrun)
}

let path = try Process.checkNonZeroExit(
arguments: [xcrun, "-sdk", "macosx", "--find", executable],
environment: env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct PredictableRandomNumberGenerator: RandomNumberGenerator {
z = (z ^ (z &>> 27)) &* 0x94d049bb133111eb
return z ^ (z &>> 31)
}

var initState = seed
state = (initNext(&initState), initNext(&initState),
initNext(&initState), initNext(&initState))
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftDriver/Utilities/RelativePathAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension RelativePath {

return basename
}

/// Retrieve the basename of the relative path without any extensions,
/// even if there are several, and without any leading dots. Roughly
/// equivalent to the regex `/[^.]+/`.
Expand All @@ -42,12 +42,12 @@ extension AbsolutePath {

fileprivate func firstBasename(of name: String) -> String {
var copy = name[...]

// Remove leading dots, as in dotfiles.
if let i = copy.firstIndex(where: { $0 != "." }) {
copy.removeSubrange(..<i)
}

// Truncate at the first (obviously non-leading) dot.
if let i = copy.firstIndex(of: ".") {
copy.removeSubrange(i...)
Expand Down
Loading