From 5b26629a4d8ca388db1b272a7c8b8ea37f45c9f9 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Sat, 5 Sep 2020 16:21:14 +0300 Subject: Support 'runnables' options in the vs code extension --- editors/code/src/lsp_ext.ts | 2 ++ editors/code/src/run.ts | 2 ++ editors/code/src/tasks.ts | 10 +++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'editors/code/src') diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index eb422d3e7..f286b68a6 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -69,8 +69,10 @@ export interface Runnable { args: { workspaceRoot?: string; cargoArgs: string[]; + cargoExtraArgs: string[]; executableArgs: string[]; expectTest?: boolean; + overrideCargo?: string; }; } export const runnables = new lc.RequestType("experimental/runnables"); diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index de68f27ae..459b7f250 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts @@ -129,6 +129,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise } const args = [...runnable.args.cargoArgs]; // should be a copy! + args.push(...runnable.args.cargoExtraArgs); // Append user-specified cargo options. if (runnable.args.executableArgs.length > 0) { args.push('--', ...runnable.args.executableArgs); } @@ -139,6 +140,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise args: args.slice(1), cwd: runnable.args.workspaceRoot || ".", env: prepareEnv(runnable, config.runnableEnv), + overrideCargo: runnable.args.overrideCargo, }; const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate() diff --git a/editors/code/src/tasks.ts b/editors/code/src/tasks.ts index 14abbd5b7..a3ff15102 100644 --- a/editors/code/src/tasks.ts +++ b/editors/code/src/tasks.ts @@ -13,6 +13,7 @@ export interface CargoTaskDefinition extends vscode.TaskDefinition { args?: string[]; cwd?: string; env?: { [key: string]: string }; + overrideCargo?: string; } class CargoTaskProvider implements vscode.TaskProvider { @@ -98,7 +99,14 @@ export async function buildCargoTask( } if (!exec) { - exec = new vscode.ShellExecution(toolchain.cargoPath(), args, definition); + // Check whether we must use a user-defined substitute for cargo. + const cargoCommand = definition.overrideCargo ? definition.overrideCargo : toolchain.cargoPath(); + + // Prepare the whole command as one line. It is required if user has provided override command which contains spaces, + // for example "wrapper cargo". Without manual preparation the overridden command will be quoted and fail to execute. + const fullCommand = [cargoCommand, ...args].join(" "); + + exec = new vscode.ShellExecution(fullCommand, definition); } return new vscode.Task( -- cgit v1.2.3