Skip to content

Pass -v to plugin compilation if in verbose mode #5623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Sources/Commands/SwiftTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ public class SwiftTool {
fileSystem: self.fileSystem,
cacheDir: cacheDir,
toolchain: self.getHostToolchain(),
enableSandbox: !self.options.security.shouldDisableSandbox
enableSandbox: !self.options.security.shouldDisableSandbox,
verboseOutput: self.logLevel <= .info
)
// register the plugin runner system with the cancellation handler
self.cancellator.register(name: "plugin runner", handler: pluginScriptRunner)
Expand Down
8 changes: 7 additions & 1 deletion Sources/Workspace/DefaultPluginScriptRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable {
private let toolchain: UserToolchain
private let enableSandbox: Bool
private let cancellator: Cancellator
private let verboseOutput: Bool

private let sdkRootCache = ThreadSafeBox<AbsolutePath>()

public init(fileSystem: FileSystem, cacheDir: AbsolutePath, toolchain: UserToolchain, enableSandbox: Bool = true) {
public init(fileSystem: FileSystem, cacheDir: AbsolutePath, toolchain: UserToolchain, enableSandbox: Bool = true, verboseOutput: Bool = false) {
self.fileSystem = fileSystem
self.cacheDir = cacheDir
self.toolchain = toolchain
self.enableSandbox = enableSandbox
self.cancellator = Cancellator(observabilityScope: .none)
self.verboseOutput = verboseOutput
}

/// 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.
Expand Down Expand Up @@ -199,6 +201,10 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner, Cancellable {
// Finally add the output path of the compiled executable.
commandLine += ["-o", execFilePath.pathString]

if (verboseOutput) {
commandLine.append("-v")
}

// First try to create the output directory.
do {
observabilityScope.emit(debug: "Plugin compilation output directory '\(execFilePath.parentDirectory)'")
Expand Down