Skip to content

Commit 5fe2020

Browse files
authored
Pass -v to plugin compilation if in verbose mode (#5626)
This matches what we already do for package manifests. rdar://95117842 (cherry picked from commit fc44db1)
1 parent 0402ec1 commit 5fe2020

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Sources/Commands/SwiftTool.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,8 @@ public class SwiftTool {
686686
fileSystem: self.fileSystem,
687687
cacheDir: cacheDir,
688688
toolchain: self.getHostToolchain(),
689-
enableSandbox: !self.options.security.shouldDisableSandbox
689+
enableSandbox: !self.options.security.shouldDisableSandbox,
690+
verboseOutput: self.logLevel <= .info
690691
)
691692
// register the plugin runner system with the cancellation handler
692693
self.cancellator.register(name: "plugin runner", handler: pluginScriptRunner)

Sources/Workspace/DefaultPluginScriptRunner.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable {
2626
private let toolchain: UserToolchain
2727
private let enableSandbox: Bool
2828
private let cancellator: Cancellator
29+
private let verboseOutput: Bool
2930

3031
private let sdkRootCache = ThreadSafeBox<AbsolutePath>()
3132

32-
public init(fileSystem: FileSystem, cacheDir: AbsolutePath, toolchain: UserToolchain, enableSandbox: Bool = true) {
33+
public init(fileSystem: FileSystem, cacheDir: AbsolutePath, toolchain: UserToolchain, enableSandbox: Bool = true, verboseOutput: Bool = false) {
3334
self.fileSystem = fileSystem
3435
self.cacheDir = cacheDir
3536
self.toolchain = toolchain
3637
self.enableSandbox = enableSandbox
3738
self.cancellator = Cancellator(observabilityScope: .none)
39+
self.verboseOutput = verboseOutput
3840
}
3941

4042
/// Starts evaluating a plugin by compiling it and running it as a subprocess. The name is used as the basename for the executable and auxiliary files. The tools version controls the availability of APIs in PackagePlugin, and should be set to the tools version of the package that defines the plugin (not the package containing the target to which it is being applied). This function returns immediately and then repeated calls the output handler on the given callback queue as plain-text output is received from the plugin, and then eventually calls the completion handler on the given callback queue once the plugin is done.
@@ -199,6 +201,10 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable {
199201
// Finally add the output path of the compiled executable.
200202
commandLine += ["-o", execFilePath.pathString]
201203

204+
if (verboseOutput) {
205+
commandLine.append("-v")
206+
}
207+
202208
// First try to create the output directory.
203209
do {
204210
observabilityScope.emit(debug: "Plugin compilation output directory '\(execFilePath.parentDirectory)'")

0 commit comments

Comments
 (0)