Skip to content

Commit 5401da4

Browse files
committed
Pass -v to plugin compilation if in verbose mode
This matches what we already do for package manifests. rdar://95117842
1 parent ba596a6 commit 5401da4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Sources/Commands/SwiftTool.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,19 @@ public class SwiftTool {
630630
}
631631

632632
func getPluginScriptRunner(customPluginsDir: AbsolutePath? = .none) throws -> PluginScriptRunner {
633+
var extraPluginFlags = [String]()
634+
if self.logLevel <= .info {
635+
extraPluginFlags.append("-v")
636+
}
637+
633638
let pluginsDir = try customPluginsDir ?? self.getActiveWorkspace().location.pluginWorkingDirectory
634639
let cacheDir = pluginsDir.appending(component: "cache")
635640
let pluginScriptRunner = try DefaultPluginScriptRunner(
636641
fileSystem: self.fileSystem,
637642
cacheDir: cacheDir,
638643
toolchain: self.getHostToolchain(),
639-
enableSandbox: !self.options.security.shouldDisableSandbox
644+
enableSandbox: !self.options.security.shouldDisableSandbox,
645+
extraPluginFlags: extraPluginFlags
640646
)
641647
// register the plugin runner system with the cancellation handler
642648
self.cancellator.register(name: "plugin runner", handler: pluginScriptRunner)

Sources/Workspace/DefaultPluginScriptRunner.swift

Lines changed: 6 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 extraPluginFlags: [String]
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, extraPluginFlags: [String] = []) {
3334
self.fileSystem = fileSystem
3435
self.cacheDir = cacheDir
3536
self.toolchain = toolchain
3637
self.enableSandbox = enableSandbox
3738
self.cancellator = Cancellator(observabilityScope: .none)
39+
self.extraPluginFlags = extraPluginFlags
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,9 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable {
199201
// Finally add the output path of the compiled executable.
200202
commandLine += ["-o", execFilePath.pathString]
201203

204+
// Add any extra flags to the commandline.
205+
commandLine += self.extraPluginFlags
206+
202207
// First try to create the output directory.
203208
do {
204209
observabilityScope.emit(debug: "Plugin compilation output directory '\(execFilePath.parentDirectory)'")

0 commit comments

Comments
 (0)