Skip to content

Commit c39ba02

Browse files
committed
Show a “pretty path” for outputs
So newcomers can find their products.
1 parent 7fa3c98 commit c39ba02

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Sources/Build/describe().swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
244244
let inputs = product.modules.flatMap{ [$0.targetName] + IncrementalNode(module: $0, prefix: prefix).inputs }
245245

246246
let shell = ShellTool(
247-
description: "Linking \(product)",
247+
description: "Linking \(outpath.prettyPath)",
248248
inputs: inputs,
249249
outputs: [product.targetName, outpath],
250250
args: args)

Sources/Utility/Path.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,20 @@ extension String {
269269
let cleaned = characters.split(separator: "/").map(String.init).joined(separator: "/")
270270
return abs ? "/\(cleaned)" : cleaned
271271
}
272+
273+
/**
274+
- Returns: A path suitable for display to the user, if possible,
275+
a path relative to the current working directory.
276+
- Note: As such this function relies on the working directory
277+
not changing during execution.
278+
*/
279+
public var prettyPath: String {
280+
if let wd = try? getcwd() {
281+
return Path(self).relative(to: wd)
282+
} else if let abspath = try? abspath() {
283+
return abspath
284+
} else {
285+
return self
286+
}
287+
}
272288
}

0 commit comments

Comments
 (0)