Skip to content

Move UserToolchain and Destination #1764

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
Aug 28, 2018
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
1 change: 1 addition & 0 deletions Sources/Commands/SwiftTestTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Basic
import Build
import Utility
import PackageGraph
import Workspace

import func POSIX.exit

Expand Down
1 change: 1 addition & 0 deletions Sources/TestSupport/Resources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Build
import Foundation
import Commands
import PackageLoading
import Workspace

#if os(macOS)
private func bundleRoot() -> AbsolutePath {
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions Sources/Workspace/Diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ public enum ResolverDiagnostics {
}
}

public struct InvalidToolchainDiagnostic: DiagnosticData, Error {
public static let id = DiagnosticID(
type: InvalidToolchainDiagnostic.self,
name: "org.swift.diags.invalid-toolchain",
description: {
$0 <<< "toolchain is invalid:" <<< { $0.error }
}
)

public let error: String
public init(_ error: String) {
self.error = error
}
}

public enum WorkspaceDiagnostics {

//MARK: - Errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ public final class UserToolchain: Toolchain {
/// Path to the xctest utility.
///
/// This is only present on macOS.
let xctest: AbsolutePath?
public let xctest: AbsolutePath?

/// Path to llbuild.
let llbuild: AbsolutePath
public let llbuild: AbsolutePath

/// The compilation destination object.
let destination: Destination
public let destination: Destination

/// Search paths from the PATH environment variable.
let envSearchPaths: [AbsolutePath]

/// Returns the runtime library for the given sanitizer.
func runtimeLibrary(for sanitizer: Sanitizer) throws -> AbsolutePath {
public func runtimeLibrary(for sanitizer: Sanitizer) throws -> AbsolutePath {
// FIXME: This is only for SwiftPM development time support. It is OK
// for now but we shouldn't need to resolve the symlink. We need to lay
// down symlinks to runtimes in our fake toolchain as part of the
Expand All @@ -85,7 +85,7 @@ public final class UserToolchain: Toolchain {

// Ensure that the runtime is present.
guard localFileSystem.exists(runtime) else {
throw Error.invalidToolchain(problem: "Missing runtime for \(sanitizer) sanitizer")
throw InvalidToolchainDiagnostic("Missing runtime for \(sanitizer) sanitizer")
}

return runtime
Expand All @@ -96,7 +96,7 @@ public final class UserToolchain: Toolchain {
func validateCompiler(at path: AbsolutePath?) throws {
guard let path = path else { return }
guard localFileSystem.isExecutableFile(path) else {
throw Error.invalidToolchain(problem: "could not find the `swiftc` at expected path \(path.asString)")
throw InvalidToolchainDiagnostic("could not find the `swiftc` at expected path \(path.asString)")
}
}

Expand All @@ -117,7 +117,7 @@ public final class UserToolchain: Toolchain {
} else if let SWIFT_EXEC = SWIFT_EXEC {
resolvedBinDirCompiler = SWIFT_EXEC
} else {
throw Error.invalidToolchain(problem: "could not find the `swiftc` at expected path \(binDirCompiler.asString)")
throw InvalidToolchainDiagnostic("could not find the `swiftc` at expected path \(binDirCompiler.asString)")
}

// The compiler for compilation tasks is SWIFT_EXEC or the bin dir compiler.
Expand All @@ -144,14 +144,14 @@ public final class UserToolchain: Toolchain {
// No value in env, so search for `clang`.
let foundPath = try Process.checkNonZeroExit(arguments: whichClangArgs).chomp()
guard !foundPath.isEmpty else {
throw Error.invalidToolchain(problem: "could not find `clang`")
throw InvalidToolchainDiagnostic("could not find `clang`")
}
clangCompiler = AbsolutePath(foundPath)
}

// Check that it's valid in the file system.
guard localFileSystem.isExecutableFile(clangCompiler) else {
throw Error.invalidToolchain(problem: "could not find `clang` at expected path \(clangCompiler.asString)")
throw InvalidToolchainDiagnostic("could not find `clang` at expected path \(clangCompiler.asString)")
}
_clangCompiler = clangCompiler
return clangCompiler
Expand All @@ -175,7 +175,7 @@ public final class UserToolchain: Toolchain {
// Look for llbuild in bin dir.
llbuild = binDir.appending(component: "swift-build-tool")
guard localFileSystem.exists(llbuild) else {
throw Error.invalidToolchain(problem: "could not find `llbuild` at expected path \(llbuild.asString)")
throw InvalidToolchainDiagnostic("could not find `llbuild` at expected path \(llbuild.asString)")
}


Expand Down
1 change: 1 addition & 0 deletions Tests/CommandsTests/BuildToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import XCTest
import TestSupport
import Basic
import Commands
import Workspace

struct BuildResult {
let output: String
Expand Down
1 change: 1 addition & 0 deletions Tests/FunctionalPerformanceTests/BuildPerfTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Commands
import TestSupport
import Basic
import Utility
import Workspace

class BuildPerfTests: XCTestCasePerf {

Expand Down
1 change: 1 addition & 0 deletions Tests/FunctionalTests/CFamilyTargetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Basic
import PackageModel
import SourceControl
import Utility
import Workspace

typealias Process = Basic.Process

Expand Down
1 change: 1 addition & 0 deletions Tests/FunctionalTests/DependencyResolutionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Basic
import Commands
import TestSupport
import SourceControl
import Workspace

class DependencyResolutionTests: XCTestCase {
func testInternalSimple() {
Expand Down
2 changes: 1 addition & 1 deletion Tests/FunctionalTests/MiscellaneousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import XCTest
import TestSupport
import Basic
import struct Commands.Destination
import PackageModel
import Utility
import SPMLibc
import class Foundation.ProcessInfo
import Workspace

typealias ProcessID = Basic.Process.ProcessID

Expand Down
1 change: 1 addition & 0 deletions Tests/FunctionalTests/ModuleMapTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Commands
import TestSupport
import Basic
import Utility
import Workspace

class ModuleMapsTestCase: XCTestCase {

Expand Down
1 change: 1 addition & 0 deletions Tests/FunctionalTests/SwiftPMXCTestHelperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import TestSupport
import XCTest
import Utility
import Commands
import Workspace

class SwiftPMXCTestHelperTests: XCTestCase {
func testBasicXCTestHelper() {
Expand Down
1 change: 1 addition & 0 deletions Tests/FunctionalTests/ToolsVersionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import TestSupport
import Commands
import PackageModel
import SourceControl
import Workspace

class ToolsVersionTests: XCTestCase {

Expand Down