@@ -19,41 +19,67 @@ import struct PackageGraph.PackageGraph
19
19
import struct PackageLoading. FileRuleDescription
20
20
import protocol TSCBasic. OutputByteStream
21
21
22
+ private struct NativeBuildSystemFactory : BuildSystemFactory {
23
+ let swiftTool : SwiftTool
24
+
25
+ func makeBuildSystem(
26
+ explicitProduct: String ? ,
27
+ cacheBuildManifest: Bool ,
28
+ customBuildParameters: BuildParameters ? ,
29
+ customPackageGraphLoader: ( ( ) throws -> PackageGraph ) ? ,
30
+ customOutputStream: OutputByteStream ? ,
31
+ customLogLevel: Diagnostic . Severity ? ,
32
+ customObservabilityScope: ObservabilityScope ?
33
+ ) throws -> any BuildSystem {
34
+ let testEntryPointPath = customBuildParameters? . testProductStyle. explicitlySpecifiedEntryPointPath
35
+ let graphLoader = { try self . swiftTool. loadPackageGraph ( explicitProduct: explicitProduct, testEntryPointPath: testEntryPointPath) }
36
+ return try BuildOperation (
37
+ buildParameters: customBuildParameters ?? self . swiftTool. buildParameters ( ) ,
38
+ cacheBuildManifest: cacheBuildManifest && self . swiftTool. canUseCachedBuildManifest ( ) ,
39
+ packageGraphLoader: customPackageGraphLoader ?? graphLoader,
40
+ pluginConfiguration: . init(
41
+ scriptRunner: self . swiftTool. getPluginScriptRunner ( ) ,
42
+ workDirectory: try self . swiftTool. getActiveWorkspace ( ) . location. pluginWorkingDirectory,
43
+ disableSandbox: self . swiftTool. shouldDisableSandbox
44
+ ) ,
45
+ additionalFileRules: FileRuleDescription . swiftpmFileTypes,
46
+ pkgConfigDirectories: self . swiftTool. options. locations. pkgConfigDirectories,
47
+ outputStream: customOutputStream ?? self . swiftTool. outputStream,
48
+ logLevel: customLogLevel ?? self . swiftTool. logLevel,
49
+ fileSystem: self . swiftTool. fileSystem,
50
+ observabilityScope: customObservabilityScope ?? self . swiftTool. observabilityScope)
51
+ }
52
+ }
53
+
54
+ private struct XcodeBuildSystemFactory : BuildSystemFactory {
55
+ let swiftTool : SwiftTool
56
+
57
+ func makeBuildSystem(
58
+ explicitProduct: String ? ,
59
+ cacheBuildManifest: Bool ,
60
+ customBuildParameters: BuildParameters ? ,
61
+ customPackageGraphLoader: ( ( ) throws -> PackageGraph ) ? ,
62
+ customOutputStream: OutputByteStream ? ,
63
+ customLogLevel: Diagnostic . Severity ? ,
64
+ customObservabilityScope: ObservabilityScope ?
65
+ ) throws -> any BuildSystem {
66
+ let graphLoader = { try self . swiftTool. loadPackageGraph ( explicitProduct: explicitProduct) }
67
+ return try XcodeBuildSystem (
68
+ buildParameters: customBuildParameters ?? self . swiftTool. buildParameters ( ) ,
69
+ packageGraphLoader: customPackageGraphLoader ?? graphLoader,
70
+ outputStream: customOutputStream ?? self . swiftTool. outputStream,
71
+ logLevel: customLogLevel ?? self . swiftTool. logLevel,
72
+ fileSystem: self . swiftTool. fileSystem,
73
+ observabilityScope: customObservabilityScope ?? self . swiftTool. observabilityScope
74
+ )
75
+ }
76
+ }
77
+
22
78
extension SwiftTool {
23
79
public var defaultBuildSystemProvider : BuildSystemProvider {
24
- get throws {
25
- return . init( providers: [
26
- . native: { ( explicitProduct: String ? , cacheBuildManifest: Bool , customBuildParameters: BuildParameters ? , customPackageGraphLoader: ( ( ) throws -> PackageGraph ) ? , customOutputStream: OutputByteStream ? , customLogLevel: Diagnostic . Severity ? , customObservabilityScope: ObservabilityScope ? ) throws -> BuildSystem in
27
- let testEntryPointPath = customBuildParameters? . testProductStyle. explicitlySpecifiedEntryPointPath
28
- let graphLoader = { try self . loadPackageGraph ( explicitProduct: explicitProduct, testEntryPointPath: testEntryPointPath) }
29
- return try BuildOperation (
30
- buildParameters: customBuildParameters ?? self . buildParameters ( ) ,
31
- cacheBuildManifest: cacheBuildManifest && self . canUseCachedBuildManifest ( ) ,
32
- packageGraphLoader: customPackageGraphLoader ?? graphLoader,
33
- pluginConfiguration: . init(
34
- scriptRunner: self . getPluginScriptRunner ( ) ,
35
- workDirectory: try self . getActiveWorkspace ( ) . location. pluginWorkingDirectory,
36
- disableSandbox: self . shouldDisableSandbox
37
- ) ,
38
- additionalFileRules: FileRuleDescription . swiftpmFileTypes,
39
- pkgConfigDirectories: self . options. locations. pkgConfigDirectories,
40
- outputStream: customOutputStream ?? self . outputStream,
41
- logLevel: customLogLevel ?? self . logLevel,
42
- fileSystem: self . fileSystem,
43
- observabilityScope: customObservabilityScope ?? self . observabilityScope)
44
- } ,
45
- . xcode: { ( explicitProduct: String ? , cacheBuildManifest: Bool , customBuildParameters: BuildParameters ? , customPackageGraphLoader: ( ( ) throws -> PackageGraph ) ? , customOutputStream: OutputByteStream ? , customLogLevel: Diagnostic . Severity ? , customObservabilityScope: ObservabilityScope ? ) throws -> BuildSystem in
46
- let graphLoader = { try self . loadPackageGraph ( explicitProduct: explicitProduct) }
47
- return try XcodeBuildSystem (
48
- buildParameters: customBuildParameters ?? self . buildParameters ( ) ,
49
- packageGraphLoader: customPackageGraphLoader ?? graphLoader,
50
- outputStream: customOutputStream ?? self . outputStream,
51
- logLevel: customLogLevel ?? self . logLevel,
52
- fileSystem: self . fileSystem,
53
- observabilityScope: customObservabilityScope ?? self . observabilityScope
54
- )
55
- } ,
56
- ] )
57
- }
80
+ . init( providers: [
81
+ . native: NativeBuildSystemFactory ( swiftTool: self ) ,
82
+ . xcode: XcodeBuildSystemFactory ( swiftTool: self )
83
+ ] )
58
84
}
59
85
}
0 commit comments