mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Unherit server extra env for runnables extra env
This commit is contained in:
parent
92d56156a4
commit
2a577eb2f5
@ -261,8 +261,12 @@ export class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runnablesExtraEnv(label: string): Env {
|
runnablesExtraEnv(label: string): Env {
|
||||||
let extraEnv = this.get<RunnableEnvCfgItem[] | { [key: string]: { toString(): string } | null } | null>("runnables.extraEnv") ?? {};
|
const serverEnv = this.serverExtraEnv;
|
||||||
if (!extraEnv) return {};
|
let extraEnv =
|
||||||
|
this.get<
|
||||||
|
RunnableEnvCfgItem[] | { [key: string]: { toString(): string } | null } | null
|
||||||
|
>("runnables.extraEnv") ?? {};
|
||||||
|
if (!extraEnv) return serverEnv;
|
||||||
|
|
||||||
const platform = process.platform;
|
const platform = process.platform;
|
||||||
const checkPlatform = (it: RunnableEnvCfgItem) => {
|
const checkPlatform = (it: RunnableEnvCfgItem) => {
|
||||||
@ -283,7 +287,7 @@ export class Config {
|
|||||||
}
|
}
|
||||||
extraEnv = env;
|
extraEnv = env;
|
||||||
}
|
}
|
||||||
return substituteVariablesInEnv(
|
const runnableExtraEnv = substituteVariablesInEnv(
|
||||||
Object.fromEntries(
|
Object.fromEntries(
|
||||||
Object.entries(extraEnv).map(([k, v]) => [
|
Object.entries(extraEnv).map(([k, v]) => [
|
||||||
k,
|
k,
|
||||||
@ -291,6 +295,7 @@ export class Config {
|
|||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
return { ...runnableExtraEnv, ...serverEnv };
|
||||||
}
|
}
|
||||||
|
|
||||||
get restartServerOnConfigChange() {
|
get restartServerOnConfigChange() {
|
||||||
|
@ -6,7 +6,14 @@ import type * as ra from "./lsp_ext";
|
|||||||
import { Cargo } from "./toolchain";
|
import { Cargo } from "./toolchain";
|
||||||
import type { Ctx } from "./ctx";
|
import type { Ctx } from "./ctx";
|
||||||
import { createTaskFromRunnable, prepareEnv } from "./run";
|
import { createTaskFromRunnable, prepareEnv } from "./run";
|
||||||
import { execute, isCargoRunnableArgs, unwrapUndefinable, log, normalizeDriveLetter, Env } from "./util";
|
import {
|
||||||
|
execute,
|
||||||
|
isCargoRunnableArgs,
|
||||||
|
unwrapUndefinable,
|
||||||
|
log,
|
||||||
|
normalizeDriveLetter,
|
||||||
|
Env,
|
||||||
|
} from "./util";
|
||||||
import type { Config } from "./config";
|
import type { Config } from "./config";
|
||||||
|
|
||||||
// Here we want to keep track on everything that's currently running
|
// Here we want to keep track on everything that's currently running
|
||||||
@ -206,10 +213,7 @@ type SourceFileMap = {
|
|||||||
destination: string;
|
destination: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function discoverSourceFileMap(
|
async function discoverSourceFileMap(env: Env, cwd: string): Promise<SourceFileMap | undefined> {
|
||||||
env: Env,
|
|
||||||
cwd: string,
|
|
||||||
): Promise<SourceFileMap | undefined> {
|
|
||||||
const sysroot = env["RUSTC_TOOLCHAIN"];
|
const sysroot = env["RUSTC_TOOLCHAIN"];
|
||||||
if (sysroot) {
|
if (sysroot) {
|
||||||
// let's try to use the default toolchain
|
// let's try to use the default toolchain
|
||||||
@ -304,10 +308,7 @@ const knownEngines: {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getDebugExecutable(
|
async function getDebugExecutable(runnableArgs: ra.CargoRunnableArgs, env: Env): Promise<string> {
|
||||||
runnableArgs: ra.CargoRunnableArgs,
|
|
||||||
env: Env,
|
|
||||||
): Promise<string> {
|
|
||||||
const cargo = new Cargo(runnableArgs.workspaceRoot || ".", env);
|
const cargo = new Cargo(runnableArgs.workspaceRoot || ".", env);
|
||||||
const executable = await cargo.executableFromArgs(runnableArgs);
|
const executable = await cargo.executableFromArgs(runnableArgs);
|
||||||
|
|
||||||
|
@ -122,10 +122,7 @@ export class RunnableQuickPick implements vscode.QuickPickItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function prepareBaseEnv(
|
export function prepareBaseEnv(inheritEnv: boolean, base?: Env): Env {
|
||||||
inheritEnv: boolean,
|
|
||||||
base?: Env,
|
|
||||||
): Env {
|
|
||||||
const env: Env = { RUST_BACKTRACE: "short" };
|
const env: Env = { RUST_BACKTRACE: "short" };
|
||||||
if (inheritEnv) {
|
if (inheritEnv) {
|
||||||
Object.assign(env, process.env);
|
Object.assign(env, process.env);
|
||||||
@ -136,11 +133,7 @@ export function prepareBaseEnv(
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function prepareEnv(
|
export function prepareEnv(inheritEnv: boolean, runnableEnv?: Env, runnableEnvCfg?: Env): Env {
|
||||||
inheritEnv: boolean,
|
|
||||||
runnableEnv?: Env,
|
|
||||||
runnableEnvCfg?: Env,
|
|
||||||
): Env {
|
|
||||||
const env = prepareBaseEnv(inheritEnv, runnableEnv);
|
const env = prepareBaseEnv(inheritEnv, runnableEnv);
|
||||||
|
|
||||||
if (runnableEnvCfg) {
|
if (runnableEnvCfg) {
|
||||||
|
@ -134,11 +134,9 @@ export async function targetToExecution(
|
|||||||
}
|
}
|
||||||
return new vscode.ProcessExecution(command, args, {
|
return new vscode.ProcessExecution(command, args, {
|
||||||
cwd: options?.cwd,
|
cwd: options?.cwd,
|
||||||
env:
|
env: Object.fromEntries(
|
||||||
Object.fromEntries(
|
Object.entries(options?.env ?? {}).map(([key, value]) => [key, value ?? ""]),
|
||||||
Object.entries(options?.env ?? {}).map(([key, value]) => [key, value ?? ""])
|
),
|
||||||
)
|
|
||||||
,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export class Cargo {
|
|||||||
constructor(
|
constructor(
|
||||||
readonly rootFolder: string,
|
readonly rootFolder: string,
|
||||||
readonly env: Env,
|
readonly env: Env,
|
||||||
) { }
|
) {}
|
||||||
|
|
||||||
// Made public for testing purposes
|
// Made public for testing purposes
|
||||||
static artifactSpec(cargoArgs: string[], executableArgs?: string[]): ArtifactSpec {
|
static artifactSpec(cargoArgs: string[], executableArgs?: string[]): ArtifactSpec {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user