@@ -16,6 +16,7 @@ import Foundation
16
16
@main
17
17
struct CMakeSmokeTest : CommandPlugin {
18
18
func performCommand( context: PluginContext , arguments: [ String ] ) async throws {
19
+ print ( arguments)
19
20
var args = ArgumentExtractor ( arguments)
20
21
let hostOS = try OS . host ( )
21
22
@@ -33,6 +34,7 @@ struct CMakeSmokeTest: CommandPlugin {
33
34
if let sysrootPath {
34
35
print ( " using sysroot at \( sysrootPath) " )
35
36
}
37
+ let extraCMakeArgs = args. extractOption ( named: " extra-cmake-arg " )
36
38
37
39
let moduleCachePath = context. pluginWorkDirectoryURL. appending ( component: " module-cache " ) . path ( )
38
40
@@ -80,38 +82,38 @@ struct CMakeSmokeTest: CommandPlugin {
80
82
" -DCMAKE_MAKE_PROGRAM= \( ninjaPath) " ,
81
83
" -DCMAKE_BUILD_TYPE:=Debug " ,
82
84
" -DCMAKE_Swift_FLAGS=' \( sharedSwiftFlags. joined ( separator: " " ) ) ' "
83
- ] + cMakeProjectArgs
85
+ ] + cMakeProjectArgs + extraCMakeArgs
84
86
85
87
print ( " Building swift-tools-support-core " )
86
- try await Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftToolsSupportCoreURL. path ( ) ] , workingDirectory: swiftToolsSupportCoreBuildURL)
87
- try await Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftToolsSupportCoreBuildURL)
88
+ try Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftToolsSupportCoreURL. path ( ) ] , workingDirectory: swiftToolsSupportCoreBuildURL)
89
+ try Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftToolsSupportCoreBuildURL)
88
90
print ( " Built swift-tools-support-core " )
89
91
90
92
if hostOS != . macOS {
91
93
print ( " Building swift-system " )
92
- try await Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftSystemURL. path ( ) ] , workingDirectory: swiftSystemBuildURL)
93
- try await Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftSystemBuildURL)
94
+ try Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftSystemURL. path ( ) ] , workingDirectory: swiftSystemBuildURL)
95
+ try Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftSystemBuildURL)
94
96
print ( " Built swift-system " )
95
97
}
96
98
97
99
print ( " Building llbuild " )
98
- try await Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ " -DLLBUILD_SUPPORT_BINDINGS:=Swift " , llbuildURL. path ( ) ] , workingDirectory: llbuildBuildURL)
99
- try await Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: llbuildBuildURL)
100
+ try Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ " -DLLBUILD_SUPPORT_BINDINGS:=Swift " , llbuildURL. path ( ) ] , workingDirectory: llbuildBuildURL)
101
+ try Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: llbuildBuildURL)
100
102
print ( " Built llbuild " )
101
103
102
104
print ( " Building swift-argument-parser " )
103
- try await Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ " -DBUILD_TESTING=NO " , " -DBUILD_EXAMPLES=NO " , swiftArgumentParserURL. path ( ) ] , workingDirectory: swiftArgumentParserBuildURL)
104
- try await Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftArgumentParserBuildURL)
105
+ try Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ " -DBUILD_TESTING=NO " , " -DBUILD_EXAMPLES=NO " , swiftArgumentParserURL. path ( ) ] , workingDirectory: swiftArgumentParserBuildURL)
106
+ try Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftArgumentParserBuildURL)
105
107
print ( " Built swift-argument-parser " )
106
108
107
109
print ( " Building swift-driver " )
108
- try await Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftDriverURL. path ( ) ] , workingDirectory: swiftDriverBuildURL)
109
- try await Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftDriverBuildURL)
110
+ try Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftDriverURL. path ( ) ] , workingDirectory: swiftDriverBuildURL)
111
+ try Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftDriverBuildURL)
110
112
print ( " Built swift-driver " )
111
113
112
114
print ( " Building swift-build in \( swiftBuildBuildURL) " )
113
- try await Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftBuildURL. path ( ) ] , workingDirectory: swiftBuildBuildURL)
114
- try await Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftBuildBuildURL)
115
+ try Process . checkNonZeroExit ( url: cmakeURL, arguments: sharedCMakeArgs + [ swiftBuildURL. path ( ) ] , workingDirectory: swiftBuildBuildURL)
116
+ try Process . checkNonZeroExit ( url: ninjaURL, arguments: [ ] , workingDirectory: swiftBuildBuildURL)
115
117
print ( " Built swift-build " )
116
118
}
117
119
@@ -166,29 +168,18 @@ enum OS {
166
168
}
167
169
168
170
extension Process {
169
- func run( ) async throws {
170
- try await withCheckedThrowingContinuation { continuation in
171
- terminationHandler = { _ in
172
- continuation. resume ( )
173
- }
174
-
175
- do {
176
- try run ( )
177
- } catch {
178
- terminationHandler = nil
179
- continuation. resume ( throwing: error)
180
- }
181
- }
182
- }
183
-
184
- static func checkNonZeroExit( url: URL , arguments: [ String ] , workingDirectory: URL , environment: [ String : String ] ? = nil ) async throws {
171
+ static func checkNonZeroExit( url: URL , arguments: [ String ] , workingDirectory: URL , environment: [ String : String ] ? = nil ) throws {
185
172
print ( " \( url. path ( ) ) \( arguments. joined ( separator: " " ) ) " )
186
173
let process = Process ( )
187
174
process. executableURL = url
188
175
process. arguments = arguments
189
176
process. currentDirectoryURL = workingDirectory
190
177
process. environment = environment
191
- try await process. run ( )
178
+ process. standardOutput = nil
179
+ process. standardError = nil
180
+ process. standardInput = nil
181
+ try process. run ( )
182
+ process. waitUntilExit ( )
192
183
if process. terminationStatus != 0 {
193
184
throw Errors . processError ( terminationReason: process. terminationReason, terminationStatus: process. terminationStatus)
194
185
}
0 commit comments