@@ -69,11 +69,19 @@ struct MiniMake {
6969 }
7070
7171 /// 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
7479 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 )
7785 return taskKey
7886 }
7987
@@ -163,25 +171,32 @@ struct MiniMake {
163171 explain ( " Task \( task. output) should be built because it doesn't exist " )
164172 return true
165173 }
166- let outputMtime = try ? outputURL. resourceValues ( forKeys: [ . contentModificationDateKey] ) . contentModificationDate
174+ let outputMtime = try ? outputURL. resourceValues ( forKeys: [ . contentModificationDateKey] )
175+ . contentModificationDate
167176 return task. inputs. contains { input in
168177 let inputURL = URL ( fileURLWithPath: input)
169178 // Ignore directory modification times
170179 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)
172182 if fileExists && isDirectory. boolValue {
173183 return false
174184 }
175185
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!
178190 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+ )
180194 }
181195 return shouldBuild
182196 }
183197 }
184- var progressPrinter = ProgressPrinter ( total: self . computeTotalTasksForDisplay ( task: self . tasks [ output] !) )
198+ var progressPrinter = ProgressPrinter (
199+ total: self . computeTotalTasksForDisplay ( task: self . tasks [ output] !) )
185200
186201 func runTask( taskKey: TaskKey ) throws {
187202 guard var task = self . tasks [ taskKey] else {
0 commit comments