about summary refs log tree commit diff
path: root/editors/code/src/debug.ts
diff options
context:
space:
mode:
authorvsrs <vit@conrlab.com>2020-07-02 19:47:40 +0300
committervsrs <vit@conrlab.com>2020-07-03 14:23:51 +0300
commit7b79d24ad5b251c0806a07aa7769e824f3c37fec (patch)
tree1bf651ecddfdaecaccba02c3e9100f73c72e65a8 /editors/code/src/debug.ts
parent57576ac420989070e695bac195d516a410191ad9 (diff)
downloadrust-7b79d24ad5b251c0806a07aa7769e824f3c37fec.tar.gz
rust-7b79d24ad5b251c0806a07aa7769e824f3c37fec.zip
Add runnable env support.
Diffstat (limited to 'editors/code/src/debug.ts')
-rw-r--r--editors/code/src/debug.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts
index 61c12dbe074..525d26923ae 100644
--- a/editors/code/src/debug.ts
+++ b/editors/code/src/debug.ts
@@ -5,9 +5,10 @@ import * as ra from './lsp_ext';
 
 import { Cargo } from './toolchain';
 import { Ctx } from "./ctx";
+import { prepareEnv } from "./run";
 
 const debugOutput = vscode.window.createOutputChannel("Debug");
-type DebugConfigProvider = (config: ra.Runnable, executable: string, sourceFileMap?: Record<string, string>) => vscode.DebugConfiguration;
+type DebugConfigProvider = (config: ra.Runnable, executable: string, env: Record<string, string>, sourceFileMap?: Record<string, string>) => vscode.DebugConfiguration;
 
 export async function makeDebugConfig(ctx: Ctx, runnable: ra.Runnable): Promise<void> {
     const scope = ctx.activeRustEditor?.document.uri;
@@ -92,7 +93,8 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
     }
 
     const executable = await getDebugExecutable(runnable);
-    const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), debugOptions.sourceFileMap);
+    const env = prepareEnv(runnable, ctx.config);
+    const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, debugOptions.sourceFileMap);
     if (debugConfig.type in debugOptions.engineSettings) {
         const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type];
         for (var key in settingsMap) {
@@ -121,7 +123,7 @@ async function getDebugExecutable(runnable: ra.Runnable): Promise<string> {
     return executable;
 }
 
-function getLldbDebugConfig(runnable: ra.Runnable, executable: string, sourceFileMap?: Record<string, string>): vscode.DebugConfiguration {
+function getLldbDebugConfig(runnable: ra.Runnable, executable: string, env: Record<string, string>, sourceFileMap?: Record<string, string>): vscode.DebugConfiguration {
     return {
         type: "lldb",
         request: "launch",
@@ -130,11 +132,12 @@ function getLldbDebugConfig(runnable: ra.Runnable, executable: string, sourceFil
         args: runnable.args.executableArgs,
         cwd: runnable.args.workspaceRoot,
         sourceMap: sourceFileMap,
-        sourceLanguages: ["rust"]
+        sourceLanguages: ["rust"],
+        env
     };
 }
 
-function getCppvsDebugConfig(runnable: ra.Runnable, executable: string, sourceFileMap?: Record<string, string>): vscode.DebugConfiguration {
+function getCppvsDebugConfig(runnable: ra.Runnable, executable: string, env: Record<string, string>, sourceFileMap?: Record<string, string>): vscode.DebugConfiguration {
     return {
         type: (os.platform() === "win32") ? "cppvsdbg" : "cppdbg",
         request: "launch",
@@ -142,6 +145,7 @@ function getCppvsDebugConfig(runnable: ra.Runnable, executable: string, sourceFi
         program: executable,
         args: runnable.args.executableArgs,
         cwd: runnable.args.workspaceRoot,
-        sourceFileMap: sourceFileMap,
+        sourceFileMap,
+        env,
     };
 }