Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions utils/swift-xcodegen/Sources/swift-xcodegen/SwiftXcodegen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

import ArgumentParser
import Darwin
import Foundation
import SwiftXcodeGen

@main
Expand Down Expand Up @@ -399,14 +399,27 @@ struct SwiftXcodegen: AsyncParsableCommand, Sendable {
try lldbLLVMWorkspace.write("LLDB+LLVM", into: outputDir)
}
}
showCaveatsIfNeeded()
}

func printingTimeTaken<T>(_ fn: () async throws -> T) async rethrows -> T {
let start = Date()
let result = try await fn()

// Note we don't print the time taken when we fail.
let delta = Date().timeIntervalSince(start)
log.info("Successfully generated in \(Int((delta * 1000).rounded()))ms")

return result
}

func run() async {
// Set the log level
log.logLevel = .init(self.logLevel ?? (self.quiet ? .warning : .info))
do {
try await generate()
try await printingTimeTaken {
try await generate()
}
showCaveatsIfNeeded()
} catch {
log.error("\(error)")
}
Expand Down