Skip to content

Commit b61696c

Browse files
committed
PackageLoading: make some of the private API more public
This extends the visibility of some of the private implementation to the package level to allow use for testing without `@testable` imports.
1 parent 52f6ddf commit b61696c

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,16 +1013,16 @@ public final class ManifestLoader: ManifestLoaderProtocol {
10131013
}
10141014

10151015
extension ManifestLoader {
1016-
struct CacheKey: Hashable {
1016+
package struct CacheKey: Hashable {
10171017
let packageIdentity: PackageIdentity
10181018
let manifestPath: AbsolutePath
10191019
let manifestContents: [UInt8]
10201020
let toolsVersion: ToolsVersion
10211021
let env: Environment
10221022
let swiftpmVersion: String
1023-
let sha256Checksum: String
1023+
package let sha256Checksum: String
10241024

1025-
init (packageIdentity: PackageIdentity,
1025+
package init (packageIdentity: PackageIdentity,
10261026
packageLocation: String,
10271027
manifestPath: AbsolutePath,
10281028
toolsVersion: ToolsVersion,
@@ -1051,7 +1051,7 @@ extension ManifestLoader {
10511051
self.sha256Checksum = sha256Checksum
10521052
}
10531053

1054-
func hash(into hasher: inout Hasher) {
1054+
package func hash(into hasher: inout Hasher) {
10551055
hasher.combine(self.sha256Checksum)
10561056
}
10571057

@@ -1082,7 +1082,7 @@ extension ManifestLoader {
10821082
}
10831083

10841084
extension ManifestLoader {
1085-
struct EvaluationResult: Codable {
1085+
package struct EvaluationResult: Codable {
10861086
/// The path to the diagnostics file (.dia).
10871087
///
10881088
/// This is only present if serialized diagnostics are enabled.
@@ -1094,11 +1094,18 @@ extension ManifestLoader {
10941094
var compilerOutput: String?
10951095

10961096
/// The manifest in JSON format.
1097-
var manifestJSON: String?
1097+
package var manifestJSON: String?
10981098

10991099
/// The command line used to compile the manifest
11001100
var compilerCommandLine: [String]?
11011101

1102+
package init(diagnosticFile: AbsolutePath? = nil, compilerOutput: String? = nil, manifestJSON: String? = nil, compilerCommandLine: [String]? = nil) {
1103+
self.diagnosticFile = diagnosticFile
1104+
self.compilerOutput = compilerOutput
1105+
self.manifestJSON = manifestJSON
1106+
self.compilerCommandLine = compilerCommandLine
1107+
}
1108+
11021109
/// Any non-compiler error that might have occurred during manifest loading.
11031110
///
11041111
/// For e.g., we could have failed to spawn the process or create temporary file.

Sources/PackageLoading/PkgConfig.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ extension PkgConfig {
159159
///
160160
/// See: https://www.freedesktop.org/wiki/Software/pkg-config/
161161
// This is only internal so it can be unit tested.
162-
internal struct PkgConfigParser {
162+
package struct PkgConfigParser {
163163
public let pcFile: Basics.AbsolutePath
164164
private let fileSystem: FileSystem
165165
public private(set) var variables = [String: String]()
@@ -458,7 +458,7 @@ internal struct PkgConfigParser {
458458
}
459459

460460
// This is only internal so it can be unit tested.
461-
internal struct PCFileFinder {
461+
package struct PCFileFinder {
462462
/// Cached results of locations `pkg-config` will search for `.pc` files
463463
/// FIXME: This shouldn't use a static variable, since the first lookup
464464
/// will cache the result of whatever `brewPrefix` was passed in. It is
@@ -512,7 +512,7 @@ internal struct PCFileFinder {
512512
/// again when instantiating a `PCFileFinder()`. This is intended only for
513513
/// use by testing. This is a temporary workaround for the use of a static
514514
/// variable by this class.
515-
internal static func resetCachedPkgConfigPaths() {
515+
package static func resetCachedPkgConfigPaths() {
516516
PCFileFinder.pkgConfigPaths = nil
517517
}
518518

@@ -539,7 +539,7 @@ internal struct PCFileFinder {
539539
}
540540
}
541541

542-
internal enum PkgConfigError: Swift.Error, CustomStringConvertible {
542+
package enum PkgConfigError: Swift.Error, CustomStringConvertible {
543543
case couldNotFindConfigFile(name: String)
544544
case parsingError(String)
545545
case prohibitedFlags(String)

0 commit comments

Comments
 (0)