refactor: Store the CLI command directly in RustTargetDefinition

This commit is contained in:
Wilfred Hughes 2024-03-13 17:13:26 -07:00
parent 2e109c7da8
commit 4422a90b11
2 changed files with 18 additions and 14 deletions

View file

@ -2,6 +2,7 @@ import * as vscode from "vscode";
import type * as lc from "vscode-languageclient";
import * as ra from "./lsp_ext";
import * as tasks from "./tasks";
import * as toolchain from "./toolchain";
import type { CtxInit } from "./ctx";
import { makeDebugConfig } from "./debug";
@ -111,10 +112,21 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise
throw `Unexpected runnable kind: ${runnable.kind}`;
}
const args = createArgs(runnable);
let program: string;
let args = createArgs(runnable);
if (runnable.args.overrideCargo) {
// Split on spaces to allow overrides like "wrapper cargo".
const cargoParts = runnable.args.overrideCargo.split(" ");
program = unwrapUndefinable(cargoParts[0]);
args = [...cargoParts.slice(1), ...args];
} else {
program = await toolchain.cargoPath();
}
const definition: tasks.RustTargetDefinition = {
type: tasks.TASK_TYPE,
program,
args,
cwd: runnable.args.workspaceRoot || ".",
env: prepareEnv(runnable, config.runnablesExtraEnv),