@@ -69,11 +69,19 @@ struct MiniMake {
69
69
}
70
70
71
71
/// Adds a task to the build system
72
- mutating func addTask( inputFiles: [ String ] = [ ] , inputTasks: [ TaskKey ] = [ ] , output: String , attributes: [ TaskAttribute ] = [ ] , build: @escaping ( Task ) throws -> Void ) -> TaskKey {
73
- let displayName = output. hasPrefix ( self . buildCwd) ? String ( output. dropFirst ( self . buildCwd. count + 1 ) ) : output
72
+ mutating func addTask(
73
+ inputFiles: [ String ] = [ ] , inputTasks: [ TaskKey ] = [ ] , output: String ,
74
+ attributes: [ TaskAttribute ] = [ ] , build: @escaping ( Task ) throws -> Void
75
+ ) -> TaskKey {
76
+ let displayName =
77
+ output. hasPrefix ( self . buildCwd)
78
+ ? String ( output. dropFirst ( self . buildCwd. count + 1 ) ) : output
74
79
let taskKey = TaskKey ( id: output)
75
- let info = TaskInfo ( wants: inputTasks, inputs: inputFiles, output: output, attributes: attributes)
76
- self . tasks [ taskKey] = Task ( info: info, wants: Set ( inputTasks) , attributes: Set ( attributes) , displayName: displayName, key: taskKey, build: build, isDone: false )
80
+ let info = TaskInfo (
81
+ wants: inputTasks, inputs: inputFiles, output: output, attributes: attributes)
82
+ self . tasks [ taskKey] = Task (
83
+ info: info, wants: Set ( inputTasks) , attributes: Set ( attributes) ,
84
+ displayName: displayName, key: taskKey, build: build, isDone: false )
77
85
return taskKey
78
86
}
79
87
@@ -163,25 +171,32 @@ struct MiniMake {
163
171
explain ( " Task \( task. output) should be built because it doesn't exist " )
164
172
return true
165
173
}
166
- let outputMtime = try ? outputURL. resourceValues ( forKeys: [ . contentModificationDateKey] ) . contentModificationDate
174
+ let outputMtime = try ? outputURL. resourceValues ( forKeys: [ . contentModificationDateKey] )
175
+ . contentModificationDate
167
176
return task. inputs. contains { input in
168
177
let inputURL = URL ( fileURLWithPath: input)
169
178
// Ignore directory modification times
170
179
var isDirectory : ObjCBool = false
171
- let fileExists = FileManager . default. fileExists ( atPath: input, isDirectory: & isDirectory)
180
+ let fileExists = FileManager . default. fileExists (
181
+ atPath: input, isDirectory: & isDirectory)
172
182
if fileExists && isDirectory. boolValue {
173
183
return false
174
184
}
175
185
176
- let inputMtime = try ? inputURL. resourceValues ( forKeys: [ . contentModificationDateKey] ) . contentModificationDate
177
- let shouldBuild = outputMtime == nil || inputMtime == nil || outputMtime! < inputMtime!
186
+ let inputMtime = try ? inputURL. resourceValues ( forKeys: [ . contentModificationDateKey]
187
+ ) . contentModificationDate
188
+ let shouldBuild =
189
+ outputMtime == nil || inputMtime == nil || outputMtime! < inputMtime!
178
190
if shouldBuild {
179
- explain ( " Task \( task. output) should be re-built because \( input) is newer: \( outputMtime? . timeIntervalSince1970 ?? 0 ) < \( inputMtime? . timeIntervalSince1970 ?? 0 ) " )
191
+ explain (
192
+ " Task \( task. output) should be re-built because \( input) is newer: \( outputMtime? . timeIntervalSince1970 ?? 0 ) < \( inputMtime? . timeIntervalSince1970 ?? 0 ) "
193
+ )
180
194
}
181
195
return shouldBuild
182
196
}
183
197
}
184
- var progressPrinter = ProgressPrinter ( total: self . computeTotalTasksForDisplay ( task: self . tasks [ output] !) )
198
+ var progressPrinter = ProgressPrinter (
199
+ total: self . computeTotalTasksForDisplay ( task: self . tasks [ output] !) )
185
200
186
201
func runTask( taskKey: TaskKey ) throws {
187
202
guard var task = self . tasks [ taskKey] else {
0 commit comments