Skip to content

Commit 3df9a03

Browse files
Silence [7/7] all: building
1 parent b4da184 commit 3df9a03

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Plugins/PackageToJS/MiniMake.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ struct MiniMake {
66
enum TaskAttribute {
77
/// Task is phony, meaning it must be built even if its inputs are up to date
88
case phony
9+
/// Don't print anything when building this task
10+
case silent
911
}
1012
/// A task to build
1113
struct Task {
@@ -84,15 +86,16 @@ struct MiniMake {
8486
private static var reset: String { "\u{001B}[0m" }
8587

8688
mutating func started(_ task: Task) {
87-
self.print(task.displayName, "\(Self.green)building\(Self.reset)")
89+
self.print(task, "\(Self.green)building\(Self.reset)")
8890
}
8991

9092
mutating func skipped(_ task: Task) {
91-
self.print(task.displayName, "\(Self.yellow)skipped\(Self.reset)")
93+
self.print(task, "\(Self.yellow)skipped\(Self.reset)")
9294
}
9395

94-
private mutating func print(_ subjectPath: String, _ message: @autoclosure () -> String) {
95-
Swift.print("[\(self.built + 1)/\(self.total)] \(subjectPath): \(message())")
96+
private mutating func print(_ task: Task, _ message: @autoclosure () -> String) {
97+
guard !task.attributes.contains(.silent) else { return }
98+
Swift.print("[\(self.built + 1)/\(self.total)] \(task.displayName): \(message())")
9699
self.built += 1
97100
}
98101
}
@@ -102,7 +105,7 @@ struct MiniMake {
102105
func visit(task: Task) -> Int {
103106
guard !visited.contains(task.key) else { return 0 }
104107
visited.insert(task.key)
105-
var total = 1
108+
var total = task.attributes.contains(.silent) ? 0 : 1
106109
for want in task.wants {
107110
total += visit(task: self.tasks[want]!)
108111
}

Plugins/PackageToJS/PackageToJS.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct PackageToJS: CommandPlugin {
104104
let allTask = constructPackagingPlan(
105105
make: &make, options: options, context: context, wasmProductArtifact: productArtifact,
106106
selfPackage: selfPackage, outputDir: outputDir)
107+
print("Packaging...")
107108
try make.build(output: allTask)
108109
print("Packaging finished")
109110
}
@@ -215,7 +216,7 @@ struct PackageToJS: CommandPlugin {
215216
}
216217
packageInputs.append(copied)
217218
}
218-
return make.addTask(inputTasks: packageInputs, output: "all", attributes: [.phony]) { _ in }
219+
return make.addTask(inputTasks: packageInputs, output: "all", attributes: [.phony, .silent]) { _ in }
219220
}
220221
}
221222

0 commit comments

Comments
 (0)