Skip to content

Mostly explicit import tools-support-core APIs #1176

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
Sep 11, 2022
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
14 changes: 13 additions & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic
import SwiftOptions

import class Dispatch.DispatchQueue

import TSCBasic // <<<
Copy link
Contributor

Choose a reason for hiding this comment

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

Guessing this can be removed now. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Afraid not :-(. The import TSCBasic // <<< instances are all importing the module as I couldn't figure out how to import the <<< operator from TSC. If that is possible, I'd be happy to go through and remove the instances.

import class TSCBasic.DiagnosticsEngine
import enum TSCBasic.ProcessEnv
import protocol TSCBasic.DiagnosticData
import protocol TSCBasic.FileSystem
import protocol TSCBasic.OutputByteStream
import struct TSCBasic.AbsolutePath
import struct TSCBasic.Diagnostic
import struct TSCBasic.FileInfo
import struct TSCBasic.RelativePath
import var TSCBasic.localFileSystem
import var TSCBasic.stderrStream
import var TSCBasic.stdoutStream
import enum TSCUtility.Diagnostics
import struct TSCUtility.Version

Expand Down
7 changes: 6 additions & 1 deletion Sources/SwiftDriver/Driver/OutputFileMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import struct Foundation.Data
import class Foundation.JSONEncoder
import class Foundation.JSONDecoder

import class TSCBasic.DiagnosticsEngine
import protocol TSCBasic.FileSystem
import struct TSCBasic.AbsolutePath
import struct TSCBasic.ByteString
import struct TSCBasic.RelativePath

/// Mapping of input file paths to specific output files.
public struct OutputFileMap: Hashable, Codable {
static let singleInputKey = try! VirtualPath.intern(path: ".")
Expand Down
8 changes: 7 additions & 1 deletion Sources/SwiftDriver/Driver/ToolExecutionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

#if canImport(Darwin)
import Darwin.C
Expand All @@ -22,6 +21,13 @@ import Glibc
#error("Missing libc or equivalent")
#endif

import TSCBasic // <<<
import class TSCBasic.DiagnosticsEngine
import struct TSCBasic.Diagnostic
import struct TSCBasic.ProcessResult
import var TSCBasic.stderrStream
import var TSCBasic.stdoutStream

/// Delegate for printing execution information on the command-line.
@_spi(Testing) public final class ToolExecutionDelegate: JobExecutionDelegate {
/// Quasi-PIDs are _negative_ PID-like unique keys used to
Expand Down
7 changes: 6 additions & 1 deletion Sources/SwiftDriver/Execution/ArgsResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
//===----------------------------------------------------------------------===//

import class Foundation.NSLock
import TSCBasic

import TSCBasic // <<<
import func TSCBasic.withTemporaryDirectory
import protocol TSCBasic.FileSystem
import struct TSCBasic.AbsolutePath

@_implementationOnly import Yams

/// How the resolver is to handle usage of response files
Expand Down
3 changes: 2 additions & 1 deletion Sources/SwiftDriver/Execution/DriverExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import struct TSCBasic.ProcessResult

import struct Foundation.Data
import class Foundation.JSONDecoder
import var Foundation.EXIT_SUCCESS
Expand Down
4 changes: 3 additions & 1 deletion Sources/SwiftDriver/Execution/ProcessProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import class TSCBasic.Process
import struct TSCBasic.ProcessResult

import class Foundation.FileHandle
import struct Foundation.Data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import func TSCBasic.determineTempDirectory

/// A map from a module identifier to a set of module dependency graphs
/// Used to compute distinct graphs corresponding to different target versions for a given clang module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import struct TSCBasic.SHA256
import struct TSCBasic.AbsolutePath

import struct Foundation.Data
import class Foundation.JSONEncoder

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import func TSCBasic.topologicalSort

@_spi(Testing) public extension InterModuleDependencyGraph {
/// For targets that are built alongside the driver's current module, the scanning action will report them as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import protocol TSCBasic.FileSystem
import struct TSCBasic.AbsolutePath

import Dispatch

// An inter-module dependency oracle, responsible for responding to queries about
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import TSCBasic // <<<
import protocol TSCBasic.FileSystem
import struct TSCBasic.AbsolutePath
import struct TSCBasic.Diagnostic
import var TSCBasic.localFileSystem
import var TSCBasic.stdoutStream

import SwiftOptions
import struct Foundation.Data
import class Foundation.JSONEncoder
Expand Down
6 changes: 5 additions & 1 deletion Sources/SwiftDriver/IncrementalCompilation/BuildRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import class TSCBasic.DiagnosticsEngine
import struct TSCBasic.AbsolutePath
import struct TSCBasic.Diagnostic

@_implementationOnly import Yams

/// Holds the info about inputs needed to plan incremenal compilation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import class TSCBasic.DiagnosticsEngine
import protocol TSCBasic.FileSystem
import struct TSCBasic.AbsolutePath
import struct TSCBasic.ByteString
import struct TSCBasic.ProcessResult
import struct TSCBasic.SHA256

import SwiftOptions
import class Dispatch.DispatchQueue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import TSCBasic // <<<
import protocol TSCBasic.WritableByteStream

// MARK: - Asking to write dot files / interface
public struct DependencyGraphDotFileWriter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import Dispatch

/// A filename from another module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import protocol TSCBasic.FileSystem

import class Dispatch.DispatchQueue

extension IncrementalCompilationState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
//===----------------------------------------------------------------------===//

import Dispatch
import TSCBasic
import SwiftOptions

import protocol TSCBasic.FileSystem
import struct TSCUtility.Version

extension IncrementalCompilationState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import SwiftOptions
import protocol Foundation.LocalizedError

import class TSCBasic.DiagnosticsEngine
import protocol TSCBasic.FileSystem
import struct TSCBasic.Diagnostic
import struct TSCBasic.ProcessResult

/// In a separate file to ensure that ``IncrementalCompilationState/protectedState``
/// can only be accessed via ``IncrementalCompilationState/blockingConcurrentMutation(_:)`` and
/// ``IncrementalCompilationState/blockingConcurrentAccessOrMutation(_:)``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//

import Dispatch
import TSCBasic
import SwiftOptions

/// An instance of `IncrementalCompilationState` encapsulates the data necessary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import SwiftOptions
import class Dispatch.DispatchQueue

import class TSCBasic.DiagnosticsEngine
import protocol TSCBasic.FileSystem

// Initial incremental state computation
extension IncrementalCompilationState {
static func computeIncrementalStateForPlanning(driver: inout Driver)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/IncrementalCompilation/InputInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import struct TSCBasic.ProcessResult

/// Contains information about the current status of an input to the incremental
/// build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic
import SwiftOptions

import protocol TSCBasic.FileSystem
import struct TSCBasic.ByteString
import enum TSCUtility.BitcodeElement
import enum TSCUtility.Bitstream
import class TSCUtility.BitstreamWriter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import class TSCBasic.DiagnosticsEngine

// MARK: - DependencySource
/// Points to the source of dependencies, i.e. the file read to obtain the information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic

extension ModuleDependencyGraph {

// MARK: Integrator - state & creation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

// MARK: - ModuleDependencyGraph.Node
extension ModuleDependencyGraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import class TSCBasic.DiagnosticsEngine

extension ModuleDependencyGraph {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import protocol TSCBasic.FileSystem
import struct TSCBasic.ByteString
import class TSCUtility.BitstreamWriter
import enum TSCUtility.BitcodeElement
import enum TSCUtility.Bitstream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic

/// Because the incremental compilation system treats files containing Swift source code specially,
/// it is helpful to statically distinguish them wherever an input must be swift source code.
public struct SwiftSourceFile: Hashable {
Expand Down
2 changes: 0 additions & 2 deletions Sources/SwiftDriver/Jobs/APIDigesterJobs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
//
//===----------------------------------------------------------------------===//

import TSCBasic

enum DigesterMode: String {
case api, abi

Expand Down
3 changes: 2 additions & 1 deletion Sources/SwiftDriver/Jobs/AutolinkExtractJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import struct TSCBasic.RelativePath

// On ELF/WASM platforms there's no built in autolinking mechanism, so we
// pull the info we need from the .o files directly and pass them as an
Expand Down
4 changes: 3 additions & 1 deletion Sources/SwiftDriver/Jobs/CommandLineArguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import SwiftOptions

import struct TSCBasic.AbsolutePath

/// Utilities for manipulating a list of command line arguments, including
/// constructing one from a set of ParsedOptions.
extension Array where Element == Job.ArgTemplate {
Expand Down
4 changes: 3 additions & 1 deletion Sources/SwiftDriver/Jobs/CompileJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import TSCBasic

import SwiftOptions

import struct TSCBasic.RelativePath

extension Driver {
/// Add the appropriate compile mode option to the command line for a compile job.
mutating func addCompileModeOption(outputType: FileType?, commandLine: inout [Job.ArgTemplate]) {
Expand Down
Loading