1010//
1111//===----------------------------------------------------------------------===//
1212
13- @testable import PackageModel
14- @testable import TSCUtility
15- @testable import Build
1613import Basics
14+ import Build
15+ import PackageModel
1716import SPMBuildCore
17+ import TSCUtility
1818import XCTest
1919
20- struct MockToolchain : PackageModel . Toolchain {
20+ public struct MockToolchain : PackageModel . Toolchain {
2121#if os(Windows)
22- let librarianPath = AbsolutePath ( " /fake/path/to/link.exe " )
22+ public let librarianPath = AbsolutePath ( " /fake/path/to/link.exe " )
2323#elseif os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
24- let librarianPath = AbsolutePath ( " /fake/path/to/libtool " )
24+ public let librarianPath = AbsolutePath ( " /fake/path/to/libtool " )
2525#else
26- let librarianPath = AbsolutePath ( " /fake/path/to/llvm-ar " )
26+ public let librarianPath = AbsolutePath ( " /fake/path/to/llvm-ar " )
2727#endif
28- let swiftCompilerPath = AbsolutePath ( " /fake/path/to/swiftc " )
29- let includeSearchPaths = [ AbsolutePath] ( )
30- let librarySearchPaths = [ AbsolutePath] ( )
31- let swiftResourcesPath : AbsolutePath ? = nil
32- let swiftStaticResourcesPath : AbsolutePath ? = nil
33- let isSwiftDevelopmentToolchain = false
34- let sdkRootPath : AbsolutePath ? = nil
35- let swiftPluginServerPath : AbsolutePath ? = nil
36- let extraFlags = PackageModel . BuildFlags ( )
37- let installedSwiftPMConfiguration = InstalledSwiftPMConfiguration . default
38-
39- func getClangCompiler( ) throws -> AbsolutePath {
28+ public let swiftCompilerPath = AbsolutePath ( " /fake/path/to/swiftc " )
29+ public let includeSearchPaths = [ AbsolutePath] ( )
30+ public let librarySearchPaths = [ AbsolutePath] ( )
31+ public let swiftResourcesPath : AbsolutePath ? = nil
32+ public let swiftStaticResourcesPath : AbsolutePath ? = nil
33+ public let isSwiftDevelopmentToolchain = false
34+ public let sdkRootPath : AbsolutePath ? = nil
35+ public let swiftPluginServerPath : AbsolutePath ? = nil
36+ public let extraFlags = PackageModel . BuildFlags ( )
37+ public let installedSwiftPMConfiguration = InstalledSwiftPMConfiguration . default
38+
39+ public func getClangCompiler( ) throws -> AbsolutePath {
4040 return " /fake/path/to/clang "
4141 }
4242
43- func _isClangCompilerVendorApple( ) throws -> Bool ? {
43+ public func _isClangCompilerVendorApple( ) throws -> Bool ? {
4444 #if os(macOS)
4545 return true
4646 #else
4747 return false
4848 #endif
4949 }
50+
51+ public init ( ) {
52+ }
5053}
5154
5255
5356extension Basics . Triple {
54- static let x86_64MacOS = try ! Self ( " x86_64-apple-macosx " )
55- static let x86_64Linux = try ! Self ( " x86_64-unknown-linux-gnu " )
56- static let arm64Linux = try ! Self ( " aarch64-unknown-linux-gnu " )
57- static let arm64Android = try ! Self ( " aarch64-unknown-linux-android " )
58- static let windows = try ! Self ( " x86_64-unknown-windows-msvc " )
59- static let wasi = try ! Self ( " wasm32-unknown-wasi " )
57+ public static let x86_64MacOS = try ! Self ( " x86_64-apple-macosx " )
58+ public static let x86_64Linux = try ! Self ( " x86_64-unknown-linux-gnu " )
59+ public static let arm64Linux = try ! Self ( " aarch64-unknown-linux-gnu " )
60+ public static let arm64Android = try ! Self ( " aarch64-unknown-linux-android " )
61+ public static let windows = try ! Self ( " x86_64-unknown-windows-msvc " )
62+ public static let wasi = try ! Self ( " wasm32-unknown-wasi " )
6063}
6164
62- let hostTriple = try ! UserToolchain . default. targetTriple
65+ public let hostTriple = try ! UserToolchain . default. targetTriple
6366#if os(macOS)
64- let defaultTargetTriple : String = hostTriple. tripleString ( forPlatformVersion: " 10.13 " )
67+ public let defaultTargetTriple : String = hostTriple. tripleString ( forPlatformVersion: " 10.13 " )
6568#else
66- let defaultTargetTriple : String = hostTriple. tripleString
69+ public let defaultTargetTriple : String = hostTriple. tripleString
6770#endif
6871
69- func mockBuildParameters(
72+ public func mockBuildParameters(
7073 buildPath: AbsolutePath = " /path/to/build " ,
7174 config: BuildConfiguration = . debug,
7275 toolchain: PackageModel . Toolchain = MockToolchain ( ) ,
@@ -108,7 +111,7 @@ func mockBuildParameters(
108111 )
109112}
110113
111- func mockBuildParameters( environment: BuildEnvironment ) -> BuildParameters {
114+ public func mockBuildParameters( environment: BuildEnvironment ) -> BuildParameters {
112115 let triple : Basics . Triple
113116 switch environment. platform {
114117 case . macOS:
@@ -130,34 +133,34 @@ enum BuildError: Swift.Error {
130133 case error( String )
131134}
132135
133- struct BuildPlanResult {
136+ public struct BuildPlanResult {
134137
135- let plan : Build . BuildPlan
136- let targetMap : [ String : TargetBuildDescription ]
137- let productMap : [ String : Build . ProductBuildDescription ]
138+ public let plan : Build . BuildPlan
139+ public let targetMap : [ String : TargetBuildDescription ]
140+ public let productMap : [ String : Build . ProductBuildDescription ]
138141
139- init ( plan: Build . BuildPlan ) throws {
142+ public init ( plan: Build . BuildPlan ) throws {
140143 self . plan = plan
141144 self . productMap = try Dictionary ( throwingUniqueKeysWithValues: plan. buildProducts. compactMap { $0 as? Build . ProductBuildDescription } . map { ( $0. product. name, $0) } )
142145 self . targetMap = try Dictionary ( throwingUniqueKeysWithValues: plan. targetMap. map { ( $0. 0 . name, $0. 1 ) } )
143146 }
144147
145- func checkTargetsCount( _ count: Int , file: StaticString = #file, line: UInt = #line) {
148+ public func checkTargetsCount( _ count: Int , file: StaticString = #file, line: UInt = #line) {
146149 XCTAssertEqual ( plan. targetMap. count, count, file: file, line: line)
147150 }
148151
149- func checkProductsCount( _ count: Int , file: StaticString = #file, line: UInt = #line) {
152+ public func checkProductsCount( _ count: Int , file: StaticString = #file, line: UInt = #line) {
150153 XCTAssertEqual ( plan. productMap. count, count, file: file, line: line)
151154 }
152155
153- func target( for name: String ) throws -> TargetBuildDescription {
156+ public func target( for name: String ) throws -> TargetBuildDescription {
154157 guard let target = targetMap [ name] else {
155158 throw BuildError . error ( " Target \( name) not found. " )
156159 }
157160 return target
158161 }
159162
160- func buildProduct( for name: String ) throws -> Build . ProductBuildDescription {
163+ public func buildProduct( for name: String ) throws -> Build . ProductBuildDescription {
161164 guard let product = productMap [ name] else {
162165 // <rdar://problem/30162871> Display the thrown error on macOS
163166 throw BuildError . error ( " Product \( name) not found. " )
@@ -167,7 +170,7 @@ struct BuildPlanResult {
167170}
168171
169172extension TargetBuildDescription {
170- func swiftTarget( ) throws -> SwiftTargetBuildDescription {
173+ public func swiftTarget( ) throws -> SwiftTargetBuildDescription {
171174 switch self {
172175 case . swift( let target) :
173176 return target
@@ -176,7 +179,7 @@ extension TargetBuildDescription {
176179 }
177180 }
178181
179- func clangTarget( ) throws -> ClangTargetBuildDescription {
182+ public func clangTarget( ) throws -> ClangTargetBuildDescription {
180183 switch self {
181184 case . clang( let target) :
182185 return target
0 commit comments