@@ -41,12 +41,15 @@ class NextCompiler {
41
41
var workingDir : String
42
42
}
43
43
44
- // One compilation at a time.
44
+ /// Queue for one compilation at a time.
45
45
static let compileQueue = DispatchQueue ( label: " InjectionCompile " )
46
+ /// Last build error.
47
+ static var lastError : String ?
48
+
46
49
/// Base for temporary files
47
50
let tmpbase = " /tmp/injectionNext "
48
- /// Injection pending if information was not available and last error
49
- var pendingSource : String ? , lastError : String ?
51
+ /// Injection pending if information was not available
52
+ var pendingSource : String ?
50
53
/// Information for compiling a file per source file.
51
54
var compilations = [ String: Compilation] ( )
52
55
/// Last Injected
@@ -84,7 +87,7 @@ class NextCompiler {
84
87
connected? . injectionNumber += 1
85
88
AppDelegate . ui. setMenuIcon ( . busy)
86
89
compileNumber += 1
87
- lastError = nil
90
+ Self . lastError = nil
88
91
89
92
// Support for https://github.com/johnno1962/Compilertron
90
93
let isCompilertron = connected == nil && source. hasSuffix ( " .cpp " )
@@ -220,20 +223,23 @@ class NextCompiler {
220
223
[ " -c " , source, " -Xclang " , " -fno-validate-pch " ] ) + baseOptionsToAdd
221
224
222
225
// Call compiler process
223
- if let errors = Popen . task ( exec: compiler,
226
+ let compile = Topen ( exec: compiler,
224
227
arguments: stored. arguments + languageSpecific,
225
- cd: stored. workingDir, errors: nil ) { // Always returns stdout
226
- if errors. contains ( " error: " ) {
227
- print ( ( [ compiler] + stored. arguments +
228
- languageSpecific) . joined ( separator: " " ) )
229
- _ = error ( " Recompile failed for: \( source) \n " + errors)
230
- lastError = errors
231
- return nil
232
- }
233
- for slow : String in errors [
228
+ cd: stored. workingDir)
229
+ var errors = " "
230
+ while let line = compile. readLine ( ) {
231
+ if let slow: String = line [
234
232
#"(?<=/)\w+\.swift:\d+:\d+: warning: expression took \d+ms to type-check.*"# ] {
235
233
log ( slow)
236
234
}
235
+ errors += line+ " \n "
236
+ }
237
+ if errors. contains ( " error: " ) {
238
+ print ( ( [ compiler] + stored. arguments +
239
+ languageSpecific) . joined ( separator: " " ) )
240
+ _ = error ( " Recompile failed for: \( source) \n " + errors)
241
+ Self . lastError = errors
242
+ return nil
237
243
}
238
244
239
245
return object
@@ -296,7 +302,7 @@ class NextCompiler {
296
302
297
303
if let errors = Popen . system ( linkCommand, errors: true ) {
298
304
_ = error ( " Linking failed: \n \( linkCommand) \n errors: \n " + errors)
299
- lastError = errors
305
+ Self . lastError = errors
300
306
return nil
301
307
}
302
308
@@ -319,7 +325,7 @@ class NextCompiler {
319
325
"""
320
326
if let errors = Popen . system ( codesign, errors: true ) {
321
327
_ = error ( " Codesign failed \( codesign) errors: \n " + errors)
322
- lastError = errors
328
+ Self . lastError = errors
323
329
}
324
330
}
325
331
return try ? Data ( contentsOf: URL ( fileURLWithPath: dylib) )
0 commit comments